repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
MAVENSDC/PyTplot
pytplot/QtPlotter/generate.py
_set_pyqtgraph_title
def _set_pyqtgraph_title(layout): """ Private function to add a title to the first row of the window. Returns True if a Title is set. Else, returns False. """ if 'title_size' in pytplot.tplot_opt_glob: size = pytplot.tplot_opt_glob['title_size'] if 'title_text' in pytplot.tplot_opt_glob...
python
def _set_pyqtgraph_title(layout): """ Private function to add a title to the first row of the window. Returns True if a Title is set. Else, returns False. """ if 'title_size' in pytplot.tplot_opt_glob: size = pytplot.tplot_opt_glob['title_size'] if 'title_text' in pytplot.tplot_opt_glob...
[ "def", "_set_pyqtgraph_title", "(", "layout", ")", ":", "if", "'title_size'", "in", "pytplot", ".", "tplot_opt_glob", ":", "size", "=", "pytplot", ".", "tplot_opt_glob", "[", "'title_size'", "]", "if", "'title_text'", "in", "pytplot", ".", "tplot_opt_glob", ":",...
Private function to add a title to the first row of the window. Returns True if a Title is set. Else, returns False.
[ "Private", "function", "to", "add", "a", "title", "to", "the", "first", "row", "of", "the", "window", ".", "Returns", "True", "if", "a", "Title", "is", "set", ".", "Else", "returns", "False", "." ]
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/QtPlotter/generate.py#L102-L113
MAVENSDC/PyTplot
pytplot/store_data.py
store_data
def store_data(name, data=None, delete=False, newname=None): """ This function creates a "Tplot Variable" based on the inputs, and stores this data in memory. Tplot Variables store all of the information needed to generate a plot. Parameters: name : str Name of the ...
python
def store_data(name, data=None, delete=False, newname=None): """ This function creates a "Tplot Variable" based on the inputs, and stores this data in memory. Tplot Variables store all of the information needed to generate a plot. Parameters: name : str Name of the ...
[ "def", "store_data", "(", "name", ",", "data", "=", "None", ",", "delete", "=", "False", ",", "newname", "=", "None", ")", ":", "global", "tplot_num", "create_time", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "if", "delete", "is", "True", ...
This function creates a "Tplot Variable" based on the inputs, and stores this data in memory. Tplot Variables store all of the information needed to generate a plot. Parameters: name : str Name of the tplot variable that will be created data : dict A python d...
[ "This", "function", "creates", "a", "Tplot", "Variable", "based", "on", "the", "inputs", "and", "stores", "this", "data", "in", "memory", ".", "Tplot", "Variables", "store", "all", "of", "the", "information", "needed", "to", "generate", "a", "plot", ".", "...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/store_data.py#L18-L163
MAVENSDC/PyTplot
pytplot/get_data.py
get_data
def get_data(name): """ This function extracts the data from the Tplot Variables stored in memory. Parameters: name : str Name of the tplot variable Returns: time_val : pandas dataframe index data_val : list Examples: >>> # R...
python
def get_data(name): """ This function extracts the data from the Tplot Variables stored in memory. Parameters: name : str Name of the tplot variable Returns: time_val : pandas dataframe index data_val : list Examples: >>> # R...
[ "def", "get_data", "(", "name", ")", ":", "global", "data_quants", "if", "name", "not", "in", "data_quants", ".", "keys", "(", ")", ":", "print", "(", "\"That name is currently not in pytplot\"", ")", "return", "temp_data_quant", "=", "data_quants", "[", "name",...
This function extracts the data from the Tplot Variables stored in memory. Parameters: name : str Name of the tplot variable Returns: time_val : pandas dataframe index data_val : list Examples: >>> # Retrieve the data from Variable 1...
[ "This", "function", "extracts", "the", "data", "from", "the", "Tplot", "Variables", "stored", "in", "memory", ".", "Parameters", ":", "name", ":", "str", "Name", "of", "the", "tplot", "variable", "Returns", ":", "time_val", ":", "pandas", "dataframe", "index...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/get_data.py#L8-L39
MAVENSDC/PyTplot
pytplot/QtPlotter/CustomAxis/AxisItem.py
AxisItem.generateDrawSpecs
def generateDrawSpecs(self, p): """ Calls tickValues() and tickStrings() to determine where and how ticks should be drawn, then generates from this a set of drawing commands to be interpreted by drawPicture(). """ profiler = debug.Profiler() # bounds = self.bound...
python
def generateDrawSpecs(self, p): """ Calls tickValues() and tickStrings() to determine where and how ticks should be drawn, then generates from this a set of drawing commands to be interpreted by drawPicture(). """ profiler = debug.Profiler() # bounds = self.bound...
[ "def", "generateDrawSpecs", "(", "self", ",", "p", ")", ":", "profiler", "=", "debug", ".", "Profiler", "(", ")", "# bounds = self.boundingRect()", "bounds", "=", "self", ".", "mapRectFromParent", "(", "self", ".", "geometry", "(", ")", ")", "linkedView", "=...
Calls tickValues() and tickStrings() to determine where and how ticks should be drawn, then generates from this a set of drawing commands to be interpreted by drawPicture().
[ "Calls", "tickValues", "()", "and", "tickStrings", "()", "to", "determine", "where", "and", "how", "ticks", "should", "be", "drawn", "then", "generates", "from", "this", "a", "set", "of", "drawing", "commands", "to", "be", "interpreted", "by", "drawPicture", ...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/QtPlotter/CustomAxis/AxisItem.py#L40-L285
MAVENSDC/PyTplot
pytplot/staticplot.py
static2dplot
def static2dplot(var, time): """ If the static option is set in tplot, and is supplied with a time, then the spectrogram plot(s) for which it is set will have another window pop up, with y and z values plotted at the specified time. """ # Grab names of data loaded in as tplot variables. names = list(py...
python
def static2dplot(var, time): """ If the static option is set in tplot, and is supplied with a time, then the spectrogram plot(s) for which it is set will have another window pop up, with y and z values plotted at the specified time. """ # Grab names of data loaded in as tplot variables. names = list(py...
[ "def", "static2dplot", "(", "var", ",", "time", ")", ":", "# Grab names of data loaded in as tplot variables.", "names", "=", "list", "(", "pytplot", ".", "data_quants", ".", "keys", "(", ")", ")", "# Get data we'll actually work with here.", "valid_variables", "=", "...
If the static option is set in tplot, and is supplied with a time, then the spectrogram plot(s) for which it is set will have another window pop up, with y and z values plotted at the specified time.
[ "If", "the", "static", "option", "is", "set", "in", "tplot", "and", "is", "supplied", "with", "a", "time", "then", "the", "spectrogram", "plot", "(", "s", ")", "for", "which", "it", "is", "set", "will", "have", "another", "window", "pop", "up", "with",...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/staticplot.py#L7-L90
MAVENSDC/PyTplot
pytplot/netcdf_to_tplot.py
netcdf_to_tplot
def netcdf_to_tplot(filenames, time ='', prefix='', suffix='', plot=False, merge=False): ''' This function will automatically create tplot variables from CDF files. Parameters: filenames : str/list of str The file names and full paths of netCDF files. time: str The n...
python
def netcdf_to_tplot(filenames, time ='', prefix='', suffix='', plot=False, merge=False): ''' This function will automatically create tplot variables from CDF files. Parameters: filenames : str/list of str The file names and full paths of netCDF files. time: str The n...
[ "def", "netcdf_to_tplot", "(", "filenames", ",", "time", "=", "''", ",", "prefix", "=", "''", ",", "suffix", "=", "''", ",", "plot", "=", "False", ",", "merge", "=", "False", ")", ":", "from", "netCDF4", "import", "Dataset", "stored_variables", "=", "[...
This function will automatically create tplot variables from CDF files. Parameters: filenames : str/list of str The file names and full paths of netCDF files. time: str The name of the netCDF file's time variable. prefix: str The tplot variable names will...
[ "This", "function", "will", "automatically", "create", "tplot", "variables", "from", "CDF", "files", "." ]
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/netcdf_to_tplot.py#L20-L148
MAVENSDC/PyTplot
pytplot/tplot_rename.py
tplot_rename
def tplot_rename(old_name, new_name): """ This function will rename tplot variables that are already stored in memory. Parameters: old_name : str Old name of the Tplot Variable new_name : str New name of the Tplot Variable Returns: None ...
python
def tplot_rename(old_name, new_name): """ This function will rename tplot variables that are already stored in memory. Parameters: old_name : str Old name of the Tplot Variable new_name : str New name of the Tplot Variable Returns: None ...
[ "def", "tplot_rename", "(", "old_name", ",", "new_name", ")", ":", "#check if old name is in current dictionary", "if", "old_name", "not", "in", "pytplot", ".", "data_quants", ".", "keys", "(", ")", ":", "print", "(", "\"That name is currently not in pytplot\"", ")", ...
This function will rename tplot variables that are already stored in memory. Parameters: old_name : str Old name of the Tplot Variable new_name : str New name of the Tplot Variable Returns: None Examples: >>> # Rename Variabl...
[ "This", "function", "will", "rename", "tplot", "variables", "that", "are", "already", "stored", "in", "memory", ".", "Parameters", ":", "old_name", ":", "str", "Old", "name", "of", "the", "Tplot", "Variable", "new_name", ":", "str", "New", "name", "of", "t...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/tplot_rename.py#L9-L45
MAVENSDC/PyTplot
pytplot/__init__.py
TVar._check_spec_bins_ordering
def _check_spec_bins_ordering(self): """ This is a private function of the TVar object, this is run during object creation to check if spec_bins are ascending or descending """ if self.spec_bins is None: return if len(self.spec_bins) == len(self.data.index): ...
python
def _check_spec_bins_ordering(self): """ This is a private function of the TVar object, this is run during object creation to check if spec_bins are ascending or descending """ if self.spec_bins is None: return if len(self.spec_bins) == len(self.data.index): ...
[ "def", "_check_spec_bins_ordering", "(", "self", ")", ":", "if", "self", ".", "spec_bins", "is", "None", ":", "return", "if", "len", "(", "self", ".", "spec_bins", ")", "==", "len", "(", "self", ".", "data", ".", "index", ")", ":", "self", ".", "spec...
This is a private function of the TVar object, this is run during object creation to check if spec_bins are ascending or descending
[ "This", "is", "a", "private", "function", "of", "the", "TVar", "object", "this", "is", "run", "during", "object", "creation", "to", "check", "if", "spec_bins", "are", "ascending", "or", "descending" ]
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/__init__.py#L138-L163
MAVENSDC/PyTplot
pytplot/tplot_names.py
tplot_names
def tplot_names(): """ This function will print out and return a list of all current Tplot Variables stored in the memory. Parameters: None Returns: list : list of str A list of all Tplot Variables stored in the memory Examples: >>> i...
python
def tplot_names(): """ This function will print out and return a list of all current Tplot Variables stored in the memory. Parameters: None Returns: list : list of str A list of all Tplot Variables stored in the memory Examples: >>> i...
[ "def", "tplot_names", "(", ")", ":", "index", "=", "0", "return_names", "=", "[", "]", "for", "key", ",", "_", "in", "data_quants", ".", "items", "(", ")", ":", "if", "isinstance", "(", "data_quants", "[", "key", "]", ".", "data", ",", "list", ")",...
This function will print out and return a list of all current Tplot Variables stored in the memory. Parameters: None Returns: list : list of str A list of all Tplot Variables stored in the memory Examples: >>> import pytplot >>> x_dat...
[ "This", "function", "will", "print", "out", "and", "return", "a", "list", "of", "all", "current", "Tplot", "Variables", "stored", "in", "the", "memory", ".", "Parameters", ":", "None", "Returns", ":", "list", ":", "list", "of", "str", "A", "list", "of", ...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/tplot_names.py#L8-L46
MAVENSDC/PyTplot
pytplot/interactiveplot.py
interactiveplot
def interactiveplot(t_average=None): """ If the interactive option is set to True in tplot, this function will take in the stored tplot variables and create a 2D interactive window that will pop up when any one of the tplot variables is plotted (so long as at least one of the tplot variables is a spectrogra...
python
def interactiveplot(t_average=None): """ If the interactive option is set to True in tplot, this function will take in the stored tplot variables and create a 2D interactive window that will pop up when any one of the tplot variables is plotted (so long as at least one of the tplot variables is a spectrogra...
[ "def", "interactiveplot", "(", "t_average", "=", "None", ")", ":", "# Grab names of data loaded in as tplot variables.", "names", "=", "list", "(", "pytplot", ".", "data_quants", ".", "keys", "(", ")", ")", "# Get data we'll actually work with here.", "valid_variables", ...
If the interactive option is set to True in tplot, this function will take in the stored tplot variables and create a 2D interactive window that will pop up when any one of the tplot variables is plotted (so long as at least one of the tplot variables is a spectrogram). If the mouse hovers over a spectrogram pl...
[ "If", "the", "interactive", "option", "is", "set", "to", "True", "in", "tplot", "this", "function", "will", "take", "in", "the", "stored", "tplot", "variables", "and", "create", "a", "2D", "interactive", "window", "that", "will", "pop", "up", "when", "any"...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/interactiveplot.py#L8-L162
MAVENSDC/PyTplot
pytplot/cdf_to_tplot.py
cdf_to_tplot
def cdf_to_tplot(filenames, varformat=None, get_support_data=False, prefix='', suffix='', plot=False, merge=False): """ This function will automatically create tplot variables from CDF files. .. note:: Variables must have an attribute named "VAR_TYPE". If the attribute entry ...
python
def cdf_to_tplot(filenames, varformat=None, get_support_data=False, prefix='', suffix='', plot=False, merge=False): """ This function will automatically create tplot variables from CDF files. .. note:: Variables must have an attribute named "VAR_TYPE". If the attribute entry ...
[ "def", "cdf_to_tplot", "(", "filenames", ",", "varformat", "=", "None", ",", "get_support_data", "=", "False", ",", "prefix", "=", "''", ",", "suffix", "=", "''", ",", "plot", "=", "False", ",", "merge", "=", "False", ")", ":", "stored_variables", "=", ...
This function will automatically create tplot variables from CDF files. .. note:: Variables must have an attribute named "VAR_TYPE". If the attribute entry is "data" (or "support_data"), then they will be added as tplot variables. Additionally, data variables should have attributes named "...
[ "This", "function", "will", "automatically", "create", "tplot", "variables", "from", "CDF", "files", "." ]
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/cdf_to_tplot.py#L17-L177
MAVENSDC/PyTplot
pytplot/get_timespan.py
get_timespan
def get_timespan(name): """ This function extracts the time span from the Tplot Variables stored in memory. Parameters: name : str Name of the tplot variable Returns: time_begin : float The beginning of the time series time_end : float ...
python
def get_timespan(name): """ This function extracts the time span from the Tplot Variables stored in memory. Parameters: name : str Name of the tplot variable Returns: time_begin : float The beginning of the time series time_end : float ...
[ "def", "get_timespan", "(", "name", ")", ":", "if", "name", "not", "in", "data_quants", ".", "keys", "(", ")", ":", "print", "(", "\"That name is currently not in pytplot\"", ")", "return", "print", "(", "\"Start Time: \"", "+", "tplot_utilities", ".", "int_to_s...
This function extracts the time span from the Tplot Variables stored in memory. Parameters: name : str Name of the tplot variable Returns: time_begin : float The beginning of the time series time_end : float The end of the time series...
[ "This", "function", "extracts", "the", "time", "span", "from", "the", "Tplot", "Variables", "stored", "in", "memory", ".", "Parameters", ":", "name", ":", "str", "Name", "of", "the", "tplot", "variable", "Returns", ":", "time_begin", ":", "float", "The", "...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/get_timespan.py#L10-L40
MAVENSDC/PyTplot
pytplot/timebar.py
timebar
def timebar(t, varname = None, databar = False, delete = False, color = 'black', thick = 1, dash = False): """ This function will add a vertical bar to all time series plots. This is useful if you want to bring attention to a specific time. Parameters: t : flt/list The ti...
python
def timebar(t, varname = None, databar = False, delete = False, color = 'black', thick = 1, dash = False): """ This function will add a vertical bar to all time series plots. This is useful if you want to bring attention to a specific time. Parameters: t : flt/list The ti...
[ "def", "timebar", "(", "t", ",", "varname", "=", "None", ",", "databar", "=", "False", ",", "delete", "=", "False", ",", "color", "=", "'black'", ",", "thick", "=", "1", ",", "dash", "=", "False", ")", ":", "# make sure t entered is a list", "if", "not...
This function will add a vertical bar to all time series plots. This is useful if you want to bring attention to a specific time. Parameters: t : flt/list The time in seconds since Jan 01 1970 to place the vertical bar. If a list of numbers are supplied, multiple bars wi...
[ "This", "function", "will", "add", "a", "vertical", "bar", "to", "all", "time", "series", "plots", ".", "This", "is", "useful", "if", "you", "want", "to", "bring", "attention", "to", "a", "specific", "time", ".", "Parameters", ":", "t", ":", "flt", "/"...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/timebar.py#L11-L110
MAVENSDC/PyTplot
pytplot/options.py
options
def options(name, option, value): """ This function allows the user to set a large variety of options for individual plots. Parameters: name : str Name of the tplot variable option : str The name of the option. See section below value : str/int/floa...
python
def options(name, option, value): """ This function allows the user to set a large variety of options for individual plots. Parameters: name : str Name of the tplot variable option : str The name of the option. See section below value : str/int/floa...
[ "def", "options", "(", "name", ",", "option", ",", "value", ")", ":", "if", "not", "isinstance", "(", "name", ",", "list", ")", ":", "name", "=", "[", "name", "]", "option", "=", "option", ".", "lower", "(", ")", "for", "i", "in", "name", ":", ...
This function allows the user to set a large variety of options for individual plots. Parameters: name : str Name of the tplot variable option : str The name of the option. See section below value : str/int/float/list The value of the option. S...
[ "This", "function", "allows", "the", "user", "to", "set", "a", "large", "variety", "of", "options", "for", "individual", "plots", ".", "Parameters", ":", "name", ":", "str", "Name", "of", "the", "tplot", "variable", "option", ":", "str", "The", "name", "...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/options.py#L10-L235
MAVENSDC/PyTplot
pytplot/tplot_restore.py
tplot_restore
def tplot_restore(filename): """ This function will restore tplot variables that have been saved with the "tplot_save" command. .. note:: This function is compatible with the IDL tplot_save routine. If you have a ".tplot" file generated from IDL, this procedure will restore the data c...
python
def tplot_restore(filename): """ This function will restore tplot variables that have been saved with the "tplot_save" command. .. note:: This function is compatible with the IDL tplot_save routine. If you have a ".tplot" file generated from IDL, this procedure will restore the data c...
[ "def", "tplot_restore", "(", "filename", ")", ":", "#Error check", "if", "not", "(", "os", ".", "path", ".", "isfile", "(", "filename", ")", ")", ":", "print", "(", "\"Not a valid file name\"", ")", "return", "#Check if the restored file was an IDL file", "if", ...
This function will restore tplot variables that have been saved with the "tplot_save" command. .. note:: This function is compatible with the IDL tplot_save routine. If you have a ".tplot" file generated from IDL, this procedure will restore the data contained in the file. Not all plo...
[ "This", "function", "will", "restore", "tplot", "variables", "that", "have", "been", "saved", "with", "the", "tplot_save", "command", ".", "..", "note", "::", "This", "function", "is", "compatible", "with", "the", "IDL", "tplot_save", "routine", ".", "If", "...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/tplot_restore.py#L16-L114
MAVENSDC/PyTplot
pytplot/timespan.py
timespan
def timespan(t1, dt, keyword = 'days'): """ This function will set the time range for all time series plots. This is a wrapper for the function "xlim" to better handle time axes. Parameters: t1 : flt/str The time to start all time series plots. Can be given in seconds since ...
python
def timespan(t1, dt, keyword = 'days'): """ This function will set the time range for all time series plots. This is a wrapper for the function "xlim" to better handle time axes. Parameters: t1 : flt/str The time to start all time series plots. Can be given in seconds since ...
[ "def", "timespan", "(", "t1", ",", "dt", ",", "keyword", "=", "'days'", ")", ":", "if", "keyword", "is", "'days'", ":", "dt", "*=", "86400", "elif", "keyword", "is", "'hours'", ":", "dt", "*=", "3600", "elif", "keyword", "is", "'minutes'", ":", "dt",...
This function will set the time range for all time series plots. This is a wrapper for the function "xlim" to better handle time axes. Parameters: t1 : flt/str The time to start all time series plots. Can be given in seconds since epoch, or as a string in the format "YYY...
[ "This", "function", "will", "set", "the", "time", "range", "for", "all", "time", "series", "plots", ".", "This", "is", "a", "wrapper", "for", "the", "function", "xlim", "to", "better", "handle", "time", "axes", ".", "Parameters", ":", "t1", ":", "flt", ...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/timespan.py#L9-L52
MAVENSDC/PyTplot
pytplot/tplot_options.py
tplot_options
def tplot_options(option, value): """ This function allows the user to set several global options for the generated plots. Parameters: option : str The name of the option. See section below value : str/int/float/list The value of the option. See section bel...
python
def tplot_options(option, value): """ This function allows the user to set several global options for the generated plots. Parameters: option : str The name of the option. See section below value : str/int/float/list The value of the option. See section bel...
[ "def", "tplot_options", "(", "option", ",", "value", ")", ":", "option", "=", "option", ".", "lower", "(", ")", "temp", "=", "tplot_utilities", ".", "set_tplot_options", "(", "option", ",", "value", ",", "pytplot", ".", "tplot_opt_glob", ")", "pytplot", "....
This function allows the user to set several global options for the generated plots. Parameters: option : str The name of the option. See section below value : str/int/float/list The value of the option. See section below. Options: ======...
[ "This", "function", "allows", "the", "user", "to", "set", "several", "global", "options", "for", "the", "generated", "plots", ".", "Parameters", ":", "option", ":", "str", "The", "name", "of", "the", "option", ".", "See", "section", "below", "value", ":", ...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/tplot_options.py#L9-L58
MAVENSDC/PyTplot
pytplot/tplot.py
tplot
def tplot(name, var_label=None, auto_color=True, interactive=False, combine_axes=True, nb=False, save_file=None, gui=False, qt=False, bokeh=False, save_png=None, display=True, testing=False): """ ...
python
def tplot(name, var_label=None, auto_color=True, interactive=False, combine_axes=True, nb=False, save_file=None, gui=False, qt=False, bokeh=False, save_png=None, display=True, testing=False): """ ...
[ "def", "tplot", "(", "name", ",", "var_label", "=", "None", ",", "auto_color", "=", "True", ",", "interactive", "=", "False", ",", "combine_axes", "=", "True", ",", "nb", "=", "False", ",", "save_file", "=", "None", ",", "gui", "=", "False", ",", "qt...
This is the function used to display the tplot variables stored in memory. The default output is to show the plots stacked on top of one another inside a GUI window. The GUI window has the option to export the plots in either PNG or HTML formats. .. note:: This plotting routine uses the python Boke...
[ "This", "is", "the", "function", "used", "to", "display", "the", "tplot", "variables", "stored", "in", "memory", ".", "The", "default", "output", "is", "to", "show", "the", "plots", "stacked", "on", "top", "of", "one", "another", "inside", "a", "GUI", "w...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/tplot.py#L28-L245
MAVENSDC/PyTplot
pytplot/staticplot_tavg.py
static2dplot_timeaveraged
def static2dplot_timeaveraged(var, time): """ If the static_taverage option is set in tplot, and is supplied with a time range, then the spectrogram plot(s) for which it is set will have another window pop up, where the displayed y and z values are averaged by the number of seconds between the specified tim...
python
def static2dplot_timeaveraged(var, time): """ If the static_taverage option is set in tplot, and is supplied with a time range, then the spectrogram plot(s) for which it is set will have another window pop up, where the displayed y and z values are averaged by the number of seconds between the specified tim...
[ "def", "static2dplot_timeaveraged", "(", "var", ",", "time", ")", ":", "# Grab names of data loaded in as tplot variables.", "names", "=", "list", "(", "pytplot", ".", "data_quants", ".", "keys", "(", ")", ")", "# Get data we'll actually work with here.", "valid_variables...
If the static_taverage option is set in tplot, and is supplied with a time range, then the spectrogram plot(s) for which it is set will have another window pop up, where the displayed y and z values are averaged by the number of seconds between the specified time range.
[ "If", "the", "static_taverage", "option", "is", "set", "in", "tplot", "and", "is", "supplied", "with", "a", "time", "range", "then", "the", "spectrogram", "plot", "(", "s", ")", "for", "which", "it", "is", "set", "will", "have", "another", "window", "pop...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/staticplot_tavg.py#L8-L108
MAVENSDC/PyTplot
pytplot/tplot_save.py
tplot_save
def tplot_save(names, filename=None): """ This function will save tplot variables into a single file by using the python "pickle" function. This file can then be "restored" using tplot_restore. This is useful if you want to end the pytplot session, but save all of your data/options. All variables and ...
python
def tplot_save(names, filename=None): """ This function will save tplot variables into a single file by using the python "pickle" function. This file can then be "restored" using tplot_restore. This is useful if you want to end the pytplot session, but save all of your data/options. All variables and ...
[ "def", "tplot_save", "(", "names", ",", "filename", "=", "None", ")", ":", "if", "isinstance", "(", "names", ",", "int", ")", ":", "names", "=", "list", "(", "data_quants", ".", "keys", "(", ")", ")", "[", "names", "-", "1", "]", "if", "not", "is...
This function will save tplot variables into a single file by using the python "pickle" function. This file can then be "restored" using tplot_restore. This is useful if you want to end the pytplot session, but save all of your data/options. All variables and plot options can be read back into tplot with the ...
[ "This", "function", "will", "save", "tplot", "variables", "into", "a", "single", "file", "by", "using", "the", "python", "pickle", "function", ".", "This", "file", "can", "then", "be", "restored", "using", "tplot_restore", ".", "This", "is", "useful", "if", ...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/tplot_save.py#L9-L65
MAVENSDC/PyTplot
pytplot/get_ylimits.py
get_ylimits
def get_ylimits(name, trg=None): """ This function will get extract the y-limits from the Tplot Variables stored in memory. Parameters: name : str Name of the tplot variable trg : list, optional The time range that you would like to look in Retur...
python
def get_ylimits(name, trg=None): """ This function will get extract the y-limits from the Tplot Variables stored in memory. Parameters: name : str Name of the tplot variable trg : list, optional The time range that you would like to look in Retur...
[ "def", "get_ylimits", "(", "name", ",", "trg", "=", "None", ")", ":", "if", "isinstance", "(", "name", ",", "int", ")", ":", "name", "=", "list", "(", "data_quants", ".", "keys", "(", ")", ")", "[", "name", "-", "1", "]", "if", "not", "isinstance...
This function will get extract the y-limits from the Tplot Variables stored in memory. Parameters: name : str Name of the tplot variable trg : list, optional The time range that you would like to look in Returns: ymin : float The mini...
[ "This", "function", "will", "get", "extract", "the", "y", "-", "limits", "from", "the", "Tplot", "Variables", "stored", "in", "memory", ".", "Parameters", ":", "name", ":", "str", "Name", "of", "the", "tplot", "variable", "trg", ":", "list", "optional", ...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/get_ylimits.py#L9-L69
MAVENSDC/PyTplot
pytplot/timestamp.py
timestamp
def timestamp(val): """ This function will turn on a time stamp that shows up at the bottom of every generated plot. Parameters val str A string that can either be 'on' or 'off'. Returns None Examples # Turn on the timestamp i...
python
def timestamp(val): """ This function will turn on a time stamp that shows up at the bottom of every generated plot. Parameters val str A string that can either be 'on' or 'off'. Returns None Examples # Turn on the timestamp i...
[ "def", "timestamp", "(", "val", ")", ":", "if", "val", "is", "'on'", ":", "todaystring", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "'%Y-%m-%d %H%M%S'", ")", "extra_layouts", "[", "'time_stamp'", "]", "=", "todaystring", ...
This function will turn on a time stamp that shows up at the bottom of every generated plot. Parameters val str A string that can either be 'on' or 'off'. Returns None Examples # Turn on the timestamp import pytplot pytplot.tim...
[ "This", "function", "will", "turn", "on", "a", "time", "stamp", "that", "shows", "up", "at", "the", "bottom", "of", "every", "generated", "plot", ".", "Parameters", "val", "str", "A", "string", "that", "can", "either", "be", "on", "or", "off", ".", "Re...
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/timestamp.py#L9-L35
MAVENSDC/PyTplot
pytplot/QtPlotter/CustomImage/UpdatingImage.py
makeARGBwithNaNs
def makeARGBwithNaNs(data, lut=None, levels=None, scale=None, useRGBA=False): """ This is the same as pyqtgraph.makeARGB, except that all NaN's in the data are set to transparent pixels """ nanlocations = np.isnan(data) profile = debug.Profiler() if data.ndim not in (2, 3): raise...
python
def makeARGBwithNaNs(data, lut=None, levels=None, scale=None, useRGBA=False): """ This is the same as pyqtgraph.makeARGB, except that all NaN's in the data are set to transparent pixels """ nanlocations = np.isnan(data) profile = debug.Profiler() if data.ndim not in (2, 3): raise...
[ "def", "makeARGBwithNaNs", "(", "data", ",", "lut", "=", "None", ",", "levels", "=", "None", ",", "scale", "=", "None", ",", "useRGBA", "=", "False", ")", ":", "nanlocations", "=", "np", ".", "isnan", "(", "data", ")", "profile", "=", "debug", ".", ...
This is the same as pyqtgraph.makeARGB, except that all NaN's in the data are set to transparent pixels
[ "This", "is", "the", "same", "as", "pyqtgraph", ".", "makeARGB", "except", "that", "all", "NaN", "s", "in", "the", "data", "are", "set", "to", "transparent", "pixels" ]
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/QtPlotter/CustomImage/UpdatingImage.py#L225-L351
MAVENSDC/PyTplot
pytplot/QtPlotter/CustomImage/UpdatingImage.py
UpdatingImage.paint
def paint(self, p, *args): ''' I have no idea why, but we need to generate the picture after painting otherwise it draws incorrectly. ''' if self.picturenotgened: self.generatePicture(self.getBoundingParents()[0].rect()) self.picturenotgened = False ...
python
def paint(self, p, *args): ''' I have no idea why, but we need to generate the picture after painting otherwise it draws incorrectly. ''' if self.picturenotgened: self.generatePicture(self.getBoundingParents()[0].rect()) self.picturenotgened = False ...
[ "def", "paint", "(", "self", ",", "p", ",", "*", "args", ")", ":", "if", "self", ".", "picturenotgened", ":", "self", ".", "generatePicture", "(", "self", ".", "getBoundingParents", "(", ")", "[", "0", "]", ".", "rect", "(", ")", ")", "self", ".", ...
I have no idea why, but we need to generate the picture after painting otherwise it draws incorrectly.
[ "I", "have", "no", "idea", "why", "but", "we", "need", "to", "generate", "the", "picture", "after", "painting", "otherwise", "it", "draws", "incorrectly", "." ]
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/QtPlotter/CustomImage/UpdatingImage.py#L94-L103
MAVENSDC/PyTplot
pytplot/QtPlotter/CustomImage/UpdatingImage.py
UpdatingImage.setImage
def setImage(self, image=None, autoLevels=None, **kargs): """ Same this as ImageItem.setImage, but we don't update the drawing """ profile = debug.Profiler() gotNewData = False if image is None: if self.image is None: return e...
python
def setImage(self, image=None, autoLevels=None, **kargs): """ Same this as ImageItem.setImage, but we don't update the drawing """ profile = debug.Profiler() gotNewData = False if image is None: if self.image is None: return e...
[ "def", "setImage", "(", "self", ",", "image", "=", "None", ",", "autoLevels", "=", "None", ",", "*", "*", "kargs", ")", ":", "profile", "=", "debug", ".", "Profiler", "(", ")", "gotNewData", "=", "False", "if", "image", "is", "None", ":", "if", "se...
Same this as ImageItem.setImage, but we don't update the drawing
[ "Same", "this", "as", "ImageItem", ".", "setImage", "but", "we", "don", "t", "update", "the", "drawing" ]
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/QtPlotter/CustomImage/UpdatingImage.py#L168-L222
MAVENSDC/PyTplot
pytplot/QtPlotter/PyTPlot_Exporter.py
PytplotExporter.getPaintItems
def getPaintItems(self, root=None): """Return a list of all items that should be painted in the correct order.""" if root is None: root = self.item preItems = [] postItems = [] if isinstance(root, QtGui.QGraphicsScene): childs = [i for i in root.items() if...
python
def getPaintItems(self, root=None): """Return a list of all items that should be painted in the correct order.""" if root is None: root = self.item preItems = [] postItems = [] if isinstance(root, QtGui.QGraphicsScene): childs = [i for i in root.items() if...
[ "def", "getPaintItems", "(", "self", ",", "root", "=", "None", ")", ":", "if", "root", "is", "None", ":", "root", "=", "self", ".", "item", "preItems", "=", "[", "]", "postItems", "=", "[", "]", "if", "isinstance", "(", "root", ",", "QtGui", ".", ...
Return a list of all items that should be painted in the correct order.
[ "Return", "a", "list", "of", "all", "items", "that", "should", "be", "painted", "in", "the", "correct", "order", "." ]
train
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/QtPlotter/PyTPlot_Exporter.py#L92-L119
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/normalize_fun.py
run_norm
def run_norm(net, df=None, norm_type='zscore', axis='row', keep_orig=False): ''' A dataframe (more accurately a dictionary of dataframes, e.g. mat, mat_up...) can be passed to run_norm and a normalization will be run ( e.g. zscore) on either the rows or columns ''' # df here is actually a dictionary of sev...
python
def run_norm(net, df=None, norm_type='zscore', axis='row', keep_orig=False): ''' A dataframe (more accurately a dictionary of dataframes, e.g. mat, mat_up...) can be passed to run_norm and a normalization will be run ( e.g. zscore) on either the rows or columns ''' # df here is actually a dictionary of sev...
[ "def", "run_norm", "(", "net", ",", "df", "=", "None", ",", "norm_type", "=", "'zscore'", ",", "axis", "=", "'row'", ",", "keep_orig", "=", "False", ")", ":", "# df here is actually a dictionary of several dataframes, 'mat', 'mat_orig',", "# etc", "if", "df", "is"...
A dataframe (more accurately a dictionary of dataframes, e.g. mat, mat_up...) can be passed to run_norm and a normalization will be run ( e.g. zscore) on either the rows or columns
[ "A", "dataframe", "(", "more", "accurately", "a", "dictionary", "of", "dataframes", "e", ".", "g", ".", "mat", "mat_up", "...", ")", "can", "be", "passed", "to", "run_norm", "and", "a", "normalization", "will", "be", "run", "(", "e", ".", "g", ".", "...
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/normalize_fun.py#L5-L23
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/normalize_fun.py
qn_df
def qn_df(df, axis='row', keep_orig=False): ''' do quantile normalization of a dataframe dictionary, does not write to net ''' df_qn = {} for mat_type in df: inst_df = df[mat_type] # using transpose to do row qn if axis == 'row': inst_df = inst_df.transpose() missing_values = inst_df....
python
def qn_df(df, axis='row', keep_orig=False): ''' do quantile normalization of a dataframe dictionary, does not write to net ''' df_qn = {} for mat_type in df: inst_df = df[mat_type] # using transpose to do row qn if axis == 'row': inst_df = inst_df.transpose() missing_values = inst_df....
[ "def", "qn_df", "(", "df", ",", "axis", "=", "'row'", ",", "keep_orig", "=", "False", ")", ":", "df_qn", "=", "{", "}", "for", "mat_type", "in", "df", ":", "inst_df", "=", "df", "[", "mat_type", "]", "# using transpose to do row qn", "if", "axis", "=="...
do quantile normalization of a dataframe dictionary, does not write to net
[ "do", "quantile", "normalization", "of", "a", "dataframe", "dictionary", "does", "not", "write", "to", "net" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/normalize_fun.py#L25-L65
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/normalize_fun.py
calc_common_dist
def calc_common_dist(df): ''' calculate a common distribution (for col qn only) that will be used to qn ''' # axis is col tmp_arr = np.array([]) col_names = df.columns.tolist() for inst_col in col_names: # sort column tmp_vect = df[inst_col].sort_values(ascending=False).values # stacking ...
python
def calc_common_dist(df): ''' calculate a common distribution (for col qn only) that will be used to qn ''' # axis is col tmp_arr = np.array([]) col_names = df.columns.tolist() for inst_col in col_names: # sort column tmp_vect = df[inst_col].sort_values(ascending=False).values # stacking ...
[ "def", "calc_common_dist", "(", "df", ")", ":", "# axis is col", "tmp_arr", "=", "np", ".", "array", "(", "[", "]", ")", "col_names", "=", "df", ".", "columns", ".", "tolist", "(", ")", "for", "inst_col", "in", "col_names", ":", "# sort column", "tmp_vec...
calculate a common distribution (for col qn only) that will be used to qn
[ "calculate", "a", "common", "distribution", "(", "for", "col", "qn", "only", ")", "that", "will", "be", "used", "to", "qn" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/normalize_fun.py#L100-L125
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/normalize_fun.py
zscore_df
def zscore_df(df, axis='row', keep_orig=False): ''' take the zscore of a dataframe dictionary, does not write to net (self) ''' df_z = {} for mat_type in df: if keep_orig and mat_type == 'mat': mat_orig = deepcopy(df[mat_type]) inst_df = df[mat_type] if axis == 'row': inst_df = inst...
python
def zscore_df(df, axis='row', keep_orig=False): ''' take the zscore of a dataframe dictionary, does not write to net (self) ''' df_z = {} for mat_type in df: if keep_orig and mat_type == 'mat': mat_orig = deepcopy(df[mat_type]) inst_df = df[mat_type] if axis == 'row': inst_df = inst...
[ "def", "zscore_df", "(", "df", ",", "axis", "=", "'row'", ",", "keep_orig", "=", "False", ")", ":", "df_z", "=", "{", "}", "for", "mat_type", "in", "df", ":", "if", "keep_orig", "and", "mat_type", "==", "'mat'", ":", "mat_orig", "=", "deepcopy", "(",...
take the zscore of a dataframe dictionary, does not write to net (self)
[ "take", "the", "zscore", "of", "a", "dataframe", "dictionary", "does", "not", "write", "to", "net", "(", "self", ")" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/normalize_fun.py#L127-L150
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/cat_pval.py
main
def main(net): ''' calculate pvalue of category closeness ''' # calculate the distance between the data points within the same category and # compare to null distribution for inst_rc in ['row', 'col']: inst_nodes = deepcopy(net.dat['nodes'][inst_rc]) inst_index = deepcopy(net.dat['node_info'][inst...
python
def main(net): ''' calculate pvalue of category closeness ''' # calculate the distance between the data points within the same category and # compare to null distribution for inst_rc in ['row', 'col']: inst_nodes = deepcopy(net.dat['nodes'][inst_rc]) inst_index = deepcopy(net.dat['node_info'][inst...
[ "def", "main", "(", "net", ")", ":", "# calculate the distance between the data points within the same category and", "# compare to null distribution", "for", "inst_rc", "in", "[", "'row'", ",", "'col'", "]", ":", "inst_nodes", "=", "deepcopy", "(", "net", ".", "dat", ...
calculate pvalue of category closeness
[ "calculate", "pvalue", "of", "category", "closeness" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/cat_pval.py#L5-L54
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/proc_df_labels.py
main
def main(df): ''' 1) check that rows are strings (in case of numerical names) 2) check for tuples, and in that case load tuples to categories ''' import numpy as np from ast import literal_eval as make_tuple test = {} test['row'] = df['mat'].index.tolist() test['col'] = df['mat'].columns.tolist() ...
python
def main(df): ''' 1) check that rows are strings (in case of numerical names) 2) check for tuples, and in that case load tuples to categories ''' import numpy as np from ast import literal_eval as make_tuple test = {} test['row'] = df['mat'].index.tolist() test['col'] = df['mat'].columns.tolist() ...
[ "def", "main", "(", "df", ")", ":", "import", "numpy", "as", "np", "from", "ast", "import", "literal_eval", "as", "make_tuple", "test", "=", "{", "}", "test", "[", "'row'", "]", "=", "df", "[", "'mat'", "]", ".", "index", ".", "tolist", "(", ")", ...
1) check that rows are strings (in case of numerical names) 2) check for tuples, and in that case load tuples to categories
[ "1", ")", "check", "that", "rows", "are", "strings", "(", "in", "case", "of", "numerical", "names", ")", "2", ")", "check", "for", "tuples", "and", "in", "that", "case", "load", "tuples", "to", "categories" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/proc_df_labels.py#L1-L62
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/data_formats.py
df_to_dat
def df_to_dat(net, df, define_cat_colors=False): ''' This is always run when data is loaded. ''' from . import categories # check if df has unique values df['mat'] = make_unique_labels.main(net, df['mat']) net.dat['mat'] = df['mat'].values net.dat['nodes']['row'] = df['mat'].index.tolist() net.dat['...
python
def df_to_dat(net, df, define_cat_colors=False): ''' This is always run when data is loaded. ''' from . import categories # check if df has unique values df['mat'] = make_unique_labels.main(net, df['mat']) net.dat['mat'] = df['mat'].values net.dat['nodes']['row'] = df['mat'].index.tolist() net.dat['...
[ "def", "df_to_dat", "(", "net", ",", "df", ",", "define_cat_colors", "=", "False", ")", ":", "from", ".", "import", "categories", "# check if df has unique values", "df", "[", "'mat'", "]", "=", "make_unique_labels", ".", "main", "(", "net", ",", "df", "[", ...
This is always run when data is loaded.
[ "This", "is", "always", "run", "when", "data", "is", "loaded", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/data_formats.py#L3-L39
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/data_formats.py
mat_to_numpy_arr
def mat_to_numpy_arr(self): ''' convert list to numpy array - numpy arrays can not be saved as json ''' import numpy as np self.dat['mat'] = np.asarray(self.dat['mat'])
python
def mat_to_numpy_arr(self): ''' convert list to numpy array - numpy arrays can not be saved as json ''' import numpy as np self.dat['mat'] = np.asarray(self.dat['mat'])
[ "def", "mat_to_numpy_arr", "(", "self", ")", ":", "import", "numpy", "as", "np", "self", ".", "dat", "[", "'mat'", "]", "=", "np", ".", "asarray", "(", "self", ".", "dat", "[", "'mat'", "]", ")" ]
convert list to numpy array - numpy arrays can not be saved as json
[ "convert", "list", "to", "numpy", "array", "-", "numpy", "arrays", "can", "not", "be", "saved", "as", "json" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/data_formats.py#L69-L72
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/calc_clust.py
cluster_row_and_col
def cluster_row_and_col(net, dist_type='cosine', linkage_type='average', dendro=True, run_clustering=True, run_rank=True, ignore_cat=False, calc_cat_pval=False, links=False): ''' cluster net.dat and make visualization json, net.viz. optionally leave out dendrogram col...
python
def cluster_row_and_col(net, dist_type='cosine', linkage_type='average', dendro=True, run_clustering=True, run_rank=True, ignore_cat=False, calc_cat_pval=False, links=False): ''' cluster net.dat and make visualization json, net.viz. optionally leave out dendrogram col...
[ "def", "cluster_row_and_col", "(", "net", ",", "dist_type", "=", "'cosine'", ",", "linkage_type", "=", "'average'", ",", "dendro", "=", "True", ",", "run_clustering", "=", "True", ",", "run_rank", "=", "True", ",", "ignore_cat", "=", "False", ",", "calc_cat_...
cluster net.dat and make visualization json, net.viz. optionally leave out dendrogram colorbar groups with dendro argument
[ "cluster", "net", ".", "dat", "and", "make", "visualization", "json", "net", ".", "viz", ".", "optionally", "leave", "out", "dendrogram", "colorbar", "groups", "with", "dendro", "argument" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/calc_clust.py#L1-L49
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/categories.py
check_categories
def check_categories(lines): ''' find out how many row and col categories are available ''' # count the number of row categories rcat_line = lines[0].split('\t') # calc the number of row names and categories num_rc = 0 found_end = False # skip first tab for inst_string in rcat_line[1:]: if ins...
python
def check_categories(lines): ''' find out how many row and col categories are available ''' # count the number of row categories rcat_line = lines[0].split('\t') # calc the number of row names and categories num_rc = 0 found_end = False # skip first tab for inst_string in rcat_line[1:]: if ins...
[ "def", "check_categories", "(", "lines", ")", ":", "# count the number of row categories", "rcat_line", "=", "lines", "[", "0", "]", ".", "split", "(", "'\\t'", ")", "# calc the number of row names and categories", "num_rc", "=", "0", "found_end", "=", "False", "# s...
find out how many row and col categories are available
[ "find", "out", "how", "many", "row", "and", "col", "categories", "are", "available" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/categories.py#L1-L37
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/categories.py
dict_cat
def dict_cat(net, define_cat_colors=False): ''' make a dictionary of node-category associations ''' # print('---------------------------------') # print('---- dict_cat: before setting cat colors') # print('---------------------------------\n') # print(define_cat_colors) # print(net.viz['cat_colors']) ...
python
def dict_cat(net, define_cat_colors=False): ''' make a dictionary of node-category associations ''' # print('---------------------------------') # print('---- dict_cat: before setting cat colors') # print('---------------------------------\n') # print(define_cat_colors) # print(net.viz['cat_colors']) ...
[ "def", "dict_cat", "(", "net", ",", "define_cat_colors", "=", "False", ")", ":", "# print('---------------------------------')", "# print('---- dict_cat: before setting cat colors')", "# print('---------------------------------\\n')", "# print(define_cat_colors)", "# print(net.viz['cat_c...
make a dictionary of node-category associations
[ "make", "a", "dictionary", "of", "node", "-", "category", "associations" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/categories.py#L39-L131
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/categories.py
calc_cat_clust_order
def calc_cat_clust_order(net, inst_rc): ''' cluster category subset of data ''' from .__init__ import Network from copy import deepcopy from . import calc_clust, run_filter inst_keys = list(net.dat['node_info'][inst_rc].keys()) all_cats = [x for x in inst_keys if 'cat-' in x] if len(all_cats) > 0: ...
python
def calc_cat_clust_order(net, inst_rc): ''' cluster category subset of data ''' from .__init__ import Network from copy import deepcopy from . import calc_clust, run_filter inst_keys = list(net.dat['node_info'][inst_rc].keys()) all_cats = [x for x in inst_keys if 'cat-' in x] if len(all_cats) > 0: ...
[ "def", "calc_cat_clust_order", "(", "net", ",", "inst_rc", ")", ":", "from", ".", "__init__", "import", "Network", "from", "copy", "import", "deepcopy", "from", ".", "import", "calc_clust", ",", "run_filter", "inst_keys", "=", "list", "(", "net", ".", "dat",...
cluster category subset of data
[ "cluster", "category", "subset", "of", "data" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/categories.py#L137-L234
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/categories.py
order_categories
def order_categories(unordered_cats): ''' If categories are strings, then simple ordering is fine. If categories are values then I'll need to order based on their values. The final ordering is given as the original categories (including titles) in a ordered list. ''' no_titles = remove_titles(unordered_c...
python
def order_categories(unordered_cats): ''' If categories are strings, then simple ordering is fine. If categories are values then I'll need to order based on their values. The final ordering is given as the original categories (including titles) in a ordered list. ''' no_titles = remove_titles(unordered_c...
[ "def", "order_categories", "(", "unordered_cats", ")", ":", "no_titles", "=", "remove_titles", "(", "unordered_cats", ")", "all_are_numbers", "=", "check_all_numbers", "(", "no_titles", ")", "if", "all_are_numbers", ":", "ordered_cats", "=", "order_cats_based_on_values"...
If categories are strings, then simple ordering is fine. If categories are values then I'll need to order based on their values. The final ordering is given as the original categories (including titles) in a ordered list.
[ "If", "categories", "are", "strings", "then", "simple", "ordering", "is", "fine", ".", "If", "categories", "are", "values", "then", "I", "ll", "need", "to", "order", "based", "on", "their", "values", ".", "The", "final", "ordering", "is", "given", "as", ...
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/categories.py#L237-L254
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.load_file_as_string
def load_file_as_string(self, file_string, filename=''): ''' Load file as a string. ''' load_data.load_file_as_string(self, file_string, filename=filename)
python
def load_file_as_string(self, file_string, filename=''): ''' Load file as a string. ''' load_data.load_file_as_string(self, file_string, filename=filename)
[ "def", "load_file_as_string", "(", "self", ",", "file_string", ",", "filename", "=", "''", ")", ":", "load_data", ".", "load_file_as_string", "(", "self", ",", "file_string", ",", "filename", "=", "filename", ")" ]
Load file as a string.
[ "Load", "file", "as", "a", "string", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L56-L60
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.load_data_file_to_net
def load_data_file_to_net(self, filename): ''' Load Clustergrammer's dat format (saved as JSON). ''' inst_dat = self.load_json_to_dict(filename) load_data.load_data_to_net(self, inst_dat)
python
def load_data_file_to_net(self, filename): ''' Load Clustergrammer's dat format (saved as JSON). ''' inst_dat = self.load_json_to_dict(filename) load_data.load_data_to_net(self, inst_dat)
[ "def", "load_data_file_to_net", "(", "self", ",", "filename", ")", ":", "inst_dat", "=", "self", ".", "load_json_to_dict", "(", "filename", ")", "load_data", ".", "load_data_to_net", "(", "self", ",", "inst_dat", ")" ]
Load Clustergrammer's dat format (saved as JSON).
[ "Load", "Clustergrammer", "s", "dat", "format", "(", "saved", "as", "JSON", ")", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L82-L87
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.cluster
def cluster(self, dist_type='cosine', run_clustering=True, dendro=True, views=['N_row_sum', 'N_row_var'], linkage_type='average', sim_mat=False, filter_sim=0.1, calc_cat_pval=False, run_enrichr=None, enrichrgram=None): ''' The main function performs hierarchica...
python
def cluster(self, dist_type='cosine', run_clustering=True, dendro=True, views=['N_row_sum', 'N_row_var'], linkage_type='average', sim_mat=False, filter_sim=0.1, calc_cat_pval=False, run_enrichr=None, enrichrgram=None): ''' The main function performs hierarchica...
[ "def", "cluster", "(", "self", ",", "dist_type", "=", "'cosine'", ",", "run_clustering", "=", "True", ",", "dendro", "=", "True", ",", "views", "=", "[", "'N_row_sum'", ",", "'N_row_var'", "]", ",", "linkage_type", "=", "'average'", ",", "sim_mat", "=", ...
The main function performs hierarchical clustering, optionally generates filtered views (e.g. row-filtered views), and generates the :``visualization_json``.
[ "The", "main", "function", "performs", "hierarchical", "clustering", "optionally", "generates", "filtered", "views", "(", "e", ".", "g", ".", "row", "-", "filtered", "views", ")", "and", "generates", "the", ":", "visualization_json", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L89-L106
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.load_df
def load_df(self, df): ''' Load Pandas DataFrame. ''' # self.__init__() self.reset() df_dict = {} df_dict['mat'] = deepcopy(df) # always define category colors if applicable when loading a df data_formats.df_to_dat(self, df_dict, define_cat_colors=True)
python
def load_df(self, df): ''' Load Pandas DataFrame. ''' # self.__init__() self.reset() df_dict = {} df_dict['mat'] = deepcopy(df) # always define category colors if applicable when loading a df data_formats.df_to_dat(self, df_dict, define_cat_colors=True)
[ "def", "load_df", "(", "self", ",", "df", ")", ":", "# self.__init__()", "self", ".", "reset", "(", ")", "df_dict", "=", "{", "}", "df_dict", "[", "'mat'", "]", "=", "deepcopy", "(", "df", ")", "# always define category colors if applicable when loading a df", ...
Load Pandas DataFrame.
[ "Load", "Pandas", "DataFrame", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L148-L158
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.df_to_dat
def df_to_dat(self, df, define_cat_colors=False): ''' Load Pandas DataFrame (will be deprecated). ''' data_formats.df_to_dat(self, df, define_cat_colors)
python
def df_to_dat(self, df, define_cat_colors=False): ''' Load Pandas DataFrame (will be deprecated). ''' data_formats.df_to_dat(self, df, define_cat_colors)
[ "def", "df_to_dat", "(", "self", ",", "df", ",", "define_cat_colors", "=", "False", ")", ":", "data_formats", ".", "df_to_dat", "(", "self", ",", "df", ",", "define_cat_colors", ")" ]
Load Pandas DataFrame (will be deprecated).
[ "Load", "Pandas", "DataFrame", "(", "will", "be", "deprecated", ")", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L167-L171
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.widget
def widget(self, which_viz='viz'): ''' Generate a widget visualization using the widget. The export_viz_to_widget method passes the visualization JSON to the instantiated widget, which is returned and visualized on the front-end. ''' if hasattr(self, 'widget_class') == True: # run cluster...
python
def widget(self, which_viz='viz'): ''' Generate a widget visualization using the widget. The export_viz_to_widget method passes the visualization JSON to the instantiated widget, which is returned and visualized on the front-end. ''' if hasattr(self, 'widget_class') == True: # run cluster...
[ "def", "widget", "(", "self", ",", "which_viz", "=", "'viz'", ")", ":", "if", "hasattr", "(", "self", ",", "'widget_class'", ")", "==", "True", ":", "# run clustering if necessary", "if", "len", "(", "self", ".", "viz", "[", "'row_nodes'", "]", ")", "=="...
Generate a widget visualization using the widget. The export_viz_to_widget method passes the visualization JSON to the instantiated widget, which is returned and visualized on the front-end.
[ "Generate", "a", "widget", "visualization", "using", "the", "widget", ".", "The", "export_viz_to_widget", "method", "passes", "the", "visualization", "JSON", "to", "the", "instantiated", "widget", "which", "is", "returned", "and", "visualized", "on", "the", "front...
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L210-L227
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.widget_df
def widget_df(self): ''' Export a DataFrame from the front-end visualization. For instance, a user can filter to show only a single cluster using the dendrogram and then get a dataframe of this cluster using the widget_df method. ''' if hasattr(self, 'widget_instance') == True: if self.w...
python
def widget_df(self): ''' Export a DataFrame from the front-end visualization. For instance, a user can filter to show only a single cluster using the dendrogram and then get a dataframe of this cluster using the widget_df method. ''' if hasattr(self, 'widget_instance') == True: if self.w...
[ "def", "widget_df", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'widget_instance'", ")", "==", "True", ":", "if", "self", ".", "widget_instance", ".", "mat_string", "!=", "''", ":", "tmp_net", "=", "deepcopy", "(", "Network", "(", ")", "...
Export a DataFrame from the front-end visualization. For instance, a user can filter to show only a single cluster using the dendrogram and then get a dataframe of this cluster using the widget_df method.
[ "Export", "a", "DataFrame", "from", "the", "front", "-", "end", "visualization", ".", "For", "instance", "a", "user", "can", "filter", "to", "show", "only", "a", "single", "cluster", "using", "the", "dendrogram", "and", "then", "get", "a", "dataframe", "of...
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L230-L261
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.write_json_to_file
def write_json_to_file(self, net_type, filename, indent='no-indent'): ''' Save dat or viz as a JSON to file. ''' export_data.write_json_to_file(self, net_type, filename, indent)
python
def write_json_to_file(self, net_type, filename, indent='no-indent'): ''' Save dat or viz as a JSON to file. ''' export_data.write_json_to_file(self, net_type, filename, indent)
[ "def", "write_json_to_file", "(", "self", ",", "net_type", ",", "filename", ",", "indent", "=", "'no-indent'", ")", ":", "export_data", ".", "write_json_to_file", "(", "self", ",", "net_type", ",", "filename", ",", "indent", ")" ]
Save dat or viz as a JSON to file.
[ "Save", "dat", "or", "viz", "as", "a", "JSON", "to", "file", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L263-L267
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.filter_sum
def filter_sum(self, inst_rc, threshold, take_abs=True): ''' Filter a network's rows or columns based on the sum across rows or columns. ''' inst_df = self.dat_to_df() if inst_rc == 'row': inst_df = run_filter.df_filter_row_sum(inst_df, threshold, take_abs) elif inst_rc == 'col': ins...
python
def filter_sum(self, inst_rc, threshold, take_abs=True): ''' Filter a network's rows or columns based on the sum across rows or columns. ''' inst_df = self.dat_to_df() if inst_rc == 'row': inst_df = run_filter.df_filter_row_sum(inst_df, threshold, take_abs) elif inst_rc == 'col': ins...
[ "def", "filter_sum", "(", "self", ",", "inst_rc", ",", "threshold", ",", "take_abs", "=", "True", ")", ":", "inst_df", "=", "self", ".", "dat_to_df", "(", ")", "if", "inst_rc", "==", "'row'", ":", "inst_df", "=", "run_filter", ".", "df_filter_row_sum", "...
Filter a network's rows or columns based on the sum across rows or columns.
[ "Filter", "a", "network", "s", "rows", "or", "columns", "based", "on", "the", "sum", "across", "rows", "or", "columns", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L275-L284
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.filter_N_top
def filter_N_top(self, inst_rc, N_top, rank_type='sum'): ''' Filter the matrix rows or columns based on sum/variance, and only keep the top N. ''' inst_df = self.dat_to_df() inst_df = run_filter.filter_N_top(inst_rc, inst_df, N_top, rank_type) self.df_to_dat(inst_df)
python
def filter_N_top(self, inst_rc, N_top, rank_type='sum'): ''' Filter the matrix rows or columns based on sum/variance, and only keep the top N. ''' inst_df = self.dat_to_df() inst_df = run_filter.filter_N_top(inst_rc, inst_df, N_top, rank_type) self.df_to_dat(inst_df)
[ "def", "filter_N_top", "(", "self", ",", "inst_rc", ",", "N_top", ",", "rank_type", "=", "'sum'", ")", ":", "inst_df", "=", "self", ".", "dat_to_df", "(", ")", "inst_df", "=", "run_filter", ".", "filter_N_top", "(", "inst_rc", ",", "inst_df", ",", "N_top...
Filter the matrix rows or columns based on sum/variance, and only keep the top N.
[ "Filter", "the", "matrix", "rows", "or", "columns", "based", "on", "sum", "/", "variance", "and", "only", "keep", "the", "top", "N", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L286-L295
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.filter_threshold
def filter_threshold(self, inst_rc, threshold, num_occur=1): ''' Filter the matrix rows or columns based on num_occur values being above a threshold (in absolute value). ''' inst_df = self.dat_to_df() inst_df = run_filter.filter_threshold(inst_df, inst_rc, threshold, num_occur) self....
python
def filter_threshold(self, inst_rc, threshold, num_occur=1): ''' Filter the matrix rows or columns based on num_occur values being above a threshold (in absolute value). ''' inst_df = self.dat_to_df() inst_df = run_filter.filter_threshold(inst_df, inst_rc, threshold, num_occur) self....
[ "def", "filter_threshold", "(", "self", ",", "inst_rc", ",", "threshold", ",", "num_occur", "=", "1", ")", ":", "inst_df", "=", "self", ".", "dat_to_df", "(", ")", "inst_df", "=", "run_filter", ".", "filter_threshold", "(", "inst_df", ",", "inst_rc", ",", ...
Filter the matrix rows or columns based on num_occur values being above a threshold (in absolute value).
[ "Filter", "the", "matrix", "rows", "or", "columns", "based", "on", "num_occur", "values", "being", "above", "a", "threshold", "(", "in", "absolute", "value", ")", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L297-L307
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.filter_cat
def filter_cat(self, axis, cat_index, cat_name): ''' Filter the matrix based on their category. cat_index is the index of the category, the first category has index=1. ''' run_filter.filter_cat(self, axis, cat_index, cat_name)
python
def filter_cat(self, axis, cat_index, cat_name): ''' Filter the matrix based on their category. cat_index is the index of the category, the first category has index=1. ''' run_filter.filter_cat(self, axis, cat_index, cat_name)
[ "def", "filter_cat", "(", "self", ",", "axis", ",", "cat_index", ",", "cat_name", ")", ":", "run_filter", ".", "filter_cat", "(", "self", ",", "axis", ",", "cat_index", ",", "cat_name", ")" ]
Filter the matrix based on their category. cat_index is the index of the category, the first category has index=1.
[ "Filter", "the", "matrix", "based", "on", "their", "category", ".", "cat_index", "is", "the", "index", "of", "the", "category", "the", "first", "category", "has", "index", "=", "1", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L309-L313
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.clip
def clip(self, lower=None, upper=None): ''' Trim values at input thresholds using pandas function ''' df = self.export_df() df = df.clip(lower=lower, upper=upper) self.load_df(df)
python
def clip(self, lower=None, upper=None): ''' Trim values at input thresholds using pandas function ''' df = self.export_df() df = df.clip(lower=lower, upper=upper) self.load_df(df)
[ "def", "clip", "(", "self", ",", "lower", "=", "None", ",", "upper", "=", "None", ")", ":", "df", "=", "self", ".", "export_df", "(", ")", "df", "=", "df", ".", "clip", "(", "lower", "=", "lower", ",", "upper", "=", "upper", ")", "self", ".", ...
Trim values at input thresholds using pandas function
[ "Trim", "values", "at", "input", "thresholds", "using", "pandas", "function" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L321-L327
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.normalize
def normalize(self, df=None, norm_type='zscore', axis='row', keep_orig=False): ''' Normalize the matrix rows or columns using Z-score (zscore) or Quantile Normalization (qn). Users can optionally pass in a DataFrame to be normalized (and this will be incorporated into the Network object). ''' normalize_...
python
def normalize(self, df=None, norm_type='zscore', axis='row', keep_orig=False): ''' Normalize the matrix rows or columns using Z-score (zscore) or Quantile Normalization (qn). Users can optionally pass in a DataFrame to be normalized (and this will be incorporated into the Network object). ''' normalize_...
[ "def", "normalize", "(", "self", ",", "df", "=", "None", ",", "norm_type", "=", "'zscore'", ",", "axis", "=", "'row'", ",", "keep_orig", "=", "False", ")", ":", "normalize_fun", ".", "run_norm", "(", "self", ",", "df", ",", "norm_type", ",", "axis", ...
Normalize the matrix rows or columns using Z-score (zscore) or Quantile Normalization (qn). Users can optionally pass in a DataFrame to be normalized (and this will be incorporated into the Network object).
[ "Normalize", "the", "matrix", "rows", "or", "columns", "using", "Z", "-", "score", "(", "zscore", ")", "or", "Quantile", "Normalization", "(", "qn", ")", ".", "Users", "can", "optionally", "pass", "in", "a", "DataFrame", "to", "be", "normalized", "(", "a...
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L329-L333
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.downsample
def downsample(self, df=None, ds_type='kmeans', axis='row', num_samples=100, random_state=1000): ''' Downsample the matrix rows or columns (currently supporting kmeans only). Users can optionally pass in a DataFrame to be downsampled (and this will be incorporated into the network object). ''' return d...
python
def downsample(self, df=None, ds_type='kmeans', axis='row', num_samples=100, random_state=1000): ''' Downsample the matrix rows or columns (currently supporting kmeans only). Users can optionally pass in a DataFrame to be downsampled (and this will be incorporated into the network object). ''' return d...
[ "def", "downsample", "(", "self", ",", "df", "=", "None", ",", "ds_type", "=", "'kmeans'", ",", "axis", "=", "'row'", ",", "num_samples", "=", "100", ",", "random_state", "=", "1000", ")", ":", "return", "downsample_fun", ".", "main", "(", "self", ",",...
Downsample the matrix rows or columns (currently supporting kmeans only). Users can optionally pass in a DataFrame to be downsampled (and this will be incorporated into the network object).
[ "Downsample", "the", "matrix", "rows", "or", "columns", "(", "currently", "supporting", "kmeans", "only", ")", ".", "Users", "can", "optionally", "pass", "in", "a", "DataFrame", "to", "be", "downsampled", "(", "and", "this", "will", "be", "incorporated", "in...
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L335-L340
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.random_sample
def random_sample(self, num_samples, df=None, replace=False, weights=None, random_state=100, axis='row'): ''' Return random sample of matrix. ''' if df is None: df = self.dat_to_df() if axis == 'row': axis = 0 if axis == 'col': axis = 1 df = self.export_df() df = df....
python
def random_sample(self, num_samples, df=None, replace=False, weights=None, random_state=100, axis='row'): ''' Return random sample of matrix. ''' if df is None: df = self.dat_to_df() if axis == 'row': axis = 0 if axis == 'col': axis = 1 df = self.export_df() df = df....
[ "def", "random_sample", "(", "self", ",", "num_samples", ",", "df", "=", "None", ",", "replace", "=", "False", ",", "weights", "=", "None", ",", "random_state", "=", "100", ",", "axis", "=", "'row'", ")", ":", "if", "df", "is", "None", ":", "df", "...
Return random sample of matrix.
[ "Return", "random", "sample", "of", "matrix", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L342-L358
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.add_cats
def add_cats(self, axis, cat_data): ''' Add categories to rows or columns using cat_data array of objects. Each object in cat_data is a dictionary with one key (category title) and value (rows/column names) that have this category. Categories will be added onto the existing categories and will be added in the o...
python
def add_cats(self, axis, cat_data): ''' Add categories to rows or columns using cat_data array of objects. Each object in cat_data is a dictionary with one key (category title) and value (rows/column names) that have this category. Categories will be added onto the existing categories and will be added in the o...
[ "def", "add_cats", "(", "self", ",", "axis", ",", "cat_data", ")", ":", "for", "inst_data", "in", "cat_data", ":", "categories", ".", "add_cats", "(", "self", ",", "axis", ",", "inst_data", ")" ]
Add categories to rows or columns using cat_data array of objects. Each object in cat_data is a dictionary with one key (category title) and value (rows/column names) that have this category. Categories will be added onto the existing categories and will be added in the order of the objects in the array. Example `...
[ "Add", "categories", "to", "rows", "or", "columns", "using", "cat_data", "array", "of", "objects", ".", "Each", "object", "in", "cat_data", "is", "a", "dictionary", "with", "one", "key", "(", "category", "title", ")", "and", "value", "(", "rows", "/", "c...
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L360-L390
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.enrichrgram
def enrichrgram(self, lib, axis='row'): ''' Add Enrichr gene enrichment results to your visualization (where your rows are genes). Run enrichrgram before clustering to incldue enrichment results as row categories. Enrichrgram can also be run on the front-end using the Enrichr logo at the top left. ...
python
def enrichrgram(self, lib, axis='row'): ''' Add Enrichr gene enrichment results to your visualization (where your rows are genes). Run enrichrgram before clustering to incldue enrichment results as row categories. Enrichrgram can also be run on the front-end using the Enrichr logo at the top left. ...
[ "def", "enrichrgram", "(", "self", ",", "lib", ",", "axis", "=", "'row'", ")", ":", "df", "=", "self", ".", "export_df", "(", ")", "df", ",", "bar_info", "=", "enr_fun", ".", "add_enrichr_cats", "(", "df", ",", "axis", ",", "lib", ")", "self", ".",...
Add Enrichr gene enrichment results to your visualization (where your rows are genes). Run enrichrgram before clustering to incldue enrichment results as row categories. Enrichrgram can also be run on the front-end using the Enrichr logo at the top left. Set lib to the Enrichr library that you want to ...
[ "Add", "Enrichr", "gene", "enrichment", "results", "to", "your", "visualization", "(", "where", "your", "rows", "are", "genes", ")", ".", "Run", "enrichrgram", "before", "clustering", "to", "incldue", "enrichment", "results", "as", "row", "categories", ".", "E...
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L406-L438
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.load_gene_exp_to_df
def load_gene_exp_to_df(inst_path): ''' Loads gene expression data from 10x in sparse matrix format and returns a Pandas dataframe ''' import pandas as pd from scipy import io from scipy import sparse from ast import literal_eval as make_tuple # matrix Matrix = io.mmread( inst_...
python
def load_gene_exp_to_df(inst_path): ''' Loads gene expression data from 10x in sparse matrix format and returns a Pandas dataframe ''' import pandas as pd from scipy import io from scipy import sparse from ast import literal_eval as make_tuple # matrix Matrix = io.mmread( inst_...
[ "def", "load_gene_exp_to_df", "(", "inst_path", ")", ":", "import", "pandas", "as", "pd", "from", "scipy", "import", "io", "from", "scipy", "import", "sparse", "from", "ast", "import", "literal_eval", "as", "make_tuple", "# matrix", "Matrix", "=", "io", ".", ...
Loads gene expression data from 10x in sparse matrix format and returns a Pandas dataframe
[ "Loads", "gene", "expression", "data", "from", "10x", "in", "sparse", "matrix", "format", "and", "returns", "a", "Pandas", "dataframe" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L453-L551
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.sim_same_and_diff_category_samples
def sim_same_and_diff_category_samples(self, df, cat_index=1, dist_type='cosine', equal_var=False, plot_roc=True, precalc_dist=False, calc_roc=True): ''' Calculate the similarity of samples from the same and different categori...
python
def sim_same_and_diff_category_samples(self, df, cat_index=1, dist_type='cosine', equal_var=False, plot_roc=True, precalc_dist=False, calc_roc=True): ''' Calculate the similarity of samples from the same and different categori...
[ "def", "sim_same_and_diff_category_samples", "(", "self", ",", "df", ",", "cat_index", "=", "1", ",", "dist_type", "=", "'cosine'", ",", "equal_var", "=", "False", ",", "plot_roc", "=", "True", ",", "precalc_dist", "=", "False", ",", "calc_roc", "=", "True",...
Calculate the similarity of samples from the same and different categories. The cat_index gives the index of the category, where 1 in the first category
[ "Calculate", "the", "similarity", "of", "samples", "from", "the", "same", "and", "different", "categories", ".", "The", "cat_index", "gives", "the", "index", "of", "the", "category", "where", "1", "in", "the", "first", "category" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L583-L663
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.generate_signatures
def generate_signatures(self, df_ini, category_level, pval_cutoff=0.05, num_top_dims=False, verbose=True, equal_var=False): ''' Generate signatures for column categories ''' df_t = df_ini.transpose() # remove columns with constant values df_t = df_t.loc[:, (df_t != d...
python
def generate_signatures(self, df_ini, category_level, pval_cutoff=0.05, num_top_dims=False, verbose=True, equal_var=False): ''' Generate signatures for column categories ''' df_t = df_ini.transpose() # remove columns with constant values df_t = df_t.loc[:, (df_t != d...
[ "def", "generate_signatures", "(", "self", ",", "df_ini", ",", "category_level", ",", "pval_cutoff", "=", "0.05", ",", "num_top_dims", "=", "False", ",", "verbose", "=", "True", ",", "equal_var", "=", "False", ")", ":", "df_t", "=", "df_ini", ".", "transpo...
Generate signatures for column categories
[ "Generate", "signatures", "for", "column", "categories" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L665-L729
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.predict_cats_from_sigs
def predict_cats_from_sigs(self, df_data_ini, df_sig_ini, dist_type='cosine', predict_level='Predict Category', truth_level=1, unknown_thresh=-1): ''' Predict category using signature ''' keep_rows = df_sig_ini.index.tolist() data_rows = df_data_ini.index.tolist() ...
python
def predict_cats_from_sigs(self, df_data_ini, df_sig_ini, dist_type='cosine', predict_level='Predict Category', truth_level=1, unknown_thresh=-1): ''' Predict category using signature ''' keep_rows = df_sig_ini.index.tolist() data_rows = df_data_ini.index.tolist() ...
[ "def", "predict_cats_from_sigs", "(", "self", ",", "df_data_ini", ",", "df_sig_ini", ",", "dist_type", "=", "'cosine'", ",", "predict_level", "=", "'Predict Category'", ",", "truth_level", "=", "1", ",", "unknown_thresh", "=", "-", "1", ")", ":", "keep_rows", ...
Predict category using signature
[ "Predict", "category", "using", "signature" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L731-L791
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
Network.confusion_matrix_and_correct_series
def confusion_matrix_and_correct_series(self, y_info): ''' Generate confusion matrix from y_info ''' a = deepcopy(y_info['true']) true_count = dict((i, a.count(i)) for i in set(a)) a = deepcopy(y_info['pred']) pred_count = dict((i, a.count(i)) for i in set(a)) sorted_cats = sorte...
python
def confusion_matrix_and_correct_series(self, y_info): ''' Generate confusion matrix from y_info ''' a = deepcopy(y_info['true']) true_count = dict((i, a.count(i)) for i in set(a)) a = deepcopy(y_info['pred']) pred_count = dict((i, a.count(i)) for i in set(a)) sorted_cats = sorte...
[ "def", "confusion_matrix_and_correct_series", "(", "self", ",", "y_info", ")", ":", "a", "=", "deepcopy", "(", "y_info", "[", "'true'", "]", ")", "true_count", "=", "dict", "(", "(", "i", ",", "a", ".", "count", "(", "i", ")", ")", "for", "i", "in", ...
Generate confusion matrix from y_info
[ "Generate", "confusion", "matrix", "from", "y_info" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L793-L825
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/load_data.py
load_data_to_net
def load_data_to_net(net, inst_net): ''' load data into nodes and mat, also convert mat to numpy array''' net.dat['nodes'] = inst_net['nodes'] net.dat['mat'] = inst_net['mat'] data_formats.mat_to_numpy_arr(net)
python
def load_data_to_net(net, inst_net): ''' load data into nodes and mat, also convert mat to numpy array''' net.dat['nodes'] = inst_net['nodes'] net.dat['mat'] = inst_net['mat'] data_formats.mat_to_numpy_arr(net)
[ "def", "load_data_to_net", "(", "net", ",", "inst_net", ")", ":", "net", ".", "dat", "[", "'nodes'", "]", "=", "inst_net", "[", "'nodes'", "]", "net", ".", "dat", "[", "'mat'", "]", "=", "inst_net", "[", "'mat'", "]", "data_formats", ".", "mat_to_numpy...
load data into nodes and mat, also convert mat to numpy array
[ "load", "data", "into", "nodes", "and", "mat", "also", "convert", "mat", "to", "numpy", "array" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/load_data.py#L96-L100
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/export_data.py
export_net_json
def export_net_json(net, net_type, indent='no-indent'): ''' export json string of dat ''' import json from copy import deepcopy if net_type == 'dat': exp_dict = deepcopy(net.dat) if type(exp_dict['mat']) is not list: exp_dict['mat'] = exp_dict['mat'].tolist() if 'mat_orig' in exp_dict: ...
python
def export_net_json(net, net_type, indent='no-indent'): ''' export json string of dat ''' import json from copy import deepcopy if net_type == 'dat': exp_dict = deepcopy(net.dat) if type(exp_dict['mat']) is not list: exp_dict['mat'] = exp_dict['mat'].tolist() if 'mat_orig' in exp_dict: ...
[ "def", "export_net_json", "(", "net", ",", "net_type", ",", "indent", "=", "'no-indent'", ")", ":", "import", "json", "from", "copy", "import", "deepcopy", "if", "net_type", "==", "'dat'", ":", "exp_dict", "=", "deepcopy", "(", "net", ".", "dat", ")", "i...
export json string of dat
[ "export", "json", "string", "of", "dat" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/export_data.py#L1-L29
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/export_data.py
write_matrix_to_tsv
def write_matrix_to_tsv(net, filename=None, df=None): ''' This will export the matrix in net.dat or a dataframe (optional df in arguments) as a tsv file. Row/column categories will be saved as tuples in tsv, which can be read back into the network object. ''' import pandas as pd if df is None: df = n...
python
def write_matrix_to_tsv(net, filename=None, df=None): ''' This will export the matrix in net.dat or a dataframe (optional df in arguments) as a tsv file. Row/column categories will be saved as tuples in tsv, which can be read back into the network object. ''' import pandas as pd if df is None: df = n...
[ "def", "write_matrix_to_tsv", "(", "net", ",", "filename", "=", "None", ",", "df", "=", "None", ")", ":", "import", "pandas", "as", "pd", "if", "df", "is", "None", ":", "df", "=", "net", ".", "dat_to_df", "(", ")", "return", "df", "[", "'mat'", "]"...
This will export the matrix in net.dat or a dataframe (optional df in arguments) as a tsv file. Row/column categories will be saved as tuples in tsv, which can be read back into the network object.
[ "This", "will", "export", "the", "matrix", "in", "net", ".", "dat", "or", "a", "dataframe", "(", "optional", "df", "in", "arguments", ")", "as", "a", "tsv", "file", ".", "Row", "/", "column", "categories", "will", "be", "saved", "as", "tuples", "in", ...
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/export_data.py#L31-L42
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/make_unique_labels.py
main
def main(net, df=None): ''' Run in load_data module (which runs when file is loaded or dataframe is loaded), check for duplicate row/col names, and add index to names if necesary ''' if df is None: df = net.export_df() # rows ############# rows = df.index.tolist() if type(rows[0]) is str: if...
python
def main(net, df=None): ''' Run in load_data module (which runs when file is loaded or dataframe is loaded), check for duplicate row/col names, and add index to names if necesary ''' if df is None: df = net.export_df() # rows ############# rows = df.index.tolist() if type(rows[0]) is str: if...
[ "def", "main", "(", "net", ",", "df", "=", "None", ")", ":", "if", "df", "is", "None", ":", "df", "=", "net", ".", "export_df", "(", ")", "# rows", "#############", "rows", "=", "df", ".", "index", ".", "tolist", "(", ")", "if", "type", "(", "r...
Run in load_data module (which runs when file is loaded or dataframe is loaded), check for duplicate row/col names, and add index to names if necesary
[ "Run", "in", "load_data", "module", "(", "which", "runs", "when", "file", "is", "loaded", "or", "dataframe", "is", "loaded", ")", "check", "for", "duplicate", "row", "/", "col", "names", "and", "add", "index", "to", "names", "if", "necesary" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/make_unique_labels.py#L3-L71
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/make_viz.py
viz_json
def viz_json(net, dendro=True, links=False): ''' make the dictionary for the clustergram.js visualization ''' from . import calc_clust import numpy as np all_dist = calc_clust.group_cutoffs() for inst_rc in net.dat['nodes']: inst_keys = net.dat['node_info'][inst_rc] all_cats = [x for x in inst_keys...
python
def viz_json(net, dendro=True, links=False): ''' make the dictionary for the clustergram.js visualization ''' from . import calc_clust import numpy as np all_dist = calc_clust.group_cutoffs() for inst_rc in net.dat['nodes']: inst_keys = net.dat['node_info'][inst_rc] all_cats = [x for x in inst_keys...
[ "def", "viz_json", "(", "net", ",", "dendro", "=", "True", ",", "links", "=", "False", ")", ":", "from", ".", "import", "calc_clust", "import", "numpy", "as", "np", "all_dist", "=", "calc_clust", ".", "group_cutoffs", "(", ")", "for", "inst_rc", "in", ...
make the dictionary for the clustergram.js visualization
[ "make", "the", "dictionary", "for", "the", "clustergram", ".", "js", "visualization" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/make_viz.py#L1-L94
ismms-himc/clustergrammer2
setupbase.py
install_npm
def install_npm(path=None, build_dir=None, source_dir=None, build_cmd='build', force=False, npm=None): """Return a Command for managing an npm installation. Note: The command is skipped if the `--skip-npm` flag is used. Parameters ---------- path: str, optional The base path of the node pa...
python
def install_npm(path=None, build_dir=None, source_dir=None, build_cmd='build', force=False, npm=None): """Return a Command for managing an npm installation. Note: The command is skipped if the `--skip-npm` flag is used. Parameters ---------- path: str, optional The base path of the node pa...
[ "def", "install_npm", "(", "path", "=", "None", ",", "build_dir", "=", "None", ",", "source_dir", "=", "None", ",", "build_cmd", "=", "'build'", ",", "force", "=", "False", ",", "npm", "=", "None", ")", ":", "class", "NPM", "(", "BaseCommand", ")", "...
Return a Command for managing an npm installation. Note: The command is skipped if the `--skip-npm` flag is used. Parameters ---------- path: str, optional The base path of the node package. Defaults to the repo root. build_dir: str, optional The target build directory. If this a...
[ "Return", "a", "Command", "for", "managing", "an", "npm", "installation", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/setupbase.py#L321-L377
ismms-himc/clustergrammer2
setupbase.py
_glob_pjoin
def _glob_pjoin(*parts): """Join paths for glob processing""" if parts[0] in ('.', ''): parts = parts[1:] return pjoin(*parts).replace(os.sep, '/')
python
def _glob_pjoin(*parts): """Join paths for glob processing""" if parts[0] in ('.', ''): parts = parts[1:] return pjoin(*parts).replace(os.sep, '/')
[ "def", "_glob_pjoin", "(", "*", "parts", ")", ":", "if", "parts", "[", "0", "]", "in", "(", "'.'", ",", "''", ")", ":", "parts", "=", "parts", "[", "1", ":", "]", "return", "pjoin", "(", "*", "parts", ")", ".", "replace", "(", "os", ".", "sep...
Join paths for glob processing
[ "Join", "paths", "for", "glob", "processing" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/setupbase.py#L507-L511
ismms-himc/clustergrammer2
setupbase.py
_get_data_files
def _get_data_files(data_specs, existing, top=HERE): """Expand data file specs into valid data files metadata. Parameters ---------- data_specs: list of tuples See [create_cmdclass] for description. existing: list of tuples The existing distrubution data_files metadata. Returns...
python
def _get_data_files(data_specs, existing, top=HERE): """Expand data file specs into valid data files metadata. Parameters ---------- data_specs: list of tuples See [create_cmdclass] for description. existing: list of tuples The existing distrubution data_files metadata. Returns...
[ "def", "_get_data_files", "(", "data_specs", ",", "existing", ",", "top", "=", "HERE", ")", ":", "# Extract the existing data files into a staging object.", "file_data", "=", "defaultdict", "(", "list", ")", "for", "(", "path", ",", "files", ")", "in", "existing",...
Expand data file specs into valid data files metadata. Parameters ---------- data_specs: list of tuples See [create_cmdclass] for description. existing: list of tuples The existing distrubution data_files metadata. Returns ------- A valid list of data_files items.
[ "Expand", "data", "file", "specs", "into", "valid", "data", "files", "metadata", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/setupbase.py#L514-L554
ismms-himc/clustergrammer2
setupbase.py
_get_files
def _get_files(file_patterns, top=HERE): """Expand file patterns to a list of paths. Parameters ----------- file_patterns: list or str A list of glob patterns for the data file locations. The globs can be recursive if they include a `**`. They should be relative paths from the t...
python
def _get_files(file_patterns, top=HERE): """Expand file patterns to a list of paths. Parameters ----------- file_patterns: list or str A list of glob patterns for the data file locations. The globs can be recursive if they include a `**`. They should be relative paths from the t...
[ "def", "_get_files", "(", "file_patterns", ",", "top", "=", "HERE", ")", ":", "if", "not", "isinstance", "(", "file_patterns", ",", "(", "list", ",", "tuple", ")", ")", ":", "file_patterns", "=", "[", "file_patterns", "]", "for", "i", ",", "p", "in", ...
Expand file patterns to a list of paths. Parameters ----------- file_patterns: list or str A list of glob patterns for the data file locations. The globs can be recursive if they include a `**`. They should be relative paths from the top directory or absolute paths. top:...
[ "Expand", "file", "patterns", "to", "a", "list", "of", "paths", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/setupbase.py#L557-L595
ismms-himc/clustergrammer2
setupbase.py
_get_package_data
def _get_package_data(root, file_patterns=None): """Expand file patterns to a list of `package_data` paths. Parameters ----------- root: str The relative path to the package root from `HERE`. file_patterns: list or str, optional A list of glob patterns for the data file locations. ...
python
def _get_package_data(root, file_patterns=None): """Expand file patterns to a list of `package_data` paths. Parameters ----------- root: str The relative path to the package root from `HERE`. file_patterns: list or str, optional A list of glob patterns for the data file locations. ...
[ "def", "_get_package_data", "(", "root", ",", "file_patterns", "=", "None", ")", ":", "if", "file_patterns", "is", "None", ":", "file_patterns", "=", "[", "'*'", "]", "return", "_get_files", "(", "file_patterns", ",", "_glob_pjoin", "(", "HERE", ",", "root",...
Expand file patterns to a list of `package_data` paths. Parameters ----------- root: str The relative path to the package root from `HERE`. file_patterns: list or str, optional A list of glob patterns for the data file locations. The globs can be recursive if they include a `**`...
[ "Expand", "file", "patterns", "to", "a", "list", "of", "package_data", "paths", "." ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/setupbase.py#L598-L616
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/run_filter.py
df_filter_row_sum
def df_filter_row_sum(df, threshold, take_abs=True): ''' filter rows in matrix at some threshold and remove columns that have a sum below this threshold ''' from copy import deepcopy from .__init__ import Network net = Network() if take_abs is True: df_copy = deepcopy(df['mat'].abs()) else: df_c...
python
def df_filter_row_sum(df, threshold, take_abs=True): ''' filter rows in matrix at some threshold and remove columns that have a sum below this threshold ''' from copy import deepcopy from .__init__ import Network net = Network() if take_abs is True: df_copy = deepcopy(df['mat'].abs()) else: df_c...
[ "def", "df_filter_row_sum", "(", "df", ",", "threshold", ",", "take_abs", "=", "True", ")", ":", "from", "copy", "import", "deepcopy", "from", ".", "__init__", "import", "Network", "net", "=", "Network", "(", ")", "if", "take_abs", "is", "True", ":", "df...
filter rows in matrix at some threshold and remove columns that have a sum below this threshold
[ "filter", "rows", "in", "matrix", "at", "some", "threshold", "and", "remove", "columns", "that", "have", "a", "sum", "below", "this", "threshold" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/run_filter.py#L1-L33
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/run_filter.py
df_filter_col_sum
def df_filter_col_sum(df, threshold, take_abs=True): ''' filter columns in matrix at some threshold and remove rows that have all zero values ''' from copy import deepcopy from .__init__ import Network net = Network() if take_abs is True: df_copy = deepcopy(df['mat'].abs()) else: df_copy = deepc...
python
def df_filter_col_sum(df, threshold, take_abs=True): ''' filter columns in matrix at some threshold and remove rows that have all zero values ''' from copy import deepcopy from .__init__ import Network net = Network() if take_abs is True: df_copy = deepcopy(df['mat'].abs()) else: df_copy = deepc...
[ "def", "df_filter_col_sum", "(", "df", ",", "threshold", ",", "take_abs", "=", "True", ")", ":", "from", "copy", "import", "deepcopy", "from", ".", "__init__", "import", "Network", "net", "=", "Network", "(", ")", "if", "take_abs", "is", "True", ":", "df...
filter columns in matrix at some threshold and remove rows that have all zero values
[ "filter", "columns", "in", "matrix", "at", "some", "threshold", "and", "remove", "rows", "that", "have", "all", "zero", "values" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/run_filter.py#L35-L68
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/run_filter.py
filter_threshold
def filter_threshold(df, inst_rc, threshold, num_occur=1): ''' Filter a network's rows or cols based on num_occur values being above a threshold (in absolute_value) ''' from copy import deepcopy inst_df = deepcopy(df['mat']) if inst_rc == 'col': inst_df = inst_df.transpose() inst_df = inst_df.abs...
python
def filter_threshold(df, inst_rc, threshold, num_occur=1): ''' Filter a network's rows or cols based on num_occur values being above a threshold (in absolute_value) ''' from copy import deepcopy inst_df = deepcopy(df['mat']) if inst_rc == 'col': inst_df = inst_df.transpose() inst_df = inst_df.abs...
[ "def", "filter_threshold", "(", "df", ",", "inst_rc", ",", "threshold", ",", "num_occur", "=", "1", ")", ":", "from", "copy", "import", "deepcopy", "inst_df", "=", "deepcopy", "(", "df", "[", "'mat'", "]", ")", "if", "inst_rc", "==", "'col'", ":", "ins...
Filter a network's rows or cols based on num_occur values being above a threshold (in absolute_value)
[ "Filter", "a", "network", "s", "rows", "or", "cols", "based", "on", "num_occur", "values", "being", "above", "a", "threshold", "(", "in", "absolute_value", ")" ]
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/run_filter.py#L118-L169
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/make_clust_fun.py
make_clust
def make_clust(net, dist_type='cosine', run_clustering=True, dendro=True, requested_views=['pct_row_sum', 'N_row_sum'], linkage_type='average', sim_mat=False, filter_sim=0.1, calc_cat_pval=False, sim_mat_views=['N_row_sum'], ...
python
def make_clust(net, dist_type='cosine', run_clustering=True, dendro=True, requested_views=['pct_row_sum', 'N_row_sum'], linkage_type='average', sim_mat=False, filter_sim=0.1, calc_cat_pval=False, sim_mat_views=['N_row_sum'], ...
[ "def", "make_clust", "(", "net", ",", "dist_type", "=", "'cosine'", ",", "run_clustering", "=", "True", ",", "dendro", "=", "True", ",", "requested_views", "=", "[", "'pct_row_sum'", ",", "'N_row_sum'", "]", ",", "linkage_type", "=", "'average'", ",", "sim_m...
This will calculate multiple views of a clustergram by filtering the data and clustering after each filtering. This filtering will keep the top N rows based on some quantity (sum, num-non-zero, etc).
[ "This", "will", "calculate", "multiple", "views", "of", "a", "clustergram", "by", "filtering", "the", "data", "and", "clustering", "after", "each", "filtering", ".", "This", "filtering", "will", "keep", "the", "top", "N", "rows", "based", "on", "some", "quan...
train
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/make_clust_fun.py#L1-L99
vstinner/bytecode
bytecode/flags.py
infer_flags
def infer_flags(bytecode, is_async=False): """Infer the proper flags for a bytecode based on the instructions. """ flags = CompilerFlags(0) if not isinstance(bytecode, (_bytecode.Bytecode, _bytecode.ConcreteBytecode, _bytecode.ControlFlo...
python
def infer_flags(bytecode, is_async=False): """Infer the proper flags for a bytecode based on the instructions. """ flags = CompilerFlags(0) if not isinstance(bytecode, (_bytecode.Bytecode, _bytecode.ConcreteBytecode, _bytecode.ControlFlo...
[ "def", "infer_flags", "(", "bytecode", ",", "is_async", "=", "False", ")", ":", "flags", "=", "CompilerFlags", "(", "0", ")", "if", "not", "isinstance", "(", "bytecode", ",", "(", "_bytecode", ".", "Bytecode", ",", "_bytecode", ".", "ConcreteBytecode", ","...
Infer the proper flags for a bytecode based on the instructions.
[ "Infer", "the", "proper", "flags", "for", "a", "bytecode", "based", "on", "the", "instructions", "." ]
train
https://github.com/vstinner/bytecode/blob/e2a27287a464a10557c89c7959f3c4c4ac3cb8bf/bytecode/flags.py#L33-L89
vstinner/bytecode
bytecode/cfg.py
ControlFlowGraph.to_bytecode
def to_bytecode(self): """Convert to Bytecode.""" used_blocks = set() for block in self: target_block = block.get_jump() if target_block is not None: used_blocks.add(id(target_block)) labels = {} jumps = [] instructions = [] ...
python
def to_bytecode(self): """Convert to Bytecode.""" used_blocks = set() for block in self: target_block = block.get_jump() if target_block is not None: used_blocks.add(id(target_block)) labels = {} jumps = [] instructions = [] ...
[ "def", "to_bytecode", "(", "self", ")", ":", "used_blocks", "=", "set", "(", ")", "for", "block", "in", "self", ":", "target_block", "=", "block", ".", "get_jump", "(", ")", "if", "target_block", "is", "not", "None", ":", "used_blocks", ".", "add", "("...
Convert to Bytecode.
[ "Convert", "to", "Bytecode", "." ]
train
https://github.com/vstinner/bytecode/blob/e2a27287a464a10557c89c7959f3c4c4ac3cb8bf/bytecode/cfg.py#L279-L315
vstinner/bytecode
bytecode/cfg.py
ControlFlowGraph.to_code
def to_code(self, stacksize=None): """Convert to code.""" if stacksize is None: stacksize = self.compute_stacksize() bc = self.to_bytecode() return bc.to_code(stacksize=stacksize)
python
def to_code(self, stacksize=None): """Convert to code.""" if stacksize is None: stacksize = self.compute_stacksize() bc = self.to_bytecode() return bc.to_code(stacksize=stacksize)
[ "def", "to_code", "(", "self", ",", "stacksize", "=", "None", ")", ":", "if", "stacksize", "is", "None", ":", "stacksize", "=", "self", ".", "compute_stacksize", "(", ")", "bc", "=", "self", ".", "to_bytecode", "(", ")", "return", "bc", ".", "to_code",...
Convert to code.
[ "Convert", "to", "code", "." ]
train
https://github.com/vstinner/bytecode/blob/e2a27287a464a10557c89c7959f3c4c4ac3cb8bf/bytecode/cfg.py#L317-L322
vstinner/bytecode
bytecode/instr.py
Instr.set
def set(self, name, arg=UNSET): """Modify the instruction in-place. Replace name and arg attributes. Don't modify lineno. """ self._set(name, arg, self._lineno)
python
def set(self, name, arg=UNSET): """Modify the instruction in-place. Replace name and arg attributes. Don't modify lineno. """ self._set(name, arg, self._lineno)
[ "def", "set", "(", "self", ",", "name", ",", "arg", "=", "UNSET", ")", ":", "self", ".", "_set", "(", "name", ",", "arg", ",", "self", ".", "_lineno", ")" ]
Modify the instruction in-place. Replace name and arg attributes. Don't modify lineno.
[ "Modify", "the", "instruction", "in", "-", "place", "." ]
train
https://github.com/vstinner/bytecode/blob/e2a27287a464a10557c89c7959f3c4c4ac3cb8bf/bytecode/instr.py#L248-L253
riga/tfdeploy
tfdeploy.py
setup
def setup(tf, order=None): """ Sets up global variables (currently only the tensorflow version) to adapt to peculiarities of different tensorflow versions. This function should only be called before :py:class:`Model` creation, not for evaluation. Therefore, the tensorflow module *tf* must be passed: ...
python
def setup(tf, order=None): """ Sets up global variables (currently only the tensorflow version) to adapt to peculiarities of different tensorflow versions. This function should only be called before :py:class:`Model` creation, not for evaluation. Therefore, the tensorflow module *tf* must be passed: ...
[ "def", "setup", "(", "tf", ",", "order", "=", "None", ")", ":", "global", "_tf_version_string", ",", "_tf_version", "_tf_version_string", "=", "tf", ".", "__version__", "_tf_version", "=", "_parse_tf_version", "(", "_tf_version_string", ")", "if", "order", "is",...
Sets up global variables (currently only the tensorflow version) to adapt to peculiarities of different tensorflow versions. This function should only be called before :py:class:`Model` creation, not for evaluation. Therefore, the tensorflow module *tf* must be passed: .. code-block:: python import...
[ "Sets", "up", "global", "variables", "(", "currently", "only", "the", "tensorflow", "version", ")", "to", "adapt", "to", "peculiarities", "of", "different", "tensorflow", "versions", ".", "This", "function", "should", "only", "be", "called", "before", ":", "py...
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L805-L827
riga/tfdeploy
tfdeploy.py
optimize
def optimize(order): """ optimize(impl) Tries to set the implementation type of all registered :py:class:`Operation` classes to *impl*. This has no effect when an op does not implement that type. The behavior is equivalent to: .. code-block:: python for op in Operation.__subclasses__(): ...
python
def optimize(order): """ optimize(impl) Tries to set the implementation type of all registered :py:class:`Operation` classes to *impl*. This has no effect when an op does not implement that type. The behavior is equivalent to: .. code-block:: python for op in Operation.__subclasses__(): ...
[ "def", "optimize", "(", "order", ")", ":", "if", "not", "isinstance", "(", "order", ",", "(", "list", ",", "tuple", ")", ")", ":", "order", "=", "[", "order", "]", "for", "op", "in", "Operation", ".", "__subclasses__", "(", ")", ":", "for", "impl",...
optimize(impl) Tries to set the implementation type of all registered :py:class:`Operation` classes to *impl*. This has no effect when an op does not implement that type. The behavior is equivalent to: .. code-block:: python for op in Operation.__subclasses__(): if impl in op.impls:...
[ "optimize", "(", "impl", ")", "Tries", "to", "set", "the", "implementation", "type", "of", "all", "registered", ":", "py", ":", "class", ":", "Operation", "classes", "to", "*", "impl", "*", ".", "This", "has", "no", "effect", "when", "an", "op", "does"...
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L838-L860
riga/tfdeploy
tfdeploy.py
print_tensor
def print_tensor(td_tensor, indent="| ", max_depth=-1, depth=0): """ print_tensor(td_tensor, indent=" ", max_depth=-1) Prints the dependency graph of a :py:class:`Tensor` *td_tensor*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where...
python
def print_tensor(td_tensor, indent="| ", max_depth=-1, depth=0): """ print_tensor(td_tensor, indent=" ", max_depth=-1) Prints the dependency graph of a :py:class:`Tensor` *td_tensor*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where...
[ "def", "print_tensor", "(", "td_tensor", ",", "indent", "=", "\"| \"", ",", "max_depth", "=", "-", "1", ",", "depth", "=", "0", ")", ":", "offset", "=", "depth", "*", "indent", "line", "=", "\"td tensor: %s\"", "%", "td_tensor", ".", "name", "if", "t...
print_tensor(td_tensor, indent=" ", max_depth=-1) Prints the dependency graph of a :py:class:`Tensor` *td_tensor*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where each tensor and each op count as a level.
[ "print_tensor", "(", "td_tensor", "indent", "=", "max_depth", "=", "-", "1", ")", "Prints", "the", "dependency", "graph", "of", "a", ":", "py", ":", "class", ":", "Tensor", "*", "td_tensor", "*", "where", "each", "new", "level", "is", "indented", "by", ...
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L863-L877
riga/tfdeploy
tfdeploy.py
print_op
def print_op(td_op, indent="| ", max_depth=-1, depth=0): """ print_op(td_op, indent=" ", max_depth=-1) Prints the dependency graph of a :py:class:`Operation` *td_op*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where each tensor ...
python
def print_op(td_op, indent="| ", max_depth=-1, depth=0): """ print_op(td_op, indent=" ", max_depth=-1) Prints the dependency graph of a :py:class:`Operation` *td_op*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where each tensor ...
[ "def", "print_op", "(", "td_op", ",", "indent", "=", "\"| \"", ",", "max_depth", "=", "-", "1", ",", "depth", "=", "0", ")", ":", "offset", "=", "depth", "*", "indent", "line", "=", "\"td op: %s (%s)\"", "%", "(", "td_op", ".", "name", ",", "\",\""...
print_op(td_op, indent=" ", max_depth=-1) Prints the dependency graph of a :py:class:`Operation` *td_op*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where each tensor and each op count as a level.
[ "print_op", "(", "td_op", "indent", "=", "max_depth", "=", "-", "1", ")", "Prints", "the", "dependency", "graph", "of", "a", ":", "py", ":", "class", ":", "Operation", "*", "td_op", "*", "where", "each", "new", "level", "is", "indented", "by", "*", "...
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L880-L893
riga/tfdeploy
tfdeploy.py
print_tf_tensor
def print_tf_tensor(tf_tensor, indent="| ", max_depth=-1, depth=0): """ print_tf_tensor(tf_tensor, indent=" ", max_depth=-1) Prints the dependency graph of a tensorflow tensor *tf_tensor*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, ...
python
def print_tf_tensor(tf_tensor, indent="| ", max_depth=-1, depth=0): """ print_tf_tensor(tf_tensor, indent=" ", max_depth=-1) Prints the dependency graph of a tensorflow tensor *tf_tensor*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, ...
[ "def", "print_tf_tensor", "(", "tf_tensor", ",", "indent", "=", "\"| \"", ",", "max_depth", "=", "-", "1", ",", "depth", "=", "0", ")", ":", "offset", "=", "depth", "*", "indent", "shape", "=", "tuple", "(", "int", "(", "i", ")", "for", "i", "in"...
print_tf_tensor(tf_tensor, indent=" ", max_depth=-1) Prints the dependency graph of a tensorflow tensor *tf_tensor*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where each tensor and each op count as a level.
[ "print_tf_tensor", "(", "tf_tensor", "indent", "=", "max_depth", "=", "-", "1", ")", "Prints", "the", "dependency", "graph", "of", "a", "tensorflow", "tensor", "*", "tf_tensor", "*", "where", "each", "new", "level", "is", "indented", "by", "*", "indent", "...
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L896-L909
riga/tfdeploy
tfdeploy.py
print_tf_op
def print_tf_op(tf_op, indent="| ", max_depth=-1, depth=0): """ print_tf_op(tf_tensor, indent=" ", max_depth=-1) Prints the dependency graph of a tensorflow operation *tf_op*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where each ...
python
def print_tf_op(tf_op, indent="| ", max_depth=-1, depth=0): """ print_tf_op(tf_tensor, indent=" ", max_depth=-1) Prints the dependency graph of a tensorflow operation *tf_op*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where each ...
[ "def", "print_tf_op", "(", "tf_op", ",", "indent", "=", "\"| \"", ",", "max_depth", "=", "-", "1", ",", "depth", "=", "0", ")", ":", "offset", "=", "depth", "*", "indent", "line", "=", "\"tf op: %s (%s)\"", "%", "(", "tf_op", ".", "name", ",", "tf_...
print_tf_op(tf_tensor, indent=" ", max_depth=-1) Prints the dependency graph of a tensorflow operation *tf_op*, where each new level is indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where each tensor and each op count as a level.
[ "print_tf_op", "(", "tf_tensor", "indent", "=", "max_depth", "=", "-", "1", ")", "Prints", "the", "dependency", "graph", "of", "a", "tensorflow", "operation", "*", "tf_op", "*", "where", "each", "new", "level", "is", "indented", "by", "*", "indent", "*", ...
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L912-L925
riga/tfdeploy
tfdeploy.py
LinSpace
def LinSpace(start, stop, num): """ Linspace op. """ return np.linspace(start, stop, num=num, dtype=np.float32),
python
def LinSpace(start, stop, num): """ Linspace op. """ return np.linspace(start, stop, num=num, dtype=np.float32),
[ "def", "LinSpace", "(", "start", ",", "stop", ",", "num", ")", ":", "return", "np", ".", "linspace", "(", "start", ",", "stop", ",", "num", "=", "num", ",", "dtype", "=", "np", ".", "float32", ")", "," ]
Linspace op.
[ "Linspace", "op", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1003-L1007
riga/tfdeploy
tfdeploy.py
Range
def Range(start, limit, delta): """ Range op. """ return np.arange(start, limit, delta, dtype=np.int32),
python
def Range(start, limit, delta): """ Range op. """ return np.arange(start, limit, delta, dtype=np.int32),
[ "def", "Range", "(", "start", ",", "limit", ",", "delta", ")", ":", "return", "np", ".", "arange", "(", "start", ",", "limit", ",", "delta", ",", "dtype", "=", "np", ".", "int32", ")", "," ]
Range op.
[ "Range", "op", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1011-L1015
riga/tfdeploy
tfdeploy.py
RandomStandardNormal
def RandomStandardNormal(shape, dtype, seed): """ Standard (mu=0, sigma=1) gaussian op. """ if seed: np.random.seed(seed) return np.random.normal(size=reduce(mul, shape)).reshape(shape).astype(dtype_map[dtype]),
python
def RandomStandardNormal(shape, dtype, seed): """ Standard (mu=0, sigma=1) gaussian op. """ if seed: np.random.seed(seed) return np.random.normal(size=reduce(mul, shape)).reshape(shape).astype(dtype_map[dtype]),
[ "def", "RandomStandardNormal", "(", "shape", ",", "dtype", ",", "seed", ")", ":", "if", "seed", ":", "np", ".", "random", ".", "seed", "(", "seed", ")", "return", "np", ".", "random", ".", "normal", "(", "size", "=", "reduce", "(", "mul", ",", "sha...
Standard (mu=0, sigma=1) gaussian op.
[ "Standard", "(", "mu", "=", "0", "sigma", "=", "1", ")", "gaussian", "op", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1023-L1029
riga/tfdeploy
tfdeploy.py
TruncatedNormal
def TruncatedNormal(shape, dtype, seed): """ Standard (mu=0, sigma=1) gaussian op with truncation above 2 sigma. """ if seed: np.random.seed(seed) n = reduce(mul, shape) r = np.empty(n, dtype=dtype_map[dtype]) idxs = np.ones(n, dtype=np.bool) while n: r[idxs] = np.random....
python
def TruncatedNormal(shape, dtype, seed): """ Standard (mu=0, sigma=1) gaussian op with truncation above 2 sigma. """ if seed: np.random.seed(seed) n = reduce(mul, shape) r = np.empty(n, dtype=dtype_map[dtype]) idxs = np.ones(n, dtype=np.bool) while n: r[idxs] = np.random....
[ "def", "TruncatedNormal", "(", "shape", ",", "dtype", ",", "seed", ")", ":", "if", "seed", ":", "np", ".", "random", ".", "seed", "(", "seed", ")", "n", "=", "reduce", "(", "mul", ",", "shape", ")", "r", "=", "np", ".", "empty", "(", "n", ",", ...
Standard (mu=0, sigma=1) gaussian op with truncation above 2 sigma.
[ "Standard", "(", "mu", "=", "0", "sigma", "=", "1", ")", "gaussian", "op", "with", "truncation", "above", "2", "sigma", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1033-L1046
riga/tfdeploy
tfdeploy.py
RandomUniform
def RandomUniform(shape, dtype, seed): """ Random uniform op. """ if seed: np.random.seed(seed) return np.random.uniform(size=shape).astype(dtype_map[dtype]),
python
def RandomUniform(shape, dtype, seed): """ Random uniform op. """ if seed: np.random.seed(seed) return np.random.uniform(size=shape).astype(dtype_map[dtype]),
[ "def", "RandomUniform", "(", "shape", ",", "dtype", ",", "seed", ")", ":", "if", "seed", ":", "np", ".", "random", ".", "seed", "(", "seed", ")", "return", "np", ".", "random", ".", "uniform", "(", "size", "=", "shape", ")", ".", "astype", "(", "...
Random uniform op.
[ "Random", "uniform", "op", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1050-L1056
riga/tfdeploy
tfdeploy.py
RandomUniformInt
def RandomUniformInt(shape, minval, maxval, seed): """ Random uniform int op. """ if seed: np.random.seed(seed) return np.random.randint(minval, maxval, size=shape),
python
def RandomUniformInt(shape, minval, maxval, seed): """ Random uniform int op. """ if seed: np.random.seed(seed) return np.random.randint(minval, maxval, size=shape),
[ "def", "RandomUniformInt", "(", "shape", ",", "minval", ",", "maxval", ",", "seed", ")", ":", "if", "seed", ":", "np", ".", "random", ".", "seed", "(", "seed", ")", "return", "np", ".", "random", ".", "randint", "(", "minval", ",", "maxval", ",", "...
Random uniform int op.
[ "Random", "uniform", "int", "op", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1060-L1066
riga/tfdeploy
tfdeploy.py
RandomShuffle
def RandomShuffle(a, seed): """ Random uniform op. """ if seed: np.random.seed(seed) r = a.copy() np.random.shuffle(r) return r,
python
def RandomShuffle(a, seed): """ Random uniform op. """ if seed: np.random.seed(seed) r = a.copy() np.random.shuffle(r) return r,
[ "def", "RandomShuffle", "(", "a", ",", "seed", ")", ":", "if", "seed", ":", "np", ".", "random", ".", "seed", "(", "seed", ")", "r", "=", "a", ".", "copy", "(", ")", "np", ".", "random", ".", "shuffle", "(", "r", ")", "return", "r", "," ]
Random uniform op.
[ "Random", "uniform", "op", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1070-L1078
riga/tfdeploy
tfdeploy.py
Rank
def Rank(a): """ Rank op. """ return np.array([len(a.shape)], dtype=np.int32),
python
def Rank(a): """ Rank op. """ return np.array([len(a.shape)], dtype=np.int32),
[ "def", "Rank", "(", "a", ")", ":", "return", "np", ".", "array", "(", "[", "len", "(", "a", ".", "shape", ")", "]", ",", "dtype", "=", "np", ".", "int32", ")", "," ]
Rank op.
[ "Rank", "op", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1114-L1118
riga/tfdeploy
tfdeploy.py
Squeeze
def Squeeze(a, squeeze_dims): """ Squeeze op, i.e. removes singular axes. """ if not squeeze_dims: squeeze_dims = list(range(len(a.shape))) slices = [(0 if (dim == 1 and i in squeeze_dims) else slice(None)) \ for i, dim in enumerate(a.shape)] return np.copy(a)[slices],
python
def Squeeze(a, squeeze_dims): """ Squeeze op, i.e. removes singular axes. """ if not squeeze_dims: squeeze_dims = list(range(len(a.shape))) slices = [(0 if (dim == 1 and i in squeeze_dims) else slice(None)) \ for i, dim in enumerate(a.shape)] return np.copy(a)[slices],
[ "def", "Squeeze", "(", "a", ",", "squeeze_dims", ")", ":", "if", "not", "squeeze_dims", ":", "squeeze_dims", "=", "list", "(", "range", "(", "len", "(", "a", ".", "shape", ")", ")", ")", "slices", "=", "[", "(", "0", "if", "(", "dim", "==", "1", ...
Squeeze op, i.e. removes singular axes.
[ "Squeeze", "op", "i", ".", "e", ".", "removes", "singular", "axes", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1130-L1138
riga/tfdeploy
tfdeploy.py
ExpandDims
def ExpandDims(a, dim): """ Expand dim op, i.e. add singular axis at dim. """ shape = list(a.shape) if dim >= 0: shape.insert(dim, 1) else: shape.insert(len(shape) + dim + 1, 1) return np.copy(a).reshape(*shape),
python
def ExpandDims(a, dim): """ Expand dim op, i.e. add singular axis at dim. """ shape = list(a.shape) if dim >= 0: shape.insert(dim, 1) else: shape.insert(len(shape) + dim + 1, 1) return np.copy(a).reshape(*shape),
[ "def", "ExpandDims", "(", "a", ",", "dim", ")", ":", "shape", "=", "list", "(", "a", ".", "shape", ")", "if", "dim", ">=", "0", ":", "shape", ".", "insert", "(", "dim", ",", "1", ")", "else", ":", "shape", ".", "insert", "(", "len", "(", "sha...
Expand dim op, i.e. add singular axis at dim.
[ "Expand", "dim", "op", "i", ".", "e", ".", "add", "singular", "axis", "at", "dim", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1142-L1151
riga/tfdeploy
tfdeploy.py
Slice
def Slice(a, begin, size): """ Slicing op. """ return np.copy(a)[[slice(*tpl) for tpl in zip(begin, begin+size)]],
python
def Slice(a, begin, size): """ Slicing op. """ return np.copy(a)[[slice(*tpl) for tpl in zip(begin, begin+size)]],
[ "def", "Slice", "(", "a", ",", "begin", ",", "size", ")", ":", "return", "np", ".", "copy", "(", "a", ")", "[", "[", "slice", "(", "*", "tpl", ")", "for", "tpl", "in", "zip", "(", "begin", ",", "begin", "+", "size", ")", "]", "]", "," ]
Slicing op.
[ "Slicing", "op", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1159-L1163
riga/tfdeploy
tfdeploy.py
Split
def Split(axis, a, n): """ Split op with n splits. """ return tuple(np.split(np.copy(a), n, axis=axis))
python
def Split(axis, a, n): """ Split op with n splits. """ return tuple(np.split(np.copy(a), n, axis=axis))
[ "def", "Split", "(", "axis", ",", "a", ",", "n", ")", ":", "return", "tuple", "(", "np", ".", "split", "(", "np", ".", "copy", "(", "a", ")", ",", "n", ",", "axis", "=", "axis", ")", ")" ]
Split op with n splits.
[ "Split", "op", "with", "n", "splits", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1167-L1171
riga/tfdeploy
tfdeploy.py
SplitV
def SplitV(a, splits, axis): """ Split op with multiple split sizes. """ return tuple(np.split(np.copy(a), np.cumsum(splits), axis=axis))
python
def SplitV(a, splits, axis): """ Split op with multiple split sizes. """ return tuple(np.split(np.copy(a), np.cumsum(splits), axis=axis))
[ "def", "SplitV", "(", "a", ",", "splits", ",", "axis", ")", ":", "return", "tuple", "(", "np", ".", "split", "(", "np", ".", "copy", "(", "a", ")", ",", "np", ".", "cumsum", "(", "splits", ")", ",", "axis", "=", "axis", ")", ")" ]
Split op with multiple split sizes.
[ "Split", "op", "with", "multiple", "split", "sizes", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1175-L1179
riga/tfdeploy
tfdeploy.py
ConcatV2
def ConcatV2(inputs): """ Concat op. """ axis = inputs.pop() return np.concatenate(inputs, axis=axis),
python
def ConcatV2(inputs): """ Concat op. """ axis = inputs.pop() return np.concatenate(inputs, axis=axis),
[ "def", "ConcatV2", "(", "inputs", ")", ":", "axis", "=", "inputs", ".", "pop", "(", ")", "return", "np", ".", "concatenate", "(", "inputs", ",", "axis", "=", "axis", ")", "," ]
Concat op.
[ "Concat", "op", "." ]
train
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1199-L1204