repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
mabuchilab/QNET
src/qnet/algebra/core/abstract_algebra.py
Expression.bound_symbols
def bound_symbols(self): """Set of bound SymPy symbols in the expression""" if self._bound_symbols is None: res = set.union( set([]), # dummy arg (union fails without arguments) *[_bound_symbols(val) for val in self.kwargs.values()]) res.update( ...
python
def bound_symbols(self): """Set of bound SymPy symbols in the expression""" if self._bound_symbols is None: res = set.union( set([]), # dummy arg (union fails without arguments) *[_bound_symbols(val) for val in self.kwargs.values()]) res.update( ...
[ "def", "bound_symbols", "(", "self", ")", ":", "if", "self", ".", "_bound_symbols", "is", "None", ":", "res", "=", "set", ".", "union", "(", "set", "(", "[", "]", ")", ",", "# dummy arg (union fails without arguments)", "*", "[", "_bound_symbols", "(", "va...
Set of bound SymPy symbols in the expression
[ "Set", "of", "bound", "SymPy", "symbols", "in", "the", "expression" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/abstract_algebra.py#L642-L652
train
62,900
daler/metaseq
metaseq/scripts/download_metaseq_example_data.py
download
def download(url, dest): """ Platform-agnostic downloader. """ u = urllib.FancyURLopener() logger.info("Downloading %s..." % url) u.retrieve(url, dest) logger.info('Done, see %s' % dest) return dest
python
def download(url, dest): """ Platform-agnostic downloader. """ u = urllib.FancyURLopener() logger.info("Downloading %s..." % url) u.retrieve(url, dest) logger.info('Done, see %s' % dest) return dest
[ "def", "download", "(", "url", ",", "dest", ")", ":", "u", "=", "urllib", ".", "FancyURLopener", "(", ")", "logger", ".", "info", "(", "\"Downloading %s...\"", "%", "url", ")", "u", ".", "retrieve", "(", "url", ",", "dest", ")", "logger", ".", "info"...
Platform-agnostic downloader.
[ "Platform", "-", "agnostic", "downloader", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/scripts/download_metaseq_example_data.py#L35-L43
train
62,901
daler/metaseq
metaseq/scripts/download_metaseq_example_data.py
logged_command
def logged_command(cmds): "helper function to log a command and then run it" logger.info(' '.join(cmds)) os.system(' '.join(cmds))
python
def logged_command(cmds): "helper function to log a command and then run it" logger.info(' '.join(cmds)) os.system(' '.join(cmds))
[ "def", "logged_command", "(", "cmds", ")", ":", "logger", ".", "info", "(", "' '", ".", "join", "(", "cmds", ")", ")", "os", ".", "system", "(", "' '", ".", "join", "(", "cmds", ")", ")" ]
helper function to log a command and then run it
[ "helper", "function", "to", "log", "a", "command", "and", "then", "run", "it" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/scripts/download_metaseq_example_data.py#L189-L192
train
62,902
daler/metaseq
metaseq/scripts/download_metaseq_example_data.py
get_cufflinks
def get_cufflinks(): "Download cufflinks GTF files" for size, md5, url in cufflinks: cuff_gtf = os.path.join(args.data_dir, os.path.basename(url)) if not _up_to_date(md5, cuff_gtf): download(url, cuff_gtf)
python
def get_cufflinks(): "Download cufflinks GTF files" for size, md5, url in cufflinks: cuff_gtf = os.path.join(args.data_dir, os.path.basename(url)) if not _up_to_date(md5, cuff_gtf): download(url, cuff_gtf)
[ "def", "get_cufflinks", "(", ")", ":", "for", "size", ",", "md5", ",", "url", "in", "cufflinks", ":", "cuff_gtf", "=", "os", ".", "path", ".", "join", "(", "args", ".", "data_dir", ",", "os", ".", "path", ".", "basename", "(", "url", ")", ")", "i...
Download cufflinks GTF files
[ "Download", "cufflinks", "GTF", "files" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/scripts/download_metaseq_example_data.py#L195-L200
train
62,903
daler/metaseq
metaseq/scripts/download_metaseq_example_data.py
get_bams
def get_bams(): """ Download BAM files if needed, extract only chr17 reads, and regenerate .bai """ for size, md5, url in bams: bam = os.path.join( args.data_dir, os.path.basename(url).replace('.bam', '_%s.bam' % CHROM)) if not _up_to_date(md5, bam): l...
python
def get_bams(): """ Download BAM files if needed, extract only chr17 reads, and regenerate .bai """ for size, md5, url in bams: bam = os.path.join( args.data_dir, os.path.basename(url).replace('.bam', '_%s.bam' % CHROM)) if not _up_to_date(md5, bam): l...
[ "def", "get_bams", "(", ")", ":", "for", "size", ",", "md5", ",", "url", "in", "bams", ":", "bam", "=", "os", ".", "path", ".", "join", "(", "args", ".", "data_dir", ",", "os", ".", "path", ".", "basename", "(", "url", ")", ".", "replace", "(",...
Download BAM files if needed, extract only chr17 reads, and regenerate .bai
[ "Download", "BAM", "files", "if", "needed", "extract", "only", "chr17", "reads", "and", "regenerate", ".", "bai" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/scripts/download_metaseq_example_data.py#L203-L233
train
62,904
daler/metaseq
metaseq/scripts/download_metaseq_example_data.py
get_gtf
def get_gtf(): """ Download GTF file from Ensembl, only keeping the chr17 entries. """ size, md5, url = GTF full_gtf = os.path.join(args.data_dir, os.path.basename(url)) subset_gtf = os.path.join( args.data_dir, os.path.basename(url).replace('.gtf.gz', '_%s.gtf' % CHROM)) if...
python
def get_gtf(): """ Download GTF file from Ensembl, only keeping the chr17 entries. """ size, md5, url = GTF full_gtf = os.path.join(args.data_dir, os.path.basename(url)) subset_gtf = os.path.join( args.data_dir, os.path.basename(url).replace('.gtf.gz', '_%s.gtf' % CHROM)) if...
[ "def", "get_gtf", "(", ")", ":", "size", ",", "md5", ",", "url", "=", "GTF", "full_gtf", "=", "os", ".", "path", ".", "join", "(", "args", ".", "data_dir", ",", "os", ".", "path", ".", "basename", "(", "url", ")", ")", "subset_gtf", "=", "os", ...
Download GTF file from Ensembl, only keeping the chr17 entries.
[ "Download", "GTF", "file", "from", "Ensembl", "only", "keeping", "the", "chr17", "entries", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/scripts/download_metaseq_example_data.py#L269-L288
train
62,905
daler/metaseq
metaseq/scripts/download_metaseq_example_data.py
make_db
def make_db(): """ Create gffutils database """ size, md5, fn = DB if not _up_to_date(md5, fn): gffutils.create_db(fn.replace('.db', ''), fn, verbose=True, force=True)
python
def make_db(): """ Create gffutils database """ size, md5, fn = DB if not _up_to_date(md5, fn): gffutils.create_db(fn.replace('.db', ''), fn, verbose=True, force=True)
[ "def", "make_db", "(", ")", ":", "size", ",", "md5", ",", "fn", "=", "DB", "if", "not", "_up_to_date", "(", "md5", ",", "fn", ")", ":", "gffutils", ".", "create_db", "(", "fn", ".", "replace", "(", "'.db'", ",", "''", ")", ",", "fn", ",", "verb...
Create gffutils database
[ "Create", "gffutils", "database" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/scripts/download_metaseq_example_data.py#L291-L297
train
62,906
daler/metaseq
metaseq/scripts/download_metaseq_example_data.py
cufflinks_conversion
def cufflinks_conversion(): """ convert Cufflinks output GTF files into tables of score and FPKM. """ for size, md5, fn in cufflinks_tables: fn = os.path.join(args.data_dir, fn) table = fn.replace('.gtf.gz', '.table') if not _up_to_date(md5, table): logger.info("Conve...
python
def cufflinks_conversion(): """ convert Cufflinks output GTF files into tables of score and FPKM. """ for size, md5, fn in cufflinks_tables: fn = os.path.join(args.data_dir, fn) table = fn.replace('.gtf.gz', '.table') if not _up_to_date(md5, table): logger.info("Conve...
[ "def", "cufflinks_conversion", "(", ")", ":", "for", "size", ",", "md5", ",", "fn", "in", "cufflinks_tables", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "args", ".", "data_dir", ",", "fn", ")", "table", "=", "fn", ".", "replace", "(", "'....
convert Cufflinks output GTF files into tables of score and FPKM.
[ "convert", "Cufflinks", "output", "GTF", "files", "into", "tables", "of", "score", "and", "FPKM", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/scripts/download_metaseq_example_data.py#L300-L319
train
62,907
daler/metaseq
metaseq/minibrowser.py
BaseMiniBrowser.plot
def plot(self, feature): """ Spawns a new figure showing data for `feature`. :param feature: A `pybedtools.Interval` object Using the pybedtools.Interval `feature`, creates figure specified in :meth:`BaseMiniBrowser.make_fig` and plots data on panels according to `self....
python
def plot(self, feature): """ Spawns a new figure showing data for `feature`. :param feature: A `pybedtools.Interval` object Using the pybedtools.Interval `feature`, creates figure specified in :meth:`BaseMiniBrowser.make_fig` and plots data on panels according to `self....
[ "def", "plot", "(", "self", ",", "feature", ")", ":", "if", "isinstance", "(", "feature", ",", "gffutils", ".", "Feature", ")", ":", "feature", "=", "asinterval", "(", "feature", ")", "self", ".", "make_fig", "(", ")", "axes", "=", "[", "]", "for", ...
Spawns a new figure showing data for `feature`. :param feature: A `pybedtools.Interval` object Using the pybedtools.Interval `feature`, creates figure specified in :meth:`BaseMiniBrowser.make_fig` and plots data on panels according to `self.panels()`.
[ "Spawns", "a", "new", "figure", "showing", "data", "for", "feature", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/minibrowser.py#L82-L99
train
62,908
daler/metaseq
metaseq/minibrowser.py
BaseMiniBrowser.example_panel
def example_panel(self, ax, feature): """ A example panel that just prints the text of the feature. """ txt = '%s:%s-%s' % (feature.chrom, feature.start, feature.stop) ax.text(0.5, 0.5, txt, transform=ax.transAxes) return feature
python
def example_panel(self, ax, feature): """ A example panel that just prints the text of the feature. """ txt = '%s:%s-%s' % (feature.chrom, feature.start, feature.stop) ax.text(0.5, 0.5, txt, transform=ax.transAxes) return feature
[ "def", "example_panel", "(", "self", ",", "ax", ",", "feature", ")", ":", "txt", "=", "'%s:%s-%s'", "%", "(", "feature", ".", "chrom", ",", "feature", ".", "start", ",", "feature", ".", "stop", ")", "ax", ".", "text", "(", "0.5", ",", "0.5", ",", ...
A example panel that just prints the text of the feature.
[ "A", "example", "panel", "that", "just", "prints", "the", "text", "of", "the", "feature", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/minibrowser.py#L123-L129
train
62,909
daler/metaseq
metaseq/minibrowser.py
SignalMiniBrowser.signal_panel
def signal_panel(self, ax, feature): """ Plots each genomic signal as a line using the corresponding plotting_kwargs """ for gs, kwargs in zip(self.genomic_signal_objs, self.plotting_kwargs): x, y = gs.local_coverage(feature, **self.local_coverage_kwargs) ...
python
def signal_panel(self, ax, feature): """ Plots each genomic signal as a line using the corresponding plotting_kwargs """ for gs, kwargs in zip(self.genomic_signal_objs, self.plotting_kwargs): x, y = gs.local_coverage(feature, **self.local_coverage_kwargs) ...
[ "def", "signal_panel", "(", "self", ",", "ax", ",", "feature", ")", ":", "for", "gs", ",", "kwargs", "in", "zip", "(", "self", ".", "genomic_signal_objs", ",", "self", ".", "plotting_kwargs", ")", ":", "x", ",", "y", "=", "gs", ".", "local_coverage", ...
Plots each genomic signal as a line using the corresponding plotting_kwargs
[ "Plots", "each", "genomic", "signal", "as", "a", "line", "using", "the", "corresponding", "plotting_kwargs" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/minibrowser.py#L450-L459
train
62,910
daler/metaseq
metaseq/minibrowser.py
GeneModelMiniBrowser.panels
def panels(self): """ Add 2 panels to the figure, top for signal and bottom for gene models """ ax1 = self.fig.add_subplot(211) ax2 = self.fig.add_subplot(212, sharex=ax1) return (ax2, self.gene_panel), (ax1, self.signal_panel)
python
def panels(self): """ Add 2 panels to the figure, top for signal and bottom for gene models """ ax1 = self.fig.add_subplot(211) ax2 = self.fig.add_subplot(212, sharex=ax1) return (ax2, self.gene_panel), (ax1, self.signal_panel)
[ "def", "panels", "(", "self", ")", ":", "ax1", "=", "self", ".", "fig", ".", "add_subplot", "(", "211", ")", "ax2", "=", "self", ".", "fig", ".", "add_subplot", "(", "212", ",", "sharex", "=", "ax1", ")", "return", "(", "ax2", ",", "self", ".", ...
Add 2 panels to the figure, top for signal and bottom for gene models
[ "Add", "2", "panels", "to", "the", "figure", "top", "for", "signal", "and", "bottom", "for", "gene", "models" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/minibrowser.py#L475-L481
train
62,911
hfaran/progressive
progressive/examples.py
simple
def simple(): """Simple example using just the Bar class This example is intended to show usage of the Bar class at the lowest level. """ MAX_VALUE = 100 # Create our test progress bar bar = Bar(max_value=MAX_VALUE, fallback=True) bar.cursor.clear_lines(2) # Before beginning to d...
python
def simple(): """Simple example using just the Bar class This example is intended to show usage of the Bar class at the lowest level. """ MAX_VALUE = 100 # Create our test progress bar bar = Bar(max_value=MAX_VALUE, fallback=True) bar.cursor.clear_lines(2) # Before beginning to d...
[ "def", "simple", "(", ")", ":", "MAX_VALUE", "=", "100", "# Create our test progress bar", "bar", "=", "Bar", "(", "max_value", "=", "MAX_VALUE", ",", "fallback", "=", "True", ")", "bar", ".", "cursor", ".", "clear_lines", "(", "2", ")", "# Before beginning ...
Simple example using just the Bar class This example is intended to show usage of the Bar class at the lowest level.
[ "Simple", "example", "using", "just", "the", "Bar", "class" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/examples.py#L16-L37
train
62,912
hfaran/progressive
progressive/examples.py
tree
def tree(): """Example showing tree progress view""" ############# # Test data # ############# # For this example, we're obviously going to be feeding fictitious data # to ProgressTree, so here it is leaf_values = [Value(0) for i in range(6)] bd_defaults = dict(type=Bar, kwargs=dict(...
python
def tree(): """Example showing tree progress view""" ############# # Test data # ############# # For this example, we're obviously going to be feeding fictitious data # to ProgressTree, so here it is leaf_values = [Value(0) for i in range(6)] bd_defaults = dict(type=Bar, kwargs=dict(...
[ "def", "tree", "(", ")", ":", "#############", "# Test data #", "#############", "# For this example, we're obviously going to be feeding fictitious data", "# to ProgressTree, so here it is", "leaf_values", "=", "[", "Value", "(", "0", ")", "for", "i", "in", "range", "(",...
Example showing tree progress view
[ "Example", "showing", "tree", "progress", "view" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/examples.py#L40-L111
train
62,913
daler/metaseq
metaseq/plotutils.py
ci_plot
def ci_plot(x, arr, conf=0.95, ax=None, line_kwargs=None, fill_kwargs=None): """ Plots the mean and 95% ci for the given array on the given axes Parameters ---------- x : 1-D array-like x values for the plot arr : 2-D array-like The array to calculate mean and std for conf...
python
def ci_plot(x, arr, conf=0.95, ax=None, line_kwargs=None, fill_kwargs=None): """ Plots the mean and 95% ci for the given array on the given axes Parameters ---------- x : 1-D array-like x values for the plot arr : 2-D array-like The array to calculate mean and std for conf...
[ "def", "ci_plot", "(", "x", ",", "arr", ",", "conf", "=", "0.95", ",", "ax", "=", "None", ",", "line_kwargs", "=", "None", ",", "fill_kwargs", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "fig", "=", "plt", ".", "figure", "(", ")", "ax...
Plots the mean and 95% ci for the given array on the given axes Parameters ---------- x : 1-D array-like x values for the plot arr : 2-D array-like The array to calculate mean and std for conf : float [.5 - 1] Confidence interval to use ax : matplotlib.Axes Th...
[ "Plots", "the", "mean", "and", "95%", "ci", "for", "the", "given", "array", "on", "the", "given", "axes" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/plotutils.py#L16-L50
train
62,914
daler/metaseq
metaseq/plotutils.py
add_labels_to_subsets
def add_labels_to_subsets(ax, subset_by, subset_order, text_kwargs=None, add_hlines=True, hline_kwargs=None): """ Helper function for adding labels to subsets within a heatmap. Assumes that imshow() was called with `subsets` and `subset_order`. Parameters ---------- a...
python
def add_labels_to_subsets(ax, subset_by, subset_order, text_kwargs=None, add_hlines=True, hline_kwargs=None): """ Helper function for adding labels to subsets within a heatmap. Assumes that imshow() was called with `subsets` and `subset_order`. Parameters ---------- a...
[ "def", "add_labels_to_subsets", "(", "ax", ",", "subset_by", ",", "subset_order", ",", "text_kwargs", "=", "None", ",", "add_hlines", "=", "True", ",", "hline_kwargs", "=", "None", ")", ":", "_text_kwargs", "=", "dict", "(", "transform", "=", "ax", ".", "g...
Helper function for adding labels to subsets within a heatmap. Assumes that imshow() was called with `subsets` and `subset_order`. Parameters ---------- ax : matplotlib.Axes The axes to label. Generally you can use `fig.array_axes` attribute of the Figure object returned by `metaseq.p...
[ "Helper", "function", "for", "adding", "labels", "to", "subsets", "within", "a", "heatmap", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/plotutils.py#L233-L269
train
62,915
daler/metaseq
metaseq/plotutils.py
calculate_limits
def calculate_limits(array_dict, method='global', percentiles=None, limit=()): """ Calculate limits for a group of arrays in a flexible manner. Returns a dictionary of calculated (vmin, vmax), with the same keys as `array_dict`. Useful for plotting heatmaps of multiple datasets, and the vmin/vmax ...
python
def calculate_limits(array_dict, method='global', percentiles=None, limit=()): """ Calculate limits for a group of arrays in a flexible manner. Returns a dictionary of calculated (vmin, vmax), with the same keys as `array_dict`. Useful for plotting heatmaps of multiple datasets, and the vmin/vmax ...
[ "def", "calculate_limits", "(", "array_dict", ",", "method", "=", "'global'", ",", "percentiles", "=", "None", ",", "limit", "=", "(", ")", ")", ":", "if", "percentiles", "is", "not", "None", ":", "for", "percentile", "in", "percentiles", ":", "if", "not...
Calculate limits for a group of arrays in a flexible manner. Returns a dictionary of calculated (vmin, vmax), with the same keys as `array_dict`. Useful for plotting heatmaps of multiple datasets, and the vmin/vmax values of the colormaps need to be matched across all (or a subset) of heatmaps. P...
[ "Calculate", "limits", "for", "a", "group", "of", "arrays", "in", "a", "flexible", "manner", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/plotutils.py#L272-L338
train
62,916
daler/metaseq
metaseq/plotutils.py
ci
def ci(arr, conf=0.95): """ Column-wise confidence interval. Parameters ---------- arr : array-like conf : float Confidence interval Returns ------- m : array column-wise mean lower : array lower column-wise confidence bound upper : array up...
python
def ci(arr, conf=0.95): """ Column-wise confidence interval. Parameters ---------- arr : array-like conf : float Confidence interval Returns ------- m : array column-wise mean lower : array lower column-wise confidence bound upper : array up...
[ "def", "ci", "(", "arr", ",", "conf", "=", "0.95", ")", ":", "m", "=", "arr", ".", "mean", "(", "axis", "=", "0", ")", "n", "=", "len", "(", "arr", ")", "se", "=", "arr", ".", "std", "(", "axis", "=", "0", ")", "/", "np", ".", "sqrt", "...
Column-wise confidence interval. Parameters ---------- arr : array-like conf : float Confidence interval Returns ------- m : array column-wise mean lower : array lower column-wise confidence bound upper : array upper column-wise confidence bound
[ "Column", "-", "wise", "confidence", "interval", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/plotutils.py#L341-L365
train
62,917
daler/metaseq
metaseq/plotutils.py
nice_log
def nice_log(x): """ Uses a log scale but with negative numbers. :param x: NumPy array """ neg = x < 0 xi = np.log2(np.abs(x) + 1) xi[neg] = -xi[neg] return xi
python
def nice_log(x): """ Uses a log scale but with negative numbers. :param x: NumPy array """ neg = x < 0 xi = np.log2(np.abs(x) + 1) xi[neg] = -xi[neg] return xi
[ "def", "nice_log", "(", "x", ")", ":", "neg", "=", "x", "<", "0", "xi", "=", "np", ".", "log2", "(", "np", ".", "abs", "(", "x", ")", "+", "1", ")", "xi", "[", "neg", "]", "=", "-", "xi", "[", "neg", "]", "return", "xi" ]
Uses a log scale but with negative numbers. :param x: NumPy array
[ "Uses", "a", "log", "scale", "but", "with", "negative", "numbers", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/plotutils.py#L368-L377
train
62,918
daler/metaseq
metaseq/plotutils.py
tip_fdr
def tip_fdr(a, alpha=0.05): """ Returns adjusted TIP p-values for a particular `alpha`. (see :func:`tip_zscores` for more info) :param a: NumPy array, where each row is the signal for a feature :param alpha: False discovery rate """ zscores = tip_zscores(a) pvals = stats.norm.pdf(zsco...
python
def tip_fdr(a, alpha=0.05): """ Returns adjusted TIP p-values for a particular `alpha`. (see :func:`tip_zscores` for more info) :param a: NumPy array, where each row is the signal for a feature :param alpha: False discovery rate """ zscores = tip_zscores(a) pvals = stats.norm.pdf(zsco...
[ "def", "tip_fdr", "(", "a", ",", "alpha", "=", "0.05", ")", ":", "zscores", "=", "tip_zscores", "(", "a", ")", "pvals", "=", "stats", ".", "norm", ".", "pdf", "(", "zscores", ")", "rejected", ",", "fdrs", "=", "fdrcorrection", "(", "pvals", ")", "r...
Returns adjusted TIP p-values for a particular `alpha`. (see :func:`tip_zscores` for more info) :param a: NumPy array, where each row is the signal for a feature :param alpha: False discovery rate
[ "Returns", "adjusted", "TIP", "p", "-", "values", "for", "a", "particular", "alpha", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/plotutils.py#L469-L482
train
62,919
daler/metaseq
metaseq/plotutils.py
prepare_logged
def prepare_logged(x, y): """ Transform `x` and `y` to a log scale while dealing with zeros. This function scales `x` and `y` such that the points that are zero in one array are set to the min of the other array. When plotting expression data, frequently one sample will have reads in a particu...
python
def prepare_logged(x, y): """ Transform `x` and `y` to a log scale while dealing with zeros. This function scales `x` and `y` such that the points that are zero in one array are set to the min of the other array. When plotting expression data, frequently one sample will have reads in a particu...
[ "def", "prepare_logged", "(", "x", ",", "y", ")", ":", "xi", "=", "np", ".", "log2", "(", "x", ")", "yi", "=", "np", ".", "log2", "(", "y", ")", "xv", "=", "np", ".", "isfinite", "(", "xi", ")", "yv", "=", "np", ".", "isfinite", "(", "yi", ...
Transform `x` and `y` to a log scale while dealing with zeros. This function scales `x` and `y` such that the points that are zero in one array are set to the min of the other array. When plotting expression data, frequently one sample will have reads in a particular feature but the other sample will ...
[ "Transform", "x", "and", "y", "to", "a", "log", "scale", "while", "dealing", "with", "zeros", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/plotutils.py#L485-L512
train
62,920
daler/metaseq
metaseq/plotutils.py
_updatecopy
def _updatecopy(orig, update_with, keys=None, override=False): """ Update a copy of dest with source. If `keys` is a list, then only update with those keys. """ d = orig.copy() if keys is None: keys = update_with.keys() for k in keys: if k in update_with: if k in...
python
def _updatecopy(orig, update_with, keys=None, override=False): """ Update a copy of dest with source. If `keys` is a list, then only update with those keys. """ d = orig.copy() if keys is None: keys = update_with.keys() for k in keys: if k in update_with: if k in...
[ "def", "_updatecopy", "(", "orig", ",", "update_with", ",", "keys", "=", "None", ",", "override", "=", "False", ")", ":", "d", "=", "orig", ".", "copy", "(", ")", "if", "keys", "is", "None", ":", "keys", "=", "update_with", ".", "keys", "(", ")", ...
Update a copy of dest with source. If `keys` is a list, then only update with those keys.
[ "Update", "a", "copy", "of", "dest", "with", "source", ".", "If", "keys", "is", "a", "list", "then", "only", "update", "with", "those", "keys", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/plotutils.py#L915-L928
train
62,921
daler/metaseq
metaseq/plotutils.py
MarginalHistScatter.append
def append(self, x, y, scatter_kwargs, hist_kwargs=None, xhist_kwargs=None, yhist_kwargs=None, num_ticks=3, labels=None, hist_share=False, marginal_histograms=True): """ Adds a new scatter to self.scatter_ax as well as marginal histograms for the same data, borrowin...
python
def append(self, x, y, scatter_kwargs, hist_kwargs=None, xhist_kwargs=None, yhist_kwargs=None, num_ticks=3, labels=None, hist_share=False, marginal_histograms=True): """ Adds a new scatter to self.scatter_ax as well as marginal histograms for the same data, borrowin...
[ "def", "append", "(", "self", ",", "x", ",", "y", ",", "scatter_kwargs", ",", "hist_kwargs", "=", "None", ",", "xhist_kwargs", "=", "None", ",", "yhist_kwargs", "=", "None", ",", "num_ticks", "=", "3", ",", "labels", "=", "None", ",", "hist_share", "="...
Adds a new scatter to self.scatter_ax as well as marginal histograms for the same data, borrowing addtional room from the axes. Parameters ---------- x, y : array-like Data to be plotted scatter_kwargs : dict Keyword arguments that are passed directly t...
[ "Adds", "a", "new", "scatter", "to", "self", ".", "scatter_ax", "as", "well", "as", "marginal", "histograms", "for", "the", "same", "data", "borrowing", "addtional", "room", "from", "the", "axes", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/plotutils.py#L980-L1089
train
62,922
daler/metaseq
metaseq/plotutils.py
MarginalHistScatter.add_legends
def add_legends(self, xhists=True, yhists=False, scatter=True, **kwargs): """ Add legends to axes. """ axs = [] if xhists: axs.extend(self.hxs) if yhists: axs.extend(self.hys) if scatter: axs.extend(self.ax) for ax in a...
python
def add_legends(self, xhists=True, yhists=False, scatter=True, **kwargs): """ Add legends to axes. """ axs = [] if xhists: axs.extend(self.hxs) if yhists: axs.extend(self.hys) if scatter: axs.extend(self.ax) for ax in a...
[ "def", "add_legends", "(", "self", ",", "xhists", "=", "True", ",", "yhists", "=", "False", ",", "scatter", "=", "True", ",", "*", "*", "kwargs", ")", ":", "axs", "=", "[", "]", "if", "xhists", ":", "axs", ".", "extend", "(", "self", ".", "hxs", ...
Add legends to axes.
[ "Add", "legends", "to", "axes", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/plotutils.py#L1091-L1104
train
62,923
daler/metaseq
metaseq/_genomic_signal.py
genomic_signal
def genomic_signal(fn, kind): """ Factory function that makes the right class for the file format. Typically you'll only need this function to create a new genomic signal object. :param fn: Filename :param kind: String. Format of the file; see metaseq.genomic_signal._registry....
python
def genomic_signal(fn, kind): """ Factory function that makes the right class for the file format. Typically you'll only need this function to create a new genomic signal object. :param fn: Filename :param kind: String. Format of the file; see metaseq.genomic_signal._registry....
[ "def", "genomic_signal", "(", "fn", ",", "kind", ")", ":", "try", ":", "klass", "=", "_registry", "[", "kind", ".", "lower", "(", ")", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "'No support for %s format, choices are %s'", "%", "(", "kind",...
Factory function that makes the right class for the file format. Typically you'll only need this function to create a new genomic signal object. :param fn: Filename :param kind: String. Format of the file; see metaseq.genomic_signal._registry.keys()
[ "Factory", "function", "that", "makes", "the", "right", "class", "for", "the", "file", "format", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/_genomic_signal.py#L50-L70
train
62,924
daler/metaseq
metaseq/_genomic_signal.py
BamSignal.genome
def genome(self): """ "genome" dictionary ready for pybedtools, based on the BAM header. """ # This gets the underlying pysam Samfile object f = self.adapter.fileobj d = {} for ref, length in zip(f.references, f.lengths): d[ref] = (0, length) r...
python
def genome(self): """ "genome" dictionary ready for pybedtools, based on the BAM header. """ # This gets the underlying pysam Samfile object f = self.adapter.fileobj d = {} for ref, length in zip(f.references, f.lengths): d[ref] = (0, length) r...
[ "def", "genome", "(", "self", ")", ":", "# This gets the underlying pysam Samfile object", "f", "=", "self", ".", "adapter", ".", "fileobj", "d", "=", "{", "}", "for", "ref", ",", "length", "in", "zip", "(", "f", ".", "references", ",", "f", ".", "length...
"genome" dictionary ready for pybedtools, based on the BAM header.
[ "genome", "dictionary", "ready", "for", "pybedtools", "based", "on", "the", "BAM", "header", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/_genomic_signal.py#L204-L213
train
62,925
daler/metaseq
metaseq/_genomic_signal.py
BamSignal.mapped_read_count
def mapped_read_count(self, force=False): """ Counts total reads in a BAM file. If a file self.bam + '.scale' exists, then just read the first line of that file that doesn't start with a "#". If such a file doesn't exist, then it will be created with the number of reads as the ...
python
def mapped_read_count(self, force=False): """ Counts total reads in a BAM file. If a file self.bam + '.scale' exists, then just read the first line of that file that doesn't start with a "#". If such a file doesn't exist, then it will be created with the number of reads as the ...
[ "def", "mapped_read_count", "(", "self", ",", "force", "=", "False", ")", ":", "# Already run?", "if", "self", ".", "_readcount", "and", "not", "force", ":", "return", "self", ".", "_readcount", "if", "os", ".", "path", ".", "exists", "(", "self", ".", ...
Counts total reads in a BAM file. If a file self.bam + '.scale' exists, then just read the first line of that file that doesn't start with a "#". If such a file doesn't exist, then it will be created with the number of reads as the first and only line in the file. The result i...
[ "Counts", "total", "reads", "in", "a", "BAM", "file", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/_genomic_signal.py#L215-L265
train
62,926
daler/metaseq
metaseq/tableprinter.py
print_2x2_table
def print_2x2_table(table, row_labels, col_labels, fmt="%d"): """ Prints a table used for Fisher's exact test. Adds row, column, and grand totals. :param table: The four cells of a 2x2 table: [r1c1, r1c2, r2c1, r2c2] :param row_labels: A length-2 list of row names :param col_labels: A length-2 ...
python
def print_2x2_table(table, row_labels, col_labels, fmt="%d"): """ Prints a table used for Fisher's exact test. Adds row, column, and grand totals. :param table: The four cells of a 2x2 table: [r1c1, r1c2, r2c1, r2c2] :param row_labels: A length-2 list of row names :param col_labels: A length-2 ...
[ "def", "print_2x2_table", "(", "table", ",", "row_labels", ",", "col_labels", ",", "fmt", "=", "\"%d\"", ")", ":", "grand", "=", "sum", "(", "table", ")", "# Separate table into components and get row/col sums", "t11", ",", "t12", ",", "t21", ",", "t22", "=", ...
Prints a table used for Fisher's exact test. Adds row, column, and grand totals. :param table: The four cells of a 2x2 table: [r1c1, r1c2, r2c1, r2c2] :param row_labels: A length-2 list of row names :param col_labels: A length-2 list of column names
[ "Prints", "a", "table", "used", "for", "Fisher", "s", "exact", "test", ".", "Adds", "row", "column", "and", "grand", "totals", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/tableprinter.py#L4-L60
train
62,927
daler/metaseq
metaseq/tableprinter.py
print_row_perc_table
def print_row_perc_table(table, row_labels, col_labels): """ given a table, print the percentages rather than the totals """ r1c1, r1c2, r2c1, r2c2 = map(float, table) row1 = r1c1 + r1c2 row2 = r2c1 + r2c2 blocks = [ (r1c1, row1), (r1c2, row1), (r2c1, row2), ...
python
def print_row_perc_table(table, row_labels, col_labels): """ given a table, print the percentages rather than the totals """ r1c1, r1c2, r2c1, r2c2 = map(float, table) row1 = r1c1 + r1c2 row2 = r2c1 + r2c2 blocks = [ (r1c1, row1), (r1c2, row1), (r2c1, row2), ...
[ "def", "print_row_perc_table", "(", "table", ",", "row_labels", ",", "col_labels", ")", ":", "r1c1", ",", "r1c2", ",", "r2c1", ",", "r2c2", "=", "map", "(", "float", ",", "table", ")", "row1", "=", "r1c1", "+", "r1c2", "row2", "=", "r2c1", "+", "r2c2...
given a table, print the percentages rather than the totals
[ "given", "a", "table", "print", "the", "percentages", "rather", "than", "the", "totals" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/tableprinter.py#L63-L89
train
62,928
daler/metaseq
metaseq/tableprinter.py
print_col_perc_table
def print_col_perc_table(table, row_labels, col_labels): """ given a table, print the cols as percentages """ r1c1, r1c2, r2c1, r2c2 = map(float, table) col1 = r1c1 + r2c1 col2 = r1c2 + r2c2 blocks = [ (r1c1, col1), (r1c2, col2), (r2c1, col1), (r2c2, col2)] ...
python
def print_col_perc_table(table, row_labels, col_labels): """ given a table, print the cols as percentages """ r1c1, r1c2, r2c1, r2c2 = map(float, table) col1 = r1c1 + r2c1 col2 = r1c2 + r2c2 blocks = [ (r1c1, col1), (r1c2, col2), (r2c1, col1), (r2c2, col2)] ...
[ "def", "print_col_perc_table", "(", "table", ",", "row_labels", ",", "col_labels", ")", ":", "r1c1", ",", "r1c2", ",", "r2c1", ",", "r2c2", "=", "map", "(", "float", ",", "table", ")", "col1", "=", "r1c1", "+", "r2c1", "col2", "=", "r1c2", "+", "r2c2...
given a table, print the cols as percentages
[ "given", "a", "table", "print", "the", "cols", "as", "percentages" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/tableprinter.py#L92-L120
train
62,929
hfaran/progressive
progressive/tree.py
ProgressTree.draw
def draw(self, tree, bar_desc=None, save_cursor=True, flush=True): """Draw ``tree`` to the terminal :type tree: dict :param tree: ``tree`` should be a tree representing a hierarchy; each key should be a string describing that hierarchy level and value should also be ``d...
python
def draw(self, tree, bar_desc=None, save_cursor=True, flush=True): """Draw ``tree`` to the terminal :type tree: dict :param tree: ``tree`` should be a tree representing a hierarchy; each key should be a string describing that hierarchy level and value should also be ``d...
[ "def", "draw", "(", "self", ",", "tree", ",", "bar_desc", "=", "None", ",", "save_cursor", "=", "True", ",", "flush", "=", "True", ")", ":", "if", "save_cursor", ":", "self", ".", "cursor", ".", "save", "(", ")", "tree", "=", "deepcopy", "(", "tree...
Draw ``tree`` to the terminal :type tree: dict :param tree: ``tree`` should be a tree representing a hierarchy; each key should be a string describing that hierarchy level and value should also be ``dict`` except for leaves which should be ``BarDescriptors``. See ``...
[ "Draw", "tree", "to", "the", "terminal" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/tree.py#L73-L109
train
62,930
hfaran/progressive
progressive/tree.py
ProgressTree.make_room
def make_room(self, tree): """Clear lines in terminal below current cursor position as required This is important to do before drawing to ensure sufficient room at the bottom of your terminal. :type tree: dict :param tree: tree as described in ``BarDescriptor`` """ ...
python
def make_room(self, tree): """Clear lines in terminal below current cursor position as required This is important to do before drawing to ensure sufficient room at the bottom of your terminal. :type tree: dict :param tree: tree as described in ``BarDescriptor`` """ ...
[ "def", "make_room", "(", "self", ",", "tree", ")", ":", "lines_req", "=", "self", ".", "lines_required", "(", "tree", ")", "self", ".", "cursor", ".", "clear_lines", "(", "lines_req", ")" ]
Clear lines in terminal below current cursor position as required This is important to do before drawing to ensure sufficient room at the bottom of your terminal. :type tree: dict :param tree: tree as described in ``BarDescriptor``
[ "Clear", "lines", "in", "terminal", "below", "current", "cursor", "position", "as", "required" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/tree.py#L111-L121
train
62,931
hfaran/progressive
progressive/tree.py
ProgressTree.lines_required
def lines_required(self, tree, count=0): """Calculate number of lines required to draw ``tree``""" if all([ isinstance(tree, dict), type(tree) != BarDescriptor ]): return sum(self.lines_required(v, count=count) for v in tree.values()) + ...
python
def lines_required(self, tree, count=0): """Calculate number of lines required to draw ``tree``""" if all([ isinstance(tree, dict), type(tree) != BarDescriptor ]): return sum(self.lines_required(v, count=count) for v in tree.values()) + ...
[ "def", "lines_required", "(", "self", ",", "tree", ",", "count", "=", "0", ")", ":", "if", "all", "(", "[", "isinstance", "(", "tree", ",", "dict", ")", ",", "type", "(", "tree", ")", "!=", "BarDescriptor", "]", ")", ":", "return", "sum", "(", "s...
Calculate number of lines required to draw ``tree``
[ "Calculate", "number", "of", "lines", "required", "to", "draw", "tree" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/tree.py#L123-L135
train
62,932
hfaran/progressive
progressive/tree.py
ProgressTree._calculate_values
def _calculate_values(self, tree, bar_d): """Calculate values for drawing bars of non-leafs in ``tree`` Recurses through ``tree``, replaces ``dict``s with ``(BarDescriptor, dict)`` so ``ProgressTree._draw`` can use the ``BarDescriptor``s to draw the tree """ if a...
python
def _calculate_values(self, tree, bar_d): """Calculate values for drawing bars of non-leafs in ``tree`` Recurses through ``tree``, replaces ``dict``s with ``(BarDescriptor, dict)`` so ``ProgressTree._draw`` can use the ``BarDescriptor``s to draw the tree """ if a...
[ "def", "_calculate_values", "(", "self", ",", "tree", ",", "bar_d", ")", ":", "if", "all", "(", "[", "isinstance", "(", "tree", ",", "dict", ")", ",", "type", "(", "tree", ")", "!=", "BarDescriptor", "]", ")", ":", "# Calculate value and max_value", "max...
Calculate values for drawing bars of non-leafs in ``tree`` Recurses through ``tree``, replaces ``dict``s with ``(BarDescriptor, dict)`` so ``ProgressTree._draw`` can use the ``BarDescriptor``s to draw the tree
[ "Calculate", "values", "for", "drawing", "bars", "of", "non", "-", "leafs", "in", "tree" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/tree.py#L141-L177
train
62,933
hfaran/progressive
progressive/tree.py
ProgressTree._draw
def _draw(self, tree, indent=0): """Recurse through ``tree`` and draw all nodes""" if all([ isinstance(tree, dict), type(tree) != BarDescriptor ]): for k, v in sorted(tree.items()): bar_desc, subdict = v[0], v[1] args = [self.c...
python
def _draw(self, tree, indent=0): """Recurse through ``tree`` and draw all nodes""" if all([ isinstance(tree, dict), type(tree) != BarDescriptor ]): for k, v in sorted(tree.items()): bar_desc, subdict = v[0], v[1] args = [self.c...
[ "def", "_draw", "(", "self", ",", "tree", ",", "indent", "=", "0", ")", ":", "if", "all", "(", "[", "isinstance", "(", "tree", ",", "dict", ")", ",", "type", "(", "tree", ")", "!=", "BarDescriptor", "]", ")", ":", "for", "k", ",", "v", "in", ...
Recurse through ``tree`` and draw all nodes
[ "Recurse", "through", "tree", "and", "draw", "all", "nodes" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/tree.py#L179-L195
train
62,934
daler/metaseq
metaseq/persistence.py
load_features_and_arrays
def load_features_and_arrays(prefix, mmap_mode='r'): """ Returns the features and NumPy arrays that were saved with save_features_and_arrays. Parameters ---------- prefix : str Path to where data are saved mmap_mode : {None, 'r+', 'r', 'w+', 'c'} Mode in which to memory-ma...
python
def load_features_and_arrays(prefix, mmap_mode='r'): """ Returns the features and NumPy arrays that were saved with save_features_and_arrays. Parameters ---------- prefix : str Path to where data are saved mmap_mode : {None, 'r+', 'r', 'w+', 'c'} Mode in which to memory-ma...
[ "def", "load_features_and_arrays", "(", "prefix", ",", "mmap_mode", "=", "'r'", ")", ":", "features", "=", "pybedtools", ".", "BedTool", "(", "prefix", "+", "'.features'", ")", "arrays", "=", "np", ".", "load", "(", "prefix", "+", "'.npz'", ",", "mmap_mode...
Returns the features and NumPy arrays that were saved with save_features_and_arrays. Parameters ---------- prefix : str Path to where data are saved mmap_mode : {None, 'r+', 'r', 'w+', 'c'} Mode in which to memory-map the file. See np.load for details.
[ "Returns", "the", "features", "and", "NumPy", "arrays", "that", "were", "saved", "with", "save_features_and_arrays", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/persistence.py#L10-L26
train
62,935
daler/metaseq
metaseq/persistence.py
save_features_and_arrays
def save_features_and_arrays(features, arrays, prefix, compressed=False, link_features=False, overwrite=False): """ Saves NumPy arrays of processed data, along with the features that correspond to each row, to files for later use. Two files will be saved, both starting with...
python
def save_features_and_arrays(features, arrays, prefix, compressed=False, link_features=False, overwrite=False): """ Saves NumPy arrays of processed data, along with the features that correspond to each row, to files for later use. Two files will be saved, both starting with...
[ "def", "save_features_and_arrays", "(", "features", ",", "arrays", ",", "prefix", ",", "compressed", "=", "False", ",", "link_features", "=", "False", ",", "overwrite", "=", "False", ")", ":", "if", "link_features", ":", "if", "isinstance", "(", "features", ...
Saves NumPy arrays of processed data, along with the features that correspond to each row, to files for later use. Two files will be saved, both starting with `prefix`: prefix.features : a file of features. If GFF features were provided, this will be in GFF format, if BED features were provid...
[ "Saves", "NumPy", "arrays", "of", "processed", "data", "along", "with", "the", "features", "that", "correspond", "to", "each", "row", "to", "files", "for", "later", "use", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/persistence.py#L29-L92
train
62,936
hthiery/python-fritzhome
pyfritzhome/cli.py
list_all
def list_all(fritz, args): """Command that prints all device information.""" devices = fritz.get_devices() for device in devices: print('#' * 30) print('name=%s' % device.name) print(' ain=%s' % device.ain) print(' id=%s' % device.identifier) print(' productname=%...
python
def list_all(fritz, args): """Command that prints all device information.""" devices = fritz.get_devices() for device in devices: print('#' * 30) print('name=%s' % device.name) print(' ain=%s' % device.ain) print(' id=%s' % device.identifier) print(' productname=%...
[ "def", "list_all", "(", "fritz", ",", "args", ")", ":", "devices", "=", "fritz", ".", "get_devices", "(", ")", "for", "device", "in", "devices", ":", "print", "(", "'#'", "*", "30", ")", "print", "(", "'name=%s'", "%", "device", ".", "name", ")", "...
Command that prints all device information.
[ "Command", "that", "prints", "all", "device", "information", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/cli.py#L18-L61
train
62,937
hthiery/python-fritzhome
pyfritzhome/cli.py
device_statistics
def device_statistics(fritz, args): """Command that prints the device statistics.""" stats = fritz.get_device_statistics(args.ain) print(stats)
python
def device_statistics(fritz, args): """Command that prints the device statistics.""" stats = fritz.get_device_statistics(args.ain) print(stats)
[ "def", "device_statistics", "(", "fritz", ",", "args", ")", ":", "stats", "=", "fritz", ".", "get_device_statistics", "(", "args", ".", "ain", ")", "print", "(", "stats", ")" ]
Command that prints the device statistics.
[ "Command", "that", "prints", "the", "device", "statistics", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/cli.py#L74-L77
train
62,938
daler/metaseq
metaseq/helpers.py
chunker
def chunker(f, n): """ Utility function to split iterable `f` into `n` chunks """ f = iter(f) x = [] while 1: if len(x) < n: try: x.append(f.next()) except StopIteration: if len(x) > 0: yield tuple(x) ...
python
def chunker(f, n): """ Utility function to split iterable `f` into `n` chunks """ f = iter(f) x = [] while 1: if len(x) < n: try: x.append(f.next()) except StopIteration: if len(x) > 0: yield tuple(x) ...
[ "def", "chunker", "(", "f", ",", "n", ")", ":", "f", "=", "iter", "(", "f", ")", "x", "=", "[", "]", "while", "1", ":", "if", "len", "(", "x", ")", "<", "n", ":", "try", ":", "x", ".", "append", "(", "f", ".", "next", "(", ")", ")", "...
Utility function to split iterable `f` into `n` chunks
[ "Utility", "function", "to", "split", "iterable", "f", "into", "n", "chunks" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/helpers.py#L18-L34
train
62,939
daler/metaseq
metaseq/helpers.py
split_feature
def split_feature(f, n): """ Split an interval into `n` roughly equal portions """ if not isinstance(n, int): raise ValueError('n must be an integer') orig_feature = copy(f) step = (f.stop - f.start) / n for i in range(f.start, f.stop, step): f = copy(orig_feature) st...
python
def split_feature(f, n): """ Split an interval into `n` roughly equal portions """ if not isinstance(n, int): raise ValueError('n must be an integer') orig_feature = copy(f) step = (f.stop - f.start) / n for i in range(f.start, f.stop, step): f = copy(orig_feature) st...
[ "def", "split_feature", "(", "f", ",", "n", ")", ":", "if", "not", "isinstance", "(", "n", ",", "int", ")", ":", "raise", "ValueError", "(", "'n must be an integer'", ")", "orig_feature", "=", "copy", "(", "f", ")", "step", "=", "(", "f", ".", "stop"...
Split an interval into `n` roughly equal portions
[ "Split", "an", "interval", "into", "n", "roughly", "equal", "portions" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/helpers.py#L67-L83
train
62,940
daler/metaseq
metaseq/helpers.py
tointerval
def tointerval(s): """ If string, then convert to an interval; otherwise just return the input """ if isinstance(s, basestring): m = coord_re.search(s) if m.group('strand'): return pybedtools.create_interval_from_list([ m.group('chrom'), m.grou...
python
def tointerval(s): """ If string, then convert to an interval; otherwise just return the input """ if isinstance(s, basestring): m = coord_re.search(s) if m.group('strand'): return pybedtools.create_interval_from_list([ m.group('chrom'), m.grou...
[ "def", "tointerval", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "basestring", ")", ":", "m", "=", "coord_re", ".", "search", "(", "s", ")", "if", "m", ".", "group", "(", "'strand'", ")", ":", "return", "pybedtools", ".", "create_interval_...
If string, then convert to an interval; otherwise just return the input
[ "If", "string", "then", "convert", "to", "an", "interval", ";", "otherwise", "just", "return", "the", "input" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/helpers.py#L93-L113
train
62,941
hfaran/progressive
progressive/bar.py
Bar.max_width
def max_width(self): """Get maximum width of progress bar :rtype: int :returns: Maximum column width of progress bar """ value, unit = float(self._width_str[:-1]), self._width_str[-1] ensure(unit in ["c", "%"], ValueError, "Width unit must be either 'c' o...
python
def max_width(self): """Get maximum width of progress bar :rtype: int :returns: Maximum column width of progress bar """ value, unit = float(self._width_str[:-1]), self._width_str[-1] ensure(unit in ["c", "%"], ValueError, "Width unit must be either 'c' o...
[ "def", "max_width", "(", "self", ")", ":", "value", ",", "unit", "=", "float", "(", "self", ".", "_width_str", "[", ":", "-", "1", "]", ")", ",", "self", ".", "_width_str", "[", "-", "1", "]", "ensure", "(", "unit", "in", "[", "\"c\"", ",", "\"...
Get maximum width of progress bar :rtype: int :returns: Maximum column width of progress bar
[ "Get", "maximum", "width", "of", "progress", "bar" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/bar.py#L144-L166
train
62,942
hfaran/progressive
progressive/bar.py
Bar.full_line_width
def full_line_width(self): """Find actual length of bar_str e.g., Progress [ | ] 10/10 """ bar_str_len = sum([ self._indent, ((len(self.title) + 1) if self._title_pos in ["left", "right"] else 0), # Title if present len(self.start...
python
def full_line_width(self): """Find actual length of bar_str e.g., Progress [ | ] 10/10 """ bar_str_len = sum([ self._indent, ((len(self.title) + 1) if self._title_pos in ["left", "right"] else 0), # Title if present len(self.start...
[ "def", "full_line_width", "(", "self", ")", ":", "bar_str_len", "=", "sum", "(", "[", "self", ".", "_indent", ",", "(", "(", "len", "(", "self", ".", "title", ")", "+", "1", ")", "if", "self", ".", "_title_pos", "in", "[", "\"left\"", ",", "\"right...
Find actual length of bar_str e.g., Progress [ | ] 10/10
[ "Find", "actual", "length", "of", "bar_str" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/bar.py#L169-L184
train
62,943
hfaran/progressive
progressive/bar.py
Bar._supports_colors
def _supports_colors(term, raise_err, colors): """Check if ``term`` supports ``colors`` :raises ColorUnsupportedError: This is raised if ``raise_err`` is ``False`` and a color in ``colors`` is unsupported by ``term`` :type raise_err: bool :param raise_err: Set to ``False`` t...
python
def _supports_colors(term, raise_err, colors): """Check if ``term`` supports ``colors`` :raises ColorUnsupportedError: This is raised if ``raise_err`` is ``False`` and a color in ``colors`` is unsupported by ``term`` :type raise_err: bool :param raise_err: Set to ``False`` t...
[ "def", "_supports_colors", "(", "term", ",", "raise_err", ",", "colors", ")", ":", "for", "color", "in", "colors", ":", "try", ":", "if", "isinstance", "(", "color", ",", "str", ")", ":", "req_colors", "=", "16", "if", "\"bright\"", "in", "color", "els...
Check if ``term`` supports ``colors`` :raises ColorUnsupportedError: This is raised if ``raise_err`` is ``False`` and a color in ``colors`` is unsupported by ``term`` :type raise_err: bool :param raise_err: Set to ``False`` to return a ``bool`` indicating color support r...
[ "Check", "if", "term", "supports", "colors" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/bar.py#L243-L270
train
62,944
hfaran/progressive
progressive/bar.py
Bar._get_format_callable
def _get_format_callable(term, color, back_color): """Get string-coloring callable Get callable for string output using ``color`` on ``back_color`` on ``term`` :param term: blessings.Terminal instance :param color: Color that callable will color the string it's passed ...
python
def _get_format_callable(term, color, back_color): """Get string-coloring callable Get callable for string output using ``color`` on ``back_color`` on ``term`` :param term: blessings.Terminal instance :param color: Color that callable will color the string it's passed ...
[ "def", "_get_format_callable", "(", "term", ",", "color", ",", "back_color", ")", ":", "if", "isinstance", "(", "color", ",", "str", ")", ":", "ensure", "(", "any", "(", "isinstance", "(", "back_color", ",", "t", ")", "for", "t", "in", "[", "str", ",...
Get string-coloring callable Get callable for string output using ``color`` on ``back_color`` on ``term`` :param term: blessings.Terminal instance :param color: Color that callable will color the string it's passed :param back_color: Back color for the string :retur...
[ "Get", "string", "-", "coloring", "callable" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/bar.py#L273-L301
train
62,945
hfaran/progressive
progressive/bar.py
Bar.draw
def draw(self, value, newline=True, flush=True): """Draw the progress bar :type value: int :param value: Progress value relative to ``self.max_value`` :type newline: bool :param newline: If this is set, a newline will be written after drawing """ # This is esse...
python
def draw(self, value, newline=True, flush=True): """Draw the progress bar :type value: int :param value: Progress value relative to ``self.max_value`` :type newline: bool :param newline: If this is set, a newline will be written after drawing """ # This is esse...
[ "def", "draw", "(", "self", ",", "value", ",", "newline", "=", "True", ",", "flush", "=", "True", ")", ":", "# This is essentially winch-handling without having", "# to do winch-handling; cleanly redrawing on winch is difficult", "# and out of the intended scope of this class...
Draw the progress bar :type value: int :param value: Progress value relative to ``self.max_value`` :type newline: bool :param newline: If this is set, a newline will be written after drawing
[ "Draw", "the", "progress", "bar" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/bar.py#L339-L408
train
62,946
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
get_text
def get_text(nodelist): """Get the value from a text node.""" value = [] for node in nodelist: if node.nodeType == node.TEXT_NODE: value.append(node.data) return ''.join(value)
python
def get_text(nodelist): """Get the value from a text node.""" value = [] for node in nodelist: if node.nodeType == node.TEXT_NODE: value.append(node.data) return ''.join(value)
[ "def", "get_text", "(", "nodelist", ")", ":", "value", "=", "[", "]", "for", "node", "in", "nodelist", ":", "if", "node", ".", "nodeType", "==", "node", ".", "TEXT_NODE", ":", "value", ".", "append", "(", "node", ".", "data", ")", "return", "''", "...
Get the value from a text node.
[ "Get", "the", "value", "from", "a", "text", "node", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L14-L20
train
62,947
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome._request
def _request(self, url, params=None, timeout=10): """Send a request with parameters.""" rsp = self._session.get(url, params=params, timeout=timeout) rsp.raise_for_status() return rsp.text.strip()
python
def _request(self, url, params=None, timeout=10): """Send a request with parameters.""" rsp = self._session.get(url, params=params, timeout=timeout) rsp.raise_for_status() return rsp.text.strip()
[ "def", "_request", "(", "self", ",", "url", ",", "params", "=", "None", ",", "timeout", "=", "10", ")", ":", "rsp", "=", "self", ".", "_session", ".", "get", "(", "url", ",", "params", "=", "params", ",", "timeout", "=", "timeout", ")", "rsp", "....
Send a request with parameters.
[ "Send", "a", "request", "with", "parameters", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L47-L51
train
62,948
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome._login_request
def _login_request(self, username=None, secret=None): """Send a login request with paramerters.""" url = 'http://' + self._host + '/login_sid.lua' params = {} if username: params['username'] = username if secret: params['response'] = secret plain ...
python
def _login_request(self, username=None, secret=None): """Send a login request with paramerters.""" url = 'http://' + self._host + '/login_sid.lua' params = {} if username: params['username'] = username if secret: params['response'] = secret plain ...
[ "def", "_login_request", "(", "self", ",", "username", "=", "None", ",", "secret", "=", "None", ")", ":", "url", "=", "'http://'", "+", "self", ".", "_host", "+", "'/login_sid.lua'", "params", "=", "{", "}", "if", "username", ":", "params", "[", "'user...
Send a login request with paramerters.
[ "Send", "a", "login", "request", "with", "paramerters", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L53-L68
train
62,949
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome._logout_request
def _logout_request(self): """Send a logout request.""" _LOGGER.debug('logout') url = 'http://' + self._host + '/login_sid.lua' params = { 'security:command/logout': '1', 'sid': self._sid } self._request(url, params)
python
def _logout_request(self): """Send a logout request.""" _LOGGER.debug('logout') url = 'http://' + self._host + '/login_sid.lua' params = { 'security:command/logout': '1', 'sid': self._sid } self._request(url, params)
[ "def", "_logout_request", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "'logout'", ")", "url", "=", "'http://'", "+", "self", ".", "_host", "+", "'/login_sid.lua'", "params", "=", "{", "'security:command/logout'", ":", "'1'", ",", "'sid'", ":", "se...
Send a logout request.
[ "Send", "a", "logout", "request", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L70-L79
train
62,950
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome._create_login_secret
def _create_login_secret(challenge, password): """Create a login secret.""" to_hash = (challenge + '-' + password).encode('UTF-16LE') hashed = hashlib.md5(to_hash).hexdigest() return '{0}-{1}'.format(challenge, hashed)
python
def _create_login_secret(challenge, password): """Create a login secret.""" to_hash = (challenge + '-' + password).encode('UTF-16LE') hashed = hashlib.md5(to_hash).hexdigest() return '{0}-{1}'.format(challenge, hashed)
[ "def", "_create_login_secret", "(", "challenge", ",", "password", ")", ":", "to_hash", "=", "(", "challenge", "+", "'-'", "+", "password", ")", ".", "encode", "(", "'UTF-16LE'", ")", "hashed", "=", "hashlib", ".", "md5", "(", "to_hash", ")", ".", "hexdig...
Create a login secret.
[ "Create", "a", "login", "secret", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L82-L86
train
62,951
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome._aha_request
def _aha_request(self, cmd, ain=None, param=None, rf=str): """Send an AHA request.""" url = 'http://' + self._host + '/webservices/homeautoswitch.lua' params = { 'switchcmd': cmd, 'sid': self._sid } if param: params['param'] = param if ...
python
def _aha_request(self, cmd, ain=None, param=None, rf=str): """Send an AHA request.""" url = 'http://' + self._host + '/webservices/homeautoswitch.lua' params = { 'switchcmd': cmd, 'sid': self._sid } if param: params['param'] = param if ...
[ "def", "_aha_request", "(", "self", ",", "cmd", ",", "ain", "=", "None", ",", "param", "=", "None", ",", "rf", "=", "str", ")", ":", "url", "=", "'http://'", "+", "self", ".", "_host", "+", "'/webservices/homeautoswitch.lua'", "params", "=", "{", "'swi...
Send an AHA request.
[ "Send", "an", "AHA", "request", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L88-L106
train
62,952
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.login
def login(self): """Login and get a valid session ID.""" try: (sid, challenge) = self._login_request() if sid == '0000000000000000': secret = self._create_login_secret(challenge, self._password) (sid2, challenge) = self._login_request(username=self...
python
def login(self): """Login and get a valid session ID.""" try: (sid, challenge) = self._login_request() if sid == '0000000000000000': secret = self._create_login_secret(challenge, self._password) (sid2, challenge) = self._login_request(username=self...
[ "def", "login", "(", "self", ")", ":", "try", ":", "(", "sid", ",", "challenge", ")", "=", "self", ".", "_login_request", "(", ")", "if", "sid", "==", "'0000000000000000'", ":", "secret", "=", "self", ".", "_create_login_secret", "(", "challenge", ",", ...
Login and get a valid session ID.
[ "Login", "and", "get", "a", "valid", "session", "ID", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L108-L121
train
62,953
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.get_device_elements
def get_device_elements(self): """Get the DOM elements for the device list.""" plain = self._aha_request('getdevicelistinfos') dom = xml.dom.minidom.parseString(plain) _LOGGER.debug(dom) return dom.getElementsByTagName("device")
python
def get_device_elements(self): """Get the DOM elements for the device list.""" plain = self._aha_request('getdevicelistinfos') dom = xml.dom.minidom.parseString(plain) _LOGGER.debug(dom) return dom.getElementsByTagName("device")
[ "def", "get_device_elements", "(", "self", ")", ":", "plain", "=", "self", ".", "_aha_request", "(", "'getdevicelistinfos'", ")", "dom", "=", "xml", ".", "dom", ".", "minidom", ".", "parseString", "(", "plain", ")", "_LOGGER", ".", "debug", "(", "dom", "...
Get the DOM elements for the device list.
[ "Get", "the", "DOM", "elements", "for", "the", "device", "list", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L128-L133
train
62,954
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.get_device_element
def get_device_element(self, ain): """Get the DOM element for the specified device.""" elements = self.get_device_elements() for element in elements: if element.getAttribute('identifier') == ain: return element return None
python
def get_device_element(self, ain): """Get the DOM element for the specified device.""" elements = self.get_device_elements() for element in elements: if element.getAttribute('identifier') == ain: return element return None
[ "def", "get_device_element", "(", "self", ",", "ain", ")", ":", "elements", "=", "self", ".", "get_device_elements", "(", ")", "for", "element", "in", "elements", ":", "if", "element", ".", "getAttribute", "(", "'identifier'", ")", "==", "ain", ":", "retur...
Get the DOM element for the specified device.
[ "Get", "the", "DOM", "element", "for", "the", "specified", "device", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L135-L141
train
62,955
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.get_devices
def get_devices(self): """Get the list of all known devices.""" devices = [] for element in self.get_device_elements(): device = FritzhomeDevice(self, node=element) devices.append(device) return devices
python
def get_devices(self): """Get the list of all known devices.""" devices = [] for element in self.get_device_elements(): device = FritzhomeDevice(self, node=element) devices.append(device) return devices
[ "def", "get_devices", "(", "self", ")", ":", "devices", "=", "[", "]", "for", "element", "in", "self", ".", "get_device_elements", "(", ")", ":", "device", "=", "FritzhomeDevice", "(", "self", ",", "node", "=", "element", ")", "devices", ".", "append", ...
Get the list of all known devices.
[ "Get", "the", "list", "of", "all", "known", "devices", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L143-L149
train
62,956
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.get_device_by_ain
def get_device_by_ain(self, ain): """Returns a device specified by the AIN.""" devices = self.get_devices() for device in devices: if device.ain == ain: return device
python
def get_device_by_ain(self, ain): """Returns a device specified by the AIN.""" devices = self.get_devices() for device in devices: if device.ain == ain: return device
[ "def", "get_device_by_ain", "(", "self", ",", "ain", ")", ":", "devices", "=", "self", ".", "get_devices", "(", ")", "for", "device", "in", "devices", ":", "if", "device", ".", "ain", "==", "ain", ":", "return", "device" ]
Returns a device specified by the AIN.
[ "Returns", "a", "device", "specified", "by", "the", "AIN", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L151-L156
train
62,957
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.set_target_temperature
def set_target_temperature(self, ain, temperature): """Set the thermostate target temperature.""" param = 16 + ((float(temperature) - 8) * 2) if param < min(range(16, 56)): param = 253 elif param > max(range(16, 56)): param = 254 self._aha_request('sethkr...
python
def set_target_temperature(self, ain, temperature): """Set the thermostate target temperature.""" param = 16 + ((float(temperature) - 8) * 2) if param < min(range(16, 56)): param = 253 elif param > max(range(16, 56)): param = 254 self._aha_request('sethkr...
[ "def", "set_target_temperature", "(", "self", ",", "ain", ",", "temperature", ")", ":", "param", "=", "16", "+", "(", "(", "float", "(", "temperature", ")", "-", "8", ")", "*", "2", ")", "if", "param", "<", "min", "(", "range", "(", "16", ",", "5...
Set the thermostate target temperature.
[ "Set", "the", "thermostate", "target", "temperature", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L202-L210
train
62,958
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
FritzhomeDevice.update
def update(self): """Update the device values.""" node = self._fritz.get_device_element(self.ain) self._update_from_node(node)
python
def update(self): """Update the device values.""" node = self._fritz.get_device_element(self.ain) self._update_from_node(node)
[ "def", "update", "(", "self", ")", ":", "node", "=", "self", ".", "_fritz", ".", "get_device_element", "(", "self", ".", "ain", ")", "self", ".", "_update_from_node", "(", "node", ")" ]
Update the device values.
[ "Update", "the", "device", "values", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L409-L412
train
62,959
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
FritzhomeDevice.get_hkr_state
def get_hkr_state(self): """Get the thermostate state.""" self.update() try: return { 126.5: 'off', 127.0: 'on', self.eco_temperature: 'eco', self.comfort_temperature: 'comfort' }[self.target_temperature] ...
python
def get_hkr_state(self): """Get the thermostate state.""" self.update() try: return { 126.5: 'off', 127.0: 'on', self.eco_temperature: 'eco', self.comfort_temperature: 'comfort' }[self.target_temperature] ...
[ "def", "get_hkr_state", "(", "self", ")", ":", "self", ".", "update", "(", ")", "try", ":", "return", "{", "126.5", ":", "'off'", ",", "127.0", ":", "'on'", ",", "self", ".", "eco_temperature", ":", "'eco'", ",", "self", ".", "comfort_temperature", ":"...
Get the thermostate state.
[ "Get", "the", "thermostate", "state", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L492-L503
train
62,960
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
FritzhomeDevice.set_hkr_state
def set_hkr_state(self, state): """Set the state of the thermostat. Possible values for state are: 'on', 'off', 'comfort', 'eco'. """ try: value = { 'off': 0, 'on': 100, 'eco': self.eco_temperature, 'comfort': s...
python
def set_hkr_state(self, state): """Set the state of the thermostat. Possible values for state are: 'on', 'off', 'comfort', 'eco'. """ try: value = { 'off': 0, 'on': 100, 'eco': self.eco_temperature, 'comfort': s...
[ "def", "set_hkr_state", "(", "self", ",", "state", ")", ":", "try", ":", "value", "=", "{", "'off'", ":", "0", ",", "'on'", ":", "100", ",", "'eco'", ":", "self", ".", "eco_temperature", ",", "'comfort'", ":", "self", ".", "comfort_temperature", "}", ...
Set the state of the thermostat. Possible values for state are: 'on', 'off', 'comfort', 'eco'.
[ "Set", "the", "state", "of", "the", "thermostat", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L505-L520
train
62,961
hfaran/progressive
progressive/cursor.py
Cursor.write
def write(self, s): """Writes ``s`` to the terminal output stream Writes can be disabled by setting the environment variable `PROGRESSIVE_NOWRITE` to `'True'` """ should_write_s = os.getenv('PROGRESSIVE_NOWRITE') != "True" if should_write_s: self._stream....
python
def write(self, s): """Writes ``s`` to the terminal output stream Writes can be disabled by setting the environment variable `PROGRESSIVE_NOWRITE` to `'True'` """ should_write_s = os.getenv('PROGRESSIVE_NOWRITE') != "True" if should_write_s: self._stream....
[ "def", "write", "(", "self", ",", "s", ")", ":", "should_write_s", "=", "os", ".", "getenv", "(", "'PROGRESSIVE_NOWRITE'", ")", "!=", "\"True\"", "if", "should_write_s", ":", "self", ".", "_stream", ".", "write", "(", "s", ")" ]
Writes ``s`` to the terminal output stream Writes can be disabled by setting the environment variable `PROGRESSIVE_NOWRITE` to `'True'`
[ "Writes", "s", "to", "the", "terminal", "output", "stream" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/cursor.py#L18-L26
train
62,962
hfaran/progressive
progressive/cursor.py
Cursor.save
def save(self): """Saves current cursor position, so that it can be restored later""" self.write(self.term.save) self._saved = True
python
def save(self): """Saves current cursor position, so that it can be restored later""" self.write(self.term.save) self._saved = True
[ "def", "save", "(", "self", ")", ":", "self", ".", "write", "(", "self", ".", "term", ".", "save", ")", "self", ".", "_saved", "=", "True" ]
Saves current cursor position, so that it can be restored later
[ "Saves", "current", "cursor", "position", "so", "that", "it", "can", "be", "restored", "later" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/cursor.py#L28-L31
train
62,963
hfaran/progressive
progressive/cursor.py
Cursor.newline
def newline(self): """Effects a newline by moving the cursor down and clearing""" self.write(self.term.move_down) self.write(self.term.clear_bol)
python
def newline(self): """Effects a newline by moving the cursor down and clearing""" self.write(self.term.move_down) self.write(self.term.clear_bol)
[ "def", "newline", "(", "self", ")", ":", "self", ".", "write", "(", "self", ".", "term", ".", "move_down", ")", "self", ".", "write", "(", "self", ".", "term", ".", "clear_bol", ")" ]
Effects a newline by moving the cursor down and clearing
[ "Effects", "a", "newline", "by", "moving", "the", "cursor", "down", "and", "clearing" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/cursor.py#L46-L49
train
62,964
daler/metaseq
metaseq/results_table.py
ResultsTable.attach_db
def attach_db(self, db): """ Attach a gffutils.FeatureDB for access to features. Useful if you want to attach a db after this instance has already been created. Parameters ---------- db : gffutils.FeatureDB """ if db is not None: if i...
python
def attach_db(self, db): """ Attach a gffutils.FeatureDB for access to features. Useful if you want to attach a db after this instance has already been created. Parameters ---------- db : gffutils.FeatureDB """ if db is not None: if i...
[ "def", "attach_db", "(", "self", ",", "db", ")", ":", "if", "db", "is", "not", "None", ":", "if", "isinstance", "(", "db", ",", "basestring", ")", ":", "db", "=", "gffutils", ".", "FeatureDB", "(", "db", ")", "if", "not", "isinstance", "(", "db", ...
Attach a gffutils.FeatureDB for access to features. Useful if you want to attach a db after this instance has already been created. Parameters ---------- db : gffutils.FeatureDB
[ "Attach", "a", "gffutils", ".", "FeatureDB", "for", "access", "to", "features", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L88-L106
train
62,965
daler/metaseq
metaseq/results_table.py
ResultsTable.features
def features(self, ignore_unknown=False): """ Generator of features. If a gffutils.FeatureDB is attached, returns a pybedtools.Interval for every feature in the dataframe's index. Parameters ---------- ignore_unknown : bool If True, silently ignores ...
python
def features(self, ignore_unknown=False): """ Generator of features. If a gffutils.FeatureDB is attached, returns a pybedtools.Interval for every feature in the dataframe's index. Parameters ---------- ignore_unknown : bool If True, silently ignores ...
[ "def", "features", "(", "self", ",", "ignore_unknown", "=", "False", ")", ":", "if", "not", "self", ".", "db", ":", "raise", "ValueError", "(", "\"Please attach a gffutils.FeatureDB\"", ")", "for", "i", "in", "self", ".", "data", ".", "index", ":", "try", ...
Generator of features. If a gffutils.FeatureDB is attached, returns a pybedtools.Interval for every feature in the dataframe's index. Parameters ---------- ignore_unknown : bool If True, silently ignores features that are not found in the db.
[ "Generator", "of", "features", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L108-L129
train
62,966
daler/metaseq
metaseq/results_table.py
ResultsTable.reindex_to
def reindex_to(self, x, attribute="Name"): """ Returns a copy that only has rows corresponding to feature names in x. Parameters ---------- x : str or pybedtools.BedTool BED, GFF, GTF, or VCF where the "Name" field (that is, the value returned by feature[...
python
def reindex_to(self, x, attribute="Name"): """ Returns a copy that only has rows corresponding to feature names in x. Parameters ---------- x : str or pybedtools.BedTool BED, GFF, GTF, or VCF where the "Name" field (that is, the value returned by feature[...
[ "def", "reindex_to", "(", "self", ",", "x", ",", "attribute", "=", "\"Name\"", ")", ":", "names", "=", "[", "i", "[", "attribute", "]", "for", "i", "in", "x", "]", "new", "=", "self", ".", "copy", "(", ")", "new", ".", "data", "=", "new", ".", ...
Returns a copy that only has rows corresponding to feature names in x. Parameters ---------- x : str or pybedtools.BedTool BED, GFF, GTF, or VCF where the "Name" field (that is, the value returned by feature['Name']) or any arbitrary attribute attribute : str ...
[ "Returns", "a", "copy", "that", "only", "has", "rows", "corresponding", "to", "feature", "names", "in", "x", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L131-L147
train
62,967
daler/metaseq
metaseq/results_table.py
ResultsTable.align_with
def align_with(self, other): """ Align the dataframe's index with another. """ return self.__class__(self.data.reindex_like(other), **self._kwargs)
python
def align_with(self, other): """ Align the dataframe's index with another. """ return self.__class__(self.data.reindex_like(other), **self._kwargs)
[ "def", "align_with", "(", "self", ",", "other", ")", ":", "return", "self", ".", "__class__", "(", "self", ".", "data", ".", "reindex_like", "(", "other", ")", ",", "*", "*", "self", ".", "_kwargs", ")" ]
Align the dataframe's index with another.
[ "Align", "the", "dataframe", "s", "index", "with", "another", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L182-L186
train
62,968
daler/metaseq
metaseq/results_table.py
ResultsTable.radviz
def radviz(self, column_names, transforms=dict(), **kwargs): """ Radviz plot. Useful for exploratory visualization, a radviz plot can show multivariate data in 2D. Conceptually, the variables (here, specified in `column_names`) are distributed evenly around the unit circle. Th...
python
def radviz(self, column_names, transforms=dict(), **kwargs): """ Radviz plot. Useful for exploratory visualization, a radviz plot can show multivariate data in 2D. Conceptually, the variables (here, specified in `column_names`) are distributed evenly around the unit circle. Th...
[ "def", "radviz", "(", "self", ",", "column_names", ",", "transforms", "=", "dict", "(", ")", ",", "*", "*", "kwargs", ")", ":", "# make a copy of data", "x", "=", "self", ".", "data", "[", "column_names", "]", ".", "copy", "(", ")", "for", "k", ",", ...
Radviz plot. Useful for exploratory visualization, a radviz plot can show multivariate data in 2D. Conceptually, the variables (here, specified in `column_names`) are distributed evenly around the unit circle. Then each point (here, each row in the dataframe) is attached to each ...
[ "Radviz", "plot", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L543-L656
train
62,969
daler/metaseq
metaseq/results_table.py
ResultsTable.strip_unknown_features
def strip_unknown_features(self): """ Remove features not found in the `gffutils.FeatureDB`. This will typically include 'ambiguous', 'no_feature', etc, but can also be useful if the database was created from a different one than was used to create the table. """ ...
python
def strip_unknown_features(self): """ Remove features not found in the `gffutils.FeatureDB`. This will typically include 'ambiguous', 'no_feature', etc, but can also be useful if the database was created from a different one than was used to create the table. """ ...
[ "def", "strip_unknown_features", "(", "self", ")", ":", "if", "not", "self", ".", "db", ":", "return", "self", "ind", "=", "[", "]", "for", "i", ",", "gene_id", "in", "enumerate", "(", "self", ".", "data", ".", "index", ")", ":", "try", ":", "self"...
Remove features not found in the `gffutils.FeatureDB`. This will typically include 'ambiguous', 'no_feature', etc, but can also be useful if the database was created from a different one than was used to create the table.
[ "Remove", "features", "not", "found", "in", "the", "gffutils", ".", "FeatureDB", ".", "This", "will", "typically", "include", "ambiguous", "no_feature", "etc", "but", "can", "also", "be", "useful", "if", "the", "database", "was", "created", "from", "a", "dif...
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L671-L688
train
62,970
daler/metaseq
metaseq/results_table.py
ResultsTable.genes_with_peak
def genes_with_peak(self, peaks, transform_func=None, split=False, intersect_kwargs=None, id_attribute='ID', *args, **kwargs): """ Returns a boolean index of genes that have a peak nearby. Parameters ---------- peaks : string or py...
python
def genes_with_peak(self, peaks, transform_func=None, split=False, intersect_kwargs=None, id_attribute='ID', *args, **kwargs): """ Returns a boolean index of genes that have a peak nearby. Parameters ---------- peaks : string or py...
[ "def", "genes_with_peak", "(", "self", ",", "peaks", ",", "transform_func", "=", "None", ",", "split", "=", "False", ",", "intersect_kwargs", "=", "None", ",", "id_attribute", "=", "'ID'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "_t...
Returns a boolean index of genes that have a peak nearby. Parameters ---------- peaks : string or pybedtools.BedTool If string, then assume it's a filename to a BED/GFF/GTF file of intervals; otherwise use the pybedtools.BedTool object directly. transform_func :...
[ "Returns", "a", "boolean", "index", "of", "genes", "that", "have", "a", "peak", "nearby", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L690-L758
train
62,971
daler/metaseq
metaseq/results_table.py
DifferentialExpressionResults.enriched
def enriched(self, thresh=0.05, idx=True): """ Enriched features. {threshdoc} """ return self.upregulated(thresh=thresh, idx=idx)
python
def enriched(self, thresh=0.05, idx=True): """ Enriched features. {threshdoc} """ return self.upregulated(thresh=thresh, idx=idx)
[ "def", "enriched", "(", "self", ",", "thresh", "=", "0.05", ",", "idx", "=", "True", ")", ":", "return", "self", ".", "upregulated", "(", "thresh", "=", "thresh", ",", "idx", "=", "idx", ")" ]
Enriched features. {threshdoc}
[ "Enriched", "features", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L814-L820
train
62,972
daler/metaseq
metaseq/results_table.py
DifferentialExpressionResults.upregulated
def upregulated(self, thresh=0.05, idx=True): """ Upregulated features. {threshdoc} """ ind = ( (self.data[self.pval_column] <= thresh) & (self.data[self.lfc_column] > 0) ) if idx: return ind return self[ind]
python
def upregulated(self, thresh=0.05, idx=True): """ Upregulated features. {threshdoc} """ ind = ( (self.data[self.pval_column] <= thresh) & (self.data[self.lfc_column] > 0) ) if idx: return ind return self[ind]
[ "def", "upregulated", "(", "self", ",", "thresh", "=", "0.05", ",", "idx", "=", "True", ")", ":", "ind", "=", "(", "(", "self", ".", "data", "[", "self", ".", "pval_column", "]", "<=", "thresh", ")", "&", "(", "self", ".", "data", "[", "self", ...
Upregulated features. {threshdoc}
[ "Upregulated", "features", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L822-L834
train
62,973
daler/metaseq
metaseq/results_table.py
DifferentialExpressionResults.disenriched
def disenriched(self, thresh=0.05, idx=True): """ Disenriched features. {threshdoc} """ return self.downregulated(thresh=thresh, idx=idx)
python
def disenriched(self, thresh=0.05, idx=True): """ Disenriched features. {threshdoc} """ return self.downregulated(thresh=thresh, idx=idx)
[ "def", "disenriched", "(", "self", ",", "thresh", "=", "0.05", ",", "idx", "=", "True", ")", ":", "return", "self", ".", "downregulated", "(", "thresh", "=", "thresh", ",", "idx", "=", "idx", ")" ]
Disenriched features. {threshdoc}
[ "Disenriched", "features", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L850-L856
train
62,974
daler/metaseq
metaseq/results_table.py
DESeqResults.colormapped_bedfile
def colormapped_bedfile(self, genome, cmap=None): """ Create a BED file with padj encoded as color Features will be colored according to adjusted pval (phred transformed). Downregulated features have the sign flipped. Parameters ---------- cmap : matplotlib col...
python
def colormapped_bedfile(self, genome, cmap=None): """ Create a BED file with padj encoded as color Features will be colored according to adjusted pval (phred transformed). Downregulated features have the sign flipped. Parameters ---------- cmap : matplotlib col...
[ "def", "colormapped_bedfile", "(", "self", ",", "genome", ",", "cmap", "=", "None", ")", ":", "if", "self", ".", "db", "is", "None", ":", "raise", "ValueError", "(", "\"FeatureDB required\"", ")", "db", "=", "gffutils", ".", "FeatureDB", "(", "self", "."...
Create a BED file with padj encoded as color Features will be colored according to adjusted pval (phred transformed). Downregulated features have the sign flipped. Parameters ---------- cmap : matplotlib colormap Default is matplotlib.cm.RdBu_r Notes ...
[ "Create", "a", "BED", "file", "with", "padj", "encoded", "as", "color" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L944-L1003
train
62,975
daler/metaseq
metaseq/array_helpers.py
_array_parallel
def _array_parallel(fn, cls, genelist, chunksize=250, processes=1, **kwargs): """ Returns an array of genes in `genelist`, using `bins` bins. `genelist` is a list of pybedtools.Interval objects Splits `genelist` into pieces of size `chunksize`, creating an array for each chunk and merging ret ...
python
def _array_parallel(fn, cls, genelist, chunksize=250, processes=1, **kwargs): """ Returns an array of genes in `genelist`, using `bins` bins. `genelist` is a list of pybedtools.Interval objects Splits `genelist` into pieces of size `chunksize`, creating an array for each chunk and merging ret ...
[ "def", "_array_parallel", "(", "fn", ",", "cls", ",", "genelist", ",", "chunksize", "=", "250", ",", "processes", "=", "1", ",", "*", "*", "kwargs", ")", ":", "pool", "=", "multiprocessing", ".", "Pool", "(", "processes", ")", "chunks", "=", "list", ...
Returns an array of genes in `genelist`, using `bins` bins. `genelist` is a list of pybedtools.Interval objects Splits `genelist` into pieces of size `chunksize`, creating an array for each chunk and merging ret A chunksize of 25-100 seems to work well on 8 cores.
[ "Returns", "an", "array", "of", "genes", "in", "genelist", "using", "bins", "bins", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/array_helpers.py#L394-L421
train
62,976
daler/metaseq
metaseq/array_helpers.py
_array_star
def _array_star(args): """ Unpacks the tuple `args` and calls _array. Needed to pass multiple args to a pool.map-ed function """ fn, cls, genelist, kwargs = args return _array(fn, cls, genelist, **kwargs)
python
def _array_star(args): """ Unpacks the tuple `args` and calls _array. Needed to pass multiple args to a pool.map-ed function """ fn, cls, genelist, kwargs = args return _array(fn, cls, genelist, **kwargs)
[ "def", "_array_star", "(", "args", ")", ":", "fn", ",", "cls", ",", "genelist", ",", "kwargs", "=", "args", "return", "_array", "(", "fn", ",", "cls", ",", "genelist", ",", "*", "*", "kwargs", ")" ]
Unpacks the tuple `args` and calls _array. Needed to pass multiple args to a pool.map-ed function
[ "Unpacks", "the", "tuple", "args", "and", "calls", "_array", ".", "Needed", "to", "pass", "multiple", "args", "to", "a", "pool", ".", "map", "-", "ed", "function" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/array_helpers.py#L452-L458
train
62,977
daler/metaseq
metaseq/arrayify.py
Binner.to_npz
def to_npz(self, bigwig, metric='mean0', outdir=None): """ Bin data for bigwig and save to disk. The .npz file will have the pattern {outdir}/{bigwig}.{chrom}.{windowsize}.{metric}.npz and will have two arrays, x (genomic coordinates of midpoints of each window) and y (m...
python
def to_npz(self, bigwig, metric='mean0', outdir=None): """ Bin data for bigwig and save to disk. The .npz file will have the pattern {outdir}/{bigwig}.{chrom}.{windowsize}.{metric}.npz and will have two arrays, x (genomic coordinates of midpoints of each window) and y (m...
[ "def", "to_npz", "(", "self", ",", "bigwig", ",", "metric", "=", "'mean0'", ",", "outdir", "=", "None", ")", ":", "if", "isinstance", "(", "bigwig", ",", "_genomic_signal", ".", "BigWigSignal", ")", ":", "bigwig", "=", "bigwig", ".", "fn", "if", "outdi...
Bin data for bigwig and save to disk. The .npz file will have the pattern {outdir}/{bigwig}.{chrom}.{windowsize}.{metric}.npz and will have two arrays, x (genomic coordinates of midpoints of each window) and y (metric for each window). It can be loaded like this:: d = np.l...
[ "Bin", "data", "for", "bigwig", "and", "save", "to", "disk", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/arrayify.py#L84-L142
train
62,978
daler/metaseq
metaseq/integration/signal_comparison.py
compare
def compare(signal1, signal2, features, outfn, comparefunc=np.subtract, batchsize=5000, array_kwargs=None, verbose=False): """ Compares two genomic signal objects and outputs results as a bedGraph file. Can be used for entire genome-wide comparisons due to its parallel nature. Typical usage wou...
python
def compare(signal1, signal2, features, outfn, comparefunc=np.subtract, batchsize=5000, array_kwargs=None, verbose=False): """ Compares two genomic signal objects and outputs results as a bedGraph file. Can be used for entire genome-wide comparisons due to its parallel nature. Typical usage wou...
[ "def", "compare", "(", "signal1", ",", "signal2", ",", "features", ",", "outfn", ",", "comparefunc", "=", "np", ".", "subtract", ",", "batchsize", "=", "5000", ",", "array_kwargs", "=", "None", ",", "verbose", "=", "False", ")", ":", "fout", "=", "open...
Compares two genomic signal objects and outputs results as a bedGraph file. Can be used for entire genome-wide comparisons due to its parallel nature. Typical usage would be to create genome-wide windows of equal size to provide as `features`:: windowsize = 10000 features = pybedtools.BedT...
[ "Compares", "two", "genomic", "signal", "objects", "and", "outputs", "results", "as", "a", "bedGraph", "file", ".", "Can", "be", "used", "for", "entire", "genome", "-", "wide", "comparisons", "due", "to", "its", "parallel", "nature", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/integration/signal_comparison.py#L11-L113
train
62,979
moble/h5py_cache
__init__.py
_find_next_prime
def _find_next_prime(N): """Find next prime >= N""" def is_prime(n): if n % 2 == 0: return False i = 3 while i * i <= n: if n % i: i += 2 else: return False return True if N < 3: return 2 if N % 2...
python
def _find_next_prime(N): """Find next prime >= N""" def is_prime(n): if n % 2 == 0: return False i = 3 while i * i <= n: if n % i: i += 2 else: return False return True if N < 3: return 2 if N % 2...
[ "def", "_find_next_prime", "(", "N", ")", ":", "def", "is_prime", "(", "n", ")", ":", "if", "n", "%", "2", "==", "0", ":", "return", "False", "i", "=", "3", "while", "i", "*", "i", "<=", "n", ":", "if", "n", "%", "i", ":", "i", "+=", "2", ...
Find next prime >= N
[ "Find", "next", "prime", ">", "=", "N" ]
2491896f14a8fae01e2540eec62b3a8d5cb8bfa9
https://github.com/moble/h5py_cache/blob/2491896f14a8fae01e2540eec62b3a8d5cb8bfa9/__init__.py#L5-L24
train
62,980
moble/h5py_cache
__init__.py
File
def File(name, mode='a', chunk_cache_mem_size=1024**2, w0=0.75, n_cache_chunks=None, **kwds): """Create h5py File object with cache specification This function is basically just a wrapper around the usual h5py.File constructor, but accepts two additional keywords: Parameters ---------- name : ...
python
def File(name, mode='a', chunk_cache_mem_size=1024**2, w0=0.75, n_cache_chunks=None, **kwds): """Create h5py File object with cache specification This function is basically just a wrapper around the usual h5py.File constructor, but accepts two additional keywords: Parameters ---------- name : ...
[ "def", "File", "(", "name", ",", "mode", "=", "'a'", ",", "chunk_cache_mem_size", "=", "1024", "**", "2", ",", "w0", "=", "0.75", ",", "n_cache_chunks", "=", "None", ",", "*", "*", "kwds", ")", ":", "import", "sys", "import", "numpy", "as", "np", "...
Create h5py File object with cache specification This function is basically just a wrapper around the usual h5py.File constructor, but accepts two additional keywords: Parameters ---------- name : str mode : str **kwds : dict (as keywords) Standard h5py.File arguments, passed to it...
[ "Create", "h5py", "File", "object", "with", "cache", "specification" ]
2491896f14a8fae01e2540eec62b3a8d5cb8bfa9
https://github.com/moble/h5py_cache/blob/2491896f14a8fae01e2540eec62b3a8d5cb8bfa9/__init__.py#L27-L75
train
62,981
daler/metaseq
metaseq/integration/chipseq.py
save
def save(c, prefix, relative_paths=True): """ Save data from a Chipseq object. Parameters ---------- c : Chipseq object Chipseq object, most likely after calling the `diffed_array` method prefix : str Prefix, including any leading directory paths, to save the data. relati...
python
def save(c, prefix, relative_paths=True): """ Save data from a Chipseq object. Parameters ---------- c : Chipseq object Chipseq object, most likely after calling the `diffed_array` method prefix : str Prefix, including any leading directory paths, to save the data. relati...
[ "def", "save", "(", "c", ",", "prefix", ",", "relative_paths", "=", "True", ")", ":", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "prefix", ")", "pybedtools", ".", "BedTool", "(", "c", ".", "features", ")", ".", "saveas", "(", "prefix", ...
Save data from a Chipseq object. Parameters ---------- c : Chipseq object Chipseq object, most likely after calling the `diffed_array` method prefix : str Prefix, including any leading directory paths, to save the data. relative_paths : bool If True (default), then the pa...
[ "Save", "data", "from", "a", "Chipseq", "object", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/integration/chipseq.py#L16-L73
train
62,982
daler/metaseq
metaseq/integration/chipseq.py
xcorr
def xcorr(x, y, maxlags): """ Streamlined version of matplotlib's `xcorr`, without the plots. :param x, y: NumPy arrays to cross-correlate :param maxlags: Max number of lags; result will be `2*maxlags+1` in length """ xlen = len(x) ylen = len(y) assert xlen == ylen c = np.correlate...
python
def xcorr(x, y, maxlags): """ Streamlined version of matplotlib's `xcorr`, without the plots. :param x, y: NumPy arrays to cross-correlate :param maxlags: Max number of lags; result will be `2*maxlags+1` in length """ xlen = len(x) ylen = len(y) assert xlen == ylen c = np.correlate...
[ "def", "xcorr", "(", "x", ",", "y", ",", "maxlags", ")", ":", "xlen", "=", "len", "(", "x", ")", "ylen", "=", "len", "(", "y", ")", "assert", "xlen", "==", "ylen", "c", "=", "np", ".", "correlate", "(", "x", ",", "y", ",", "mode", "=", "2",...
Streamlined version of matplotlib's `xcorr`, without the plots. :param x, y: NumPy arrays to cross-correlate :param maxlags: Max number of lags; result will be `2*maxlags+1` in length
[ "Streamlined", "version", "of", "matplotlib", "s", "xcorr", "without", "the", "plots", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/integration/chipseq.py#L410-L429
train
62,983
daler/metaseq
metaseq/integration/chipseq.py
Chipseq.plot
def plot(self, x, row_order=None, imshow_kwargs=None, strip=True): """ Plot the scaled ChIP-seq data. :param x: X-axis to use (e.g, for TSS +/- 1kb with 100 bins, this would be `np.linspace(-1000, 1000, 100)`) :param row_order: Array-like object containing row order -- typic...
python
def plot(self, x, row_order=None, imshow_kwargs=None, strip=True): """ Plot the scaled ChIP-seq data. :param x: X-axis to use (e.g, for TSS +/- 1kb with 100 bins, this would be `np.linspace(-1000, 1000, 100)`) :param row_order: Array-like object containing row order -- typic...
[ "def", "plot", "(", "self", ",", "x", ",", "row_order", "=", "None", ",", "imshow_kwargs", "=", "None", ",", "strip", "=", "True", ")", ":", "nrows", "=", "self", ".", "diffed_array", ".", "shape", "[", "0", "]", "if", "row_order", "is", "None", ":...
Plot the scaled ChIP-seq data. :param x: X-axis to use (e.g, for TSS +/- 1kb with 100 bins, this would be `np.linspace(-1000, 1000, 100)`) :param row_order: Array-like object containing row order -- typically the result of an `np.argsort` call. :param strip: Include axes...
[ "Plot", "the", "scaled", "ChIP", "-", "seq", "data", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/integration/chipseq.py#L212-L277
train
62,984
daler/metaseq
metaseq/integration/chipseq.py
Chipseq.callback
def callback(self, event): """ Callback function to spawn a mini-browser when a feature is clicked. """ artist = event.artist ind = artist.ind limit = 5 browser = True if len(event.ind) > limit: print "more than %s genes selected; not spawning ...
python
def callback(self, event): """ Callback function to spawn a mini-browser when a feature is clicked. """ artist = event.artist ind = artist.ind limit = 5 browser = True if len(event.ind) > limit: print "more than %s genes selected; not spawning ...
[ "def", "callback", "(", "self", ",", "event", ")", ":", "artist", "=", "event", ".", "artist", "ind", "=", "artist", ".", "ind", "limit", "=", "5", "browser", "=", "True", "if", "len", "(", "event", ".", "ind", ")", ">", "limit", ":", "print", "\...
Callback function to spawn a mini-browser when a feature is clicked.
[ "Callback", "function", "to", "spawn", "a", "mini", "-", "browser", "when", "a", "feature", "is", "clicked", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/integration/chipseq.py#L279-L294
train
62,985
h2non/paco
paco/observer.py
Observer.remove
def remove(self, event=None): """ Remove all the registered observers for the given event name. Arguments: event (str): event name to remove. """ observers = self._pool.get(event) if observers: self._pool[event] = []
python
def remove(self, event=None): """ Remove all the registered observers for the given event name. Arguments: event (str): event name to remove. """ observers = self._pool.get(event) if observers: self._pool[event] = []
[ "def", "remove", "(", "self", ",", "event", "=", "None", ")", ":", "observers", "=", "self", ".", "_pool", ".", "get", "(", "event", ")", "if", "observers", ":", "self", ".", "_pool", "[", "event", "]", "=", "[", "]" ]
Remove all the registered observers for the given event name. Arguments: event (str): event name to remove.
[ "Remove", "all", "the", "registered", "observers", "for", "the", "given", "event", "name", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/observer.py#L44-L53
train
62,986
h2non/paco
paco/observer.py
Observer.trigger
def trigger(self, event, *args, **kw): """ Triggers event observers for the given event name, passing custom variadic arguments. """ observers = self._pool.get(event) # If no observers registered for the event, do no-op if not observers or len(observers) == 0: ...
python
def trigger(self, event, *args, **kw): """ Triggers event observers for the given event name, passing custom variadic arguments. """ observers = self._pool.get(event) # If no observers registered for the event, do no-op if not observers or len(observers) == 0: ...
[ "def", "trigger", "(", "self", ",", "event", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "observers", "=", "self", ".", "_pool", ".", "get", "(", "event", ")", "# If no observers registered for the event, do no-op", "if", "not", "observers", "or", "le...
Triggers event observers for the given event name, passing custom variadic arguments.
[ "Triggers", "event", "observers", "for", "the", "given", "event", "name", "passing", "custom", "variadic", "arguments", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/observer.py#L66-L80
train
62,987
h2non/paco
paco/until.py
until
def until(coro, coro_test, assert_coro=None, *args, **kw): """ Repeatedly call `coro` coroutine function until `coro_test` returns `True`. This function is the inverse of `paco.whilst()`. This function is a coroutine. Arguments: coro (coroutinefunction): coroutine function to execute. ...
python
def until(coro, coro_test, assert_coro=None, *args, **kw): """ Repeatedly call `coro` coroutine function until `coro_test` returns `True`. This function is the inverse of `paco.whilst()`. This function is a coroutine. Arguments: coro (coroutinefunction): coroutine function to execute. ...
[ "def", "until", "(", "coro", ",", "coro_test", ",", "assert_coro", "=", "None", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "@", "asyncio", ".", "coroutine", "def", "assert_coro", "(", "value", ")", ":", "return", "not", "value", "return", "(", ...
Repeatedly call `coro` coroutine function until `coro_test` returns `True`. This function is the inverse of `paco.whilst()`. This function is a coroutine. Arguments: coro (coroutinefunction): coroutine function to execute. coro_test (coroutinefunction): coroutine function to test. ...
[ "Repeatedly", "call", "coro", "coroutine", "function", "until", "coro_test", "returns", "True", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/until.py#L7-L49
train
62,988
h2non/paco
paco/curry.py
curry
def curry(arity_or_fn=None, ignore_kwargs=False, evaluator=None, *args, **kw): """ Creates a function that accepts one or more arguments of a function and either invokes func returning its result if at least arity number of arguments have been provided, or returns a function that accepts the remaini...
python
def curry(arity_or_fn=None, ignore_kwargs=False, evaluator=None, *args, **kw): """ Creates a function that accepts one or more arguments of a function and either invokes func returning its result if at least arity number of arguments have been provided, or returns a function that accepts the remaini...
[ "def", "curry", "(", "arity_or_fn", "=", "None", ",", "ignore_kwargs", "=", "False", ",", "evaluator", "=", "None", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "def", "isvalidarg", "(", "x", ")", ":", "return", "all", "(", "[", "x", ".", "ki...
Creates a function that accepts one or more arguments of a function and either invokes func returning its result if at least arity number of arguments have been provided, or returns a function that accepts the remaining function arguments until the function arity is satisfied. This function is overload...
[ "Creates", "a", "function", "that", "accepts", "one", "or", "more", "arguments", "of", "a", "function", "and", "either", "invokes", "func", "returning", "its", "result", "if", "at", "least", "arity", "number", "of", "arguments", "have", "been", "provided", "...
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/curry.py#L8-L143
train
62,989
h2non/paco
paco/compose.py
compose
def compose(*coros): """ Creates a coroutine function based on the composition of the passed coroutine functions. Each function consumes the yielded result of the coroutine that follows. Composing coroutine functions f(), g(), and h() would produce the result of f(g(h())). Arguments: ...
python
def compose(*coros): """ Creates a coroutine function based on the composition of the passed coroutine functions. Each function consumes the yielded result of the coroutine that follows. Composing coroutine functions f(), g(), and h() would produce the result of f(g(h())). Arguments: ...
[ "def", "compose", "(", "*", "coros", ")", ":", "# Make list to inherit built-in type methods", "coros", "=", "list", "(", "coros", ")", "@", "asyncio", ".", "coroutine", "def", "reducer", "(", "acc", ",", "coro", ")", ":", "return", "(", "yield", "from", "...
Creates a coroutine function based on the composition of the passed coroutine functions. Each function consumes the yielded result of the coroutine that follows. Composing coroutine functions f(), g(), and h() would produce the result of f(g(h())). Arguments: *coros (coroutinefunction): v...
[ "Creates", "a", "coroutine", "function", "based", "on", "the", "composition", "of", "the", "passed", "coroutine", "functions", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/compose.py#L6-L50
train
62,990
kalbhor/MusicNow
musicnow/command_line.py
add_config
def add_config(): """ Prompts user for API keys, adds them in an .ini file stored in the same location as that of the script """ genius_key = input('Enter Genius key : ') bing_key = input('Enter Bing key : ') CONFIG['keys']['bing_key'] = bing_key CONFIG['keys']['genius_key'] = genius_k...
python
def add_config(): """ Prompts user for API keys, adds them in an .ini file stored in the same location as that of the script """ genius_key = input('Enter Genius key : ') bing_key = input('Enter Bing key : ') CONFIG['keys']['bing_key'] = bing_key CONFIG['keys']['genius_key'] = genius_k...
[ "def", "add_config", "(", ")", ":", "genius_key", "=", "input", "(", "'Enter Genius key : '", ")", "bing_key", "=", "input", "(", "'Enter Bing key : '", ")", "CONFIG", "[", "'keys'", "]", "[", "'bing_key'", "]", "=", "bing_key", "CONFIG", "[", "'keys'", "]",...
Prompts user for API keys, adds them in an .ini file stored in the same location as that of the script
[ "Prompts", "user", "for", "API", "keys", "adds", "them", "in", "an", ".", "ini", "file", "stored", "in", "the", "same", "location", "as", "that", "of", "the", "script" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/command_line.py#L66-L79
train
62,991
kalbhor/MusicNow
musicnow/command_line.py
get_tracks_from_album
def get_tracks_from_album(album_name): ''' Gets tracks from an album using Spotify's API ''' spotify = spotipy.Spotify() album = spotify.search(q='album:' + album_name, limit=1) album_id = album['tracks']['items'][0]['album']['id'] results = spotify.album_tracks(album_id=str(album_id)) ...
python
def get_tracks_from_album(album_name): ''' Gets tracks from an album using Spotify's API ''' spotify = spotipy.Spotify() album = spotify.search(q='album:' + album_name, limit=1) album_id = album['tracks']['items'][0]['album']['id'] results = spotify.album_tracks(album_id=str(album_id)) ...
[ "def", "get_tracks_from_album", "(", "album_name", ")", ":", "spotify", "=", "spotipy", ".", "Spotify", "(", ")", "album", "=", "spotify", ".", "search", "(", "q", "=", "'album:'", "+", "album_name", ",", "limit", "=", "1", ")", "album_id", "=", "album",...
Gets tracks from an album using Spotify's API
[ "Gets", "tracks", "from", "an", "album", "using", "Spotify", "s", "API" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/command_line.py#L82-L96
train
62,992
kalbhor/MusicNow
musicnow/command_line.py
get_url
def get_url(song_input, auto): ''' Provides user with a list of songs to choose from returns the url of chosen song. ''' youtube_list = OrderedDict() num = 0 # List of songs index html = requests.get("https://www.youtube.com/results", params={'search_query': song_in...
python
def get_url(song_input, auto): ''' Provides user with a list of songs to choose from returns the url of chosen song. ''' youtube_list = OrderedDict() num = 0 # List of songs index html = requests.get("https://www.youtube.com/results", params={'search_query': song_in...
[ "def", "get_url", "(", "song_input", ",", "auto", ")", ":", "youtube_list", "=", "OrderedDict", "(", ")", "num", "=", "0", "# List of songs index", "html", "=", "requests", ".", "get", "(", "\"https://www.youtube.com/results\"", ",", "params", "=", "{", "'sear...
Provides user with a list of songs to choose from returns the url of chosen song.
[ "Provides", "user", "with", "a", "list", "of", "songs", "to", "choose", "from", "returns", "the", "url", "of", "chosen", "song", "." ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/command_line.py#L99-L135
train
62,993
kalbhor/MusicNow
musicnow/command_line.py
prompt
def prompt(youtube_list): ''' Prompts for song number from list of songs ''' option = int(input('\nEnter song number > ')) try: song_url = list(youtube_list.values())[option - 1] song_title = list(youtube_list.keys())[option - 1] except IndexError: log.log_error('Invalid...
python
def prompt(youtube_list): ''' Prompts for song number from list of songs ''' option = int(input('\nEnter song number > ')) try: song_url = list(youtube_list.values())[option - 1] song_title = list(youtube_list.keys())[option - 1] except IndexError: log.log_error('Invalid...
[ "def", "prompt", "(", "youtube_list", ")", ":", "option", "=", "int", "(", "input", "(", "'\\nEnter song number > '", ")", ")", "try", ":", "song_url", "=", "list", "(", "youtube_list", ".", "values", "(", ")", ")", "[", "option", "-", "1", "]", "song_...
Prompts for song number from list of songs
[ "Prompts", "for", "song", "number", "from", "list", "of", "songs" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/command_line.py#L138-L164
train
62,994
kalbhor/MusicNow
musicnow/command_line.py
main
def main(): ''' Starts here, handles arguments ''' system('clear') # Must be system('cls') for windows setup() parser = argparse.ArgumentParser( description='Download songs with album art and metadata!') parser.add_argument('-c', '--config', action='store_true', ...
python
def main(): ''' Starts here, handles arguments ''' system('clear') # Must be system('cls') for windows setup() parser = argparse.ArgumentParser( description='Download songs with album art and metadata!') parser.add_argument('-c', '--config', action='store_true', ...
[ "def", "main", "(", ")", ":", "system", "(", "'clear'", ")", "# Must be system('cls') for windows", "setup", "(", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Download songs with album art and metadata!'", ")", "parser", ".", "ad...
Starts here, handles arguments
[ "Starts", "here", "handles", "arguments" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/command_line.py#L189-L267
train
62,995
vpelletier/python-hidraw
hidraw/__init__.py
HIDRaw.getRawReportDescriptor
def getRawReportDescriptor(self): """ Return a binary string containing the raw HID report descriptor. """ descriptor = _hidraw_report_descriptor() size = ctypes.c_uint() self._ioctl(_HIDIOCGRDESCSIZE, size, True) descriptor.size = size self._ioctl(_HIDIOC...
python
def getRawReportDescriptor(self): """ Return a binary string containing the raw HID report descriptor. """ descriptor = _hidraw_report_descriptor() size = ctypes.c_uint() self._ioctl(_HIDIOCGRDESCSIZE, size, True) descriptor.size = size self._ioctl(_HIDIOC...
[ "def", "getRawReportDescriptor", "(", "self", ")", ":", "descriptor", "=", "_hidraw_report_descriptor", "(", ")", "size", "=", "ctypes", ".", "c_uint", "(", ")", "self", ".", "_ioctl", "(", "_HIDIOCGRDESCSIZE", ",", "size", ",", "True", ")", "descriptor", "....
Return a binary string containing the raw HID report descriptor.
[ "Return", "a", "binary", "string", "containing", "the", "raw", "HID", "report", "descriptor", "." ]
af6527160d2c0c0f61d737f383e35fd767ce25be
https://github.com/vpelletier/python-hidraw/blob/af6527160d2c0c0f61d737f383e35fd767ce25be/hidraw/__init__.py#L63-L72
train
62,996
vpelletier/python-hidraw
hidraw/__init__.py
HIDRaw.getName
def getName(self, length=512): """ Returns device name as an unicode object. """ name = ctypes.create_string_buffer(length) self._ioctl(_HIDIOCGRAWNAME(length), name, True) return name.value.decode('UTF-8')
python
def getName(self, length=512): """ Returns device name as an unicode object. """ name = ctypes.create_string_buffer(length) self._ioctl(_HIDIOCGRAWNAME(length), name, True) return name.value.decode('UTF-8')
[ "def", "getName", "(", "self", ",", "length", "=", "512", ")", ":", "name", "=", "ctypes", ".", "create_string_buffer", "(", "length", ")", "self", ".", "_ioctl", "(", "_HIDIOCGRAWNAME", "(", "length", ")", ",", "name", ",", "True", ")", "return", "nam...
Returns device name as an unicode object.
[ "Returns", "device", "name", "as", "an", "unicode", "object", "." ]
af6527160d2c0c0f61d737f383e35fd767ce25be
https://github.com/vpelletier/python-hidraw/blob/af6527160d2c0c0f61d737f383e35fd767ce25be/hidraw/__init__.py#L88-L94
train
62,997
vpelletier/python-hidraw
hidraw/__init__.py
HIDRaw.getPhysicalAddress
def getPhysicalAddress(self, length=512): """ Returns device physical address as a string. See hidraw documentation for value signification, as it depends on device's bus type. """ name = ctypes.create_string_buffer(length) self._ioctl(_HIDIOCGRAWPHYS(length), nam...
python
def getPhysicalAddress(self, length=512): """ Returns device physical address as a string. See hidraw documentation for value signification, as it depends on device's bus type. """ name = ctypes.create_string_buffer(length) self._ioctl(_HIDIOCGRAWPHYS(length), nam...
[ "def", "getPhysicalAddress", "(", "self", ",", "length", "=", "512", ")", ":", "name", "=", "ctypes", ".", "create_string_buffer", "(", "length", ")", "self", ".", "_ioctl", "(", "_HIDIOCGRAWPHYS", "(", "length", ")", ",", "name", ",", "True", ")", "retu...
Returns device physical address as a string. See hidraw documentation for value signification, as it depends on device's bus type.
[ "Returns", "device", "physical", "address", "as", "a", "string", ".", "See", "hidraw", "documentation", "for", "value", "signification", "as", "it", "depends", "on", "device", "s", "bus", "type", "." ]
af6527160d2c0c0f61d737f383e35fd767ce25be
https://github.com/vpelletier/python-hidraw/blob/af6527160d2c0c0f61d737f383e35fd767ce25be/hidraw/__init__.py#L96-L104
train
62,998
vpelletier/python-hidraw
hidraw/__init__.py
HIDRaw.sendFeatureReport
def sendFeatureReport(self, report, report_num=0): """ Send a feature report. """ length = len(report) + 1 buf = bytearray(length) buf[0] = report_num buf[1:] = report self._ioctl( _HIDIOCSFEATURE(length), (ctypes.c_char * length).f...
python
def sendFeatureReport(self, report, report_num=0): """ Send a feature report. """ length = len(report) + 1 buf = bytearray(length) buf[0] = report_num buf[1:] = report self._ioctl( _HIDIOCSFEATURE(length), (ctypes.c_char * length).f...
[ "def", "sendFeatureReport", "(", "self", ",", "report", ",", "report_num", "=", "0", ")", ":", "length", "=", "len", "(", "report", ")", "+", "1", "buf", "=", "bytearray", "(", "length", ")", "buf", "[", "0", "]", "=", "report_num", "buf", "[", "1"...
Send a feature report.
[ "Send", "a", "feature", "report", "." ]
af6527160d2c0c0f61d737f383e35fd767ce25be
https://github.com/vpelletier/python-hidraw/blob/af6527160d2c0c0f61d737f383e35fd767ce25be/hidraw/__init__.py#L106-L118
train
62,999