repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.stop
def stop(self): """ stops itself and all the subscript """ for subscript in list(self.scripts.values()): subscript.stop() print(('--- stopping: ', self.name)) self._abort = True
python
def stop(self): """ stops itself and all the subscript """ for subscript in list(self.scripts.values()): subscript.stop() print(('--- stopping: ', self.name)) self._abort = True
[ "def", "stop", "(", "self", ")", ":", "for", "subscript", "in", "list", "(", "self", ".", "scripts", ".", "values", "(", ")", ")", ":", "subscript", ".", "stop", "(", ")", "print", "(", "(", "'--- stopping: '", ",", "self", ".", "name", ")", ")", ...
stops itself and all the subscript
[ "stops", "itself", "and", "all", "the", "subscript" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L447-L454
train
Stops all the scripts and all the scripts.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.filename
def filename(self, appendix=None, create_if_not_existing=False): """ creates a filename based Args: appendix: appendix for file Returns: filename """ # if provided path is a relative path and self.data_path exists, build path if os.path.isabs(self.s...
python
def filename(self, appendix=None, create_if_not_existing=False): """ creates a filename based Args: appendix: appendix for file Returns: filename """ # if provided path is a relative path and self.data_path exists, build path if os.path.isabs(self.s...
[ "def", "filename", "(", "self", ",", "appendix", "=", "None", ",", "create_if_not_existing", "=", "False", ")", ":", "# if provided path is a relative path and self.data_path exists, build path", "if", "os", ".", "path", ".", "isabs", "(", "self", ".", "settings", "...
creates a filename based Args: appendix: appendix for file Returns: filename
[ "creates", "a", "filename", "based", "Args", ":", "appendix", ":", "appendix", "for", "file" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L480-L510
train
Creates a filename based on the current settings.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.save_b26
def save_b26(self, filename=None): """ saves the script settings to a file: filename is filename is not provided, it is created from internal function """ if filename is None: filename = self.filename('.b26') # if platform.system() == 'Windows': # # windo...
python
def save_b26(self, filename=None): """ saves the script settings to a file: filename is filename is not provided, it is created from internal function """ if filename is None: filename = self.filename('.b26') # if platform.system() == 'Windows': # # windo...
[ "def", "save_b26", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "filename", "=", "self", ".", "filename", "(", "'.b26'", ")", "# if platform.system() == 'Windows':", "# # windows can't deal with long filenames so we hav...
saves the script settings to a file: filename is filename is not provided, it is created from internal function
[ "saves", "the", "script", "settings", "to", "a", "file", ":", "filename", "is", "filename", "is", "not", "provided", "it", "is", "created", "from", "internal", "function" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L662-L673
train
Saves the script settings to a file
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.save_image_to_disk
def save_image_to_disk(self, filename_1 = None, filename_2 = None): """ creates an image using the scripts plot function and writes it to the disk for single plots (plot_type: 'main', 'aux') - if no filname provided take default name for double plots (plot_type: 'main', 'aux'...
python
def save_image_to_disk(self, filename_1 = None, filename_2 = None): """ creates an image using the scripts plot function and writes it to the disk for single plots (plot_type: 'main', 'aux') - if no filname provided take default name for double plots (plot_type: 'main', 'aux'...
[ "def", "save_image_to_disk", "(", "self", ",", "filename_1", "=", "None", ",", "filename_2", "=", "None", ")", ":", "def", "axes_empty", "(", "ax", ")", ":", "\"\"\"\n takes an axes object and checks if it is empty\n the axes object is considered empty i...
creates an image using the scripts plot function and writes it to the disk for single plots (plot_type: 'main', 'aux') - if no filname provided take default name for double plots (plot_type: 'main', 'aux') - if no filnames provided take default name - if only one filn...
[ "creates", "an", "image", "using", "the", "scripts", "plot", "function", "and", "writes", "it", "to", "the", "disk", "for", "single", "plots", "(", "plot_type", ":", "main", "aux", ")", "-", "if", "no", "filname", "provided", "take", "default", "name", "...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L674-L744
train
Creates and saves an image to disk.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.save
def save(self, filename): """ saves the instance of the script to a file using pickle Args: filename: target filename """ if filename is None: filename = self.filename('.b26s') # if len(filename.split('\\\\?\\')) == 1: # filename = '\...
python
def save(self, filename): """ saves the instance of the script to a file using pickle Args: filename: target filename """ if filename is None: filename = self.filename('.b26s') # if len(filename.split('\\\\?\\')) == 1: # filename = '\...
[ "def", "save", "(", "self", ",", "filename", ")", ":", "if", "filename", "is", "None", ":", "filename", "=", "self", ".", "filename", "(", "'.b26s'", ")", "# if len(filename.split('\\\\\\\\?\\\\')) == 1:", "# filename = '\\\\\\\\?\\\\' + filename", "with", "open",...
saves the instance of the script to a file using pickle Args: filename: target filename
[ "saves", "the", "instance", "of", "the", "script", "to", "a", "file", "using", "pickle", "Args", ":", "filename", ":", "target", "filename" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L746-L759
train
Saves the instance of the script to a file using pickle.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.load
def load(filename, instruments = None): """ loads an script instance using pickle Args: filename: source filename instruments: optional - only needed if script requires instruments dictionary of form instruments = { ...
python
def load(filename, instruments = None): """ loads an script instance using pickle Args: filename: source filename instruments: optional - only needed if script requires instruments dictionary of form instruments = { ...
[ "def", "load", "(", "filename", ",", "instruments", "=", "None", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "infile", ":", "dataPickle", "=", "infile", ".", "read", "(", ")", "script_as_dict", "=", "pickle", ".", "loads", "(", ...
loads an script instance using pickle Args: filename: source filename instruments: optional - only needed if script requires instruments dictionary of form instruments = { name_of_instrument_1 : instance_of_instrument_1, ...
[ "loads", "an", "script", "instance", "using", "pickle", "Args", ":", "filename", ":", "source", "filename", "instruments", ":", "optional", "-", "only", "needed", "if", "script", "requires", "instruments", "dictionary", "of", "form" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L762-L798
train
Loads an instance of a script instance using pickle
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.load_data
def load_data(path): """ loads the data that has been save with Script.save. Args: path: path to folder saved by Script.save or raw_data folder within Returns: a dictionary with the data of form data = {param_1_name: param_1_data, ...} """ ...
python
def load_data(path): """ loads the data that has been save with Script.save. Args: path: path to folder saved by Script.save or raw_data folder within Returns: a dictionary with the data of form data = {param_1_name: param_1_data, ...} """ ...
[ "def", "load_data", "(", "path", ")", ":", "# check that path exists", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "print", "(", "path", ")", "raise", "AttributeError", "(", "'Path given does not exist!'", ")", "# windows can't deal wit...
loads the data that has been save with Script.save. Args: path: path to folder saved by Script.save or raw_data folder within Returns: a dictionary with the data of form data = {param_1_name: param_1_data, ...}
[ "loads", "the", "data", "that", "has", "been", "save", "with", "Script", ".", "save", ".", "Args", ":", "path", ":", "path", "to", "folder", "saved", "by", "Script", ".", "save", "or", "raw_data", "folder", "within", "Returns", ":", "a", "dictionary", ...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L801-L856
train
Loads the data that has been saved with Script. save.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.get_script_module
def get_script_module(script_information, package='pylabcontrol', verbose=False): """ wrapper to get the module for a script Args: script_information: information of the script. This can be - a dictionary - a Script instance - name of ...
python
def get_script_module(script_information, package='pylabcontrol', verbose=False): """ wrapper to get the module for a script Args: script_information: information of the script. This can be - a dictionary - a Script instance - name of ...
[ "def", "get_script_module", "(", "script_information", ",", "package", "=", "'pylabcontrol'", ",", "verbose", "=", "False", ")", ":", "module", ",", "_", ",", "_", ",", "_", ",", "_", ",", "_", ",", "_", "=", "Script", ".", "get_script_information", "(",...
wrapper to get the module for a script Args: script_information: information of the script. This can be - a dictionary - a Script instance - name of Script class package (optional): name of the package to which the script belongs, i.e. pyl...
[ "wrapper", "to", "get", "the", "module", "for", "a", "script" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L1233-L1250
train
Wrapper to get the module for a specific script
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.duplicate
def duplicate(self): """ create an copy of the script Returns: """ # get settings of script class_of_script = self.__class__ script_name = self.name script_instruments = self.instruments sub_scripts = self.scripts script_settings = self....
python
def duplicate(self): """ create an copy of the script Returns: """ # get settings of script class_of_script = self.__class__ script_name = self.name script_instruments = self.instruments sub_scripts = self.scripts script_settings = self....
[ "def", "duplicate", "(", "self", ")", ":", "# get settings of script", "class_of_script", "=", "self", ".", "__class__", "script_name", "=", "self", ".", "name", "script_instruments", "=", "self", ".", "instruments", "sub_scripts", "=", "self", ".", "scripts", "...
create an copy of the script Returns:
[ "create", "an", "copy", "of", "the", "script" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L1252-L1292
train
create an duplicate of the script
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.plot
def plot(self, figure_list): """ plots the data contained in self.data, which should be a dictionary or a deque of dictionaries for the latter use the last entry Args: figure_list: list of figure objects that are passed to self.get_axes_layout to get axis objects for plotting...
python
def plot(self, figure_list): """ plots the data contained in self.data, which should be a dictionary or a deque of dictionaries for the latter use the last entry Args: figure_list: list of figure objects that are passed to self.get_axes_layout to get axis objects for plotting...
[ "def", "plot", "(", "self", ",", "figure_list", ")", ":", "# if there is not data we do not plot anything", "if", "not", "self", ".", "data", ":", "return", "# if plot function is called when script is not running we request a plot refresh", "if", "not", "self", ".", "is_ru...
plots the data contained in self.data, which should be a dictionary or a deque of dictionaries for the latter use the last entry Args: figure_list: list of figure objects that are passed to self.get_axes_layout to get axis objects for plotting
[ "plots", "the", "data", "contained", "in", "self", ".", "data", "which", "should", "be", "a", "dictionary", "or", "a", "deque", "of", "dictionaries", "for", "the", "latter", "use", "the", "last", "entry", "Args", ":", "figure_list", ":", "list", "of", "f...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L1331-L1354
train
Plots the data contained in self. data and updates the axes layout of the last entry in self. data.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.get_axes_layout
def get_axes_layout(self, figure_list): """ returns the axes objects the script needs to plot its data the default creates a single axes object on each figure This can/should be overwritten in a child script if more axes objects are needed Args: figure_list: a list of...
python
def get_axes_layout(self, figure_list): """ returns the axes objects the script needs to plot its data the default creates a single axes object on each figure This can/should be overwritten in a child script if more axes objects are needed Args: figure_list: a list of...
[ "def", "get_axes_layout", "(", "self", ",", "figure_list", ")", ":", "axes_list", "=", "[", "]", "if", "self", ".", "_plot_refresh", "is", "True", ":", "for", "fig", "in", "figure_list", ":", "fig", ".", "clf", "(", ")", "axes_list", ".", "append", "("...
returns the axes objects the script needs to plot its data the default creates a single axes object on each figure This can/should be overwritten in a child script if more axes objects are needed Args: figure_list: a list of figure objects Returns: axes_list: a li...
[ "returns", "the", "axes", "objects", "the", "script", "needs", "to", "plot", "its", "data", "the", "default", "creates", "a", "single", "axes", "object", "on", "each", "figure", "This", "can", "/", "should", "be", "overwritten", "in", "a", "child", "script...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L1356-L1377
train
Returns the axes objects that the script needs to plot its data
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.plot_validate
def plot_validate(self, figure_list): """ plots the data contained in self.data, which should be a dictionary or a deque of dictionaries for the latter use the last entry """ axes_list = self.get_axes_layout_validate(figure_list) self._plot_validate(axes_list)
python
def plot_validate(self, figure_list): """ plots the data contained in self.data, which should be a dictionary or a deque of dictionaries for the latter use the last entry """ axes_list = self.get_axes_layout_validate(figure_list) self._plot_validate(axes_list)
[ "def", "plot_validate", "(", "self", ",", "figure_list", ")", ":", "axes_list", "=", "self", ".", "get_axes_layout_validate", "(", "figure_list", ")", "self", ".", "_plot_validate", "(", "axes_list", ")" ]
plots the data contained in self.data, which should be a dictionary or a deque of dictionaries for the latter use the last entry
[ "plots", "the", "data", "contained", "in", "self", ".", "data", "which", "should", "be", "a", "dictionary", "or", "a", "deque", "of", "dictionaries", "for", "the", "latter", "use", "the", "last", "entry" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L1379-L1386
train
This function will plot the data contained in self. data and the axes contained in self. axes.
etal/biofrills
biofrills/stats/__init__.py
uniqueof20
def uniqueof20(k, rep=10000): """Sample k times out of alphabet, how many different?""" alphabet = 'ACDEFGHIKLMNPQRSTVWY' reps = [len(set(random.choice(alphabet) for i in range(k))) for j in range(rep)] return sum(reps) / len(reps)
python
def uniqueof20(k, rep=10000): """Sample k times out of alphabet, how many different?""" alphabet = 'ACDEFGHIKLMNPQRSTVWY' reps = [len(set(random.choice(alphabet) for i in range(k))) for j in range(rep)] return sum(reps) / len(reps)
[ "def", "uniqueof20", "(", "k", ",", "rep", "=", "10000", ")", ":", "alphabet", "=", "'ACDEFGHIKLMNPQRSTVWY'", "reps", "=", "[", "len", "(", "set", "(", "random", ".", "choice", "(", "alphabet", ")", "for", "i", "in", "range", "(", "k", ")", ")", ")...
Sample k times out of alphabet, how many different?
[ "Sample", "k", "times", "out", "of", "alphabet", "how", "many", "different?" ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/stats/__init__.py#L6-L12
train
Sample k times out of alphabet how many different?
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/gui/manual_fitting_ensemble.py
FittingWindow.open_file_dialog
def open_file_dialog(self): """ opens a file dialog to get the path to a file and """ dialog = QtGui.QFileDialog filename = dialog.getExistingDirectory(self, 'Select a file:', self.data_filepath.text()) if str(filename)!='': self.data_filepath.setText(filename...
python
def open_file_dialog(self): """ opens a file dialog to get the path to a file and """ dialog = QtGui.QFileDialog filename = dialog.getExistingDirectory(self, 'Select a file:', self.data_filepath.text()) if str(filename)!='': self.data_filepath.setText(filename...
[ "def", "open_file_dialog", "(", "self", ")", ":", "dialog", "=", "QtGui", ".", "QFileDialog", "filename", "=", "dialog", ".", "getExistingDirectory", "(", "self", ",", "'Select a file:'", ",", "self", ".", "data_filepath", ".", "text", "(", ")", ")", "if", ...
opens a file dialog to get the path to a file and
[ "opens", "a", "file", "dialog", "to", "get", "the", "path", "to", "a", "file", "and" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/manual_fitting_ensemble.py#L205-L212
train
Opens a file dialog to get the path to a file and
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
Extracts member or element of obj according to pointer.
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
Calculate the amino acid frequencies in a set of SeqRecords.
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
Returns a dictionary of residue type - > frequency.
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
Remove gappy columns from an alignment.
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
Absolute counts of each residue type in a single column.
etal/biofrills
biofrills/alnutils.py
col_frequencies
def col_frequencies(col, weights=None, gap_chars='-.'): """Frequencies of each residue type (totaling 1.0) in a single column.""" counts = col_counts(col, weights, gap_chars) # Reduce to frequencies scale = 1.0 / sum(counts.values()) return dict((aa, cnt * scale) for aa, cnt in counts.iteritems())
python
def col_frequencies(col, weights=None, gap_chars='-.'): """Frequencies of each residue type (totaling 1.0) in a single column.""" counts = col_counts(col, weights, gap_chars) # Reduce to frequencies scale = 1.0 / sum(counts.values()) return dict((aa, cnt * scale) for aa, cnt in counts.iteritems())
[ "def", "col_frequencies", "(", "col", ",", "weights", "=", "None", ",", "gap_chars", "=", "'-.'", ")", ":", "counts", "=", "col_counts", "(", "col", ",", "weights", ",", "gap_chars", ")", "# Reduce to frequencies", "scale", "=", "1.0", "/", "sum", "(", "...
Frequencies of each residue type (totaling 1.0) in a single column.
[ "Frequencies", "of", "each", "residue", "type", "(", "totaling", "1", ".", "0", ")", "in", "a", "single", "column", "." ]
36684bb6c7632f96215e8b2b4ebc86640f331bcd
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/alnutils.py#L95-L100
train
Returns a dictionary of frequencies of each residue type in a single column.
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
Remove all - gap columns from aligned SeqRecords.
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
Returns a list of floating - point numbers corresponding to the number of sequences in the alignment.
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
Create a NetworkX graph from an alignment file.
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
Return Met Office guidance regarding UV exposure based on UV index
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
Return list of Site instances from retrieved sitelist data
sludgedesk/metoffer
metoffer.py
get_nearest_site
def get_nearest_site(sites, lat, lon): """ Return a string which can be used as "request" in calls to loc_forecast and loc_observations. sites: List of Site instances lat: float or int. Interesting latitude lon: float or int. Interesting longitude """ for site in site...
python
def get_nearest_site(sites, lat, lon): """ Return a string which can be used as "request" in calls to loc_forecast and loc_observations. sites: List of Site instances lat: float or int. Interesting latitude lon: float or int. Interesting longitude """ for site in site...
[ "def", "get_nearest_site", "(", "sites", ",", "lat", ",", "lon", ")", ":", "for", "site", "in", "sites", ":", "site", ".", "distance_to_coords", "(", "lat", ",", "lon", ")", "sites", ".", "sort", "(", "key", "=", "operator", ".", "attrgetter", "(", "...
Return a string which can be used as "request" in calls to loc_forecast and loc_observations. sites: List of Site instances lat: float or int. Interesting latitude lon: float or int. Interesting longitude
[ "Return", "a", "string", "which", "can", "be", "used", "as", "request", "in", "calls", "to", "loc_forecast", "and", "loc_observations", ".", "sites", ":", "List", "of", "Site", "instances", "lat", ":", "float", "or", "int", ".", "Interesting", "latitude", ...
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L343-L355
train
Returns the nearest site in a list of sites.
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
Query DataPoint RESTful API.
sludgedesk/metoffer
metoffer.py
MetOffer.loc_forecast
def loc_forecast(self, request, step, isotime=None): """ Return location-specific forecast data (including lists of available sites and time capabilities) for given time step. request: metoffer.SITELIST Returns available sites metoffer.CAPABILITIES...
python
def loc_forecast(self, request, step, isotime=None): """ Return location-specific forecast data (including lists of available sites and time capabilities) for given time step. request: metoffer.SITELIST Returns available sites metoffer.CAPABILITIES...
[ "def", "loc_forecast", "(", "self", ",", "request", ",", "step", ",", "isotime", "=", "None", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_query", "(", "VAL", ",", "FORECAST", ",", "ALL", ",", "request", ",", "step", ",", "isotime", ...
Return location-specific forecast data (including lists of available sites and time capabilities) for given time step. request: metoffer.SITELIST Returns available sites metoffer.CAPABILITIES Returns available times site ID, e.g. "3021" Returns ...
[ "Return", "location", "-", "specific", "forecast", "data", "(", "including", "lists", "of", "available", "sites", "and", "time", "capabilities", ")", "for", "given", "time", "step", ".", "request", ":", "metoffer", ".", "SITELIST", "Returns", "available", "sit...
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L190-L211
train
Returns a dictionary of location - specific forecast data for a given time step.
sludgedesk/metoffer
metoffer.py
MetOffer.loc_observations
def loc_observations(self, request): """ Return location-specific observation data, including a list of sites (time step will be HOURLY). request: metoffer.SITELIST Returns available sites metoffer.CAPABILITIES Returns available times ...
python
def loc_observations(self, request): """ Return location-specific observation data, including a list of sites (time step will be HOURLY). request: metoffer.SITELIST Returns available sites metoffer.CAPABILITIES Returns available times ...
[ "def", "loc_observations", "(", "self", ",", "request", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_query", "(", "VAL", ",", "OBSERVATIONS", ",", "ALL", ",", "request", ",", "HOURLY", ")", ".", "decode", "(", "errors", "=", "\"replace...
Return location-specific observation data, including a list of sites (time step will be HOURLY). request: metoffer.SITELIST Returns available sites metoffer.CAPABILITIES Returns available times site ID, e.g. "3021" Returns observation data for ...
[ "Return", "location", "-", "specific", "observation", "data", "including", "a", "list", "of", "sites", "(", "time", "step", "will", "be", "HOURLY", ")", ".", "request", ":", "metoffer", ".", "SITELIST", "Returns", "available", "sites", "metoffer", ".", "CAPA...
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L230-L241
train
Returns location - specific observation data including a list of sites and a list of times .
sludgedesk/metoffer
metoffer.py
MetOffer.nearest_loc_obs
def nearest_loc_obs(self, lat, lon): """ Work out nearest possible site to lat & lon coordinates and return observation data for it. lat: float or int. Latitude. lon: float or int. Longitude. """ sitelist = self.loc_observations(SITELIST) ...
python
def nearest_loc_obs(self, lat, lon): """ Work out nearest possible site to lat & lon coordinates and return observation data for it. lat: float or int. Latitude. lon: float or int. Longitude. """ sitelist = self.loc_observations(SITELIST) ...
[ "def", "nearest_loc_obs", "(", "self", ",", "lat", ",", "lon", ")", ":", "sitelist", "=", "self", ".", "loc_observations", "(", "SITELIST", ")", "sites", "=", "parse_sitelist", "(", "sitelist", ")", "site", "=", "get_nearest_site", "(", "sites", ",", "lat"...
Work out nearest possible site to lat & lon coordinates and return observation data for it. lat: float or int. Latitude. lon: float or int. Longitude.
[ "Work", "out", "nearest", "possible", "site", "to", "lat", "&", "lon", "coordinates", "and", "return", "observation", "data", "for", "it", ".", "lat", ":", "float", "or", "int", ".", "Latitude", ".", "lon", ":", "float", "or", "int", ".", "Longitude", ...
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L243-L254
train
Return the list of observations for the nearest location to lat & lon.
sludgedesk/metoffer
metoffer.py
MetOffer.text_forecast
def text_forecast(self, field, request): """ Return textual forecast data for regions, national parks or mountain areas. field: metoffer.NATIONAL_PARK Data on national parks metoffer.REGIONAL_FORECAST Regional data (see REGIONS) ...
python
def text_forecast(self, field, request): """ Return textual forecast data for regions, national parks or mountain areas. field: metoffer.NATIONAL_PARK Data on national parks metoffer.REGIONAL_FORECAST Regional data (see REGIONS) ...
[ "def", "text_forecast", "(", "self", ",", "field", ",", "request", ")", ":", "if", "request", "==", "ALL", "and", "field", "!=", "NATIONAL_PARK", ":", "# \"All\" locations only for use with national parks", "raise", "TypeError", "return", "json", ".", "loads", "("...
Return textual forecast data for regions, national parks or mountain areas. field: metoffer.NATIONAL_PARK Data on national parks metoffer.REGIONAL_FORECAST Regional data (see REGIONS) metoffer.MOUNTAIN_AREA Data on mountain areas ...
[ "Return", "textual", "forecast", "data", "for", "regions", "national", "parks", "or", "mountain", "areas", ".", "field", ":", "metoffer", ".", "NATIONAL_PARK", "Data", "on", "national", "parks", "metoffer", ".", "REGIONAL_FORECAST", "Regional", "data", "(", "see...
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L256-L274
train
Returns the textual forecast data for the given field and request.
sludgedesk/metoffer
metoffer.py
MetOffer.text_uk_extremes
def text_uk_extremes(self, request): """ Return textual data of UK extremes. request: metoffer.CAPABILITIES Returns available extreme date and issue time metoffer.LATEST Returns data of late...
python
def text_uk_extremes(self, request): """ Return textual data of UK extremes. request: metoffer.CAPABILITIES Returns available extreme date and issue time metoffer.LATEST Returns data of late...
[ "def", "text_uk_extremes", "(", "self", ",", "request", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_query", "(", "TEXT", ",", "OBSERVATIONS", ",", "UK_EXTREMES", ",", "request", ",", "\"\"", ")", ".", "decode", "(", "errors", "=", "\"...
Return textual data of UK extremes. request: metoffer.CAPABILITIES Returns available extreme date and issue time metoffer.LATEST Returns data of latest extremes ...
[ "Return", "textual", "data", "of", "UK", "extremes", ".", "request", ":", "metoffer", ".", "CAPABILITIES", "Returns", "available", "extreme", "date", "and", "issue", "time", "metoffer", ".", "LATEST", "Returns", "data", "of", "latest", "extremes", "for", "all"...
449748d31f913d961d6f0406542bb784e931a95b
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L276-L286
train
Return textual data of UK extremes.
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
Returns a dictionary of all stand alone imagery images and includes URIs for the images.
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
Returns capabilities data for forecast map overlays.
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
Returns capabilities data for observation map overlays.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/instruments.py
Instrument.read_probes
def read_probes(self, key = None): """ function is overloaded: - read_probes() - read_probes(key) Args: key: name of requested value Returns: - if called without argument: returns the values of all probes in dictionary form - ...
python
def read_probes(self, key = None): """ function is overloaded: - read_probes() - read_probes(key) Args: key: name of requested value Returns: - if called without argument: returns the values of all probes in dictionary form - ...
[ "def", "read_probes", "(", "self", ",", "key", "=", "None", ")", ":", "print", "(", "(", "'xxxxx probes'", ",", "key", ",", "self", ".", "_PROBES", "(", ")", ")", ")", "if", "key", "is", "None", ":", "# return the value all probe in dictionary form", "d", ...
function is overloaded: - read_probes() - read_probes(key) Args: key: name of requested value Returns: - if called without argument: returns the values of all probes in dictionary form - if called with argument: returns the value the requeste...
[ "function", "is", "overloaded", ":", "-", "read_probes", "()", "-", "read_probes", "(", "key", ")" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/instruments.py#L88-L117
train
read_probes returns the value of the requested key in the dictionary form
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
Load instrument from instrument_dict and append to instruments
johnnoone/json-spec
src/jsonspec/validators/draft04.py
compile
def compile(schema, pointer, context, scope=None): """ Compiles schema with `JSON Schema`_ draft-04. :param schema: obj to compile :type schema: Mapping :param pointer: uri of the schema :type pointer: Pointer, str :param context: context of this schema :type context: Context .. _`...
python
def compile(schema, pointer, context, scope=None): """ Compiles schema with `JSON Schema`_ draft-04. :param schema: obj to compile :type schema: Mapping :param pointer: uri of the schema :type pointer: Pointer, str :param context: context of this schema :type context: Context .. _`...
[ "def", "compile", "(", "schema", ",", "pointer", ",", "context", ",", "scope", "=", "None", ")", ":", "schm", "=", "deepcopy", "(", "schema", ")", "scope", "=", "urljoin", "(", "scope", "or", "str", "(", "pointer", ")", ",", "schm", ".", "pop", "("...
Compiles schema with `JSON Schema`_ draft-04. :param schema: obj to compile :type schema: Mapping :param pointer: uri of the schema :type pointer: Pointer, str :param context: context of this schema :type context: Context .. _`JSON Schema`: http://json-schema.org
[ "Compiles", "schema", "with", "JSON", "Schema", "_", "draft", "-", "04", "." ]
f91981724cea0c366bd42a6670eb07bbe31c0e0c
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/validators/draft04.py#L32-L251
train
Compile a JSON schema with JSON Schema_ draft - 04.
johnnoone/json-spec
src/jsonspec/validators/draft04.py
Draft04Validator.validate
def validate(self, obj, pointer=None): """ Validate object against validator :param obj: the object to validate """ pointer = pointer or '#' validator = deepcopy(self) validator.errors = [] validator.fail_fast = False obj = deepcopy(obj) ...
python
def validate(self, obj, pointer=None): """ Validate object against validator :param obj: the object to validate """ pointer = pointer or '#' validator = deepcopy(self) validator.errors = [] validator.fail_fast = False obj = deepcopy(obj) ...
[ "def", "validate", "(", "self", ",", "obj", ",", "pointer", "=", "None", ")", ":", "pointer", "=", "pointer", "or", "'#'", "validator", "=", "deepcopy", "(", "self", ")", "validator", ".", "errors", "=", "[", "]", "validator", ".", "fail_fast", "=", ...
Validate object against validator :param obj: the object to validate
[ "Validate", "object", "against", "validator" ]
f91981724cea0c366bd42a6670eb07bbe31c0e0c
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/validators/draft04.py#L284-L332
train
Validate object against the validator
johnnoone/json-spec
src/jsonspec/validators/draft04.py
Draft04Validator.validate_format
def validate_format(self, obj, pointer=None): """ ================= ============ Expected draft04 Alias of ----------------- ------------ date-time rfc3339.datetime email email hostname hostname ipv4 ipv4 ...
python
def validate_format(self, obj, pointer=None): """ ================= ============ Expected draft04 Alias of ----------------- ------------ date-time rfc3339.datetime email email hostname hostname ipv4 ipv4 ...
[ "def", "validate_format", "(", "self", ",", "obj", ",", "pointer", "=", "None", ")", ":", "if", "'format'", "in", "self", ".", "attrs", ":", "substituted", "=", "{", "'date-time'", ":", "'rfc3339.datetime'", ",", "'email'", ":", "'email'", ",", "'hostname'...
================= ============ Expected draft04 Alias of ----------------- ------------ date-time rfc3339.datetime email email hostname hostname ipv4 ipv4 ipv6 ipv6 uri uri =====...
[ "=================", "============", "Expected", "draft04", "Alias", "of", "-----------------", "------------", "date", "-", "time", "rfc3339", ".", "datetime", "email", "email", "hostname", "hostname", "ipv4", "ipv4", "ipv6", "ipv6", "uri", "uri", "================="...
f91981724cea0c366bd42a6670eb07bbe31c0e0c
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/validators/draft04.py#L394-L423
train
Validate that the object is in the correct format.
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
Called when validation fails.
idlesign/django-siteblocks
siteblocks/templatetags/siteblocks.py
siteblock
def siteblock(parser, token): """Two notation types are acceptable: 1. Two arguments: {% siteblock "myblock" %} Used to render "myblock" site block. 2. Four arguments: {% siteblock "myblock" as myvar %} Used to put "myblock" site block into "m...
python
def siteblock(parser, token): """Two notation types are acceptable: 1. Two arguments: {% siteblock "myblock" %} Used to render "myblock" site block. 2. Four arguments: {% siteblock "myblock" as myvar %} Used to put "myblock" site block into "m...
[ "def", "siteblock", "(", "parser", ",", "token", ")", ":", "tokens", "=", "token", ".", "split_contents", "(", ")", "tokens_num", "=", "len", "(", "tokens", ")", "if", "tokens_num", "not", "in", "(", "2", ",", "4", ")", ":", "raise", "template", ".",...
Two notation types are acceptable: 1. Two arguments: {% siteblock "myblock" %} Used to render "myblock" site block. 2. Four arguments: {% siteblock "myblock" as myvar %} Used to put "myblock" site block into "myvar" template variable.
[ "Two", "notation", "types", "are", "acceptable", ":" ]
7fdb3800f7330dd4143d55416393d83d01a09f73
https://github.com/idlesign/django-siteblocks/blob/7fdb3800f7330dd4143d55416393d83d01a09f73/siteblocks/templatetags/siteblocks.py#L13-L39
train
Returns a node that can be used to render a siteblock.
nmdp-bioinformatics/SeqAnn
seqann/blast_cmd.py
blastn
def blastn(sequences, locus, nseqs, kir=False, verbose=False, refdata=None, evalue=10): """ Gets the a list of alleles that are the most similar to the input sequence :param sequences: The input sequence record. :type sequences: SeqRecord :param locus: The gene locus associated with the ...
python
def blastn(sequences, locus, nseqs, kir=False, verbose=False, refdata=None, evalue=10): """ Gets the a list of alleles that are the most similar to the input sequence :param sequences: The input sequence record. :type sequences: SeqRecord :param locus: The gene locus associated with the ...
[ "def", "blastn", "(", "sequences", ",", "locus", ",", "nseqs", ",", "kir", "=", "False", ",", "verbose", "=", "False", ",", "refdata", "=", "None", ",", "evalue", "=", "10", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "\"Logger.\"", "+...
Gets the a list of alleles that are the most similar to the input sequence :param sequences: The input sequence record. :type sequences: SeqRecord :param locus: The gene locus associated with the sequence. :type locus: ``str`` :param nseqs: The incomplete annotation from a previous iteration. :...
[ "Gets", "the", "a", "list", "of", "alleles", "that", "are", "the", "most", "similar", "to", "the", "input", "sequence" ]
5ce91559b0a4fbe4fb7758e034eb258202632463
https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/blast_cmd.py#L40-L184
train
Runs the BLASTN command and returns the list of alleles that are the most similar to the input sequence.
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
Returns the locus of the sequence in the sequence
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
generate an address from pubkey
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
sign the parent txn outputs P2PKH
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
take care of specifics of cryptoid naming system
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
Perform a GET request for the url and return a dictionary parsed from the JSON response.
PeerAssets/pypeerassets
pypeerassets/provider/cryptoid.py
Cryptoid.getblock
def getblock(self, blockhash: str) -> dict: '''query block using <blockhash> as key.''' query = 'block.raw.dws?coin={net}&hash={blockhash}'.format( net=self.format_name(self.net), blockhash=blockhash, ) return cast(dict, self.get_url(self.explorer_url + query))
python
def getblock(self, blockhash: str) -> dict: '''query block using <blockhash> as key.''' query = 'block.raw.dws?coin={net}&hash={blockhash}'.format( net=self.format_name(self.net), blockhash=blockhash, ) return cast(dict, self.get_url(self.explorer_url + query))
[ "def", "getblock", "(", "self", ",", "blockhash", ":", "str", ")", "->", "dict", ":", "query", "=", "'block.raw.dws?coin={net}&hash={blockhash}'", ".", "format", "(", "net", "=", "self", ".", "format_name", "(", "self", ".", "net", ")", ",", "blockhash", "...
query block using <blockhash> as key.
[ "query", "block", "using", "<blockhash", ">", "as", "key", "." ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/cryptoid.py#L63-L70
train
query block using <blockhash as key.
PeerAssets/pypeerassets
pypeerassets/provider/cryptoid.py
Cryptoid.getblockhash
def getblockhash(self, blocknum: int) -> str: '''get blockhash''' query = 'getblockhash' + '&height=' + str(blocknum) return cast(str, self.api_req(query))
python
def getblockhash(self, blocknum: int) -> str: '''get blockhash''' query = 'getblockhash' + '&height=' + str(blocknum) return cast(str, self.api_req(query))
[ "def", "getblockhash", "(", "self", ",", "blocknum", ":", "int", ")", "->", "str", ":", "query", "=", "'getblockhash'", "+", "'&height='", "+", "str", "(", "blocknum", ")", "return", "cast", "(", "str", ",", "self", ".", "api_req", "(", "query", ")", ...
get blockhash
[ "get", "blockhash" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/cryptoid.py#L72-L76
train
get blockhash
PeerAssets/pypeerassets
pypeerassets/provider/cryptoid.py
Cryptoid.select_inputs
def select_inputs(self, address: str, amount: int) -> dict: '''select UTXOs''' utxos = [] utxo_sum = Decimal(-0.01) # starts from negative due to minimal fee for tx in sorted(self.listunspent(address=address), key=itemgetter('confirmations')): utxos.append( ...
python
def select_inputs(self, address: str, amount: int) -> dict: '''select UTXOs''' utxos = [] utxo_sum = Decimal(-0.01) # starts from negative due to minimal fee for tx in sorted(self.listunspent(address=address), key=itemgetter('confirmations')): utxos.append( ...
[ "def", "select_inputs", "(", "self", ",", "address", ":", "str", ",", "amount", ":", "int", ")", "->", "dict", ":", "utxos", "=", "[", "]", "utxo_sum", "=", "Decimal", "(", "-", "0.01", ")", "# starts from negative due to minimal fee", "for", "tx", "in", ...
select UTXOs
[ "select", "UTXOs" ]
8927b4a686887f44fe2cd9de777e2c827c948987
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/cryptoid.py#L98-L119
train
select UTXOs and total
edoburu/django-template-analyzer
template_analyzer/djangoanalyzer.py
_is_variable_extends
def _is_variable_extends(extend_node): """ Check whether an ``{% extends variable %}`` is used in the template. :type extend_node: ExtendsNode """ if django.VERSION < (1, 4): return extend_node.parent_name_expr # Django 1.3 else: # The FilterExpression.var can be either a strin...
python
def _is_variable_extends(extend_node): """ Check whether an ``{% extends variable %}`` is used in the template. :type extend_node: ExtendsNode """ if django.VERSION < (1, 4): return extend_node.parent_name_expr # Django 1.3 else: # The FilterExpression.var can be either a strin...
[ "def", "_is_variable_extends", "(", "extend_node", ")", ":", "if", "django", ".", "VERSION", "<", "(", "1", ",", "4", ")", ":", "return", "extend_node", ".", "parent_name_expr", "# Django 1.3", "else", ":", "# The FilterExpression.var can be either a string, or Variab...
Check whether an ``{% extends variable %}`` is used in the template. :type extend_node: ExtendsNode
[ "Check", "whether", "an", "{", "%", "extends", "variable", "%", "}", "is", "used", "in", "the", "template", "." ]
912916dadf68e5fb6bd3dbaa8e5dcad69d3086d0
https://github.com/edoburu/django-template-analyzer/blob/912916dadf68e5fb6bd3dbaa8e5dcad69d3086d0/template_analyzer/djangoanalyzer.py#L28-L38
train
Check whether a variable extends a filter expression.
edoburu/django-template-analyzer
template_analyzer/djangoanalyzer.py
_extend_blocks
def _extend_blocks(extend_node, blocks, context): """ Extends the dictionary `blocks` with *new* blocks in the parent node (recursive) :param extend_node: The ``{% extends .. %}`` node object. :type extend_node: ExtendsNode :param blocks: dict of all block names found in the template. :type blo...
python
def _extend_blocks(extend_node, blocks, context): """ Extends the dictionary `blocks` with *new* blocks in the parent node (recursive) :param extend_node: The ``{% extends .. %}`` node object. :type extend_node: ExtendsNode :param blocks: dict of all block names found in the template. :type blo...
[ "def", "_extend_blocks", "(", "extend_node", ",", "blocks", ",", "context", ")", ":", "try", ":", "# This needs a fresh parent context, or it will detection recursion in Django 1.9+,", "# and thus skip the base template, which is already loaded.", "parent", "=", "extend_node", ".",...
Extends the dictionary `blocks` with *new* blocks in the parent node (recursive) :param extend_node: The ``{% extends .. %}`` node object. :type extend_node: ExtendsNode :param blocks: dict of all block names found in the template. :type blocks: dict
[ "Extends", "the", "dictionary", "blocks", "with", "*", "new", "*", "blocks", "in", "the", "parent", "node", "(", "recursive", ")" ]
912916dadf68e5fb6bd3dbaa8e5dcad69d3086d0
https://github.com/edoburu/django-template-analyzer/blob/912916dadf68e5fb6bd3dbaa8e5dcad69d3086d0/template_analyzer/djangoanalyzer.py#L41-L78
train
Extends the dictionary blocks with new blocks in the parent node.
edoburu/django-template-analyzer
template_analyzer/djangoanalyzer.py
_extend_nodelist
def _extend_nodelist(extends_node, context, instance_types): """ Returns a list of results found in the parent template(s) :type extends_node: ExtendsNode """ results = [] # Find all blocks in the complete inheritance chain blocks = extends_node.blocks.copy() # dict with all blocks in the ...
python
def _extend_nodelist(extends_node, context, instance_types): """ Returns a list of results found in the parent template(s) :type extends_node: ExtendsNode """ results = [] # Find all blocks in the complete inheritance chain blocks = extends_node.blocks.copy() # dict with all blocks in the ...
[ "def", "_extend_nodelist", "(", "extends_node", ",", "context", ",", "instance_types", ")", ":", "results", "=", "[", "]", "# Find all blocks in the complete inheritance chain", "blocks", "=", "extends_node", ".", "blocks", ".", "copy", "(", ")", "# dict with all bloc...
Returns a list of results found in the parent template(s) :type extends_node: ExtendsNode
[ "Returns", "a", "list", "of", "results", "found", "in", "the", "parent", "template", "(", "s", ")", ":", "type", "extends_node", ":", "ExtendsNode" ]
912916dadf68e5fb6bd3dbaa8e5dcad69d3086d0
https://github.com/edoburu/django-template-analyzer/blob/912916dadf68e5fb6bd3dbaa8e5dcad69d3086d0/template_analyzer/djangoanalyzer.py#L100-L122
train
Returns a list of results found in the parent template ( s ) that are in the current template.
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
Scan through the nodelist and return a list of nodes that are found in the current scope level.
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
Returns a list of Node objects that inherit from a given list of instances.
lreis2415/PyGeoC
pygeoc/utils.py
is_integer
def is_integer(v): # type: (...) -> bool """Test whether a value is an integer (of any kind). Examples: >>> is_integer(1) True >>> is_integer(-0.123) False >>> is_integer(3.) False >>> is_integer(9223372036854775808) True >>> is_intege...
python
def is_integer(v): # type: (...) -> bool """Test whether a value is an integer (of any kind). Examples: >>> is_integer(1) True >>> is_integer(-0.123) False >>> is_integer(3.) False >>> is_integer(9223372036854775808) True >>> is_intege...
[ "def", "is_integer", "(", "v", ")", ":", "# type: (...) -> bool", "try", ":", "from", "builtins", "import", "int", "return", "isinstance", "(", "v", ",", "int", ")", "# Match both int and long on Py2", "except", "ImportError", ":", "from", "past", ".", "builtins...
Test whether a value is an integer (of any kind). Examples: >>> is_integer(1) True >>> is_integer(-0.123) False >>> is_integer(3.) False >>> is_integer(9223372036854775808) True >>> is_integer('1') False >>> is_integer(None) ...
[ "Test", "whether", "a", "value", "is", "an", "integer", "(", "of", "any", "kind", ")", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L51-L76
train
Test whether a value is an integer.
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
Get model configuration file name from argv
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
Check the input x is numerical or not.
lreis2415/PyGeoC
pygeoc/utils.py
MathClass.nashcoef
def nashcoef(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] log=False, # type: bool expon=2 # type: Union[float, int, numpy.ScalarType] ): # type: (...) -> f...
python
def nashcoef(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] log=False, # type: bool expon=2 # type: Union[float, int, numpy.ScalarType] ): # type: (...) -> f...
[ "def", "nashcoef", "(", "obsvalues", ",", "# type: Union[numpy.ndarray, List[Union[float, int]]]", "simvalues", ",", "# type: Union[numpy.ndarray, List[Union[float, int]]]", "log", "=", "False", ",", "# type: bool", "expon", "=", "2", "# type: Union[float, int, numpy.ScalarType]", ...
Calculate Nash-Sutcliffe coefficient(NSE) proposed by Nash and Sutcliffe (1970) and its variants. The following description is referred by Krause et al. (2005) and Moriasi et al. (2007). - The range of NSE lies between -inf and 1.0 (prefect fit). - Since the differences be...
[ "Calculate", "Nash", "-", "Sutcliffe", "coefficient", "(", "NSE", ")", "proposed", "by", "Nash", "and", "Sutcliffe", "(", "1970", ")", "and", "its", "variants", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L159-L237
train
Calculates the Nash - Sutcliffe coefficient for a set of observation and simulated values.
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
Calculates the R - square of determination of the given observed and simulated values.
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
Calculates the R - square error of the observed and simulated values.
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
Calculates the PBIAS value of the current object.
lreis2415/PyGeoC
pygeoc/utils.py
MathClass.rsr
def rsr(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues # type: Union[numpy.ndarray, List[Union[float, int]]] ): # type: (...) -> Union[float, numpy.ScalarType] """Calculate RSR (RMSE-to-SD Ratio). Programmed according to equation (3) in ...
python
def rsr(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues # type: Union[numpy.ndarray, List[Union[float, int]]] ): # type: (...) -> Union[float, numpy.ScalarType] """Calculate RSR (RMSE-to-SD Ratio). Programmed according to equation (3) in ...
[ "def", "rsr", "(", "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 RSR (RMSE-to-SD Ratio). Programmed according to equation (3) in Moriasi et al. 2007. Model evalutaion guidelines for systematic quantification of accuracy in watershed simulations. Transactions of the ASABE 50(3): 885-900. Args: obsvalues: observe values array ...
[ "Calculate", "RSR", "(", "RMSE", "-", "to", "-", "SD", "Ratio", ")", "." ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L345-L375
train
Calculates the RSR value of an object based on the observed and simulated values.
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
Convert string to integer or float.
lreis2415/PyGeoC
pygeoc/utils.py
StringClass.split_string
def split_string(str_src, spliters=None, elim_empty=False): # type: (AnyStr, Union[AnyStr, List[AnyStr], None], bool) -> List[AnyStr] """Split string by split character space(' ') and indent('\t') as default Examples: >>> StringClass.split_string('exec -ini test.ini', ' ') ...
python
def split_string(str_src, spliters=None, elim_empty=False): # type: (AnyStr, Union[AnyStr, List[AnyStr], None], bool) -> List[AnyStr] """Split string by split character space(' ') and indent('\t') as default Examples: >>> StringClass.split_string('exec -ini test.ini', ' ') ...
[ "def", "split_string", "(", "str_src", ",", "spliters", "=", "None", ",", "elim_empty", "=", "False", ")", ":", "# type: (AnyStr, Union[AnyStr, List[AnyStr], None], bool) -> List[AnyStr]", "if", "is_string", "(", "spliters", ")", ":", "spliters", "=", "[", "spliters",...
Split string by split character space(' ') and indent('\t') as default Examples: >>> StringClass.split_string('exec -ini test.ini', ' ') ['exec', '-ini', 'test.ini'] Args: str_src: source string spliters: e.g. [' ', '\t'], [], ' ', None elim_...
[ "Split", "string", "by", "split", "character", "space", "(", ")", "and", "indent", "(", "\\", "t", ")", "as", "default" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L427-L466
train
Split string by split character space and indent
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
Is tmp_str in strlist case insensitive?
lreis2415/PyGeoC
pygeoc/utils.py
StringClass.extract_numeric_values_from_string
def extract_numeric_values_from_string(str_contains_values): # type: (AnyStr) -> Optional[List[Union[int, float]]] """ Find numeric values from string, e.g., 1, .7, 1.2, 4e2, 3e-3, -9, etc. Reference: `how-to-extract-a-floating-number-from-a-string-in-python`_ Examples:...
python
def extract_numeric_values_from_string(str_contains_values): # type: (AnyStr) -> Optional[List[Union[int, float]]] """ Find numeric values from string, e.g., 1, .7, 1.2, 4e2, 3e-3, -9, etc. Reference: `how-to-extract-a-floating-number-from-a-string-in-python`_ Examples:...
[ "def", "extract_numeric_values_from_string", "(", "str_contains_values", ")", ":", "# type: (AnyStr) -> Optional[List[Union[int, float]]]", "numeric_const_pattern", "=", "r'[-+]?(?:(?:\\d*\\.\\d+)|(?:\\d+\\.?))(?:[Ee][+-]?\\d+)?'", "rx", "=", "re", ".", "compile", "(", "numeric_const...
Find numeric values from string, e.g., 1, .7, 1.2, 4e2, 3e-3, -9, etc. Reference: `how-to-extract-a-floating-number-from-a-string-in-python`_ Examples: >>> input_str = '.1 .12 9.1 98.1 1. 12. 1 12' >>> StringClass.extract_numeric_values_from_string(input_str) ...
[ "Find", "numeric", "values", "from", "string", "e", ".", "g", ".", "1", ".", "7", "1", ".", "2", "4e2", "3e", "-", "3", "-", "9", "etc", ".", "Reference", ":", "how", "-", "to", "-", "extract", "-", "a", "-", "floating", "-", "number", "-", "...
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L494-L527
train
This function extracts numeric values from a string which may contain numeric values.
lreis2415/PyGeoC
pygeoc/utils.py
StringClass.get_datetime
def get_datetime(formatted_str, user_fmt=None): # type: (AnyStr, Optional[AnyStr]) -> datetime """get datetime() object from string formatted %Y-%m-%d %H:%M:%S Examples: >>> StringClass.get_datetime('2008-11-9') datetime.datetime(2008, 11, 9, 0, 0) >>> String...
python
def get_datetime(formatted_str, user_fmt=None): # type: (AnyStr, Optional[AnyStr]) -> datetime """get datetime() object from string formatted %Y-%m-%d %H:%M:%S Examples: >>> StringClass.get_datetime('2008-11-9') datetime.datetime(2008, 11, 9, 0, 0) >>> String...
[ "def", "get_datetime", "(", "formatted_str", ",", "user_fmt", "=", "None", ")", ":", "# type: (AnyStr, Optional[AnyStr]) -> datetime", "date_fmts", "=", "[", "'%m-%d-%Y'", ",", "'%Y-%m-%d'", ",", "'%m-%d-%y'", ",", "'%y-%m-%d'", "]", "date_fmts", "+=", "[", "d", "...
get datetime() object from string formatted %Y-%m-%d %H:%M:%S Examples: >>> StringClass.get_datetime('2008-11-9') datetime.datetime(2008, 11, 9, 0, 0) >>> StringClass.get_datetime('2008/11/9') datetime.datetime(2008, 11, 9, 0, 0) >>> StringClass.get_d...
[ "get", "datetime", "()", "object", "from", "string", "formatted", "%Y", "-", "%m", "-", "%d", "%H", ":", "%M", ":", "%S" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L530-L577
train
get datetime object from string formatted %Y - m - d
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
Check the existence of file path.
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
Check the existence of folder path.
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
Copy files with the same name and different suffixes such as ESRI Shapefile.
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
Delete all files with same root as fileName.
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
Return true if outfile exists and is no older than base datetime.
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
get the full path of a given executable name
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
Return full path if available.
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
get file names with the given suffixes in the given directory
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
get full file names with the given suffixes in the given directory path
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
Return the core file name without suffix.
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
Add a postfix for a full file path.
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
Return the day of the year from 1 to 365 or 366
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
Execute external command and return the output lines list.
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
Get current path refers to how - do - i - get - the - path - of - the - current - executed - file - in - python _
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
Make directory if not existed
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
Removes and make the directory if it exists.
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
concatenate message list as single string with line feed.
lreis2415/PyGeoC
pygeoc/utils.py
UtilClass.writelog
def writelog(logfile, contentlist, mode='replace'): # type: (AnyStr, Union[AnyStr, List[AnyStr], Tuple[AnyStr]], AnyStr) -> None """write log""" if logfile is None: # If logfile is not assigned, just print msg. print(UtilClass.print_msg(contentlist)) else: if os....
python
def writelog(logfile, contentlist, mode='replace'): # type: (AnyStr, Union[AnyStr, List[AnyStr], Tuple[AnyStr]], AnyStr) -> None """write log""" if logfile is None: # If logfile is not assigned, just print msg. print(UtilClass.print_msg(contentlist)) else: if os....
[ "def", "writelog", "(", "logfile", ",", "contentlist", ",", "mode", "=", "'replace'", ")", ":", "# type: (AnyStr, Union[AnyStr, List[AnyStr], Tuple[AnyStr]], AnyStr) -> None", "if", "logfile", "is", "None", ":", "# If logfile is not assigned, just print msg.", "print", "(", ...
write log
[ "write", "log" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L968-L984
train
write log
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
Decode strings in dictionary which may contain unicode strings or numeric values.
lreis2415/PyGeoC
examples/ex08_raster_connectivity_analysis.py
pixels_connectivity_compute
def pixels_connectivity_compute(raster, i, j, idx): """Compute if the two given value's pixels have connectivity Compute if the two given value's pixels of raster have connectivity between the [i.j]pixel and its 8-neighborhood. If they have connectivity, then put its neighborhood to List idx and g...
python
def pixels_connectivity_compute(raster, i, j, idx): """Compute if the two given value's pixels have connectivity Compute if the two given value's pixels of raster have connectivity between the [i.j]pixel and its 8-neighborhood. If they have connectivity, then put its neighborhood to List idx and g...
[ "def", "pixels_connectivity_compute", "(", "raster", ",", "i", ",", "j", ",", "idx", ")", ":", "nrows", ",", "ncols", "=", "raster", ".", "shape", "value", "=", "raster", "[", "i", "]", "[", "j", "]", "for", "di", "in", "[", "-", "1", ",", "0", ...
Compute if the two given value's pixels have connectivity Compute if the two given value's pixels of raster have connectivity between the [i.j]pixel and its 8-neighborhood. If they have connectivity, then put its neighborhood to List idx and go in a recursion. If the [i, j]pixel and its neighborh...
[ "Compute", "if", "the", "two", "given", "value", "s", "pixels", "have", "connectivity", "Compute", "if", "the", "two", "given", "value", "s", "pixels", "of", "raster", "have", "connectivity", "between", "the", "[", "i", ".", "j", "]", "pixel", "and", "it...
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex08_raster_connectivity_analysis.py#L27-L50
train
Compute if the two given values of pixels of raster have connectivity between the i. j pixel and its 8 - neighborhood.
lreis2415/PyGeoC
examples/ex08_raster_connectivity_analysis.py
remove_existID_pixels
def remove_existID_pixels(givenvalue_pixels_positions, idx_array): """Delete the existed ID pixels who's in nparray idx_array After computing pixels connectivity, we get a set of pixels which have connectivity and have the same ID. We get these pixels positions set as nparray idx_array as well. Th...
python
def remove_existID_pixels(givenvalue_pixels_positions, idx_array): """Delete the existed ID pixels who's in nparray idx_array After computing pixels connectivity, we get a set of pixels which have connectivity and have the same ID. We get these pixels positions set as nparray idx_array as well. Th...
[ "def", "remove_existID_pixels", "(", "givenvalue_pixels_positions", ",", "idx_array", ")", ":", "# We need to give List existID_pixels a 0 value to avoid the error:\r", "# cannot compute fingerprint of empty list\r", "existID_pixels", "=", "[", "0", "]", "for", "i", "in", "range"...
Delete the existed ID pixels who's in nparray idx_array After computing pixels connectivity, we get a set of pixels which have connectivity and have the same ID. We get these pixels positions set as nparray idx_array as well. Then we need to remove these pixels from all of the given value's pixels...
[ "Delete", "the", "existed", "ID", "pixels", "who", "s", "in", "nparray", "idx_array", "After", "computing", "pixels", "connectivity", "we", "get", "a", "set", "of", "pixels", "which", "have", "connectivity", "and", "have", "the", "same", "ID", ".", "We", "...
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex08_raster_connectivity_analysis.py#L56-L85
train
Delete the existed ID pixels who s in nparray idx_array.
lreis2415/PyGeoC
examples/ex08_raster_connectivity_analysis.py
draw_ID
def draw_ID(ID, idx_array, drawID_raster): """Draw every pixel's ID After computing all given value's pixels connectivity, every pixel will have an ID. Then we need to draw these pixels' ID on the undrawed rasterfile. Args: ID: given ID value idx_array: pixels position set...
python
def draw_ID(ID, idx_array, drawID_raster): """Draw every pixel's ID After computing all given value's pixels connectivity, every pixel will have an ID. Then we need to draw these pixels' ID on the undrawed rasterfile. Args: ID: given ID value idx_array: pixels position set...
[ "def", "draw_ID", "(", "ID", ",", "idx_array", ",", "drawID_raster", ")", ":", "for", "i", "in", "range", "(", "idx_array", ".", "shape", "[", "0", "]", ")", ":", "x", "=", "idx_array", "[", "i", ",", "0", "]", "y", "=", "idx_array", "[", "i", ...
Draw every pixel's ID After computing all given value's pixels connectivity, every pixel will have an ID. Then we need to draw these pixels' ID on the undrawed rasterfile. Args: ID: given ID value idx_array: pixels position set which have the given ID value drawID_rast...
[ "Draw", "every", "pixel", "s", "ID", "After", "computing", "all", "given", "value", "s", "pixels", "connectivity", "every", "pixel", "will", "have", "an", "ID", ".", "Then", "we", "need", "to", "draw", "these", "pixels", "ID", "on", "the", "undrawed", "r...
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex08_raster_connectivity_analysis.py#L91-L110
train
Draw every pixel s ID on the undrawed rasterfile after computing all given value s pixels connectivity
datamachine/twx
twx/mtproto/rpc.py
vis
def vis(bs): """ Function to visualize byte streams. Split into bytes, print to console. :param bs: BYTE STRING """ bs = bytearray(bs) symbols_in_one_line = 8 n = len(bs) // symbols_in_one_line i = 0 for i in range(n): print(str(i*symbols_in_one_line)+" | "+" ".join(["%02X" %...
python
def vis(bs): """ Function to visualize byte streams. Split into bytes, print to console. :param bs: BYTE STRING """ bs = bytearray(bs) symbols_in_one_line = 8 n = len(bs) // symbols_in_one_line i = 0 for i in range(n): print(str(i*symbols_in_one_line)+" | "+" ".join(["%02X" %...
[ "def", "vis", "(", "bs", ")", ":", "bs", "=", "bytearray", "(", "bs", ")", "symbols_in_one_line", "=", "8", "n", "=", "len", "(", "bs", ")", "//", "symbols_in_one_line", "i", "=", "0", "for", "i", "in", "range", "(", "n", ")", ":", "print", "(", ...
Function to visualize byte streams. Split into bytes, print to console. :param bs: BYTE STRING
[ "Function", "to", "visualize", "byte", "streams", ".", "Split", "into", "bytes", "print", "to", "console", ".", ":", "param", "bs", ":", "BYTE", "STRING" ]
d9633f12f3647b1e54ba87b70b39df3b7e02b4eb
https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/mtproto/rpc.py#L6-L18
train
Function to visualize byte streams. Split into bytes print to console.
datamachine/twx
twx/mtproto/rpc.py
print_bytes
def print_bytes(data): """ Function to visualize byte streams. Split into bytes, print to console. :param bs: BYTE STRING """ bs = bytearray(data) symbols_in_one_line = 8 n = len(bs) // symbols_in_one_line i = 0 for i in range(n): print(str(i*symbols_in_one_line)+" | "+" ".jo...
python
def print_bytes(data): """ Function to visualize byte streams. Split into bytes, print to console. :param bs: BYTE STRING """ bs = bytearray(data) symbols_in_one_line = 8 n = len(bs) // symbols_in_one_line i = 0 for i in range(n): print(str(i*symbols_in_one_line)+" | "+" ".jo...
[ "def", "print_bytes", "(", "data", ")", ":", "bs", "=", "bytearray", "(", "data", ")", "symbols_in_one_line", "=", "8", "n", "=", "len", "(", "bs", ")", "//", "symbols_in_one_line", "i", "=", "0", "for", "i", "in", "range", "(", "n", ")", ":", "pri...
Function to visualize byte streams. Split into bytes, print to console. :param bs: BYTE STRING
[ "Function", "to", "visualize", "byte", "streams", ".", "Split", "into", "bytes", "print", "to", "console", ".", ":", "param", "bs", ":", "BYTE", "STRING" ]
d9633f12f3647b1e54ba87b70b39df3b7e02b4eb
https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/mtproto/rpc.py#L353-L365
train
Function to visualize byte streams. Split into bytes print to console.
datamachine/twx
twx/mtproto/rpc.py
resPQ.set_params
def set_params(self, data): """ resPQ#05162463 nonce:int128 server_nonce:int128 pq:string server_public_key_fingerprints:Vector long = ResPQ """ bytes_io = BytesIO(data) assert struct.unpack('<I', bytes_io.read(4))[0] == resPQ.constructor self.nonce = bytes_io.read(16) self.ser...
python
def set_params(self, data): """ resPQ#05162463 nonce:int128 server_nonce:int128 pq:string server_public_key_fingerprints:Vector long = ResPQ """ bytes_io = BytesIO(data) assert struct.unpack('<I', bytes_io.read(4))[0] == resPQ.constructor self.nonce = bytes_io.read(16) self.ser...
[ "def", "set_params", "(", "self", ",", "data", ")", ":", "bytes_io", "=", "BytesIO", "(", "data", ")", "assert", "struct", ".", "unpack", "(", "'<I'", ",", "bytes_io", ".", "read", "(", "4", ")", ")", "[", "0", "]", "==", "resPQ", ".", "constructor...
resPQ#05162463 nonce:int128 server_nonce:int128 pq:string server_public_key_fingerprints:Vector long = ResPQ
[ "resPQ#05162463", "nonce", ":", "int128", "server_nonce", ":", "int128", "pq", ":", "string", "server_public_key_fingerprints", ":", "Vector", "long", "=", "ResPQ" ]
d9633f12f3647b1e54ba87b70b39df3b7e02b4eb
https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/mtproto/rpc.py#L105-L119
train
Set the parameters of the class.
datamachine/twx
twx/mtproto/rpc.py
p_q_inner_data.get_bytes
def get_bytes(self): """ p_q_inner_data#83c95aec pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 = P_Q_inner_data """ pq_io = BytesIO() serialize_string(pq_io, self.pq) serialize_string(pq_io, self.p) serialize_string(pq_io, self.q) print("\nP...
python
def get_bytes(self): """ p_q_inner_data#83c95aec pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 = P_Q_inner_data """ pq_io = BytesIO() serialize_string(pq_io, self.pq) serialize_string(pq_io, self.p) serialize_string(pq_io, self.q) print("\nP...
[ "def", "get_bytes", "(", "self", ")", ":", "pq_io", "=", "BytesIO", "(", ")", "serialize_string", "(", "pq_io", ",", "self", ".", "pq", ")", "serialize_string", "(", "pq_io", ",", "self", ".", "p", ")", "serialize_string", "(", "pq_io", ",", "self", "....
p_q_inner_data#83c95aec pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 = P_Q_inner_data
[ "p_q_inner_data#83c95aec", "pq", ":", "bytes", "p", ":", "bytes", "q", ":", "bytes", "nonce", ":", "int128", "server_nonce", ":", "int128", "new_nonce", ":", "int256", "=", "P_Q_inner_data" ]
d9633f12f3647b1e54ba87b70b39df3b7e02b4eb
https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/mtproto/rpc.py#L133-L168
train
get_bytes - returns the bytes representation of the current P_Q_inner_data.
datamachine/twx
twx/mtproto/rpc.py
req_DH_params.get_bytes
def get_bytes(self): """req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:bytes q:bytes public_key_fingerprint:long encrypted_data:bytes = Server_DH_Params""" pq_io = BytesIO() serialize_string(pq_io, self.p) serialize_string(pq_io, self.q) ret = struct.pack("<I16s16s16...
python
def get_bytes(self): """req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:bytes q:bytes public_key_fingerprint:long encrypted_data:bytes = Server_DH_Params""" pq_io = BytesIO() serialize_string(pq_io, self.p) serialize_string(pq_io, self.q) ret = struct.pack("<I16s16s16...
[ "def", "get_bytes", "(", "self", ")", ":", "pq_io", "=", "BytesIO", "(", ")", "serialize_string", "(", "pq_io", ",", "self", ".", "p", ")", "serialize_string", "(", "pq_io", ",", "self", ".", "q", ")", "ret", "=", "struct", ".", "pack", "(", "\"<I16s...
req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:bytes q:bytes public_key_fingerprint:long encrypted_data:bytes = Server_DH_Params
[ "req_DH_params#d712e4be", "nonce", ":", "int128", "server_nonce", ":", "int128", "p", ":", "bytes", "q", ":", "bytes", "public_key_fingerprint", ":", "long", "encrypted_data", ":", "bytes", "=", "Server_DH_Params" ]
d9633f12f3647b1e54ba87b70b39df3b7e02b4eb
https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/mtproto/rpc.py#L182-L197
train
Return the bytes representation of the object.
datamachine/twx
twx/mtproto/rpc.py
server_DH_inner_data.set_params
def set_params(self, data): """server_DH_inner_data#b5890dba nonce:int128 server_nonce:int128 g:int dh_prime:bytes g_a:bytes server_time:int = Server_DH_inner_data""" bytes_io = BytesIO(data) assert struct.unpack("<I", bytes_io.read(4))[0] == 0xb5890dba self.nonce = bytes_io.read(16) ...
python
def set_params(self, data): """server_DH_inner_data#b5890dba nonce:int128 server_nonce:int128 g:int dh_prime:bytes g_a:bytes server_time:int = Server_DH_inner_data""" bytes_io = BytesIO(data) assert struct.unpack("<I", bytes_io.read(4))[0] == 0xb5890dba self.nonce = bytes_io.read(16) ...
[ "def", "set_params", "(", "self", ",", "data", ")", ":", "bytes_io", "=", "BytesIO", "(", "data", ")", "assert", "struct", ".", "unpack", "(", "\"<I\"", ",", "bytes_io", ".", "read", "(", "4", ")", ")", "[", "0", "]", "==", "0xb5890dba", "self", "....
server_DH_inner_data#b5890dba nonce:int128 server_nonce:int128 g:int dh_prime:bytes g_a:bytes server_time:int = Server_DH_inner_data
[ "server_DH_inner_data#b5890dba", "nonce", ":", "int128", "server_nonce", ":", "int128", "g", ":", "int", "dh_prime", ":", "bytes", "g_a", ":", "bytes", "server_time", ":", "int", "=", "Server_DH_inner_data" ]
d9633f12f3647b1e54ba87b70b39df3b7e02b4eb
https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/mtproto/rpc.py#L239-L253
train
This method is used to set the parameters of the server_DH_inner_data class attribute.
datamachine/twx
twx/mtproto/rpc.py
client_DH_inner_data.get_bytes
def get_bytes(self): """client_DH_inner_data#6643b654 nonce:int128 server_nonce:int128 retry_id:long g_b:string = Client_DH_Inner_Data""" ret = struct.pack("<I16s16sQ", client_DH_inner_data.constructor, self.nonce, self.server_nonce, self.retry_id) bytes_io = BytesIO...
python
def get_bytes(self): """client_DH_inner_data#6643b654 nonce:int128 server_nonce:int128 retry_id:long g_b:string = Client_DH_Inner_Data""" ret = struct.pack("<I16s16sQ", client_DH_inner_data.constructor, self.nonce, self.server_nonce, self.retry_id) bytes_io = BytesIO...
[ "def", "get_bytes", "(", "self", ")", ":", "ret", "=", "struct", ".", "pack", "(", "\"<I16s16sQ\"", ",", "client_DH_inner_data", ".", "constructor", ",", "self", ".", "nonce", ",", "self", ".", "server_nonce", ",", "self", ".", "retry_id", ")", "bytes_io",...
client_DH_inner_data#6643b654 nonce:int128 server_nonce:int128 retry_id:long g_b:string = Client_DH_Inner_Data
[ "client_DH_inner_data#6643b654", "nonce", ":", "int128", "server_nonce", ":", "int128", "retry_id", ":", "long", "g_b", ":", "string", "=", "Client_DH_Inner_Data" ]
d9633f12f3647b1e54ba87b70b39df3b7e02b4eb
https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/mtproto/rpc.py#L265-L275
train
Return the bytes representation of the client_DH_inner_data field.
datamachine/twx
twx/mtproto/rpc.py
set_client_DH_params.get_bytes
def get_bytes(self): """set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:bytes = Set_client_DH_params_answer""" ret = struct.pack("<I16s16s", set_client_DH_params.constructor, self.nonce, self.server_nonce) bytes_io = BytesIO() bytes_io.write(ret) s...
python
def get_bytes(self): """set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:bytes = Set_client_DH_params_answer""" ret = struct.pack("<I16s16s", set_client_DH_params.constructor, self.nonce, self.server_nonce) bytes_io = BytesIO() bytes_io.write(ret) s...
[ "def", "get_bytes", "(", "self", ")", ":", "ret", "=", "struct", ".", "pack", "(", "\"<I16s16s\"", ",", "set_client_DH_params", ".", "constructor", ",", "self", ".", "nonce", ",", "self", ".", "server_nonce", ")", "bytes_io", "=", "BytesIO", "(", ")", "b...
set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:bytes = Set_client_DH_params_answer
[ "set_client_DH_params#f5045f1f", "nonce", ":", "int128", "server_nonce", ":", "int128", "encrypted_data", ":", "bytes", "=", "Set_client_DH_params_answer" ]
d9633f12f3647b1e54ba87b70b39df3b7e02b4eb
https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/mtproto/rpc.py#L285-L294
train
Return the bytes representation of the Set_Client_DH_params message.
rosshamish/catan-py
catan/game.py
Game.do
def do(self, command: undoredo.Command): """ Does the command using the undo_manager's stack :param command: Command """ self.undo_manager.do(command) self.notify_observers()
python
def do(self, command: undoredo.Command): """ Does the command using the undo_manager's stack :param command: Command """ self.undo_manager.do(command) self.notify_observers()
[ "def", "do", "(", "self", ",", "command", ":", "undoredo", ".", "Command", ")", ":", "self", ".", "undo_manager", ".", "do", "(", "command", ")", "self", ".", "notify_observers", "(", ")" ]
Does the command using the undo_manager's stack :param command: Command
[ "Does", "the", "command", "using", "the", "undo_manager", "s", "stack", ":", "param", "command", ":", "Command" ]
120438a8f16e39c13322c5d5930e1064e1d3f4be
https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/game.py#L83-L89
train
Does the command using the undo_manager s stack