repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
johnnoone/json-spec
src/jsonspec/pointer/__init__.py
extract
def extract(obj, pointer, bypass_ref=False): """Extract member or element of obj according to pointer. :param obj: the object source :param pointer: the pointer :type pointer: Pointer, str :param bypass_ref: bypass JSON Reference event :type bypass_ref: boolean """ return Pointer(point...
python
def extract(obj, pointer, bypass_ref=False): """Extract member or element of obj according to pointer. :param obj: the object source :param pointer: the pointer :type pointer: Pointer, str :param bypass_ref: bypass JSON Reference event :type bypass_ref: boolean """ return Pointer(point...
[ "def", "extract", "(", "obj", ",", "pointer", ",", "bypass_ref", "=", "False", ")", ":", "return", "Pointer", "(", "pointer", ")", ".", "extract", "(", "obj", ",", "bypass_ref", ")" ]
Extract member or element of obj according to pointer. :param obj: the object source :param pointer: the pointer :type pointer: Pointer, str :param bypass_ref: bypass JSON Reference event :type bypass_ref: boolean
[ "Extract", "member", "or", "element", "of", "obj", "according", "to", "pointer", "." ]
f91981724cea0c366bd42a6670eb07bbe31c0e0c
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/pointer/__init__.py#L23-L33
train
etal/biofrills
biofrills/alnutils.py
aa_counts
def aa_counts(aln, weights=None, gap_chars='-.'): """Calculate the amino acid frequencies in a set of SeqRecords. Weights for each sequence in the alignment can be given as a list/tuple, usually calculated with the sequence_weights function. For convenience, you can also pass "weights=True" and the wei...
python
def aa_counts(aln, weights=None, gap_chars='-.'): """Calculate the amino acid frequencies in a set of SeqRecords. Weights for each sequence in the alignment can be given as a list/tuple, usually calculated with the sequence_weights function. For convenience, you can also pass "weights=True" and the wei...
[ "def", "aa_counts", "(", "aln", ",", "weights", "=", "None", ",", "gap_chars", "=", "'-.'", ")", ":", "if", "weights", "is", "None", ":", "counts", "=", "Counter", "(", ")", "for", "rec", "in", "aln", ":", "seq_counts", "=", "Counter", "(", "str", ...
Calculate the amino acid frequencies in a set of SeqRecords. Weights for each sequence in the alignment can be given as a list/tuple, usually calculated with the sequence_weights function. For convenience, you can also pass "weights=True" and the weights will be calculated with sequence_weights here.
[ "Calculate", "the", "amino", "acid", "frequencies", "in", "a", "set", "of", "SeqRecords", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/alnutils.py#L13-L43
train
etal/biofrills
biofrills/alnutils.py
aa_frequencies
def aa_frequencies(aln, weights=None, gap_chars='-.'): """Frequency of each residue type in an alignment. Alignment is a MultipleSeqAlignment or iterable of SeqRecords. """ counts = aa_counts(aln, weights, gap_chars) # Reduce to frequencies scale = 1.0 / sum(counts.values()) return dict((aa...
python
def aa_frequencies(aln, weights=None, gap_chars='-.'): """Frequency of each residue type in an alignment. Alignment is a MultipleSeqAlignment or iterable of SeqRecords. """ counts = aa_counts(aln, weights, gap_chars) # Reduce to frequencies scale = 1.0 / sum(counts.values()) return dict((aa...
[ "def", "aa_frequencies", "(", "aln", ",", "weights", "=", "None", ",", "gap_chars", "=", "'-.'", ")", ":", "counts", "=", "aa_counts", "(", "aln", ",", "weights", ",", "gap_chars", ")", "# Reduce to frequencies", "scale", "=", "1.0", "/", "sum", "(", "co...
Frequency of each residue type in an alignment. Alignment is a MultipleSeqAlignment or iterable of SeqRecords.
[ "Frequency", "of", "each", "residue", "type", "in", "an", "alignment", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/alnutils.py#L46-L54
train
etal/biofrills
biofrills/alnutils.py
blocks
def blocks(aln, threshold=0.5, weights=None): """Remove gappy columns from an alignment.""" assert len(aln) if weights == False: def pct_nongaps(col): return 1 - (float(col.count('-')) / len(col)) else: if weights in (None, True): weights = sequence_weights(aln, '...
python
def blocks(aln, threshold=0.5, weights=None): """Remove gappy columns from an alignment.""" assert len(aln) if weights == False: def pct_nongaps(col): return 1 - (float(col.count('-')) / len(col)) else: if weights in (None, True): weights = sequence_weights(aln, '...
[ "def", "blocks", "(", "aln", ",", "threshold", "=", "0.5", ",", "weights", "=", "None", ")", ":", "assert", "len", "(", "aln", ")", "if", "weights", "==", "False", ":", "def", "pct_nongaps", "(", "col", ")", ":", "return", "1", "-", "(", "float", ...
Remove gappy columns from an alignment.
[ "Remove", "gappy", "columns", "from", "an", "alignment", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/alnutils.py#L57-L83
train
etal/biofrills
biofrills/alnutils.py
col_counts
def col_counts(col, weights=None, gap_chars='-.'): """Absolute counts of each residue type in a single column.""" cnt = defaultdict(float) for aa, wt in zip(col, weights): if aa not in gap_chars: cnt[aa] += wt return cnt
python
def col_counts(col, weights=None, gap_chars='-.'): """Absolute counts of each residue type in a single column.""" cnt = defaultdict(float) for aa, wt in zip(col, weights): if aa not in gap_chars: cnt[aa] += wt return cnt
[ "def", "col_counts", "(", "col", ",", "weights", "=", "None", ",", "gap_chars", "=", "'-.'", ")", ":", "cnt", "=", "defaultdict", "(", "float", ")", "for", "aa", ",", "wt", "in", "zip", "(", "col", ",", "weights", ")", ":", "if", "aa", "not", "in...
Absolute counts of each residue type in a single column.
[ "Absolute", "counts", "of", "each", "residue", "type", "in", "a", "single", "column", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/alnutils.py#L86-L92
train
etal/biofrills
biofrills/alnutils.py
remove_empty_cols
def remove_empty_cols(records): """Remove all-gap columns from aligned SeqRecords.""" # In case it's a generator, turn it into a list records = list(records) seqstrs = [str(rec.seq) for rec in records] clean_cols = [col for col in zip(*seqstrs) if not all(c == '-'...
python
def remove_empty_cols(records): """Remove all-gap columns from aligned SeqRecords.""" # In case it's a generator, turn it into a list records = list(records) seqstrs = [str(rec.seq) for rec in records] clean_cols = [col for col in zip(*seqstrs) if not all(c == '-'...
[ "def", "remove_empty_cols", "(", "records", ")", ":", "# In case it's a generator, turn it into a list", "records", "=", "list", "(", "records", ")", "seqstrs", "=", "[", "str", "(", "rec", ".", "seq", ")", "for", "rec", "in", "records", "]", "clean_cols", "="...
Remove all-gap columns from aligned SeqRecords.
[ "Remove", "all", "-", "gap", "columns", "from", "aligned", "SeqRecords", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/alnutils.py#L103-L118
train
etal/biofrills
biofrills/alnutils.py
sequence_weights
def sequence_weights(aln, scaling='none', gap_chars='-.'): """Weight aligned sequences to emphasize more divergent members. Returns a list of floating-point numbers between 0 and 1, corresponding to the proportional weight of each sequence in the alignment. The first list is the weight of the first seq...
python
def sequence_weights(aln, scaling='none', gap_chars='-.'): """Weight aligned sequences to emphasize more divergent members. Returns a list of floating-point numbers between 0 and 1, corresponding to the proportional weight of each sequence in the alignment. The first list is the weight of the first seq...
[ "def", "sequence_weights", "(", "aln", ",", "scaling", "=", "'none'", ",", "gap_chars", "=", "'-.'", ")", ":", "# Probability is hard, let's estimate by sampling!", "# Sample k from a population of 20 with replacement; how many unique k were", "# chosen? Average of 10000 runs for k =...
Weight aligned sequences to emphasize more divergent members. Returns a list of floating-point numbers between 0 and 1, corresponding to the proportional weight of each sequence in the alignment. The first list is the weight of the first sequence in the alignment, and so on. Scaling schemes: -...
[ "Weight", "aligned", "sequences", "to", "emphasize", "more", "divergent", "members", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/alnutils.py#L121-L215
train
etal/biofrills
biofrills/alnutils.py
to_graph
def to_graph(alnfname, weight_func): """Create a NetworkX graph from a sequence alignment. Nodes are string sequence IDs; edge weights are the output of weight_func between each pair, by default the absolute identity (# identical chars). """ import networkx G = networkx.Graph() aln = AlignI...
python
def to_graph(alnfname, weight_func): """Create a NetworkX graph from a sequence alignment. Nodes are string sequence IDs; edge weights are the output of weight_func between each pair, by default the absolute identity (# identical chars). """ import networkx G = networkx.Graph() aln = AlignI...
[ "def", "to_graph", "(", "alnfname", ",", "weight_func", ")", ":", "import", "networkx", "G", "=", "networkx", ".", "Graph", "(", ")", "aln", "=", "AlignIO", ".", "read", "(", "alnfname", ",", "'fasta'", ")", "for", "i", ",", "arec", "in", "enumerate", ...
Create a NetworkX graph from a sequence alignment. Nodes are string sequence IDs; edge weights are the output of weight_func between each pair, by default the absolute identity (# identical chars).
[ "Create", "a", "NetworkX", "graph", "from", "a", "sequence", "alignment", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/alnutils.py#L218-L231
train
sludgedesk/metoffer
metoffer.py
guidance_UV
def guidance_UV(index): """Return Met Office guidance regarding UV exposure based on UV index""" if 0 < index < 3: guidance = "Low exposure. No protection required. You can safely stay outside" elif 2 < index < 6: guidance = "Moderate exposure. Seek shade during midday hours, cover up and we...
python
def guidance_UV(index): """Return Met Office guidance regarding UV exposure based on UV index""" if 0 < index < 3: guidance = "Low exposure. No protection required. You can safely stay outside" elif 2 < index < 6: guidance = "Moderate exposure. Seek shade during midday hours, cover up and we...
[ "def", "guidance_UV", "(", "index", ")", ":", "if", "0", "<", "index", "<", "3", ":", "guidance", "=", "\"Low exposure. No protection required. You can safely stay outside\"", "elif", "2", "<", "index", "<", "6", ":", "guidance", "=", "\"Moderate exposure. Seek shad...
Return Met Office guidance regarding UV exposure based on UV index
[ "Return", "Met", "Office", "guidance", "regarding", "UV", "exposure", "based", "on", "UV", "index" ]
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L158-L172
train
sludgedesk/metoffer
metoffer.py
parse_sitelist
def parse_sitelist(sitelist): """Return list of Site instances from retrieved sitelist data""" sites = [] for site in sitelist["Locations"]["Location"]: try: ident = site["id"] name = site["name"] except KeyError: ident = site["@id"] # Difference between l...
python
def parse_sitelist(sitelist): """Return list of Site instances from retrieved sitelist data""" sites = [] for site in sitelist["Locations"]["Location"]: try: ident = site["id"] name = site["name"] except KeyError: ident = site["@id"] # Difference between l...
[ "def", "parse_sitelist", "(", "sitelist", ")", ":", "sites", "=", "[", "]", "for", "site", "in", "sitelist", "[", "\"Locations\"", "]", "[", "\"Location\"", "]", ":", "try", ":", "ident", "=", "site", "[", "\"id\"", "]", "name", "=", "site", "[", "\"...
Return list of Site instances from retrieved sitelist data
[ "Return", "list", "of", "Site", "instances", "from", "retrieved", "sitelist", "data" ]
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L323-L340
train
sludgedesk/metoffer
metoffer.py
MetOffer._query
def _query(self, data_category, resource_category, field, request, step, isotime=None): """ Request and return data from DataPoint RESTful API. """ rest_url = "/".join([HOST, data_category, resource_category, field, DATA_TYPE, request]) query_string = "?" + "&".join(["res=" + ste...
python
def _query(self, data_category, resource_category, field, request, step, isotime=None): """ Request and return data from DataPoint RESTful API. """ rest_url = "/".join([HOST, data_category, resource_category, field, DATA_TYPE, request]) query_string = "?" + "&".join(["res=" + ste...
[ "def", "_query", "(", "self", ",", "data_category", ",", "resource_category", ",", "field", ",", "request", ",", "step", ",", "isotime", "=", "None", ")", ":", "rest_url", "=", "\"/\"", ".", "join", "(", "[", "HOST", ",", "data_category", ",", "resource_...
Request and return data from DataPoint RESTful API.
[ "Request", "and", "return", "data", "from", "DataPoint", "RESTful", "API", "." ]
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L179-L188
train
sludgedesk/metoffer
metoffer.py
MetOffer.stand_alone_imagery
def stand_alone_imagery(self): """ Returns capabilities data for stand alone imagery and includes URIs for the images. """ return json.loads(self._query(IMAGE, FORECAST, SURFACE_PRESSURE, CAPABILITIES, "").decode(errors="replace"))
python
def stand_alone_imagery(self): """ Returns capabilities data for stand alone imagery and includes URIs for the images. """ return json.loads(self._query(IMAGE, FORECAST, SURFACE_PRESSURE, CAPABILITIES, "").decode(errors="replace"))
[ "def", "stand_alone_imagery", "(", "self", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_query", "(", "IMAGE", ",", "FORECAST", ",", "SURFACE_PRESSURE", ",", "CAPABILITIES", ",", "\"\"", ")", ".", "decode", "(", "errors", "=", "\"replace\""...
Returns capabilities data for stand alone imagery and includes URIs for the images.
[ "Returns", "capabilities", "data", "for", "stand", "alone", "imagery", "and", "includes", "URIs", "for", "the", "images", "." ]
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L288-L293
train
sludgedesk/metoffer
metoffer.py
MetOffer.map_overlay_forecast
def map_overlay_forecast(self): """Returns capabilities data for forecast map overlays.""" return json.loads(self._query(LAYER, FORECAST, ALL, CAPABILITIES, "").decode(errors="replace"))
python
def map_overlay_forecast(self): """Returns capabilities data for forecast map overlays.""" return json.loads(self._query(LAYER, FORECAST, ALL, CAPABILITIES, "").decode(errors="replace"))
[ "def", "map_overlay_forecast", "(", "self", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_query", "(", "LAYER", ",", "FORECAST", ",", "ALL", ",", "CAPABILITIES", ",", "\"\"", ")", ".", "decode", "(", "errors", "=", "\"replace\"", ")", "...
Returns capabilities data for forecast map overlays.
[ "Returns", "capabilities", "data", "for", "forecast", "map", "overlays", "." ]
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L295-L297
train
sludgedesk/metoffer
metoffer.py
MetOffer.map_overlay_obs
def map_overlay_obs(self): """Returns capabilities data for observation map overlays.""" return json.loads(self._query(LAYER, OBSERVATIONS, ALL, CAPABILITIES, "").decode(errors="replace"))
python
def map_overlay_obs(self): """Returns capabilities data for observation map overlays.""" return json.loads(self._query(LAYER, OBSERVATIONS, ALL, CAPABILITIES, "").decode(errors="replace"))
[ "def", "map_overlay_obs", "(", "self", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_query", "(", "LAYER", ",", "OBSERVATIONS", ",", "ALL", ",", "CAPABILITIES", ",", "\"\"", ")", ".", "decode", "(", "errors", "=", "\"replace\"", ")", ")...
Returns capabilities data for observation map overlays.
[ "Returns", "capabilities", "data", "for", "observation", "map", "overlays", "." ]
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L299-L301
train
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/instruments.py
Instrument.load_and_append
def load_and_append(instrument_dict, instruments=None, raise_errors=False): """ load instrument from instrument_dict and append to instruments Args: instrument_dict: dictionary of form instrument_dict = { name_of_instrument_1 : {"...
python
def load_and_append(instrument_dict, instruments=None, raise_errors=False): """ load instrument from instrument_dict and append to instruments Args: instrument_dict: dictionary of form instrument_dict = { name_of_instrument_1 : {"...
[ "def", "load_and_append", "(", "instrument_dict", ",", "instruments", "=", "None", ",", "raise_errors", "=", "False", ")", ":", "if", "instruments", "is", "None", ":", "instruments", "=", "{", "}", "updated_instruments", "=", "{", "}", "updated_instruments", "...
load instrument from instrument_dict and append to instruments Args: instrument_dict: dictionary of form instrument_dict = { name_of_instrument_1 : {"settings" : settings_dictionary, "class" : name_of_class} name_of_instrument_2 :...
[ "load", "instrument", "from", "instrument_dict", "and", "append", "to", "instruments" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/instruments.py#L244-L349
train
johnnoone/json-spec
src/jsonspec/validators/draft04.py
Draft04Validator.fail
def fail(self, reason, obj, pointer=None): """ Called when validation fails. """ pointer = pointer_join(pointer) err = ValidationError(reason, obj, pointer) if self.fail_fast: raise err else: self.errors.append(err) return err
python
def fail(self, reason, obj, pointer=None): """ Called when validation fails. """ pointer = pointer_join(pointer) err = ValidationError(reason, obj, pointer) if self.fail_fast: raise err else: self.errors.append(err) return err
[ "def", "fail", "(", "self", ",", "reason", ",", "obj", ",", "pointer", "=", "None", ")", ":", "pointer", "=", "pointer_join", "(", "pointer", ")", "err", "=", "ValidationError", "(", "reason", ",", "obj", ",", "pointer", ")", "if", "self", ".", "fail...
Called when validation fails.
[ "Called", "when", "validation", "fails", "." ]
f91981724cea0c366bd42a6670eb07bbe31c0e0c
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/validators/draft04.py#L654-L664
train
nmdp-bioinformatics/SeqAnn
seqann/blast_cmd.py
get_locus
def get_locus(sequences, kir=False, verbose=False, refdata=None, evalue=10): """ Gets the locus of the sequence by running blastn :param sequences: sequenences to blast :param kir: bool whether the sequences are KIR or not :rtype: ``str`` Example usage: >>> from Bio.Seq import Seq ...
python
def get_locus(sequences, kir=False, verbose=False, refdata=None, evalue=10): """ Gets the locus of the sequence by running blastn :param sequences: sequenences to blast :param kir: bool whether the sequences are KIR or not :rtype: ``str`` Example usage: >>> from Bio.Seq import Seq ...
[ "def", "get_locus", "(", "sequences", ",", "kir", "=", "False", ",", "verbose", "=", "False", ",", "refdata", "=", "None", ",", "evalue", "=", "10", ")", ":", "if", "not", "refdata", ":", "refdata", "=", "ReferenceData", "(", ")", "file_id", "=", "st...
Gets the locus of the sequence by running blastn :param sequences: sequenences to blast :param kir: bool whether the sequences are KIR or not :rtype: ``str`` Example usage: >>> from Bio.Seq import Seq >>> from seqann.blast_cmd import get_locus >>> sequence = Seq('AGAGACTCTCCCG...
[ "Gets", "the", "locus", "of", "the", "sequence", "by", "running", "blastn" ]
5ce91559b0a4fbe4fb7758e034eb258202632463
https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/blast_cmd.py#L187-L245
train
PeerAssets/pypeerassets
pypeerassets/kutil.py
Kutil.address
def address(self) -> str: '''generate an address from pubkey''' return str(self._public_key.to_address( net_query(self.network)) )
python
def address(self) -> str: '''generate an address from pubkey''' return str(self._public_key.to_address( net_query(self.network)) )
[ "def", "address", "(", "self", ")", "->", "str", ":", "return", "str", "(", "self", ".", "_public_key", ".", "to_address", "(", "net_query", "(", "self", ".", "network", ")", ")", ")" ]
generate an address from pubkey
[ "generate", "an", "address", "from", "pubkey" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/kutil.py#L51-L56
train
PeerAssets/pypeerassets
pypeerassets/kutil.py
Kutil.sign_transaction
def sign_transaction(self, txins: Union[TxOut], tx: MutableTransaction) -> MutableTransaction: '''sign the parent txn outputs P2PKH''' solver = P2pkhSolver(self._private_key) return tx.spend(txins, [solver for i in txins])
python
def sign_transaction(self, txins: Union[TxOut], tx: MutableTransaction) -> MutableTransaction: '''sign the parent txn outputs P2PKH''' solver = P2pkhSolver(self._private_key) return tx.spend(txins, [solver for i in txins])
[ "def", "sign_transaction", "(", "self", ",", "txins", ":", "Union", "[", "TxOut", "]", ",", "tx", ":", "MutableTransaction", ")", "->", "MutableTransaction", ":", "solver", "=", "P2pkhSolver", "(", "self", ".", "_private_key", ")", "return", "tx", ".", "sp...
sign the parent txn outputs P2PKH
[ "sign", "the", "parent", "txn", "outputs", "P2PKH" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/kutil.py#L64-L69
train
PeerAssets/pypeerassets
pypeerassets/provider/cryptoid.py
Cryptoid.format_name
def format_name(net: str) -> str: '''take care of specifics of cryptoid naming system''' if net.startswith('t') or 'testnet' in net: net = net[1:] + '-test' else: net = net return net
python
def format_name(net: str) -> str: '''take care of specifics of cryptoid naming system''' if net.startswith('t') or 'testnet' in net: net = net[1:] + '-test' else: net = net return net
[ "def", "format_name", "(", "net", ":", "str", ")", "->", "str", ":", "if", "net", ".", "startswith", "(", "'t'", ")", "or", "'testnet'", "in", "net", ":", "net", "=", "net", "[", "1", ":", "]", "+", "'-test'", "else", ":", "net", "=", "net", "r...
take care of specifics of cryptoid naming system
[ "take", "care", "of", "specifics", "of", "cryptoid", "naming", "system" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/cryptoid.py#L33-L41
train
PeerAssets/pypeerassets
pypeerassets/provider/cryptoid.py
Cryptoid.get_url
def get_url(url: str) -> Union[dict, int, float, str]: '''Perform a GET request for the url and return a dictionary parsed from the JSON response.''' request = Request(url, headers={"User-Agent": "pypeerassets"}) response = cast(HTTPResponse, urlopen(request)) if response.status...
python
def get_url(url: str) -> Union[dict, int, float, str]: '''Perform a GET request for the url and return a dictionary parsed from the JSON response.''' request = Request(url, headers={"User-Agent": "pypeerassets"}) response = cast(HTTPResponse, urlopen(request)) if response.status...
[ "def", "get_url", "(", "url", ":", "str", ")", "->", "Union", "[", "dict", ",", "int", ",", "float", ",", "str", "]", ":", "request", "=", "Request", "(", "url", ",", "headers", "=", "{", "\"User-Agent\"", ":", "\"pypeerassets\"", "}", ")", "response...
Perform a GET request for the url and return a dictionary parsed from the JSON response.
[ "Perform", "a", "GET", "request", "for", "the", "url", "and", "return", "a", "dictionary", "parsed", "from", "the", "JSON", "response", "." ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/cryptoid.py#L44-L52
train
edoburu/django-template-analyzer
template_analyzer/djangoanalyzer.py
_scan_nodes
def _scan_nodes(nodelist, context, instance_types, current_block=None, ignore_blocks=None): """ Loop through all nodes of a single scope level. :type nodelist: django.template.base.NodeList :type current_block: BlockNode :param instance_types: The instance to look for """ results = [] f...
python
def _scan_nodes(nodelist, context, instance_types, current_block=None, ignore_blocks=None): """ Loop through all nodes of a single scope level. :type nodelist: django.template.base.NodeList :type current_block: BlockNode :param instance_types: The instance to look for """ results = [] f...
[ "def", "_scan_nodes", "(", "nodelist", ",", "context", ",", "instance_types", ",", "current_block", "=", "None", ",", "ignore_blocks", "=", "None", ")", ":", "results", "=", "[", "]", "for", "node", "in", "nodelist", ":", "# first check if this is the object ins...
Loop through all nodes of a single scope level. :type nodelist: django.template.base.NodeList :type current_block: BlockNode :param instance_types: The instance to look for
[ "Loop", "through", "all", "nodes", "of", "a", "single", "scope", "level", "." ]
912916dadf68e5fb6bd3dbaa8e5dcad69d3086d0
https://github.com/edoburu/django-template-analyzer/blob/912916dadf68e5fb6bd3dbaa8e5dcad69d3086d0/template_analyzer/djangoanalyzer.py#L125-L191
train
edoburu/django-template-analyzer
template_analyzer/djangoanalyzer.py
get_node_instances
def get_node_instances(nodelist, instances): """ Find the nodes of a given instance. In contract to the standard ``template.nodelist.get_nodes_by_type()`` method, this also looks into ``{% extends %}`` and ``{% include .. %}`` nodes to find all possible nodes of the given type. :param instance...
python
def get_node_instances(nodelist, instances): """ Find the nodes of a given instance. In contract to the standard ``template.nodelist.get_nodes_by_type()`` method, this also looks into ``{% extends %}`` and ``{% include .. %}`` nodes to find all possible nodes of the given type. :param instance...
[ "def", "get_node_instances", "(", "nodelist", ",", "instances", ")", ":", "context", "=", "_get_main_context", "(", "nodelist", ")", "# The Django 1.8 loader returns an adapter class; it wraps the original Template in a new object to be API compatible", "if", "TemplateAdapter", "is...
Find the nodes of a given instance. In contract to the standard ``template.nodelist.get_nodes_by_type()`` method, this also looks into ``{% extends %}`` and ``{% include .. %}`` nodes to find all possible nodes of the given type. :param instances: A class Type, or tuple of types to find. :param no...
[ "Find", "the", "nodes", "of", "a", "given", "instance", "." ]
912916dadf68e5fb6bd3dbaa8e5dcad69d3086d0
https://github.com/edoburu/django-template-analyzer/blob/912916dadf68e5fb6bd3dbaa8e5dcad69d3086d0/template_analyzer/djangoanalyzer.py#L224-L243
train
lreis2415/PyGeoC
pygeoc/utils.py
get_config_file
def get_config_file(): # type: () -> AnyStr """Get model configuration file name from argv""" parser = argparse.ArgumentParser(description="Read configuration file.") parser.add_argument('-ini', help="Full path of configuration file") args = parser.parse_args() ini_file = args.ini if not Fil...
python
def get_config_file(): # type: () -> AnyStr """Get model configuration file name from argv""" parser = argparse.ArgumentParser(description="Read configuration file.") parser.add_argument('-ini', help="Full path of configuration file") args = parser.parse_args() ini_file = args.ini if not Fil...
[ "def", "get_config_file", "(", ")", ":", "# type: () -> AnyStr", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Read configuration file.\"", ")", "parser", ".", "add_argument", "(", "'-ini'", ",", "help", "=", "\"Full path of configurati...
Get model configuration file name from argv
[ "Get", "model", "configuration", "file", "name", "from", "argv" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L1013-L1023
train
lreis2415/PyGeoC
pygeoc/utils.py
MathClass.isnumerical
def isnumerical(x): # type: (...) -> bool """Check the input x is numerical or not. Examples: >>> MathClass.isnumerical('78') True >>> MathClass.isnumerical('1.e-5') True >>> MathClass.isnumerical(None) False >>...
python
def isnumerical(x): # type: (...) -> bool """Check the input x is numerical or not. Examples: >>> MathClass.isnumerical('78') True >>> MathClass.isnumerical('1.e-5') True >>> MathClass.isnumerical(None) False >>...
[ "def", "isnumerical", "(", "x", ")", ":", "# type: (...) -> bool", "try", ":", "xx", "=", "float", "(", "x", ")", "except", "TypeError", ":", "return", "False", "except", "ValueError", ":", "return", "False", "except", "Exception", ":", "return", "False", ...
Check the input x is numerical or not. Examples: >>> MathClass.isnumerical('78') True >>> MathClass.isnumerical('1.e-5') True >>> MathClass.isnumerical(None) False >>> MathClass.isnumerical('a1.2') False ...
[ "Check", "the", "input", "x", "is", "numerical", "or", "not", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L111-L139
train
lreis2415/PyGeoC
pygeoc/utils.py
MathClass.rsquare
def rsquare(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues # type: Union[numpy.ndarray, List[Union[float, int]]] ): # type: (...) -> Union[float, numpy.ScalarType] """Calculate Coefficient of determination. Same as the square of the ...
python
def rsquare(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues # type: Union[numpy.ndarray, List[Union[float, int]]] ): # type: (...) -> Union[float, numpy.ScalarType] """Calculate Coefficient of determination. Same as the square of the ...
[ "def", "rsquare", "(", "obsvalues", ",", "# type: Union[numpy.ndarray, List[Union[float, int]]]", "simvalues", "# type: Union[numpy.ndarray, List[Union[float, int]]]", ")", ":", "# type: (...) -> Union[float, numpy.ScalarType]", "if", "len", "(", "obsvalues", ")", "!=", "len", "(...
Calculate Coefficient of determination. Same as the square of the Pearson correlation coefficient (r), and, the same as the built-in Excel function RSQ(). Programmed according to equation (1) in Legates, D.R. and G.J. McCabe, 1999. Evaluating the use of "goodness of fit" measu...
[ "Calculate", "Coefficient", "of", "determination", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L240-L284
train
lreis2415/PyGeoC
pygeoc/utils.py
MathClass.rmse
def rmse(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues # type: Union[numpy.ndarray, List[Union[float, int]]] ): # type: (...) -> Union[float, numpy.ScalarType] """Calculate RMSE. Args: obsvalues: observe values array ...
python
def rmse(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues # type: Union[numpy.ndarray, List[Union[float, int]]] ): # type: (...) -> Union[float, numpy.ScalarType] """Calculate RMSE. Args: obsvalues: observe values array ...
[ "def", "rmse", "(", "obsvalues", ",", "# type: Union[numpy.ndarray, List[Union[float, int]]]", "simvalues", "# type: Union[numpy.ndarray, List[Union[float, int]]]", ")", ":", "# type: (...) -> Union[float, numpy.ScalarType]", "if", "len", "(", "obsvalues", ")", "!=", "len", "(", ...
Calculate RMSE. Args: obsvalues: observe values array simvalues: simulate values array Examples: >>> obs = [2.92, 2.75, 2.01, 1.09, 2.87, 1.43, 1.96,\ 4.00, 2.24, 29.28, 5.88, 0.86, 13.21] >>> sim = [2.90, 2.87, 2.85, 2.83, 3.04, 2...
[ "Calculate", "RMSE", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L287-L315
train
lreis2415/PyGeoC
pygeoc/utils.py
MathClass.pbias
def pbias(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues # type: Union[numpy.ndarray, List[Union[float, int]]] ): # type: (...) -> Union[float, numpy.ScalarType] """Calculate PBIAS, or percent model bias. Args: obsvalues: obs...
python
def pbias(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues # type: Union[numpy.ndarray, List[Union[float, int]]] ): # type: (...) -> Union[float, numpy.ScalarType] """Calculate PBIAS, or percent model bias. Args: obsvalues: obs...
[ "def", "pbias", "(", "obsvalues", ",", "# type: Union[numpy.ndarray, List[Union[float, int]]]", "simvalues", "# type: Union[numpy.ndarray, List[Union[float, int]]]", ")", ":", "# type: (...) -> Union[float, numpy.ScalarType]", "if", "len", "(", "obsvalues", ")", "!=", "len", "(",...
Calculate PBIAS, or percent model bias. Args: obsvalues: observe values array simvalues: simulate values array Examples: >>> obs = [2.92, 2.75, 2.01, 1.09, 2.87, 1.43, 1.96,\ 4.00, 2.24, 29.28, 5.88, 0.86, 13.21] >>> sim = [2.90, 2...
[ "Calculate", "PBIAS", "or", "percent", "model", "bias", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L318-L342
train
lreis2415/PyGeoC
pygeoc/utils.py
StringClass.convert_str2num
def convert_str2num(unicode_str # type: Union[AnyStr, int, float, List[Union[AnyStr, float, int]], Tuple[Union[AnyStr, float, int]]] ): # type: (...) -> Union[AnyStr, int, float, List[Union[AnyStr, float, int]], Tuple[Union[AnyStr, float, int]]] """Convert string to string, inte...
python
def convert_str2num(unicode_str # type: Union[AnyStr, int, float, List[Union[AnyStr, float, int]], Tuple[Union[AnyStr, float, int]]] ): # type: (...) -> Union[AnyStr, int, float, List[Union[AnyStr, float, int]], Tuple[Union[AnyStr, float, int]]] """Convert string to string, inte...
[ "def", "convert_str2num", "(", "unicode_str", "# type: Union[AnyStr, int, float, List[Union[AnyStr, float, int]], Tuple[Union[AnyStr, float, int]]]", ")", ":", "# type: (...) -> Union[AnyStr, int, float, List[Union[AnyStr, float, int]], Tuple[Union[AnyStr, float, int]]]", "if", "MathClass", ".",...
Convert string to string, integer, or float. Support tuple or list. Examples: >>> StringClass.convert_str2num('1.23') 1.23 >>> StringClass.convert_str2num(u'1.23') 1.23 >>> StringClass.convert_str2num(u'21.') 21 >>> StringClass...
[ "Convert", "string", "to", "string", "integer", "or", "float", ".", "Support", "tuple", "or", "list", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L387-L418
train
lreis2415/PyGeoC
pygeoc/utils.py
StringClass.string_in_list
def string_in_list(tmp_str, strlist): # type: (AnyStr, List[AnyStr]) -> bool """Is tmp_str in strlist, case insensitive.""" new_str_list = strlist[:] for i, str_in_list in enumerate(new_str_list): new_str_list[i] = str_in_list.lower() return tmp_str.lower() in new_str...
python
def string_in_list(tmp_str, strlist): # type: (AnyStr, List[AnyStr]) -> bool """Is tmp_str in strlist, case insensitive.""" new_str_list = strlist[:] for i, str_in_list in enumerate(new_str_list): new_str_list[i] = str_in_list.lower() return tmp_str.lower() in new_str...
[ "def", "string_in_list", "(", "tmp_str", ",", "strlist", ")", ":", "# type: (AnyStr, List[AnyStr]) -> bool", "new_str_list", "=", "strlist", "[", ":", "]", "for", "i", ",", "str_in_list", "in", "enumerate", "(", "new_str_list", ")", ":", "new_str_list", "[", "i"...
Is tmp_str in strlist, case insensitive.
[ "Is", "tmp_str", "in", "strlist", "case", "insensitive", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L475-L481
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.is_file_exists
def is_file_exists(filename): # type: (AnyStr) -> bool """Check the existence of file path.""" if filename is None or not os.path.exists(filename) or not os.path.isfile(filename): return False else: return True
python
def is_file_exists(filename): # type: (AnyStr) -> bool """Check the existence of file path.""" if filename is None or not os.path.exists(filename) or not os.path.isfile(filename): return False else: return True
[ "def", "is_file_exists", "(", "filename", ")", ":", "# type: (AnyStr) -> bool", "if", "filename", "is", "None", "or", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", "or", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":",...
Check the existence of file path.
[ "Check", "the", "existence", "of", "file", "path", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L588-L594
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.is_dir_exists
def is_dir_exists(dirpath): # type: (AnyStr) -> bool """Check the existence of folder path.""" if dirpath is None or not os.path.exists(dirpath) or not os.path.isdir(dirpath): return False else: return True
python
def is_dir_exists(dirpath): # type: (AnyStr) -> bool """Check the existence of folder path.""" if dirpath is None or not os.path.exists(dirpath) or not os.path.isdir(dirpath): return False else: return True
[ "def", "is_dir_exists", "(", "dirpath", ")", ":", "# type: (AnyStr) -> bool", "if", "dirpath", "is", "None", "or", "not", "os", ".", "path", ".", "exists", "(", "dirpath", ")", "or", "not", "os", ".", "path", ".", "isdir", "(", "dirpath", ")", ":", "re...
Check the existence of folder path.
[ "Check", "the", "existence", "of", "folder", "path", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L597-L603
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.copy_files
def copy_files(filename, dstfilename): # type: (AnyStr, AnyStr) -> None """Copy files with the same name and different suffixes, such as ESRI Shapefile.""" FileClass.remove_files(dstfilename) dst_prefix = os.path.splitext(dstfilename)[0] pattern = os.path.splitext(filename)[0] + ...
python
def copy_files(filename, dstfilename): # type: (AnyStr, AnyStr) -> None """Copy files with the same name and different suffixes, such as ESRI Shapefile.""" FileClass.remove_files(dstfilename) dst_prefix = os.path.splitext(dstfilename)[0] pattern = os.path.splitext(filename)[0] + ...
[ "def", "copy_files", "(", "filename", ",", "dstfilename", ")", ":", "# type: (AnyStr, AnyStr) -> None", "FileClass", ".", "remove_files", "(", "dstfilename", ")", "dst_prefix", "=", "os", ".", "path", ".", "splitext", "(", "dstfilename", ")", "[", "0", "]", "p...
Copy files with the same name and different suffixes, such as ESRI Shapefile.
[ "Copy", "files", "with", "the", "same", "name", "and", "different", "suffixes", "such", "as", "ESRI", "Shapefile", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L613-L622
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.remove_files
def remove_files(filename): # type: (AnyStr) -> None """ Delete all files with same root as fileName, i.e. regardless of suffix, such as ESRI shapefile """ pattern = os.path.splitext(filename)[0] + '.*' for f in glob.iglob(pattern): os.remove(f)
python
def remove_files(filename): # type: (AnyStr) -> None """ Delete all files with same root as fileName, i.e. regardless of suffix, such as ESRI shapefile """ pattern = os.path.splitext(filename)[0] + '.*' for f in glob.iglob(pattern): os.remove(f)
[ "def", "remove_files", "(", "filename", ")", ":", "# type: (AnyStr) -> None", "pattern", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "0", "]", "+", "'.*'", "for", "f", "in", "glob", ".", "iglob", "(", "pattern", ")", ":", "os", ...
Delete all files with same root as fileName, i.e. regardless of suffix, such as ESRI shapefile
[ "Delete", "all", "files", "with", "same", "root", "as", "fileName", "i", ".", "e", ".", "regardless", "of", "suffix", "such", "as", "ESRI", "shapefile" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L625-L633
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.is_up_to_date
def is_up_to_date(outfile, basedatetime): # type: (AnyStr, datetime) -> bool """Return true if outfile exists and is no older than base datetime.""" if os.path.exists(outfile): if os.path.getmtime(outfile) >= basedatetime: return True return False
python
def is_up_to_date(outfile, basedatetime): # type: (AnyStr, datetime) -> bool """Return true if outfile exists and is no older than base datetime.""" if os.path.exists(outfile): if os.path.getmtime(outfile) >= basedatetime: return True return False
[ "def", "is_up_to_date", "(", "outfile", ",", "basedatetime", ")", ":", "# type: (AnyStr, datetime) -> bool", "if", "os", ".", "path", ".", "exists", "(", "outfile", ")", ":", "if", "os", ".", "path", ".", "getmtime", "(", "outfile", ")", ">=", "basedatetime"...
Return true if outfile exists and is no older than base datetime.
[ "Return", "true", "if", "outfile", "exists", "and", "is", "no", "older", "than", "base", "datetime", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L636-L642
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.get_executable_fullpath
def get_executable_fullpath(name, dirname=None): # type: (AnyStr, Optional[AnyStr]) -> Optional[AnyStr] """get the full path of a given executable name""" if name is None: return None if is_string(name): name = str(name) else: raise RuntimeErro...
python
def get_executable_fullpath(name, dirname=None): # type: (AnyStr, Optional[AnyStr]) -> Optional[AnyStr] """get the full path of a given executable name""" if name is None: return None if is_string(name): name = str(name) else: raise RuntimeErro...
[ "def", "get_executable_fullpath", "(", "name", ",", "dirname", "=", "None", ")", ":", "# type: (AnyStr, Optional[AnyStr]) -> Optional[AnyStr]", "if", "name", "is", "None", ":", "return", "None", "if", "is_string", "(", "name", ")", ":", "name", "=", "str", "(", ...
get the full path of a given executable name
[ "get", "the", "full", "path", "of", "a", "given", "executable", "name" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L645-L670
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.get_file_fullpath
def get_file_fullpath(name, dirname=None): # type: (AnyStr, Optional[AnyStr]) -> Optional[AnyStr] """Return full path if available.""" if name is None: return None if is_string(name): name = str(name) else: raise RuntimeError('The input functio...
python
def get_file_fullpath(name, dirname=None): # type: (AnyStr, Optional[AnyStr]) -> Optional[AnyStr] """Return full path if available.""" if name is None: return None if is_string(name): name = str(name) else: raise RuntimeError('The input functio...
[ "def", "get_file_fullpath", "(", "name", ",", "dirname", "=", "None", ")", ":", "# type: (AnyStr, Optional[AnyStr]) -> Optional[AnyStr]", "if", "name", "is", "None", ":", "return", "None", "if", "is_string", "(", "name", ")", ":", "name", "=", "str", "(", "nam...
Return full path if available.
[ "Return", "full", "path", "if", "available", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L673-L689
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.get_filename_by_suffixes
def get_filename_by_suffixes(dir_src, suffixes): # type: (AnyStr, Union[AnyStr, List[AnyStr]]) -> Optional[List[AnyStr]] """get file names with the given suffixes in the given directory Args: dir_src: directory path suffixes: wanted suffixes list, the suffix in suffixes ...
python
def get_filename_by_suffixes(dir_src, suffixes): # type: (AnyStr, Union[AnyStr, List[AnyStr]]) -> Optional[List[AnyStr]] """get file names with the given suffixes in the given directory Args: dir_src: directory path suffixes: wanted suffixes list, the suffix in suffixes ...
[ "def", "get_filename_by_suffixes", "(", "dir_src", ",", "suffixes", ")", ":", "# type: (AnyStr, Union[AnyStr, List[AnyStr]]) -> Optional[List[AnyStr]]", "list_files", "=", "os", ".", "listdir", "(", "dir_src", ")", "re_files", "=", "list", "(", ")", "if", "is_string", ...
get file names with the given suffixes in the given directory Args: dir_src: directory path suffixes: wanted suffixes list, the suffix in suffixes can with or without '.' Returns: file names with the given suffixes as list
[ "get", "file", "names", "with", "the", "given", "suffixes", "in", "the", "given", "directory" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L692-L716
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.get_full_filename_by_suffixes
def get_full_filename_by_suffixes(dir_src, suffixes): # type: (AnyStr, Union[AnyStr, List[AnyStr]]) -> Optional[List[AnyStr]] """get full file names with the given suffixes in the given directory Args: dir_src: directory path suffixes: wanted suffixes Returns: ...
python
def get_full_filename_by_suffixes(dir_src, suffixes): # type: (AnyStr, Union[AnyStr, List[AnyStr]]) -> Optional[List[AnyStr]] """get full file names with the given suffixes in the given directory Args: dir_src: directory path suffixes: wanted suffixes Returns: ...
[ "def", "get_full_filename_by_suffixes", "(", "dir_src", ",", "suffixes", ")", ":", "# type: (AnyStr, Union[AnyStr, List[AnyStr]]) -> Optional[List[AnyStr]]", "file_names", "=", "FileClass", ".", "get_filename_by_suffixes", "(", "dir_src", ",", "suffixes", ")", "if", "file_nam...
get full file names with the given suffixes in the given directory Args: dir_src: directory path suffixes: wanted suffixes Returns: full file names with the given suffixes as list
[ "get", "full", "file", "names", "with", "the", "given", "suffixes", "in", "the", "given", "directory" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L719-L733
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.get_core_name_without_suffix
def get_core_name_without_suffix(file_path): # type: (AnyStr) -> AnyStr """Return core file name without suffix. Examples: >>> FileClass.get_core_name_without_suffix(r'/home/zhulj/1990.01.30/test.01.tif') 'test.01' >>> FileClass.get_core_name_without_suffix(r...
python
def get_core_name_without_suffix(file_path): # type: (AnyStr) -> AnyStr """Return core file name without suffix. Examples: >>> FileClass.get_core_name_without_suffix(r'/home/zhulj/1990.01.30/test.01.tif') 'test.01' >>> FileClass.get_core_name_without_suffix(r...
[ "def", "get_core_name_without_suffix", "(", "file_path", ")", ":", "# type: (AnyStr) -> AnyStr", "if", "'\\\\'", "in", "file_path", ":", "file_path", "=", "file_path", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "file_name", "=", "os", ".", "path", ".", "b...
Return core file name without suffix. Examples: >>> FileClass.get_core_name_without_suffix(r'/home/zhulj/1990.01.30/test.01.tif') 'test.01' >>> FileClass.get_core_name_without_suffix(r'C:\zhulj\igsnrr\lreis.txt') 'lreis' >>> FileClass.get_core_name_wi...
[ "Return", "core", "file", "name", "without", "suffix", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L736-L765
train
lreis2415/PyGeoC
pygeoc/utils.py
FileClass.add_postfix
def add_postfix(file_path, postfix): # type: (AnyStr, AnyStr) -> AnyStr """Add postfix for a full file path. Examples: >>> FileClass.add_postfix('/home/zhulj/dem.tif', 'filled') '/home/zhulj/dem_filled.tif' >>> FileClass.add_postfix('dem.tif', 'filled') ...
python
def add_postfix(file_path, postfix): # type: (AnyStr, AnyStr) -> AnyStr """Add postfix for a full file path. Examples: >>> FileClass.add_postfix('/home/zhulj/dem.tif', 'filled') '/home/zhulj/dem_filled.tif' >>> FileClass.add_postfix('dem.tif', 'filled') ...
[ "def", "add_postfix", "(", "file_path", ",", "postfix", ")", ":", "# type: (AnyStr, AnyStr) -> AnyStr", "cur_sep", "=", "''", "for", "sep", "in", "[", "'\\\\'", ",", "'/'", ",", "os", ".", "sep", "]", ":", "if", "sep", "in", "file_path", ":", "cur_sep", ...
Add postfix for a full file path. Examples: >>> FileClass.add_postfix('/home/zhulj/dem.tif', 'filled') '/home/zhulj/dem_filled.tif' >>> FileClass.add_postfix('dem.tif', 'filled') 'dem_filled.tif' >>> FileClass.add_postfix('dem', 'filled') ...
[ "Add", "postfix", "for", "a", "full", "file", "path", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L768-L793
train
lreis2415/PyGeoC
pygeoc/utils.py
DateClass.day_of_year
def day_of_year(dt): # type: (int) -> int """Day index of year from 1 to 365 or 366""" sec = time.mktime(dt.timetuple()) t = time.localtime(sec) return t.tm_yday
python
def day_of_year(dt): # type: (int) -> int """Day index of year from 1 to 365 or 366""" sec = time.mktime(dt.timetuple()) t = time.localtime(sec) return t.tm_yday
[ "def", "day_of_year", "(", "dt", ")", ":", "# type: (int) -> int", "sec", "=", "time", ".", "mktime", "(", "dt", ".", "timetuple", "(", ")", ")", "t", "=", "time", ".", "localtime", "(", "sec", ")", "return", "t", ".", "tm_yday" ]
Day index of year from 1 to 365 or 366
[ "Day", "index", "of", "year", "from", "1", "to", "365", "or", "366" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L834-L839
train
lreis2415/PyGeoC
pygeoc/utils.py
UtilClass.run_command
def run_command(commands): # type: (Union[AnyStr, List[AnyStr]]) -> List[AnyStr] """Execute external command, and return the output lines list. In windows, refers to `handling-subprocess-crash-in-windows`_. Args: commands: string or list Returns: output ...
python
def run_command(commands): # type: (Union[AnyStr, List[AnyStr]]) -> List[AnyStr] """Execute external command, and return the output lines list. In windows, refers to `handling-subprocess-crash-in-windows`_. Args: commands: string or list Returns: output ...
[ "def", "run_command", "(", "commands", ")", ":", "# type: (Union[AnyStr, List[AnyStr]]) -> List[AnyStr]", "# commands = StringClass.convert_unicode2str(commands)", "# print(commands)", "use_shell", "=", "False", "subprocess_flags", "=", "0", "startupinfo", "=", "None", "if", "s...
Execute external command, and return the output lines list. In windows, refers to `handling-subprocess-crash-in-windows`_. Args: commands: string or list Returns: output lines .. _handling-subprocess-crash-in-windows: https://stackoverflow.com/quest...
[ "Execute", "external", "command", "and", "return", "the", "output", "lines", "list", ".", "In", "windows", "refers", "to", "handling", "-", "subprocess", "-", "crash", "-", "in", "-", "windows", "_", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L850-L912
train
lreis2415/PyGeoC
pygeoc/utils.py
UtilClass.current_path
def current_path(local_function): """Get current path, refers to `how-do-i-get-the-path-of-the-current-executed-file-in-python`_ Examples: .. code-block:: Python from pygeoc.utils import UtilClass curpath = UtilClass.current_path(lambda: 0) .. _how-d...
python
def current_path(local_function): """Get current path, refers to `how-do-i-get-the-path-of-the-current-executed-file-in-python`_ Examples: .. code-block:: Python from pygeoc.utils import UtilClass curpath = UtilClass.current_path(lambda: 0) .. _how-d...
[ "def", "current_path", "(", "local_function", ")", ":", "from", "inspect", "import", "getsourcefile", "fpath", "=", "getsourcefile", "(", "local_function", ")", "if", "fpath", "is", "None", ":", "return", "None", "return", "os", ".", "path", ".", "dirname", ...
Get current path, refers to `how-do-i-get-the-path-of-the-current-executed-file-in-python`_ Examples: .. code-block:: Python from pygeoc.utils import UtilClass curpath = UtilClass.current_path(lambda: 0) .. _how-do-i-get-the-path-of-the-current-executed-file...
[ "Get", "current", "path", "refers", "to", "how", "-", "do", "-", "i", "-", "get", "-", "the", "-", "path", "-", "of", "-", "the", "-", "current", "-", "executed", "-", "file", "-", "in", "-", "python", "_" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L915-L932
train
lreis2415/PyGeoC
pygeoc/utils.py
UtilClass.mkdir
def mkdir(dir_path): # type: (AnyStr) -> None """Make directory if not existed""" if not os.path.isdir(dir_path) or not os.path.exists(dir_path): os.makedirs(dir_path)
python
def mkdir(dir_path): # type: (AnyStr) -> None """Make directory if not existed""" if not os.path.isdir(dir_path) or not os.path.exists(dir_path): os.makedirs(dir_path)
[ "def", "mkdir", "(", "dir_path", ")", ":", "# type: (AnyStr) -> None", "if", "not", "os", ".", "path", ".", "isdir", "(", "dir_path", ")", "or", "not", "os", ".", "path", ".", "exists", "(", "dir_path", ")", ":", "os", ".", "makedirs", "(", "dir_path",...
Make directory if not existed
[ "Make", "directory", "if", "not", "existed" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L935-L939
train
lreis2415/PyGeoC
pygeoc/utils.py
UtilClass.rmmkdir
def rmmkdir(dir_path): # type: (AnyStr) -> None """If directory existed, then remove and make; else make it.""" if not os.path.isdir(dir_path) or not os.path.exists(dir_path): os.makedirs(dir_path) else: rmtree(dir_path, True) os.makedirs(dir_path)
python
def rmmkdir(dir_path): # type: (AnyStr) -> None """If directory existed, then remove and make; else make it.""" if not os.path.isdir(dir_path) or not os.path.exists(dir_path): os.makedirs(dir_path) else: rmtree(dir_path, True) os.makedirs(dir_path)
[ "def", "rmmkdir", "(", "dir_path", ")", ":", "# type: (AnyStr) -> None", "if", "not", "os", ".", "path", ".", "isdir", "(", "dir_path", ")", "or", "not", "os", ".", "path", ".", "exists", "(", "dir_path", ")", ":", "os", ".", "makedirs", "(", "dir_path...
If directory existed, then remove and make; else make it.
[ "If", "directory", "existed", "then", "remove", "and", "make", ";", "else", "make", "it", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L942-L949
train
lreis2415/PyGeoC
pygeoc/utils.py
UtilClass.print_msg
def print_msg(contentlist): # type: (Union[AnyStr, List[AnyStr], Tuple[AnyStr]]) -> AnyStr """concatenate message list as single string with line feed.""" if isinstance(contentlist, list) or isinstance(contentlist, tuple): return '\n'.join(contentlist) else: # strings ...
python
def print_msg(contentlist): # type: (Union[AnyStr, List[AnyStr], Tuple[AnyStr]]) -> AnyStr """concatenate message list as single string with line feed.""" if isinstance(contentlist, list) or isinstance(contentlist, tuple): return '\n'.join(contentlist) else: # strings ...
[ "def", "print_msg", "(", "contentlist", ")", ":", "# type: (Union[AnyStr, List[AnyStr], Tuple[AnyStr]]) -> AnyStr", "if", "isinstance", "(", "contentlist", ",", "list", ")", "or", "isinstance", "(", "contentlist", ",", "tuple", ")", ":", "return", "'\\n'", ".", "joi...
concatenate message list as single string with line feed.
[ "concatenate", "message", "list", "as", "single", "string", "with", "line", "feed", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L952-L960
train
lreis2415/PyGeoC
pygeoc/utils.py
UtilClass.decode_strs_in_dict
def decode_strs_in_dict(unicode_dict # type: Dict[Union[AnyStr, int], Union[int, float, AnyStr, List[Union[int, float, AnyStr]]]] ): # type: (...) -> Dict[Union[AnyStr, int], Any] """Decode strings in dictionary which may contains unicode strings or numeric values. ...
python
def decode_strs_in_dict(unicode_dict # type: Dict[Union[AnyStr, int], Union[int, float, AnyStr, List[Union[int, float, AnyStr]]]] ): # type: (...) -> Dict[Union[AnyStr, int], Any] """Decode strings in dictionary which may contains unicode strings or numeric values. ...
[ "def", "decode_strs_in_dict", "(", "unicode_dict", "# type: Dict[Union[AnyStr, int], Union[int, float, AnyStr, List[Union[int, float, AnyStr]]]]", ")", ":", "# type: (...) -> Dict[Union[AnyStr, int], Any]", "unicode_dict", "=", "{", "StringClass", ".", "convert_str2num", "(", "k", ")...
Decode strings in dictionary which may contains unicode strings or numeric values. - 1. integer could be key, float cannot; - 2. the function is called recursively Examples: .. code-block:: python input = {u'name': u'zhulj', u'age': u'28', u'1': ['1', 2, 3]} ...
[ "Decode", "strings", "in", "dictionary", "which", "may", "contains", "unicode", "strings", "or", "numeric", "values", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L987-L1010
train
rosshamish/catan-py
catan/game.py
Game.undo
def undo(self): """ Rewind the game to the previous state. """ self.undo_manager.undo() self.notify_observers() logging.debug('undo_manager undo stack={}'.format(self.undo_manager._undo_stack))
python
def undo(self): """ Rewind the game to the previous state. """ self.undo_manager.undo() self.notify_observers() logging.debug('undo_manager undo stack={}'.format(self.undo_manager._undo_stack))
[ "def", "undo", "(", "self", ")", ":", "self", ".", "undo_manager", ".", "undo", "(", ")", "self", ".", "notify_observers", "(", ")", "logging", ".", "debug", "(", "'undo_manager undo stack={}'", ".", "format", "(", "self", ".", "undo_manager", ".", "_undo_...
Rewind the game to the previous state.
[ "Rewind", "the", "game", "to", "the", "previous", "state", "." ]
120438a8f16e39c13322c5d5930e1064e1d3f4be
https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/game.py#L91-L97
train
rosshamish/catan-py
catan/game.py
Game.redo
def redo(self): """ Redo the latest undone command. """ self.undo_manager.redo() self.notify_observers() logging.debug('undo_manager redo stack={}'.format(self.undo_manager._redo_stack))
python
def redo(self): """ Redo the latest undone command. """ self.undo_manager.redo() self.notify_observers() logging.debug('undo_manager redo stack={}'.format(self.undo_manager._redo_stack))
[ "def", "redo", "(", "self", ")", ":", "self", ".", "undo_manager", ".", "redo", "(", ")", "self", ".", "notify_observers", "(", ")", "logging", ".", "debug", "(", "'undo_manager redo stack={}'", ".", "format", "(", "self", ".", "undo_manager", ".", "_redo_...
Redo the latest undone command.
[ "Redo", "the", "latest", "undone", "command", "." ]
120438a8f16e39c13322c5d5930e1064e1d3f4be
https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/game.py#L99-L105
train
PeerAssets/pypeerassets
pypeerassets/networks.py
net_query
def net_query(name: str) -> Constants: '''Find the NetworkParams for a network by its long or short name. Raises UnsupportedNetwork if no NetworkParams is found. ''' for net_params in networks: if name in (net_params.name, net_params.shortname,): return net_params raise Unsuppo...
python
def net_query(name: str) -> Constants: '''Find the NetworkParams for a network by its long or short name. Raises UnsupportedNetwork if no NetworkParams is found. ''' for net_params in networks: if name in (net_params.name, net_params.shortname,): return net_params raise Unsuppo...
[ "def", "net_query", "(", "name", ":", "str", ")", "->", "Constants", ":", "for", "net_params", "in", "networks", ":", "if", "name", "in", "(", "net_params", ".", "name", ",", "net_params", ".", "shortname", ",", ")", ":", "return", "net_params", "raise",...
Find the NetworkParams for a network by its long or short name. Raises UnsupportedNetwork if no NetworkParams is found.
[ "Find", "the", "NetworkParams", "for", "a", "network", "by", "its", "long", "or", "short", "name", ".", "Raises", "UnsupportedNetwork", "if", "no", "NetworkParams", "is", "found", "." ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/networks.py#L100-L109
train
rosshamish/catan-py
catan/board.py
Board.get_port_at
def get_port_at(self, tile_id, direction): """ If no port is found, a new none port is made and added to self.ports. Returns the port. :param tile_id: :param direction: :return: Port """ for port in self.ports: if port.tile_id == tile_id and ...
python
def get_port_at(self, tile_id, direction): """ If no port is found, a new none port is made and added to self.ports. Returns the port. :param tile_id: :param direction: :return: Port """ for port in self.ports: if port.tile_id == tile_id and ...
[ "def", "get_port_at", "(", "self", ",", "tile_id", ",", "direction", ")", ":", "for", "port", "in", "self", ".", "ports", ":", "if", "port", ".", "tile_id", "==", "tile_id", "and", "port", ".", "direction", "==", "direction", ":", "return", "port", "po...
If no port is found, a new none port is made and added to self.ports. Returns the port. :param tile_id: :param direction: :return: Port
[ "If", "no", "port", "is", "found", "a", "new", "none", "port", "is", "made", "and", "added", "to", "self", ".", "ports", "." ]
120438a8f16e39c13322c5d5930e1064e1d3f4be
https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/board.py#L170-L185
train
rosshamish/catan-py
catan/board.py
Board.rotate_ports
def rotate_ports(self): """ Rotates the ports 90 degrees. Useful when using the default port setup but the spectator is watching at a "rotated" angle from "true north". """ for port in self.ports: port.tile_id = ((port.tile_id + 1) % len(hexgrid.coastal_tile_ids())) +...
python
def rotate_ports(self): """ Rotates the ports 90 degrees. Useful when using the default port setup but the spectator is watching at a "rotated" angle from "true north". """ for port in self.ports: port.tile_id = ((port.tile_id + 1) % len(hexgrid.coastal_tile_ids())) +...
[ "def", "rotate_ports", "(", "self", ")", ":", "for", "port", "in", "self", ".", "ports", ":", "port", ".", "tile_id", "=", "(", "(", "port", ".", "tile_id", "+", "1", ")", "%", "len", "(", "hexgrid", ".", "coastal_tile_ids", "(", ")", ")", ")", "...
Rotates the ports 90 degrees. Useful when using the default port setup but the spectator is watching at a "rotated" angle from "true north".
[ "Rotates", "the", "ports", "90", "degrees", ".", "Useful", "when", "using", "the", "default", "port", "setup", "but", "the", "spectator", "is", "watching", "at", "a", "rotated", "angle", "from", "true", "north", "." ]
120438a8f16e39c13322c5d5930e1064e1d3f4be
https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/board.py#L226-L234
train
etal/biofrills
biofrills/sequtils.py
intersect_keys
def intersect_keys(keys, reffile, cache=False, clean_accs=False): """Extract SeqRecords from the index by matching keys. keys - an iterable of sequence identifiers/accessions to select reffile - name of a FASTA file to extract the specified sequences from cache - save an index of the reference FASTA se...
python
def intersect_keys(keys, reffile, cache=False, clean_accs=False): """Extract SeqRecords from the index by matching keys. keys - an iterable of sequence identifiers/accessions to select reffile - name of a FASTA file to extract the specified sequences from cache - save an index of the reference FASTA se...
[ "def", "intersect_keys", "(", "keys", ",", "reffile", ",", "cache", "=", "False", ",", "clean_accs", "=", "False", ")", ":", "# Build/load the index of reference sequences", "index", "=", "None", "if", "cache", ":", "refcache", "=", "reffile", "+", "'.sqlite'", ...
Extract SeqRecords from the index by matching keys. keys - an iterable of sequence identifiers/accessions to select reffile - name of a FASTA file to extract the specified sequences from cache - save an index of the reference FASTA sequence offsets to disk? clean_accs - strip HMMer extensions from sequ...
[ "Extract", "SeqRecords", "from", "the", "index", "by", "matching", "keys", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/sequtils.py#L29-L73
train
etal/biofrills
biofrills/sequtils.py
aa_frequencies
def aa_frequencies(seq, gap_chars='-.'): """Calculate the amino acid frequencies in a sequence set.""" aa_counts = Counter(seq) # Don't count gaps for gap_char in gap_chars: if gap_char in aa_counts: del aa_counts[gap_char] # Reduce to frequencies scale = 1.0 / sum(aa_counts....
python
def aa_frequencies(seq, gap_chars='-.'): """Calculate the amino acid frequencies in a sequence set.""" aa_counts = Counter(seq) # Don't count gaps for gap_char in gap_chars: if gap_char in aa_counts: del aa_counts[gap_char] # Reduce to frequencies scale = 1.0 / sum(aa_counts....
[ "def", "aa_frequencies", "(", "seq", ",", "gap_chars", "=", "'-.'", ")", ":", "aa_counts", "=", "Counter", "(", "seq", ")", "# Don't count gaps", "for", "gap_char", "in", "gap_chars", ":", "if", "gap_char", "in", "aa_counts", ":", "del", "aa_counts", "[", ...
Calculate the amino acid frequencies in a sequence set.
[ "Calculate", "the", "amino", "acid", "frequencies", "in", "a", "sequence", "set", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/sequtils.py#L76-L85
train
rosshamish/catan-py
catan/trading.py
CatanTrade.giving
def giving(self): """ Returns tuples corresponding to the number and type of each resource in the trade from giver->getter :return: eg [(2, Terrain.wood), (1, Terrain.brick)] """ logging.debug('give={}'.format(self._give)) c = Counter(self._give.copy()) r...
python
def giving(self): """ Returns tuples corresponding to the number and type of each resource in the trade from giver->getter :return: eg [(2, Terrain.wood), (1, Terrain.brick)] """ logging.debug('give={}'.format(self._give)) c = Counter(self._give.copy()) r...
[ "def", "giving", "(", "self", ")", ":", "logging", ".", "debug", "(", "'give={}'", ".", "format", "(", "self", ".", "_give", ")", ")", "c", "=", "Counter", "(", "self", ".", "_give", ".", "copy", "(", ")", ")", "return", "[", "(", "n", ",", "t"...
Returns tuples corresponding to the number and type of each resource in the trade from giver->getter :return: eg [(2, Terrain.wood), (1, Terrain.brick)]
[ "Returns", "tuples", "corresponding", "to", "the", "number", "and", "type", "of", "each", "resource", "in", "the", "trade", "from", "giver", "-", ">", "getter" ]
120438a8f16e39c13322c5d5930e1064e1d3f4be
https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/trading.py#L54-L63
train
rosshamish/catan-py
catan/trading.py
CatanTrade.getting
def getting(self): """ Returns tuples corresponding to the number and type of each resource in the trade from getter->giver :return: eg [(2, Terrain.wood), (1, Terrain.brick)] """ c = Counter(self._get.copy()) return [(n, t) for t, n in c.items()]
python
def getting(self): """ Returns tuples corresponding to the number and type of each resource in the trade from getter->giver :return: eg [(2, Terrain.wood), (1, Terrain.brick)] """ c = Counter(self._get.copy()) return [(n, t) for t, n in c.items()]
[ "def", "getting", "(", "self", ")", ":", "c", "=", "Counter", "(", "self", ".", "_get", ".", "copy", "(", ")", ")", "return", "[", "(", "n", ",", "t", ")", "for", "t", ",", "n", "in", "c", ".", "items", "(", ")", "]" ]
Returns tuples corresponding to the number and type of each resource in the trade from getter->giver :return: eg [(2, Terrain.wood), (1, Terrain.brick)]
[ "Returns", "tuples", "corresponding", "to", "the", "number", "and", "type", "of", "each", "resource", "in", "the", "trade", "from", "getter", "-", ">", "giver" ]
120438a8f16e39c13322c5d5930e1064e1d3f4be
https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/trading.py#L65-L73
train
moonso/ped_parser
ped_parser/family.py
Family.family_check
def family_check(self): """ Check if the family members break the structure of the family. eg. nonexistent parent, wrong sex on parent etc. Also extracts all trios found, this is of help for many at the moment since GATK can only do phasing of trios and duos....
python
def family_check(self): """ Check if the family members break the structure of the family. eg. nonexistent parent, wrong sex on parent etc. Also extracts all trios found, this is of help for many at the moment since GATK can only do phasing of trios and duos....
[ "def", "family_check", "(", "self", ")", ":", "#TODO Make some tests for these", "self", ".", "logger", ".", "info", "(", "\"Checking family relations for {0}\"", ".", "format", "(", "self", ".", "family_id", ")", ")", "for", "individual_id", "in", "self", ".", ...
Check if the family members break the structure of the family. eg. nonexistent parent, wrong sex on parent etc. Also extracts all trios found, this is of help for many at the moment since GATK can only do phasing of trios and duos.
[ "Check", "if", "the", "family", "members", "break", "the", "structure", "of", "the", "family", ".", "eg", ".", "nonexistent", "parent", "wrong", "sex", "on", "parent", "etc", ".", "Also", "extracts", "all", "trios", "found", "this", "is", "of", "help", "...
a7393e47139532782ea3c821aabea33d46f94323
https://github.com/moonso/ped_parser/blob/a7393e47139532782ea3c821aabea33d46f94323/ped_parser/family.py#L61-L116
train
moonso/ped_parser
ped_parser/family.py
Family.check_parent
def check_parent(self, parent_id, father = False): """ Check if the parent info is correct. If an individual is not present in file raise exeption. Input: An id that represents a parent father = True/False Raises SyntaxError if The parent id is not present ...
python
def check_parent(self, parent_id, father = False): """ Check if the parent info is correct. If an individual is not present in file raise exeption. Input: An id that represents a parent father = True/False Raises SyntaxError if The parent id is not present ...
[ "def", "check_parent", "(", "self", ",", "parent_id", ",", "father", "=", "False", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Checking parent {0}\"", ".", "format", "(", "parent_id", ")", ")", "if", "parent_id", "!=", "'0'", ":", "if", "paren...
Check if the parent info is correct. If an individual is not present in file raise exeption. Input: An id that represents a parent father = True/False Raises SyntaxError if The parent id is not present The gender of the parent is wrong.
[ "Check", "if", "the", "parent", "info", "is", "correct", ".", "If", "an", "individual", "is", "not", "present", "in", "file", "raise", "exeption", "." ]
a7393e47139532782ea3c821aabea33d46f94323
https://github.com/moonso/ped_parser/blob/a7393e47139532782ea3c821aabea33d46f94323/ped_parser/family.py#L120-L144
train
moonso/ped_parser
ped_parser/family.py
Family.to_ped
def to_ped(self, outfile=None): """ Print the individuals of the family in ped format The header will be the original ped header plus all headers found in extra info of the individuals """ ped_header = [ '#FamilyID', 'IndividualID...
python
def to_ped(self, outfile=None): """ Print the individuals of the family in ped format The header will be the original ped header plus all headers found in extra info of the individuals """ ped_header = [ '#FamilyID', 'IndividualID...
[ "def", "to_ped", "(", "self", ",", "outfile", "=", "None", ")", ":", "ped_header", "=", "[", "'#FamilyID'", ",", "'IndividualID'", ",", "'PaternalID'", ",", "'MaternalID'", ",", "'Sex'", ",", "'Phenotype'", ",", "]", "extra_headers", "=", "[", "'InheritanceM...
Print the individuals of the family in ped format The header will be the original ped header plus all headers found in extra info of the individuals
[ "Print", "the", "individuals", "of", "the", "family", "in", "ped", "format", "The", "header", "will", "be", "the", "original", "ped", "header", "plus", "all", "headers", "found", "in", "extra", "info", "of", "the", "individuals" ]
a7393e47139532782ea3c821aabea33d46f94323
https://github.com/moonso/ped_parser/blob/a7393e47139532782ea3c821aabea33d46f94323/ped_parser/family.py#L251-L307
train
PeerAssets/pypeerassets
pypeerassets/__main__.py
find_deck
def find_deck(provider: Provider, key: str, version: int, prod: bool=True) -> Optional[Deck]: '''Find specific deck by deck id.''' pa_params = param_query(provider.network) if prod: p2th = pa_params.P2TH_addr else: p2th = pa_params.test_P2TH_addr rawtx = provider.getrawtransaction(...
python
def find_deck(provider: Provider, key: str, version: int, prod: bool=True) -> Optional[Deck]: '''Find specific deck by deck id.''' pa_params = param_query(provider.network) if prod: p2th = pa_params.P2TH_addr else: p2th = pa_params.test_P2TH_addr rawtx = provider.getrawtransaction(...
[ "def", "find_deck", "(", "provider", ":", "Provider", ",", "key", ":", "str", ",", "version", ":", "int", ",", "prod", ":", "bool", "=", "True", ")", "->", "Optional", "[", "Deck", "]", ":", "pa_params", "=", "param_query", "(", "provider", ".", "net...
Find specific deck by deck id.
[ "Find", "specific", "deck", "by", "deck", "id", "." ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/__main__.py#L68-L80
train
PeerAssets/pypeerassets
pypeerassets/__main__.py
deck_spawn
def deck_spawn(provider: Provider, deck: Deck, inputs: dict, change_address: str, locktime: int=0) -> Transaction: '''Creates Deck spawn raw transaction. : key - Kutil object which we'll use to sign the tx : deck - Deck object : card - CardTransfer object : inputs - utxo...
python
def deck_spawn(provider: Provider, deck: Deck, inputs: dict, change_address: str, locktime: int=0) -> Transaction: '''Creates Deck spawn raw transaction. : key - Kutil object which we'll use to sign the tx : deck - Deck object : card - CardTransfer object : inputs - utxo...
[ "def", "deck_spawn", "(", "provider", ":", "Provider", ",", "deck", ":", "Deck", ",", "inputs", ":", "dict", ",", "change_address", ":", "str", ",", "locktime", ":", "int", "=", "0", ")", "->", "Transaction", ":", "network_params", "=", "net_query", "(",...
Creates Deck spawn raw transaction. : key - Kutil object which we'll use to sign the tx : deck - Deck object : card - CardTransfer object : inputs - utxos (has to be owned by deck issuer) : change_address - address to send the change to : locktime - tx locked until block n=int
[ "Creates", "Deck", "spawn", "raw", "transaction", "." ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/__main__.py#L83-L125
train
PeerAssets/pypeerassets
pypeerassets/__main__.py
get_card_transfer
def get_card_transfer(provider: Provider, deck: Deck, txid: str, debug: bool=False) -> Iterator: '''get a single card transfer by it's id''' rawtx = provider.getrawtransaction(txid, 1) bundle = card_bundler(provider, deck, rawtx) return card_bundle_parser(b...
python
def get_card_transfer(provider: Provider, deck: Deck, txid: str, debug: bool=False) -> Iterator: '''get a single card transfer by it's id''' rawtx = provider.getrawtransaction(txid, 1) bundle = card_bundler(provider, deck, rawtx) return card_bundle_parser(b...
[ "def", "get_card_transfer", "(", "provider", ":", "Provider", ",", "deck", ":", "Deck", ",", "txid", ":", "str", ",", "debug", ":", "bool", "=", "False", ")", "->", "Iterator", ":", "rawtx", "=", "provider", ".", "getrawtransaction", "(", "txid", ",", ...
get a single card transfer by it's id
[ "get", "a", "single", "card", "transfer", "by", "it", "s", "id" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/__main__.py#L199-L208
train
PeerAssets/pypeerassets
pypeerassets/__main__.py
find_all_valid_cards
def find_all_valid_cards(provider: Provider, deck: Deck) -> Generator: '''find all the valid cards on this deck, filtering out cards which don't play nice with deck issue mode''' # validate_card_issue_modes must recieve a full list of cards, not batches unfiltered = (card for batch in get_card_bundl...
python
def find_all_valid_cards(provider: Provider, deck: Deck) -> Generator: '''find all the valid cards on this deck, filtering out cards which don't play nice with deck issue mode''' # validate_card_issue_modes must recieve a full list of cards, not batches unfiltered = (card for batch in get_card_bundl...
[ "def", "find_all_valid_cards", "(", "provider", ":", "Provider", ",", "deck", ":", "Deck", ")", "->", "Generator", ":", "# validate_card_issue_modes must recieve a full list of cards, not batches", "unfiltered", "=", "(", "card", "for", "batch", "in", "get_card_bundles", ...
find all the valid cards on this deck, filtering out cards which don't play nice with deck issue mode
[ "find", "all", "the", "valid", "cards", "on", "this", "deck", "filtering", "out", "cards", "which", "don", "t", "play", "nice", "with", "deck", "issue", "mode" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/__main__.py#L211-L219
train
PeerAssets/pypeerassets
pypeerassets/__main__.py
card_transfer
def card_transfer(provider: Provider, card: CardTransfer, inputs: dict, change_address: str, locktime: int=0) -> Transaction: '''Prepare the CardTransfer Transaction object : card - CardTransfer object : inputs - utxos (has to be owned by deck issuer) : change_address - addr...
python
def card_transfer(provider: Provider, card: CardTransfer, inputs: dict, change_address: str, locktime: int=0) -> Transaction: '''Prepare the CardTransfer Transaction object : card - CardTransfer object : inputs - utxos (has to be owned by deck issuer) : change_address - addr...
[ "def", "card_transfer", "(", "provider", ":", "Provider", ",", "card", ":", "CardTransfer", ",", "inputs", ":", "dict", ",", "change_address", ":", "str", ",", "locktime", ":", "int", "=", "0", ")", "->", "Transaction", ":", "network_params", "=", "net_que...
Prepare the CardTransfer Transaction object : card - CardTransfer object : inputs - utxos (has to be owned by deck issuer) : change_address - address to send the change to : locktime - tx locked until block n=int
[ "Prepare", "the", "CardTransfer", "Transaction", "object" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/__main__.py#L222-L271
train
johnnoone/json-spec
src/jsonspec/validators/util.py
rfc3339_to_datetime
def rfc3339_to_datetime(data): """convert a rfc3339 date representation into a Python datetime""" try: ts = time.strptime(data, '%Y-%m-%d') return date(*ts[:3]) except ValueError: pass try: dt, _, tz = data.partition('Z') if tz: tz = offset(tz) ...
python
def rfc3339_to_datetime(data): """convert a rfc3339 date representation into a Python datetime""" try: ts = time.strptime(data, '%Y-%m-%d') return date(*ts[:3]) except ValueError: pass try: dt, _, tz = data.partition('Z') if tz: tz = offset(tz) ...
[ "def", "rfc3339_to_datetime", "(", "data", ")", ":", "try", ":", "ts", "=", "time", ".", "strptime", "(", "data", ",", "'%Y-%m-%d'", ")", "return", "date", "(", "*", "ts", "[", ":", "3", "]", ")", "except", "ValueError", ":", "pass", "try", ":", "d...
convert a rfc3339 date representation into a Python datetime
[ "convert", "a", "rfc3339", "date", "representation", "into", "a", "Python", "datetime" ]
f91981724cea0c366bd42a6670eb07bbe31c0e0c
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/validators/util.py#L92-L112
train
etal/biofrills
biofrills/cmdutils.py
log_config
def log_config(verbose=1): """Set up logging the way I like it.""" # ENH: # - do print levelname before DEBUG and WARNING # - instead of %module, name the currently running script # - make a subclass of logging.handlers.X instead? # - tweak %root? # - take __file__ as an argument? ...
python
def log_config(verbose=1): """Set up logging the way I like it.""" # ENH: # - do print levelname before DEBUG and WARNING # - instead of %module, name the currently running script # - make a subclass of logging.handlers.X instead? # - tweak %root? # - take __file__ as an argument? ...
[ "def", "log_config", "(", "verbose", "=", "1", ")", ":", "# ENH:", "# - do print levelname before DEBUG and WARNING", "# - instead of %module, name the currently running script", "# - make a subclass of logging.handlers.X instead?", "# - tweak %root?", "# - take __file__ as an argume...
Set up logging the way I like it.
[ "Set", "up", "logging", "the", "way", "I", "like", "it", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/cmdutils.py#L6-L23
train
LISE-B26/pylabcontrol
build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py
MainWindow.refresh_instruments
def refresh_instruments(self): """ if self.tree_settings has been expanded, ask instruments for their actual values """ def list_access_nested_dict(dict, somelist): """ Allows one to use a list to access a nested dictionary, for example: listAccessNest...
python
def refresh_instruments(self): """ if self.tree_settings has been expanded, ask instruments for their actual values """ def list_access_nested_dict(dict, somelist): """ Allows one to use a list to access a nested dictionary, for example: listAccessNest...
[ "def", "refresh_instruments", "(", "self", ")", ":", "def", "list_access_nested_dict", "(", "dict", ",", "somelist", ")", ":", "\"\"\"\n Allows one to use a list to access a nested dictionary, for example:\n listAccessNestedDict({'a': {'b': 1}}, ['a', 'b']) returns ...
if self.tree_settings has been expanded, ask instruments for their actual values
[ "if", "self", ".", "tree_settings", "has", "been", "expanded", "ask", "instruments", "for", "their", "actual", "values" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py#L345-L386
train
LISE-B26/pylabcontrol
build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py
MainWindow.update_parameters
def update_parameters(self, treeWidget): """ updates the internal dictionaries for scripts and instruments with values from the respective trees treeWidget: the tree from which to update """ if treeWidget == self.tree_settings: item = treeWidget.currentItem() ...
python
def update_parameters(self, treeWidget): """ updates the internal dictionaries for scripts and instruments with values from the respective trees treeWidget: the tree from which to update """ if treeWidget == self.tree_settings: item = treeWidget.currentItem() ...
[ "def", "update_parameters", "(", "self", ",", "treeWidget", ")", ":", "if", "treeWidget", "==", "self", ".", "tree_settings", ":", "item", "=", "treeWidget", ".", "currentItem", "(", ")", "instrument", ",", "path_to_instrument", "=", "item", ".", "get_instrume...
updates the internal dictionaries for scripts and instruments with values from the respective trees treeWidget: the tree from which to update
[ "updates", "the", "internal", "dictionaries", "for", "scripts", "and", "instruments", "with", "values", "from", "the", "respective", "trees" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py#L889-L947
train
LISE-B26/pylabcontrol
build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py
MainWindow.script_finished
def script_finished(self): """ waits for the script to emit the script_finshed signal """ script = self.current_script script.updateProgress.disconnect(self.update_status) self.script_thread.started.disconnect() script.finished.disconnect() self.current_s...
python
def script_finished(self): """ waits for the script to emit the script_finshed signal """ script = self.current_script script.updateProgress.disconnect(self.update_status) self.script_thread.started.disconnect() script.finished.disconnect() self.current_s...
[ "def", "script_finished", "(", "self", ")", ":", "script", "=", "self", ".", "current_script", "script", ".", "updateProgress", ".", "disconnect", "(", "self", ".", "update_status", ")", "self", ".", "script_thread", ".", "started", ".", "disconnect", "(", "...
waits for the script to emit the script_finshed signal
[ "waits", "for", "the", "script", "to", "emit", "the", "script_finshed", "signal" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py#L994-L1008
train
LISE-B26/pylabcontrol
build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py
MainWindow.update_probes
def update_probes(self, progress): """ update the probe tree """ new_values = self.read_probes.probes_values probe_count = len(self.read_probes.probes) if probe_count > self.tree_probes.topLevelItemCount(): # when run for the first time, there are no probes i...
python
def update_probes(self, progress): """ update the probe tree """ new_values = self.read_probes.probes_values probe_count = len(self.read_probes.probes) if probe_count > self.tree_probes.topLevelItemCount(): # when run for the first time, there are no probes i...
[ "def", "update_probes", "(", "self", ",", "progress", ")", ":", "new_values", "=", "self", ".", "read_probes", ".", "probes_values", "probe_count", "=", "len", "(", "self", ".", "read_probes", ".", "probes", ")", "if", "probe_count", ">", "self", ".", "tre...
update the probe tree
[ "update", "the", "probe", "tree" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py#L1022-L1047
train
LISE-B26/pylabcontrol
build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py
MainWindow.update_script_from_item
def update_script_from_item(self, item): """ updates the script based on the information provided in item Args: script: script to be updated item: B26QTreeItem that contains the new settings of the script """ script, path_to_script, script_item = item.g...
python
def update_script_from_item(self, item): """ updates the script based on the information provided in item Args: script: script to be updated item: B26QTreeItem that contains the new settings of the script """ script, path_to_script, script_item = item.g...
[ "def", "update_script_from_item", "(", "self", ",", "item", ")", ":", "script", ",", "path_to_script", ",", "script_item", "=", "item", ".", "get_script", "(", ")", "# build dictionary", "# get full information from script", "dictator", "=", "list", "(", "script_ite...
updates the script based on the information provided in item Args: script: script to be updated item: B26QTreeItem that contains the new settings of the script
[ "updates", "the", "script", "based", "on", "the", "information", "provided", "in", "item" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py#L1049-L1079
train
datamachine/twx
twx/twx.py
TWXBotApi.message_search
def message_search(self, text, on_success, peer=None, min_date=None, max_date=None, max_id=None, offset=0, limit=255): """ Unsupported in the Bot API """ raise TWXUnsupportedMethod()
python
def message_search(self, text, on_success, peer=None, min_date=None, max_date=None, max_id=None, offset=0, limit=255): """ Unsupported in the Bot API """ raise TWXUnsupportedMethod()
[ "def", "message_search", "(", "self", ",", "text", ",", "on_success", ",", "peer", "=", "None", ",", "min_date", "=", "None", ",", "max_date", "=", "None", ",", "max_id", "=", "None", ",", "offset", "=", "0", ",", "limit", "=", "255", ")", ":", "ra...
Unsupported in the Bot API
[ "Unsupported", "in", "the", "Bot", "API" ]
d9633f12f3647b1e54ba87b70b39df3b7e02b4eb
https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/twx.py#L758-L762
train
johnnoone/json-spec
src/jsonspec/operations/bases.py
Target.remove
def remove(self, pointer): """Remove element from sequence, member from mapping. :param pointer: the path to search in :return: resolved document :rtype: Target """ doc = deepcopy(self.document) parent, obj = None, doc try: # fetching ...
python
def remove(self, pointer): """Remove element from sequence, member from mapping. :param pointer: the path to search in :return: resolved document :rtype: Target """ doc = deepcopy(self.document) parent, obj = None, doc try: # fetching ...
[ "def", "remove", "(", "self", ",", "pointer", ")", ":", "doc", "=", "deepcopy", "(", "self", ".", "document", ")", "parent", ",", "obj", "=", "None", ",", "doc", "try", ":", "# fetching", "for", "token", "in", "Pointer", "(", "pointer", ")", ":", "...
Remove element from sequence, member from mapping. :param pointer: the path to search in :return: resolved document :rtype: Target
[ "Remove", "element", "from", "sequence", "member", "from", "mapping", "." ]
f91981724cea0c366bd42a6670eb07bbe31c0e0c
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/operations/bases.py#L47-L70
train
PeerAssets/pypeerassets
pypeerassets/provider/common.py
Provider._netname
def _netname(name: str) -> dict: '''resolute network name, required because some providers use shortnames and other use longnames.''' try: long = net_query(name).name short = net_query(name).shortname except AttributeError: raise UnsupportedNetwork(''...
python
def _netname(name: str) -> dict: '''resolute network name, required because some providers use shortnames and other use longnames.''' try: long = net_query(name).name short = net_query(name).shortname except AttributeError: raise UnsupportedNetwork(''...
[ "def", "_netname", "(", "name", ":", "str", ")", "->", "dict", ":", "try", ":", "long", "=", "net_query", "(", "name", ")", ".", "name", "short", "=", "net_query", "(", "name", ")", ".", "shortname", "except", "AttributeError", ":", "raise", "Unsupport...
resolute network name, required because some providers use shortnames and other use longnames.
[ "resolute", "network", "name", "required", "because", "some", "providers", "use", "shortnames", "and", "other", "use", "longnames", "." ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/common.py#L21-L32
train
PeerAssets/pypeerassets
pypeerassets/provider/common.py
Provider.sendrawtransaction
def sendrawtransaction(cls, rawtxn: str) -> str: '''sendrawtransaction remote API''' if cls.is_testnet: url = 'https://testnet-explorer.peercoin.net/api/sendrawtransaction?hex={0}'.format(rawtxn) else: url = 'https://explorer.peercoin.net/api/sendrawtransaction?hex={0}'....
python
def sendrawtransaction(cls, rawtxn: str) -> str: '''sendrawtransaction remote API''' if cls.is_testnet: url = 'https://testnet-explorer.peercoin.net/api/sendrawtransaction?hex={0}'.format(rawtxn) else: url = 'https://explorer.peercoin.net/api/sendrawtransaction?hex={0}'....
[ "def", "sendrawtransaction", "(", "cls", ",", "rawtxn", ":", "str", ")", "->", "str", ":", "if", "cls", ".", "is_testnet", ":", "url", "=", "'https://testnet-explorer.peercoin.net/api/sendrawtransaction?hex={0}'", ".", "format", "(", "rawtxn", ")", "else", ":", ...
sendrawtransaction remote API
[ "sendrawtransaction", "remote", "API" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/common.py#L62-L71
train
PeerAssets/pypeerassets
pypeerassets/provider/common.py
Provider.validateaddress
def validateaddress(self, address: str) -> bool: "Returns True if the passed address is valid, False otherwise." try: Address.from_string(address, self.network_properties) except InvalidAddress: return False return True
python
def validateaddress(self, address: str) -> bool: "Returns True if the passed address is valid, False otherwise." try: Address.from_string(address, self.network_properties) except InvalidAddress: return False return True
[ "def", "validateaddress", "(", "self", ",", "address", ":", "str", ")", "->", "bool", ":", "try", ":", "Address", ".", "from_string", "(", "address", ",", "self", ".", "network_properties", ")", "except", "InvalidAddress", ":", "return", "False", "return", ...
Returns True if the passed address is valid, False otherwise.
[ "Returns", "True", "if", "the", "passed", "address", "is", "valid", "False", "otherwise", "." ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/common.py#L116-L124
train
bennylope/smartystreets.py
smartystreets/async.py
chunker
def chunker(l, n): """ Generates n-sized chunks from the list l """ for i in ranger(0, len(l), n): yield l[i:i + n]
python
def chunker(l, n): """ Generates n-sized chunks from the list l """ for i in ranger(0, len(l), n): yield l[i:i + n]
[ "def", "chunker", "(", "l", ",", "n", ")", ":", "for", "i", "in", "ranger", "(", "0", ",", "len", "(", "l", ")", ",", "n", ")", ":", "yield", "l", "[", "i", ":", "i", "+", "n", "]" ]
Generates n-sized chunks from the list l
[ "Generates", "n", "-", "sized", "chunks", "from", "the", "list", "l" ]
f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69
https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/async.py#L24-L29
train
bennylope/smartystreets.py
smartystreets/async.py
AsyncClient.post
def post(self, endpoint, data, parallelism=5): """ Executes most of the request. The parallelism parameter is useful to avoid swamping the API service with calls. Thus the entire set of requests won't be all made at once, but in chunked groups. :param endpoint: string indicatin...
python
def post(self, endpoint, data, parallelism=5): """ Executes most of the request. The parallelism parameter is useful to avoid swamping the API service with calls. Thus the entire set of requests won't be all made at once, but in chunked groups. :param endpoint: string indicatin...
[ "def", "post", "(", "self", ",", "endpoint", ",", "data", ",", "parallelism", "=", "5", ")", ":", "headers", "=", "{", "\"Content-Type\"", ":", "\"application/json\"", ",", "\"Accept\"", ":", "\"application/json\"", ",", "\"x-standardize-only\"", ":", "\"true\""...
Executes most of the request. The parallelism parameter is useful to avoid swamping the API service with calls. Thus the entire set of requests won't be all made at once, but in chunked groups. :param endpoint: string indicating the URL component to call :param data: the JSON ready dat...
[ "Executes", "most", "of", "the", "request", "." ]
f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69
https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/async.py#L52-L120
train
idlesign/django-siteblocks
siteblocks/siteblocksapp.py
SiteBlocks._cache_init
def _cache_init(self): """Initializes local cache from Django cache.""" cache_ = cache.get(self.CACHE_KEY) if cache_ is None: cache_ = defaultdict(dict) self._cache = cache_
python
def _cache_init(self): """Initializes local cache from Django cache.""" cache_ = cache.get(self.CACHE_KEY) if cache_ is None: cache_ = defaultdict(dict) self._cache = cache_
[ "def", "_cache_init", "(", "self", ")", ":", "cache_", "=", "cache", ".", "get", "(", "self", ".", "CACHE_KEY", ")", "if", "cache_", "is", "None", ":", "cache_", "=", "defaultdict", "(", "dict", ")", "self", ".", "_cache", "=", "cache_" ]
Initializes local cache from Django cache.
[ "Initializes", "local", "cache", "from", "Django", "cache", "." ]
7fdb3800f7330dd4143d55416393d83d01a09f73
https://github.com/idlesign/django-siteblocks/blob/7fdb3800f7330dd4143d55416393d83d01a09f73/siteblocks/siteblocksapp.py#L92-L97
train
idlesign/django-siteblocks
siteblocks/siteblocksapp.py
SiteBlocks.get_contents_static
def get_contents_static(self, block_alias, context): """Returns contents of a static block.""" if 'request' not in context: # No use in further actions as we won't ever know current URL. return '' current_url = context['request'].path # Resolve current view nam...
python
def get_contents_static(self, block_alias, context): """Returns contents of a static block.""" if 'request' not in context: # No use in further actions as we won't ever know current URL. return '' current_url = context['request'].path # Resolve current view nam...
[ "def", "get_contents_static", "(", "self", ",", "block_alias", ",", "context", ")", ":", "if", "'request'", "not", "in", "context", ":", "# No use in further actions as we won't ever know current URL.", "return", "''", "current_url", "=", "context", "[", "'request'", ...
Returns contents of a static block.
[ "Returns", "contents", "of", "a", "static", "block", "." ]
7fdb3800f7330dd4143d55416393d83d01a09f73
https://github.com/idlesign/django-siteblocks/blob/7fdb3800f7330dd4143d55416393d83d01a09f73/siteblocks/siteblocksapp.py#L114-L188
train
idlesign/django-siteblocks
siteblocks/siteblocksapp.py
SiteBlocks.get_contents_dynamic
def get_contents_dynamic(self, block_alias, context): """Returns contents of a dynamic block.""" dynamic_block = get_dynamic_blocks().get(block_alias, []) if not dynamic_block: return '' dynamic_block = choice(dynamic_block) return dynamic_block(block_alias=block_ali...
python
def get_contents_dynamic(self, block_alias, context): """Returns contents of a dynamic block.""" dynamic_block = get_dynamic_blocks().get(block_alias, []) if not dynamic_block: return '' dynamic_block = choice(dynamic_block) return dynamic_block(block_alias=block_ali...
[ "def", "get_contents_dynamic", "(", "self", ",", "block_alias", ",", "context", ")", ":", "dynamic_block", "=", "get_dynamic_blocks", "(", ")", ".", "get", "(", "block_alias", ",", "[", "]", ")", "if", "not", "dynamic_block", ":", "return", "''", "dynamic_bl...
Returns contents of a dynamic block.
[ "Returns", "contents", "of", "a", "dynamic", "block", "." ]
7fdb3800f7330dd4143d55416393d83d01a09f73
https://github.com/idlesign/django-siteblocks/blob/7fdb3800f7330dd4143d55416393d83d01a09f73/siteblocks/siteblocksapp.py#L190-L197
train
hyperledger-archives/indy-ledger
ledger/tree_hasher.py
TreeHasher.hash_full_tree
def hash_full_tree(self, leaves): """Hash a set of leaves representing a valid full tree.""" root_hash, hashes = self._hash_full(leaves, 0, len(leaves)) assert len(hashes) == count_bits_set(len(leaves)) assert (self._hash_fold(hashes) == root_hash if hashes else root_hash...
python
def hash_full_tree(self, leaves): """Hash a set of leaves representing a valid full tree.""" root_hash, hashes = self._hash_full(leaves, 0, len(leaves)) assert len(hashes) == count_bits_set(len(leaves)) assert (self._hash_fold(hashes) == root_hash if hashes else root_hash...
[ "def", "hash_full_tree", "(", "self", ",", "leaves", ")", ":", "root_hash", ",", "hashes", "=", "self", ".", "_hash_full", "(", "leaves", ",", "0", ",", "len", "(", "leaves", ")", ")", "assert", "len", "(", "hashes", ")", "==", "count_bits_set", "(", ...
Hash a set of leaves representing a valid full tree.
[ "Hash", "a", "set", "of", "leaves", "representing", "a", "valid", "full", "tree", "." ]
7210c3b288e07f940eddad09b1dfc6a56be846df
https://github.com/hyperledger-archives/indy-ledger/blob/7210c3b288e07f940eddad09b1dfc6a56be846df/ledger/tree_hasher.py#L63-L69
train
lreis2415/PyGeoC
examples/ex06_model_performace_index.py
cal_model_performance
def cal_model_performance(obsl, siml): """Calculate model performance indexes.""" nse = MathClass.nashcoef(obsl, siml) r2 = MathClass.rsquare(obsl, siml) rmse = MathClass.rmse(obsl, siml) pbias = MathClass.pbias(obsl, siml) rsr = MathClass.rsr(obsl, siml) print('NSE: %.2f, R-square: %...
python
def cal_model_performance(obsl, siml): """Calculate model performance indexes.""" nse = MathClass.nashcoef(obsl, siml) r2 = MathClass.rsquare(obsl, siml) rmse = MathClass.rmse(obsl, siml) pbias = MathClass.pbias(obsl, siml) rsr = MathClass.rsr(obsl, siml) print('NSE: %.2f, R-square: %...
[ "def", "cal_model_performance", "(", "obsl", ",", "siml", ")", ":", "nse", "=", "MathClass", ".", "nashcoef", "(", "obsl", ",", "siml", ")", "r2", "=", "MathClass", ".", "rsquare", "(", "obsl", ",", "siml", ")", "rmse", "=", "MathClass", ".", "rmse", ...
Calculate model performance indexes.
[ "Calculate", "model", "performance", "indexes", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex06_model_performace_index.py#L7-L15
train
nmdp-bioinformatics/SeqAnn
seqann/gfe.py
GFE.load_features
def load_features(self): """ Loads all the known features from the feature service """ # Loading all loci that # are in self.loci variable defined # when the pyGFE object is created for loc in self.loci: if self.verbose: self.logger.inf...
python
def load_features(self): """ Loads all the known features from the feature service """ # Loading all loci that # are in self.loci variable defined # when the pyGFE object is created for loc in self.loci: if self.verbose: self.logger.inf...
[ "def", "load_features", "(", "self", ")", ":", "# Loading all loci that", "# are in self.loci variable defined", "# when the pyGFE object is created", "for", "loc", "in", "self", ".", "loci", ":", "if", "self", ".", "verbose", ":", "self", ".", "logger", ".", "info"...
Loads all the known features from the feature service
[ "Loads", "all", "the", "known", "features", "from", "the", "feature", "service" ]
5ce91559b0a4fbe4fb7758e034eb258202632463
https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/gfe.py#L100-L119
train
nmdp-bioinformatics/SeqAnn
seqann/gfe.py
GFE.locus_features
def locus_features(self, locus): """ Returns all features associated with a locus :param locus: string containing HLA locus. :type locus: ``str`` :rtype: ``dict`` """ features = self.api.list_features(locus=locus) feat_dict = {":".join([a.locus, str(a.ran...
python
def locus_features(self, locus): """ Returns all features associated with a locus :param locus: string containing HLA locus. :type locus: ``str`` :rtype: ``dict`` """ features = self.api.list_features(locus=locus) feat_dict = {":".join([a.locus, str(a.ran...
[ "def", "locus_features", "(", "self", ",", "locus", ")", ":", "features", "=", "self", ".", "api", ".", "list_features", "(", "locus", "=", "locus", ")", "feat_dict", "=", "{", "\":\"", ".", "join", "(", "[", "a", ".", "locus", ",", "str", "(", "a"...
Returns all features associated with a locus :param locus: string containing HLA locus. :type locus: ``str`` :rtype: ``dict``
[ "Returns", "all", "features", "associated", "with", "a", "locus" ]
5ce91559b0a4fbe4fb7758e034eb258202632463
https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/gfe.py#L121-L131
train
CitrineInformatics/pif-dft
dfttopif/drivers.py
tarfile_to_pif
def tarfile_to_pif(filename, temp_root_dir='', verbose=0): """ Process a tar file that contains DFT data. Input: filename - String, Path to the file to process. temp_root_dir - String, Directory in which to save temporary files. Defaults to working directory. verbose - int, How much...
python
def tarfile_to_pif(filename, temp_root_dir='', verbose=0): """ Process a tar file that contains DFT data. Input: filename - String, Path to the file to process. temp_root_dir - String, Directory in which to save temporary files. Defaults to working directory. verbose - int, How much...
[ "def", "tarfile_to_pif", "(", "filename", ",", "temp_root_dir", "=", "''", ",", "verbose", "=", "0", ")", ":", "temp_dir", "=", "temp_root_dir", "+", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", "os", ".", "makedirs", "(", "temp_dir", ")", "try", ...
Process a tar file that contains DFT data. Input: filename - String, Path to the file to process. temp_root_dir - String, Directory in which to save temporary files. Defaults to working directory. verbose - int, How much status messages to print Output: pif - ChemicalSystem, Re...
[ "Process", "a", "tar", "file", "that", "contains", "DFT", "data", "." ]
d5411dc1f6c6e8d454b132977ca7ab3bb8131a80
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/drivers.py#L59-L84
train
CitrineInformatics/pif-dft
dfttopif/drivers.py
archive_to_pif
def archive_to_pif(filename, verbose=0): """ Given a archive file that contains output from a DFT calculation, parse the data and return a PIF object. Input: filename - String, Path to the file to process. verbose - int, How much status messages to print Output: pif - ChemicalS...
python
def archive_to_pif(filename, verbose=0): """ Given a archive file that contains output from a DFT calculation, parse the data and return a PIF object. Input: filename - String, Path to the file to process. verbose - int, How much status messages to print Output: pif - ChemicalS...
[ "def", "archive_to_pif", "(", "filename", ",", "verbose", "=", "0", ")", ":", "if", "tarfile", ".", "is_tarfile", "(", "filename", ")", ":", "return", "tarfile_to_pif", "(", "filename", ",", "verbose", ")", "raise", "Exception", "(", "'Cannot process file type...
Given a archive file that contains output from a DFT calculation, parse the data and return a PIF object. Input: filename - String, Path to the file to process. verbose - int, How much status messages to print Output: pif - ChemicalSystem, Results and settings of the DFT ca...
[ "Given", "a", "archive", "file", "that", "contains", "output", "from", "a", "DFT", "calculation", "parse", "the", "data", "and", "return", "a", "PIF", "object", "." ]
d5411dc1f6c6e8d454b132977ca7ab3bb8131a80
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/drivers.py#L87-L101
train
CitrineInformatics/pif-dft
dfttopif/drivers.py
files_to_pif
def files_to_pif(files, verbose=0, quality_report=True, inline=True): '''Given a directory that contains output from a DFT calculation, parse the data and return a pif object Input: files - [str] list of files from which the parser is allowed to read. verbose - int, How much status mess...
python
def files_to_pif(files, verbose=0, quality_report=True, inline=True): '''Given a directory that contains output from a DFT calculation, parse the data and return a pif object Input: files - [str] list of files from which the parser is allowed to read. verbose - int, How much status mess...
[ "def", "files_to_pif", "(", "files", ",", "verbose", "=", "0", ",", "quality_report", "=", "True", ",", "inline", "=", "True", ")", ":", "# Look for the first parser compatible with the directory", "found_parser", "=", "False", "for", "possible_parser", "in", "[", ...
Given a directory that contains output from a DFT calculation, parse the data and return a pif object Input: files - [str] list of files from which the parser is allowed to read. verbose - int, How much status messages to print Output: pif - ChemicalSystem, Results and settings...
[ "Given", "a", "directory", "that", "contains", "output", "from", "a", "DFT", "calculation", "parse", "the", "data", "and", "return", "a", "pif", "object" ]
d5411dc1f6c6e8d454b132977ca7ab3bb8131a80
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/drivers.py#L104-L197
train
PeerAssets/pypeerassets
examples/once_issue_mode_example.py
wait_for_confirmation
def wait_for_confirmation(provider, transaction_id): 'Sleep on a loop until we see a confirmation of the transaction.' while(True): transaction = provider.gettransaction(transaction_id) if transaction["confirmations"] > 0: break time.sleep(10)
python
def wait_for_confirmation(provider, transaction_id): 'Sleep on a loop until we see a confirmation of the transaction.' while(True): transaction = provider.gettransaction(transaction_id) if transaction["confirmations"] > 0: break time.sleep(10)
[ "def", "wait_for_confirmation", "(", "provider", ",", "transaction_id", ")", ":", "while", "(", "True", ")", ":", "transaction", "=", "provider", ".", "gettransaction", "(", "transaction_id", ")", "if", "transaction", "[", "\"confirmations\"", "]", ">", "0", "...
Sleep on a loop until we see a confirmation of the transaction.
[ "Sleep", "on", "a", "loop", "until", "we", "see", "a", "confirmation", "of", "the", "transaction", "." ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/examples/once_issue_mode_example.py#L51-L57
train
PeerAssets/pypeerassets
pypeerassets/protocol.py
validate_card_issue_modes
def validate_card_issue_modes(issue_mode: int, cards: list) -> list: """validate cards against deck_issue modes""" supported_mask = 63 # sum of all issue_mode values if not bool(issue_mode & supported_mask): return [] # return empty list for i in [1 << x for x in range(len(IssueMode))]: ...
python
def validate_card_issue_modes(issue_mode: int, cards: list) -> list: """validate cards against deck_issue modes""" supported_mask = 63 # sum of all issue_mode values if not bool(issue_mode & supported_mask): return [] # return empty list for i in [1 << x for x in range(len(IssueMode))]: ...
[ "def", "validate_card_issue_modes", "(", "issue_mode", ":", "int", ",", "cards", ":", "list", ")", "->", "list", ":", "supported_mask", "=", "63", "# sum of all issue_mode values", "if", "not", "bool", "(", "issue_mode", "&", "supported_mask", ")", ":", "return"...
validate cards against deck_issue modes
[ "validate", "cards", "against", "deck_issue", "modes" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L365-L389
train
PeerAssets/pypeerassets
pypeerassets/protocol.py
Deck.p2th_address
def p2th_address(self) -> Optional[str]: '''P2TH address of this deck''' if self.id: return Kutil(network=self.network, privkey=bytearray.fromhex(self.id)).address else: return None
python
def p2th_address(self) -> Optional[str]: '''P2TH address of this deck''' if self.id: return Kutil(network=self.network, privkey=bytearray.fromhex(self.id)).address else: return None
[ "def", "p2th_address", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "id", ":", "return", "Kutil", "(", "network", "=", "self", ".", "network", ",", "privkey", "=", "bytearray", ".", "fromhex", "(", "self", ".", "id", ...
P2TH address of this deck
[ "P2TH", "address", "of", "this", "deck" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L89-L96
train
PeerAssets/pypeerassets
pypeerassets/protocol.py
Deck.p2th_wif
def p2th_wif(self) -> Optional[str]: '''P2TH privkey in WIF format''' if self.id: return Kutil(network=self.network, privkey=bytearray.fromhex(self.id)).wif else: return None
python
def p2th_wif(self) -> Optional[str]: '''P2TH privkey in WIF format''' if self.id: return Kutil(network=self.network, privkey=bytearray.fromhex(self.id)).wif else: return None
[ "def", "p2th_wif", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "id", ":", "return", "Kutil", "(", "network", "=", "self", ".", "network", ",", "privkey", "=", "bytearray", ".", "fromhex", "(", "self", ".", "id", ")"...
P2TH privkey in WIF format
[ "P2TH", "privkey", "in", "WIF", "format" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L99-L106
train
PeerAssets/pypeerassets
pypeerassets/protocol.py
Deck.metainfo_to_dict
def metainfo_to_dict(self) -> dict: '''encode deck into dictionary''' r = { "version": self.version, "name": self.name, "number_of_decimals": self.number_of_decimals, "issue_mode": self.issue_mode } if self.asset_specific_data: ...
python
def metainfo_to_dict(self) -> dict: '''encode deck into dictionary''' r = { "version": self.version, "name": self.name, "number_of_decimals": self.number_of_decimals, "issue_mode": self.issue_mode } if self.asset_specific_data: ...
[ "def", "metainfo_to_dict", "(", "self", ")", "->", "dict", ":", "r", "=", "{", "\"version\"", ":", "self", ".", "version", ",", "\"name\"", ":", "self", ".", "name", ",", "\"number_of_decimals\"", ":", "self", ".", "number_of_decimals", ",", "\"issue_mode\""...
encode deck into dictionary
[ "encode", "deck", "into", "dictionary" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L132-L145
train
PeerAssets/pypeerassets
pypeerassets/protocol.py
Deck.to_json
def to_json(self) -> dict: '''export the Deck object to json-ready format''' d = self.__dict__ d['p2th_wif'] = self.p2th_wif return d
python
def to_json(self) -> dict: '''export the Deck object to json-ready format''' d = self.__dict__ d['p2th_wif'] = self.p2th_wif return d
[ "def", "to_json", "(", "self", ")", "->", "dict", ":", "d", "=", "self", ".", "__dict__", "d", "[", "'p2th_wif'", "]", "=", "self", ".", "p2th_wif", "return", "d" ]
export the Deck object to json-ready format
[ "export", "the", "Deck", "object", "to", "json", "-", "ready", "format" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L147-L152
train
PeerAssets/pypeerassets
pypeerassets/protocol.py
CardTransfer.metainfo_to_dict
def metainfo_to_dict(self) -> dict: '''encode card into dictionary''' r = { "version": self.version, "amount": self.amount, "number_of_decimals": self.number_of_decimals } if self.asset_specific_data: r.update({'asset_specific_data': self...
python
def metainfo_to_dict(self) -> dict: '''encode card into dictionary''' r = { "version": self.version, "amount": self.amount, "number_of_decimals": self.number_of_decimals } if self.asset_specific_data: r.update({'asset_specific_data': self...
[ "def", "metainfo_to_dict", "(", "self", ")", "->", "dict", ":", "r", "=", "{", "\"version\"", ":", "self", ".", "version", ",", "\"amount\"", ":", "self", ".", "amount", ",", "\"number_of_decimals\"", ":", "self", ".", "number_of_decimals", "}", "if", "sel...
encode card into dictionary
[ "encode", "card", "into", "dictionary" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L331-L343
train
PeerAssets/pypeerassets
pypeerassets/protocol.py
DeckState._sort_cards
def _sort_cards(self, cards: Generator) -> list: '''sort cards by blocknum and blockseq''' return sorted([card.__dict__ for card in cards], key=itemgetter('blocknum', 'blockseq', 'cardseq'))
python
def _sort_cards(self, cards: Generator) -> list: '''sort cards by blocknum and blockseq''' return sorted([card.__dict__ for card in cards], key=itemgetter('blocknum', 'blockseq', 'cardseq'))
[ "def", "_sort_cards", "(", "self", ",", "cards", ":", "Generator", ")", "->", "list", ":", "return", "sorted", "(", "[", "card", ".", "__dict__", "for", "card", "in", "cards", "]", ",", "key", "=", "itemgetter", "(", "'blocknum'", ",", "'blockseq'", ",...
sort cards by blocknum and blockseq
[ "sort", "cards", "by", "blocknum", "and", "blockseq" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L439-L443
train
lreis2415/PyGeoC
examples/ex07_handling_raster_with_numpy.py
main
def main(): """Read GeoTiff raster data and perform log transformation. """ input_tif = "../tests/data/Jamaica_dem.tif" output_tif = "../tests/data/tmp_results/log_dem.tif" rst = RasterUtilClass.read_raster(input_tif) # raster data (with noDataValue as numpy.nan) as numpy array rst_valid = r...
python
def main(): """Read GeoTiff raster data and perform log transformation. """ input_tif = "../tests/data/Jamaica_dem.tif" output_tif = "../tests/data/tmp_results/log_dem.tif" rst = RasterUtilClass.read_raster(input_tif) # raster data (with noDataValue as numpy.nan) as numpy array rst_valid = r...
[ "def", "main", "(", ")", ":", "input_tif", "=", "\"../tests/data/Jamaica_dem.tif\"", "output_tif", "=", "\"../tests/data/tmp_results/log_dem.tif\"", "rst", "=", "RasterUtilClass", ".", "read_raster", "(", "input_tif", ")", "# raster data (with noDataValue as numpy.nan) as numpy...
Read GeoTiff raster data and perform log transformation.
[ "Read", "GeoTiff", "raster", "data", "and", "perform", "log", "transformation", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex07_handling_raster_with_numpy.py#L10-L21
train
zero-os/zerotier_client
zerotier/client_support.py
val_factory
def val_factory(val, datatypes): """ return an instance of `val` that is of type `datatype`. keep track of exceptions so we can produce meaningful error messages. """ exceptions = [] for dt in datatypes: try: if isinstance(val, dt): return val retu...
python
def val_factory(val, datatypes): """ return an instance of `val` that is of type `datatype`. keep track of exceptions so we can produce meaningful error messages. """ exceptions = [] for dt in datatypes: try: if isinstance(val, dt): return val retu...
[ "def", "val_factory", "(", "val", ",", "datatypes", ")", ":", "exceptions", "=", "[", "]", "for", "dt", "in", "datatypes", ":", "try", ":", "if", "isinstance", "(", "val", ",", "dt", ")", ":", "return", "val", "return", "type_handler_object", "(", "val...
return an instance of `val` that is of type `datatype`. keep track of exceptions so we can produce meaningful error messages.
[ "return", "an", "instance", "of", "val", "that", "is", "of", "type", "datatype", ".", "keep", "track", "of", "exceptions", "so", "we", "can", "produce", "meaningful", "error", "messages", "." ]
03993da11e69d837a0308a2f41ae7b378692fd82
https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_support.py#L75-L90
train
zero-os/zerotier_client
zerotier/client_support.py
handler_for
def handler_for(obj): """return the handler for the object type""" for handler_type in handlers: if isinstance(obj, handler_type): return handlers[handler_type] try: for handler_type in handlers: if issubclass(obj, handler_type): return handlers[handl...
python
def handler_for(obj): """return the handler for the object type""" for handler_type in handlers: if isinstance(obj, handler_type): return handlers[handler_type] try: for handler_type in handlers: if issubclass(obj, handler_type): return handlers[handl...
[ "def", "handler_for", "(", "obj", ")", ":", "for", "handler_type", "in", "handlers", ":", "if", "isinstance", "(", "obj", ",", "handler_type", ")", ":", "return", "handlers", "[", "handler_type", "]", "try", ":", "for", "handler_type", "in", "handlers", ":...
return the handler for the object type
[ "return", "the", "handler", "for", "the", "object", "type" ]
03993da11e69d837a0308a2f41ae7b378692fd82
https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_support.py#L189-L201
train