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
atmos-python/atmos
atmos/plot.py
SkewTAxes.semilogy
def semilogy(self, p, T, *args, **kwargs): r'''Plot data. Simple wrapper around plot so that pressure is the first (independent) input. This is essentially a wrapper around `semilogy`. Parameters ---------- p : array_like pressure values T : array_li...
python
def semilogy(self, p, T, *args, **kwargs): r'''Plot data. Simple wrapper around plot so that pressure is the first (independent) input. This is essentially a wrapper around `semilogy`. Parameters ---------- p : array_like pressure values T : array_li...
[ "def", "semilogy", "(", "self", ",", "p", ",", "T", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# We need to replace the overridden plot with the original Axis plot", "# since it is called within Axes.semilogy", "no_plot", "=", "SkewTAxes", ".", "plot", "Ske...
r'''Plot data. Simple wrapper around plot so that pressure is the first (independent) input. This is essentially a wrapper around `semilogy`. Parameters ---------- p : array_like pressure values T : array_like temperature values, can also be used...
[ "r", "Plot", "data", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/plot.py#L176-L226
train
60,900
atmos-python/atmos
atmos/plot.py
SkewTAxes.plot_barbs
def plot_barbs(self, p, u, v, xloc=1.0, x_clip_radius=0.08, y_clip_radius=0.08, **kwargs): r'''Plot wind barbs. Adds wind barbs to the skew-T plot. This is a wrapper around the `barbs` command that adds to appropriate transform to place the barbs in a vertical line, l...
python
def plot_barbs(self, p, u, v, xloc=1.0, x_clip_radius=0.08, y_clip_radius=0.08, **kwargs): r'''Plot wind barbs. Adds wind barbs to the skew-T plot. This is a wrapper around the `barbs` command that adds to appropriate transform to place the barbs in a vertical line, l...
[ "def", "plot_barbs", "(", "self", ",", "p", ",", "u", ",", "v", ",", "xloc", "=", "1.0", ",", "x_clip_radius", "=", "0.08", ",", "y_clip_radius", "=", "0.08", ",", "*", "*", "kwargs", ")", ":", "#kwargs.setdefault('length', 7)", "# Assemble array of x-locati...
r'''Plot wind barbs. Adds wind barbs to the skew-T plot. This is a wrapper around the `barbs` command that adds to appropriate transform to place the barbs in a vertical line, located as a function of pressure. Parameters ---------- p : array_like pressure v...
[ "r", "Plot", "wind", "barbs", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/plot.py#L274-L321
train
60,901
atmos-python/atmos
atmos/plot.py
SkewTAxes.plot_dry_adiabats
def plot_dry_adiabats(self, p=None, theta=None, **kwargs): r'''Plot dry adiabats. Adds dry adiabats (lines of constant potential temperature) to the plot. The default style of these lines is dashed red lines with an alpha value of 0.5. These can be overridden using keyword arguments. ...
python
def plot_dry_adiabats(self, p=None, theta=None, **kwargs): r'''Plot dry adiabats. Adds dry adiabats (lines of constant potential temperature) to the plot. The default style of these lines is dashed red lines with an alpha value of 0.5. These can be overridden using keyword arguments. ...
[ "def", "plot_dry_adiabats", "(", "self", ",", "p", "=", "None", ",", "theta", "=", "None", ",", "*", "*", "kwargs", ")", ":", "for", "artist", "in", "self", ".", "_dry_adiabats", ":", "artist", ".", "remove", "(", ")", "self", ".", "_dry_adiabats", "...
r'''Plot dry adiabats. Adds dry adiabats (lines of constant potential temperature) to the plot. The default style of these lines is dashed red lines with an alpha value of 0.5. These can be overridden using keyword arguments. Parameters ---------- p : array_like, option...
[ "r", "Plot", "dry", "adiabats", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/plot.py#L323-L389
train
60,902
atmos-python/atmos
atmos/plot.py
SkewTAxes.plot_mixing_lines
def plot_mixing_lines(self, p=None, rv=None, **kwargs): r'''Plot lines of constant mixing ratio. Adds lines of constant mixing ratio (isohumes) to the plot. The default style of these lines is dashed green lines with an alpha value of 0.8. These can be overridden using keyword arguments...
python
def plot_mixing_lines(self, p=None, rv=None, **kwargs): r'''Plot lines of constant mixing ratio. Adds lines of constant mixing ratio (isohumes) to the plot. The default style of these lines is dashed green lines with an alpha value of 0.8. These can be overridden using keyword arguments...
[ "def", "plot_mixing_lines", "(", "self", ",", "p", "=", "None", ",", "rv", "=", "None", ",", "*", "*", "kwargs", ")", ":", "for", "artist", "in", "self", ".", "_mixing_lines", ":", "artist", ".", "remove", "(", ")", "self", ".", "_mixing_lines", "=",...
r'''Plot lines of constant mixing ratio. Adds lines of constant mixing ratio (isohumes) to the plot. The default style of these lines is dashed green lines with an alpha value of 0.8. These can be overridden using keyword arguments. Parameters ---------- rv : array_like...
[ "r", "Plot", "lines", "of", "constant", "mixing", "ratio", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/plot.py#L486-L559
train
60,903
atmos-python/atmos
atmos/solve.py
get_calculatable_quantities
def get_calculatable_quantities(inputs, methods): ''' Given an interable of input quantity names and a methods dictionary, returns a list of output quantities that can be calculated. ''' output_quantities = [] updated = True while updated: updated = False for output in method...
python
def get_calculatable_quantities(inputs, methods): ''' Given an interable of input quantity names and a methods dictionary, returns a list of output quantities that can be calculated. ''' output_quantities = [] updated = True while updated: updated = False for output in method...
[ "def", "get_calculatable_quantities", "(", "inputs", ",", "methods", ")", ":", "output_quantities", "=", "[", "]", "updated", "=", "True", "while", "updated", ":", "updated", "=", "False", "for", "output", "in", "methods", ".", "keys", "(", ")", ":", "if",...
Given an interable of input quantity names and a methods dictionary, returns a list of output quantities that can be calculated.
[ "Given", "an", "interable", "of", "input", "quantity", "names", "and", "a", "methods", "dictionary", "returns", "a", "list", "of", "output", "quantities", "that", "can", "be", "calculated", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/solve.py#L32-L51
train
60,904
atmos-python/atmos
atmos/solve.py
_get_methods_that_calculate_outputs
def _get_methods_that_calculate_outputs(inputs, outputs, methods): ''' Given iterables of input variable names, output variable names, and a methods dictionary, returns the subset of the methods dictionary that can be calculated, doesn't calculate something we already have, and only contains equatio...
python
def _get_methods_that_calculate_outputs(inputs, outputs, methods): ''' Given iterables of input variable names, output variable names, and a methods dictionary, returns the subset of the methods dictionary that can be calculated, doesn't calculate something we already have, and only contains equatio...
[ "def", "_get_methods_that_calculate_outputs", "(", "inputs", ",", "outputs", ",", "methods", ")", ":", "# Get a list of everything that we can possibly calculate", "# This is useful in figuring out whether we can calculate arguments", "intermediates", "=", "get_calculatable_quantities", ...
Given iterables of input variable names, output variable names, and a methods dictionary, returns the subset of the methods dictionary that can be calculated, doesn't calculate something we already have, and only contains equations that might help calculate the outputs from the inputs.
[ "Given", "iterables", "of", "input", "variable", "names", "output", "variable", "names", "and", "a", "methods", "dictionary", "returns", "the", "subset", "of", "the", "methods", "dictionary", "that", "can", "be", "calculated", "doesn", "t", "calculate", "somethi...
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/solve.py#L54-L111
train
60,905
atmos-python/atmos
atmos/solve.py
_get_calculatable_methods_dict
def _get_calculatable_methods_dict(inputs, methods): ''' Given an iterable of input variable names and a methods dictionary, returns the subset of that methods dictionary that can be calculated and which doesn't calculate something we already have. Additionally it may only contain one method for any...
python
def _get_calculatable_methods_dict(inputs, methods): ''' Given an iterable of input variable names and a methods dictionary, returns the subset of that methods dictionary that can be calculated and which doesn't calculate something we already have. Additionally it may only contain one method for any...
[ "def", "_get_calculatable_methods_dict", "(", "inputs", ",", "methods", ")", ":", "# Initialize a return dictionary", "calculatable_methods", "=", "{", "}", "# Iterate through each potential method output", "for", "var", "in", "methods", ".", "keys", "(", ")", ":", "# S...
Given an iterable of input variable names and a methods dictionary, returns the subset of that methods dictionary that can be calculated and which doesn't calculate something we already have. Additionally it may only contain one method for any given output variable, which is the one with the fewest poss...
[ "Given", "an", "iterable", "of", "input", "variable", "names", "and", "a", "methods", "dictionary", "returns", "the", "subset", "of", "that", "methods", "dictionary", "that", "can", "be", "calculated", "and", "which", "doesn", "t", "calculate", "something", "w...
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/solve.py#L114-L147
train
60,906
atmos-python/atmos
atmos/solve.py
_get_module_methods
def _get_module_methods(module): ''' Returns a methods list corresponding to the equations in the given module. Each entry is a dictionary with keys 'output', 'args', and 'func' corresponding to the output, arguments, and function of the method. The entries may optionally include 'assumptions' and ...
python
def _get_module_methods(module): ''' Returns a methods list corresponding to the equations in the given module. Each entry is a dictionary with keys 'output', 'args', and 'func' corresponding to the output, arguments, and function of the method. The entries may optionally include 'assumptions' and ...
[ "def", "_get_module_methods", "(", "module", ")", ":", "# Set up the methods dict we will eventually return", "methods", "=", "[", "]", "funcs", "=", "[", "]", "for", "item", "in", "inspect", ".", "getmembers", "(", "equations", ")", ":", "if", "(", "item", "[...
Returns a methods list corresponding to the equations in the given module. Each entry is a dictionary with keys 'output', 'args', and 'func' corresponding to the output, arguments, and function of the method. The entries may optionally include 'assumptions' and 'overridden_by_assumptions' as keys, stati...
[ "Returns", "a", "methods", "list", "corresponding", "to", "the", "equations", "in", "the", "given", "module", ".", "Each", "entry", "is", "a", "dictionary", "with", "keys", "output", "args", "and", "func", "corresponding", "to", "the", "output", "arguments", ...
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/solve.py#L217-L257
train
60,907
atmos-python/atmos
atmos/solve.py
_check_scalar
def _check_scalar(value): '''If value is a 0-dimensional array, returns the contents of value. Otherwise, returns value. ''' if isinstance(value, np.ndarray): if value.ndim == 0: # We have a 0-dimensional array return value[None][0] return value
python
def _check_scalar(value): '''If value is a 0-dimensional array, returns the contents of value. Otherwise, returns value. ''' if isinstance(value, np.ndarray): if value.ndim == 0: # We have a 0-dimensional array return value[None][0] return value
[ "def", "_check_scalar", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "np", ".", "ndarray", ")", ":", "if", "value", ".", "ndim", "==", "0", ":", "# We have a 0-dimensional array", "return", "value", "[", "None", "]", "[", "0", "]", "r...
If value is a 0-dimensional array, returns the contents of value. Otherwise, returns value.
[ "If", "value", "is", "a", "0", "-", "dimensional", "array", "returns", "the", "contents", "of", "value", ".", "Otherwise", "returns", "value", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/solve.py#L285-L293
train
60,908
atmos-python/atmos
atmos/solve.py
calculate
def calculate(*args, **kwargs): ''' Calculates and returns a requested quantity from quantities passed in as keyword arguments. Parameters ---------- \*args : string Names of quantities to be calculated. assumptions : tuple, optional Strings specifying which assumptions to enable. Overrides the default ...
python
def calculate(*args, **kwargs): ''' Calculates and returns a requested quantity from quantities passed in as keyword arguments. Parameters ---------- \*args : string Names of quantities to be calculated. assumptions : tuple, optional Strings specifying which assumptions to enable. Overrides the default ...
[ "def", "calculate", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "raise", "ValueError", "(", "'must specify quantities to calculate'", ")", "# initialize a solver to do the work", "solver", "=", "FluidSolver...
Calculates and returns a requested quantity from quantities passed in as keyword arguments. Parameters ---------- \*args : string Names of quantities to be calculated. assumptions : tuple, optional Strings specifying which assumptions to enable. Overrides the default assumptions. See below for a list of d...
[ "Calculates", "and", "returns", "a", "requested", "quantity", "from", "quantities", "passed", "in", "as", "keyword", "arguments", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/solve.py#L736-L822
train
60,909
cls1991/ng
ng.py
ip
def ip(): """Show ip address.""" ok, err = _hack_ip() if not ok: click.secho(click.style(err, fg='red')) sys.exit(1) click.secho(click.style(err, fg='green'))
python
def ip(): """Show ip address.""" ok, err = _hack_ip() if not ok: click.secho(click.style(err, fg='red')) sys.exit(1) click.secho(click.style(err, fg='green'))
[ "def", "ip", "(", ")", ":", "ok", ",", "err", "=", "_hack_ip", "(", ")", "if", "not", "ok", ":", "click", ".", "secho", "(", "click", ".", "style", "(", "err", ",", "fg", "=", "'red'", ")", ")", "sys", ".", "exit", "(", "1", ")", "click", "...
Show ip address.
[ "Show", "ip", "address", "." ]
e975fa6c6e39067737ba4e54ee8eec605bb94b86
https://github.com/cls1991/ng/blob/e975fa6c6e39067737ba4e54ee8eec605bb94b86/ng.py#L153-L159
train
60,910
cls1991/ng
ng.py
wp
def wp(ssid): """Show wifi password.""" if not ssid: ok, err = _detect_wifi_ssid() if not ok: click.secho(click.style(err, fg='red')) sys.exit(1) ssid = err ok, err = _hack_wifi_password(ssid) if not ok: click.secho(click.style(err, fg='red')) ...
python
def wp(ssid): """Show wifi password.""" if not ssid: ok, err = _detect_wifi_ssid() if not ok: click.secho(click.style(err, fg='red')) sys.exit(1) ssid = err ok, err = _hack_wifi_password(ssid) if not ok: click.secho(click.style(err, fg='red')) ...
[ "def", "wp", "(", "ssid", ")", ":", "if", "not", "ssid", ":", "ok", ",", "err", "=", "_detect_wifi_ssid", "(", ")", "if", "not", "ok", ":", "click", ".", "secho", "(", "click", ".", "style", "(", "err", ",", "fg", "=", "'red'", ")", ")", "sys",...
Show wifi password.
[ "Show", "wifi", "password", "." ]
e975fa6c6e39067737ba4e54ee8eec605bb94b86
https://github.com/cls1991/ng/blob/e975fa6c6e39067737ba4e54ee8eec605bb94b86/ng.py#L164-L176
train
60,911
bharadwajyarlagadda/bingmaps
bingmaps/apiservices/elevations.py
ElevationsApi.build_url
def build_url(self): """Builds the URL for elevations API services based on the data given by the user. Returns: url (str): URL for the elevations API services """ url = '{protocol}/{url}/{rest}/{version}/{restapi}/{rscpath}/' \ '{query}'.format(protoco...
python
def build_url(self): """Builds the URL for elevations API services based on the data given by the user. Returns: url (str): URL for the elevations API services """ url = '{protocol}/{url}/{rest}/{version}/{restapi}/{rscpath}/' \ '{query}'.format(protoco...
[ "def", "build_url", "(", "self", ")", ":", "url", "=", "'{protocol}/{url}/{rest}/{version}/{restapi}/{rscpath}/'", "'{query}'", ".", "format", "(", "protocol", "=", "self", ".", "schema", ".", "protocol", ",", "url", "=", "self", ".", "schema", ".", "main_url", ...
Builds the URL for elevations API services based on the data given by the user. Returns: url (str): URL for the elevations API services
[ "Builds", "the", "URL", "for", "elevations", "API", "services", "based", "on", "the", "data", "given", "by", "the", "user", "." ]
6bb3cdadfb121aaff96704509cedff2710a62b6d
https://github.com/bharadwajyarlagadda/bingmaps/blob/6bb3cdadfb121aaff96704509cedff2710a62b6d/bingmaps/apiservices/elevations.py#L72-L87
train
60,912
bharadwajyarlagadda/bingmaps
bingmaps/apiservices/elevations.py
ElevationsApi.zoomlevel
def zoomlevel(self): """Retrieves zoomlevel from the output response Returns: zoomlevel (namedtuple): A namedtuple of zoomlevel from the output response """ resources = self.get_resource() zoomlevel = namedtuple('zoomlevel', 'zoomLevel') try: ...
python
def zoomlevel(self): """Retrieves zoomlevel from the output response Returns: zoomlevel (namedtuple): A namedtuple of zoomlevel from the output response """ resources = self.get_resource() zoomlevel = namedtuple('zoomlevel', 'zoomLevel') try: ...
[ "def", "zoomlevel", "(", "self", ")", ":", "resources", "=", "self", ".", "get_resource", "(", ")", "zoomlevel", "=", "namedtuple", "(", "'zoomlevel'", ",", "'zoomLevel'", ")", "try", ":", "return", "[", "zoomlevel", "(", "resource", "[", "'zoomLevel'", "]...
Retrieves zoomlevel from the output response Returns: zoomlevel (namedtuple): A namedtuple of zoomlevel from the output response
[ "Retrieves", "zoomlevel", "from", "the", "output", "response" ]
6bb3cdadfb121aaff96704509cedff2710a62b6d
https://github.com/bharadwajyarlagadda/bingmaps/blob/6bb3cdadfb121aaff96704509cedff2710a62b6d/bingmaps/apiservices/elevations.py#L165-L187
train
60,913
bharadwajyarlagadda/bingmaps
bingmaps/apiservices/elevations.py
ElevationsApi.to_json_file
def to_json_file(self, path, file_name=None): """Writes output to a JSON file with the given file name""" if bool(path) and os.path.isdir(path): self.write_to_json(path, file_name) else: self.write_to_json(os.getcwd(), file_name)
python
def to_json_file(self, path, file_name=None): """Writes output to a JSON file with the given file name""" if bool(path) and os.path.isdir(path): self.write_to_json(path, file_name) else: self.write_to_json(os.getcwd(), file_name)
[ "def", "to_json_file", "(", "self", ",", "path", ",", "file_name", "=", "None", ")", ":", "if", "bool", "(", "path", ")", "and", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "self", ".", "write_to_json", "(", "path", ",", "file_name", ")...
Writes output to a JSON file with the given file name
[ "Writes", "output", "to", "a", "JSON", "file", "with", "the", "given", "file", "name" ]
6bb3cdadfb121aaff96704509cedff2710a62b6d
https://github.com/bharadwajyarlagadda/bingmaps/blob/6bb3cdadfb121aaff96704509cedff2710a62b6d/bingmaps/apiservices/elevations.py#L189-L194
train
60,914
bharadwajyarlagadda/bingmaps
bingmaps/apiservices/locations.py
LocationByAddress.get_data
def get_data(self): """Gets data from the built url""" url = self.build_url() self.locationApiData = requests.get(url) if not self.locationApiData.status_code == 200: raise self.locationApiData.raise_for_status()
python
def get_data(self): """Gets data from the built url""" url = self.build_url() self.locationApiData = requests.get(url) if not self.locationApiData.status_code == 200: raise self.locationApiData.raise_for_status()
[ "def", "get_data", "(", "self", ")", ":", "url", "=", "self", ".", "build_url", "(", ")", "self", ".", "locationApiData", "=", "requests", ".", "get", "(", "url", ")", "if", "not", "self", ".", "locationApiData", ".", "status_code", "==", "200", ":", ...
Gets data from the built url
[ "Gets", "data", "from", "the", "built", "url" ]
6bb3cdadfb121aaff96704509cedff2710a62b6d
https://github.com/bharadwajyarlagadda/bingmaps/blob/6bb3cdadfb121aaff96704509cedff2710a62b6d/bingmaps/apiservices/locations.py#L201-L206
train
60,915
cqlengine/cqlengine
cqlengine/management.py
update_compaction
def update_compaction(model): """Updates the compaction options for the given model if necessary. :param model: The model to update. :return: `True`, if the compaction options were modified in Cassandra, `False` otherwise. :rtype: bool """ logger.debug("Checking %s for compaction diffe...
python
def update_compaction(model): """Updates the compaction options for the given model if necessary. :param model: The model to update. :return: `True`, if the compaction options were modified in Cassandra, `False` otherwise. :rtype: bool """ logger.debug("Checking %s for compaction diffe...
[ "def", "update_compaction", "(", "model", ")", ":", "logger", ".", "debug", "(", "\"Checking %s for compaction differences\"", ",", "model", ")", "table", "=", "get_table_settings", "(", "model", ")", "existing_options", "=", "table", ".", "options", ".", "copy", ...
Updates the compaction options for the given model if necessary. :param model: The model to update. :return: `True`, if the compaction options were modified in Cassandra, `False` otherwise. :rtype: bool
[ "Updates", "the", "compaction", "options", "for", "the", "given", "model", "if", "necessary", "." ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/management.py#L254-L299
train
60,916
cqlengine/cqlengine
cqlengine/connection.py
setup
def setup( hosts, default_keyspace, consistency=ConsistencyLevel.ONE, lazy_connect=False, retry_connect=False, **kwargs): """ Records the hosts and connects to one of them :param hosts: list of hosts, see http://datastax.github.io/python-driver/api/cassandra/...
python
def setup( hosts, default_keyspace, consistency=ConsistencyLevel.ONE, lazy_connect=False, retry_connect=False, **kwargs): """ Records the hosts and connects to one of them :param hosts: list of hosts, see http://datastax.github.io/python-driver/api/cassandra/...
[ "def", "setup", "(", "hosts", ",", "default_keyspace", ",", "consistency", "=", "ConsistencyLevel", ".", "ONE", ",", "lazy_connect", "=", "False", ",", "retry_connect", "=", "False", ",", "*", "*", "kwargs", ")", ":", "global", "cluster", ",", "session", "...
Records the hosts and connects to one of them :param hosts: list of hosts, see http://datastax.github.io/python-driver/api/cassandra/cluster.html :type hosts: list :param default_keyspace: The default keyspace to use :type default_keyspace: str :param consistency: The global consistency level :...
[ "Records", "the", "hosts", "and", "connects", "to", "one", "of", "them" ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/connection.py#L29-L81
train
60,917
cqlengine/cqlengine
cqlengine/columns.py
Column.validate
def validate(self, value): """ Returns a cleaned and validated value. Raises a ValidationError if there's a problem """ if value is None: if self.required: raise ValidationError('{} - None values are not allowed'.format(self.column_name or self.db_fiel...
python
def validate(self, value): """ Returns a cleaned and validated value. Raises a ValidationError if there's a problem """ if value is None: if self.required: raise ValidationError('{} - None values are not allowed'.format(self.column_name or self.db_fiel...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "if", "self", ".", "required", ":", "raise", "ValidationError", "(", "'{} - None values are not allowed'", ".", "format", "(", "self", ".", "column_name", "or", "self",...
Returns a cleaned and validated value. Raises a ValidationError if there's a problem
[ "Returns", "a", "cleaned", "and", "validated", "value", ".", "Raises", "a", "ValidationError", "if", "there", "s", "a", "problem" ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/columns.py#L138-L146
train
60,918
cqlengine/cqlengine
cqlengine/columns.py
TimeUUID.from_datetime
def from_datetime(self, dt): """ generates a UUID for a given datetime :param dt: datetime :type dt: datetime :return: """ global _last_timestamp epoch = datetime(1970, 1, 1, tzinfo=dt.tzinfo) offset = epoch.tzinfo.utcoffset(epoch).total_seconds(...
python
def from_datetime(self, dt): """ generates a UUID for a given datetime :param dt: datetime :type dt: datetime :return: """ global _last_timestamp epoch = datetime(1970, 1, 1, tzinfo=dt.tzinfo) offset = epoch.tzinfo.utcoffset(epoch).total_seconds(...
[ "def", "from_datetime", "(", "self", ",", "dt", ")", ":", "global", "_last_timestamp", "epoch", "=", "datetime", "(", "1970", ",", "1", ",", "1", ",", "tzinfo", "=", "dt", ".", "tzinfo", ")", "offset", "=", "epoch", ".", "tzinfo", ".", "utcoffset", "...
generates a UUID for a given datetime :param dt: datetime :type dt: datetime :return:
[ "generates", "a", "UUID", "for", "a", "given", "datetime" ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/columns.py#L419-L450
train
60,919
cqlengine/cqlengine
cqlengine/models.py
BaseModel._can_update
def _can_update(self): """ Called by the save function to check if this should be persisted with update or insert :return: """ if not self._is_persisted: return False pks = self._primary_keys.keys() return all([not self._values[k].changed for k in self._p...
python
def _can_update(self): """ Called by the save function to check if this should be persisted with update or insert :return: """ if not self._is_persisted: return False pks = self._primary_keys.keys() return all([not self._values[k].changed for k in self._p...
[ "def", "_can_update", "(", "self", ")", ":", "if", "not", "self", ".", "_is_persisted", ":", "return", "False", "pks", "=", "self", ".", "_primary_keys", ".", "keys", "(", ")", "return", "all", "(", "[", "not", "self", ".", "_values", "[", "k", "]", ...
Called by the save function to check if this should be persisted with update or insert :return:
[ "Called", "by", "the", "save", "function", "to", "check", "if", "this", "should", "be", "persisted", "with", "update", "or", "insert" ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/models.py#L420-L429
train
60,920
cqlengine/cqlengine
cqlengine/models.py
BaseModel.delete
def delete(self): """ Deletes this instance """ self.__dmlquery__(self.__class__, self, batch=self._batch, timestamp=self._timestamp, consistency=self.__consistency__, timeout=self._timeout).delete()
python
def delete(self): """ Deletes this instance """ self.__dmlquery__(self.__class__, self, batch=self._batch, timestamp=self._timestamp, consistency=self.__consistency__, timeout=self._timeout).delete()
[ "def", "delete", "(", "self", ")", ":", "self", ".", "__dmlquery__", "(", "self", ".", "__class__", ",", "self", ",", "batch", "=", "self", ".", "_batch", ",", "timestamp", "=", "self", ".", "_timestamp", ",", "consistency", "=", "self", ".", "__consis...
Deletes this instance
[ "Deletes", "this", "instance" ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/models.py#L647-L653
train
60,921
cqlengine/cqlengine
cqlengine/query.py
AbstractQuerySet.filter
def filter(self, *args, **kwargs): """ Adds WHERE arguments to the queryset, returning a new queryset #TODO: show examples :rtype: AbstractQuerySet """ #add arguments to the where clause filters if len([x for x in kwargs.values() if x is None]): rais...
python
def filter(self, *args, **kwargs): """ Adds WHERE arguments to the queryset, returning a new queryset #TODO: show examples :rtype: AbstractQuerySet """ #add arguments to the where clause filters if len([x for x in kwargs.values() if x is None]): rais...
[ "def", "filter", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#add arguments to the where clause filters", "if", "len", "(", "[", "x", "for", "x", "in", "kwargs", ".", "values", "(", ")", "if", "x", "is", "None", "]", ")", ":", ...
Adds WHERE arguments to the queryset, returning a new queryset #TODO: show examples :rtype: AbstractQuerySet
[ "Adds", "WHERE", "arguments", "to", "the", "queryset", "returning", "a", "new", "queryset" ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/query.py#L463-L521
train
60,922
cqlengine/cqlengine
cqlengine/query.py
AbstractQuerySet.order_by
def order_by(self, *colnames): """ orders the result set. ordering can only use clustering columns. Default order is ascending, prepend a '-' to the column name for descending """ if len(colnames) == 0: clone = copy.deepcopy(self) clone._order = [...
python
def order_by(self, *colnames): """ orders the result set. ordering can only use clustering columns. Default order is ascending, prepend a '-' to the column name for descending """ if len(colnames) == 0: clone = copy.deepcopy(self) clone._order = [...
[ "def", "order_by", "(", "self", ",", "*", "colnames", ")", ":", "if", "len", "(", "colnames", ")", "==", "0", ":", "clone", "=", "copy", ".", "deepcopy", "(", "self", ")", "clone", ".", "_order", "=", "[", "]", "return", "clone", "conditions", "=",...
orders the result set. ordering can only use clustering columns. Default order is ascending, prepend a '-' to the column name for descending
[ "orders", "the", "result", "set", ".", "ordering", "can", "only", "use", "clustering", "columns", "." ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/query.py#L548-L566
train
60,923
cqlengine/cqlengine
cqlengine/query.py
AbstractQuerySet.count
def count(self): """ Returns the number of rows matched by this query """ if self._batch: raise CQLEngineException("Only inserts, updates, and deletes are available in batch mode") if self._result_cache is None: query = self._select_query() query.count = True...
python
def count(self): """ Returns the number of rows matched by this query """ if self._batch: raise CQLEngineException("Only inserts, updates, and deletes are available in batch mode") if self._result_cache is None: query = self._select_query() query.count = True...
[ "def", "count", "(", "self", ")", ":", "if", "self", ".", "_batch", ":", "raise", "CQLEngineException", "(", "\"Only inserts, updates, and deletes are available in batch mode\"", ")", "if", "self", ".", "_result_cache", "is", "None", ":", "query", "=", "self", "."...
Returns the number of rows matched by this query
[ "Returns", "the", "number", "of", "rows", "matched", "by", "this", "query" ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/query.py#L568-L579
train
60,924
cqlengine/cqlengine
cqlengine/query.py
AbstractQuerySet.limit
def limit(self, v): """ Sets the limit on the number of results returned CQL has a default limit of 10,000 """ if not (v is None or isinstance(v, six.integer_types)): raise TypeError if v == self._limit: return self if v < 0: r...
python
def limit(self, v): """ Sets the limit on the number of results returned CQL has a default limit of 10,000 """ if not (v is None or isinstance(v, six.integer_types)): raise TypeError if v == self._limit: return self if v < 0: r...
[ "def", "limit", "(", "self", ",", "v", ")", ":", "if", "not", "(", "v", "is", "None", "or", "isinstance", "(", "v", ",", "six", ".", "integer_types", ")", ")", ":", "raise", "TypeError", "if", "v", "==", "self", ".", "_limit", ":", "return", "sel...
Sets the limit on the number of results returned CQL has a default limit of 10,000
[ "Sets", "the", "limit", "on", "the", "number", "of", "results", "returned", "CQL", "has", "a", "default", "limit", "of", "10", "000" ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/query.py#L581-L596
train
60,925
cqlengine/cqlengine
cqlengine/query.py
ModelQuerySet.update
def update(self, **values): """ Updates the rows in this queryset """ if not values: return nulled_columns = set() us = UpdateStatement(self.column_family_name, where=self._where, ttl=self._ttl, timestamp=self._timestamp, transactions=self._trans...
python
def update(self, **values): """ Updates the rows in this queryset """ if not values: return nulled_columns = set() us = UpdateStatement(self.column_family_name, where=self._where, ttl=self._ttl, timestamp=self._timestamp, transactions=self._trans...
[ "def", "update", "(", "self", ",", "*", "*", "values", ")", ":", "if", "not", "values", ":", "return", "nulled_columns", "=", "set", "(", ")", "us", "=", "UpdateStatement", "(", "self", ".", "column_family_name", ",", "where", "=", "self", ".", "_where...
Updates the rows in this queryset
[ "Updates", "the", "rows", "in", "this", "queryset" ]
7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc
https://github.com/cqlengine/cqlengine/blob/7079eaf7071cbf5a045e1d1ab57f6d1b5ba3f9dc/cqlengine/query.py#L793-L841
train
60,926
guyskk/pybeautifier
pybeautifier.py
handle
def handle(client, request): """ Handle format request request struct: { 'data': 'data_need_format', 'formaters': [ { 'name': 'formater_name', 'config': {} # None or dict }, ... # forma...
python
def handle(client, request): """ Handle format request request struct: { 'data': 'data_need_format', 'formaters': [ { 'name': 'formater_name', 'config': {} # None or dict }, ... # forma...
[ "def", "handle", "(", "client", ",", "request", ")", ":", "formaters", "=", "request", ".", "get", "(", "'formaters'", ",", "None", ")", "if", "not", "formaters", ":", "formaters", "=", "[", "{", "'name'", ":", "'autopep8'", "}", "]", "logging", ".", ...
Handle format request request struct: { 'data': 'data_need_format', 'formaters': [ { 'name': 'formater_name', 'config': {} # None or dict }, ... # formaters ] } if no f...
[ "Handle", "format", "request" ]
bf9ce19d059c3364c690947d91077183b0adb4fc
https://github.com/guyskk/pybeautifier/blob/bf9ce19d059c3364c690947d91077183b0adb4fc/pybeautifier.py#L72-L116
train
60,927
asweigart/pytweening
pytweening/__init__.py
easeInOutQuad
def easeInOutQuad(n): """A quadratic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine...
python
def easeInOutQuad(n): """A quadratic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine...
[ "def", "easeInOutQuad", "(", "n", ")", ":", "_checkRange", "(", "n", ")", "if", "n", "<", "0.5", ":", "return", "2", "*", "n", "**", "2", "else", ":", "n", "=", "n", "*", "2", "-", "1", "return", "-", "0.5", "*", "(", "n", "*", "(", "n", ...
A quadratic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "A", "quadratic", "tween", "function", "that", "accelerates", "reaches", "the", "midpoint", "and", "then", "decelerates", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L156-L170
train
60,928
asweigart/pytweening
pytweening/__init__.py
easeInOutCubic
def easeInOutCubic(n): """A cubic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine()....
python
def easeInOutCubic(n): """A cubic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine()....
[ "def", "easeInOutCubic", "(", "n", ")", ":", "_checkRange", "(", "n", ")", "n", "=", "2", "*", "n", "if", "n", "<", "1", ":", "return", "0.5", "*", "n", "**", "3", "else", ":", "n", "=", "n", "-", "2", "return", "0.5", "*", "(", "n", "**", ...
A cubic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "A", "cubic", "tween", "function", "that", "accelerates", "reaches", "the", "midpoint", "and", "then", "decelerates", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L200-L215
train
60,929
asweigart/pytweening
pytweening/__init__.py
easeInOutQuart
def easeInOutQuart(n): """A quartic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(...
python
def easeInOutQuart(n): """A quartic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(...
[ "def", "easeInOutQuart", "(", "n", ")", ":", "_checkRange", "(", "n", ")", "n", "=", "2", "*", "n", "if", "n", "<", "1", ":", "return", "0.5", "*", "n", "**", "4", "else", ":", "n", "=", "n", "-", "2", "return", "-", "0.5", "*", "(", "n", ...
A quartic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "A", "quartic", "tween", "function", "that", "accelerates", "reaches", "the", "midpoint", "and", "then", "decelerates", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L245-L260
train
60,930
asweigart/pytweening
pytweening/__init__.py
easeInOutQuint
def easeInOutQuint(n): """A quintic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(...
python
def easeInOutQuint(n): """A quintic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(...
[ "def", "easeInOutQuint", "(", "n", ")", ":", "_checkRange", "(", "n", ")", "n", "=", "2", "*", "n", "if", "n", "<", "1", ":", "return", "0.5", "*", "n", "**", "5", "else", ":", "n", "=", "n", "-", "2", "return", "0.5", "*", "(", "n", "**", ...
A quintic tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "A", "quintic", "tween", "function", "that", "accelerates", "reaches", "the", "midpoint", "and", "then", "decelerates", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L290-L305
train
60,931
asweigart/pytweening
pytweening/__init__.py
easeInOutExpo
def easeInOutExpo(n): """An exponential tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnL...
python
def easeInOutExpo(n): """An exponential tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnL...
[ "def", "easeInOutExpo", "(", "n", ")", ":", "_checkRange", "(", "n", ")", "if", "n", "==", "0", ":", "return", "0", "elif", "n", "==", "1", ":", "return", "1", "else", ":", "n", "=", "n", "*", "2", "if", "n", "<", "1", ":", "return", "0.5", ...
An exponential tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "An", "exponential", "tween", "function", "that", "accelerates", "reaches", "the", "midpoint", "and", "then", "decelerates", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L379-L400
train
60,932
asweigart/pytweening
pytweening/__init__.py
easeInOutCirc
def easeInOutCirc(n): """A circular tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(...
python
def easeInOutCirc(n): """A circular tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(...
[ "def", "easeInOutCirc", "(", "n", ")", ":", "_checkRange", "(", "n", ")", "n", "=", "n", "*", "2", "if", "n", "<", "1", ":", "return", "-", "0.5", "*", "(", "math", ".", "sqrt", "(", "1", "-", "n", "**", "2", ")", "-", "1", ")", "else", "...
A circular tween function that accelerates, reaches the midpoint, and then decelerates. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "A", "circular", "tween", "function", "that", "accelerates", "reaches", "the", "midpoint", "and", "then", "decelerates", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L430-L445
train
60,933
asweigart/pytweening
pytweening/__init__.py
easeInElastic
def easeInElastic(n, amplitude=1, period=0.3): """An elastic tween function that begins with an increasing wobble and then snaps into the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. S...
python
def easeInElastic(n, amplitude=1, period=0.3): """An elastic tween function that begins with an increasing wobble and then snaps into the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. S...
[ "def", "easeInElastic", "(", "n", ",", "amplitude", "=", "1", ",", "period", "=", "0.3", ")", ":", "_checkRange", "(", "n", ")", "return", "1", "-", "easeOutElastic", "(", "1", "-", "n", ",", "amplitude", "=", "amplitude", ",", "period", "=", "period...
An elastic tween function that begins with an increasing wobble and then snaps into the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "An", "elastic", "tween", "function", "that", "begins", "with", "an", "increasing", "wobble", "and", "then", "snaps", "into", "the", "destination", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L448-L458
train
60,934
asweigart/pytweening
pytweening/__init__.py
easeOutElastic
def easeOutElastic(n, amplitude=1, period=0.3): """An elastic tween function that overshoots the destination and then "rubber bands" into the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1....
python
def easeOutElastic(n, amplitude=1, period=0.3): """An elastic tween function that overshoots the destination and then "rubber bands" into the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1....
[ "def", "easeOutElastic", "(", "n", ",", "amplitude", "=", "1", ",", "period", "=", "0.3", ")", ":", "_checkRange", "(", "n", ")", "if", "amplitude", "<", "1", ":", "amplitude", "=", "1", "s", "=", "period", "/", "4", "else", ":", "s", "=", "perio...
An elastic tween function that overshoots the destination and then "rubber bands" into the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "An", "elastic", "tween", "function", "that", "overshoots", "the", "destination", "and", "then", "rubber", "bands", "into", "the", "destination", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L461-L478
train
60,935
asweigart/pytweening
pytweening/__init__.py
easeInOutElastic
def easeInOutElastic(n, amplitude=1, period=0.5): """An elastic tween function wobbles towards the midpoint. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(). ...
python
def easeInOutElastic(n, amplitude=1, period=0.5): """An elastic tween function wobbles towards the midpoint. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(). ...
[ "def", "easeInOutElastic", "(", "n", ",", "amplitude", "=", "1", ",", "period", "=", "0.5", ")", ":", "_checkRange", "(", "n", ")", "n", "*=", "2", "if", "n", "<", "1", ":", "return", "easeInElastic", "(", "n", ",", "amplitude", "=", "amplitude", "...
An elastic tween function wobbles towards the midpoint. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "An", "elastic", "tween", "function", "wobbles", "towards", "the", "midpoint", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L481-L495
train
60,936
asweigart/pytweening
pytweening/__init__.py
easeInBack
def easeInBack(n, s=1.70158): """A tween function that backs up first at the start and then goes to the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnL...
python
def easeInBack(n, s=1.70158): """A tween function that backs up first at the start and then goes to the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnL...
[ "def", "easeInBack", "(", "n", ",", "s", "=", "1.70158", ")", ":", "_checkRange", "(", "n", ")", "return", "n", "*", "n", "*", "(", "(", "s", "+", "1", ")", "*", "n", "-", "s", ")" ]
A tween function that backs up first at the start and then goes to the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "A", "tween", "function", "that", "backs", "up", "first", "at", "the", "start", "and", "then", "goes", "to", "the", "destination", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L498-L508
train
60,937
asweigart/pytweening
pytweening/__init__.py
easeOutBack
def easeOutBack(n, s=1.70158): """A tween function that overshoots the destination a little and then backs into the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to...
python
def easeOutBack(n, s=1.70158): """A tween function that overshoots the destination a little and then backs into the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to...
[ "def", "easeOutBack", "(", "n", ",", "s", "=", "1.70158", ")", ":", "_checkRange", "(", "n", ")", "n", "=", "n", "-", "1", "return", "n", "*", "n", "*", "(", "(", "s", "+", "1", ")", "*", "n", "+", "s", ")", "+", "1" ]
A tween function that overshoots the destination a little and then backs into the destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "A", "tween", "function", "that", "overshoots", "the", "destination", "a", "little", "and", "then", "backs", "into", "the", "destination", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L511-L522
train
60,938
asweigart/pytweening
pytweening/__init__.py
easeInOutBack
def easeInOutBack(n, s=1.70158): """A "back-in" tween function that overshoots both the start and destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine()....
python
def easeInOutBack(n, s=1.70158): """A "back-in" tween function that overshoots both the start and destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine()....
[ "def", "easeInOutBack", "(", "n", ",", "s", "=", "1.70158", ")", ":", "_checkRange", "(", "n", ")", "n", "=", "n", "*", "2", "if", "n", "<", "1", ":", "s", "*=", "1.525", "return", "0.5", "*", "(", "n", "*", "n", "*", "(", "(", "s", "+", ...
A "back-in" tween function that overshoots both the start and destination. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "A", "back", "-", "in", "tween", "function", "that", "overshoots", "both", "the", "start", "and", "destination", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L525-L542
train
60,939
asweigart/pytweening
pytweening/__init__.py
easeOutBounce
def easeOutBounce(n): """A bouncing tween function that hits the destination and then bounces to rest. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(). """...
python
def easeOutBounce(n): """A bouncing tween function that hits the destination and then bounces to rest. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(). """...
[ "def", "easeOutBounce", "(", "n", ")", ":", "_checkRange", "(", "n", ")", "if", "n", "<", "(", "1", "/", "2.75", ")", ":", "return", "7.5625", "*", "n", "*", "n", "elif", "n", "<", "(", "2", "/", "2.75", ")", ":", "n", "-=", "(", "1.5", "/"...
A bouncing tween function that hits the destination and then bounces to rest. Args: n (float): The time progress, starting at 0.0 and ending at 1.0. Returns: (float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine().
[ "A", "bouncing", "tween", "function", "that", "hits", "the", "destination", "and", "then", "bounces", "to", "rest", "." ]
20d74368e53dc7d0f77c810b624b2c90994f099d
https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L558-L578
train
60,940
nnseva/django-access
access/admin.py
AccessControlMixin.formfield_for_manytomany
def formfield_for_manytomany(self, db_field, request, **kwargs): ''' Not all Admin subclasses use get_field_queryset here, so we will use it explicitly ''' db = kwargs.get('using') kwargs['queryset'] = kwargs.get('queryset', self.get_field_queryset(db, db_field, request)) ...
python
def formfield_for_manytomany(self, db_field, request, **kwargs): ''' Not all Admin subclasses use get_field_queryset here, so we will use it explicitly ''' db = kwargs.get('using') kwargs['queryset'] = kwargs.get('queryset', self.get_field_queryset(db, db_field, request)) ...
[ "def", "formfield_for_manytomany", "(", "self", ",", "db_field", ",", "request", ",", "*", "*", "kwargs", ")", ":", "db", "=", "kwargs", ".", "get", "(", "'using'", ")", "kwargs", "[", "'queryset'", "]", "=", "kwargs", ".", "get", "(", "'queryset'", ",...
Not all Admin subclasses use get_field_queryset here, so we will use it explicitly
[ "Not", "all", "Admin", "subclasses", "use", "get_field_queryset", "here", "so", "we", "will", "use", "it", "explicitly" ]
2e8b72830b1092652ca63125a8309189d70ad584
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/admin.py#L151-L157
train
60,941
nnseva/django-access
access/admin.py
AccessControlMixin.delete_selected
def delete_selected(self, request, queryset): ''' The real delete function always evaluated either from the action, or from the instance delete link ''' opts = self.model._meta app_label = opts.app_label # Populate deletable_objects, a data structure of all related objec...
python
def delete_selected(self, request, queryset): ''' The real delete function always evaluated either from the action, or from the instance delete link ''' opts = self.model._meta app_label = opts.app_label # Populate deletable_objects, a data structure of all related objec...
[ "def", "delete_selected", "(", "self", ",", "request", ",", "queryset", ")", ":", "opts", "=", "self", ".", "model", ".", "_meta", "app_label", "=", "opts", ".", "app_label", "# Populate deletable_objects, a data structure of all related objects that", "# will also be d...
The real delete function always evaluated either from the action, or from the instance delete link
[ "The", "real", "delete", "function", "always", "evaluated", "either", "from", "the", "action", "or", "from", "the", "instance", "delete", "link" ]
2e8b72830b1092652ca63125a8309189d70ad584
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/admin.py#L288-L354
train
60,942
nnseva/django-access
access/admin.py
AccessControlMixin.get_deleted_objects
def get_deleted_objects(self, request, queryset): """ Find all objects related to instances of ``queryset`` that should also be deleted. Returns - to_delete - a nested list of strings suitable for display in the template with the ``unordered_list`` filter. - model_count ...
python
def get_deleted_objects(self, request, queryset): """ Find all objects related to instances of ``queryset`` that should also be deleted. Returns - to_delete - a nested list of strings suitable for display in the template with the ``unordered_list`` filter. - model_count ...
[ "def", "get_deleted_objects", "(", "self", ",", "request", ",", "queryset", ")", ":", "collector", "=", "NestedObjects", "(", "using", "=", "queryset", ".", "db", ")", "collector", ".", "collect", "(", "queryset", ")", "model_perms_needed", "=", "set", "(", ...
Find all objects related to instances of ``queryset`` that should also be deleted. Returns - to_delete - a nested list of strings suitable for display in the template with the ``unordered_list`` filter. - model_count - statistics for models of all deleted instances - perms_n...
[ "Find", "all", "objects", "related", "to", "instances", "of", "queryset", "that", "should", "also", "be", "deleted", "." ]
2e8b72830b1092652ca63125a8309189d70ad584
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/admin.py#L358-L421
train
60,943
nnseva/django-access
access/managers.py
AccessManager.register_plugins
def register_plugins(cls, plugins): ''' Reguster plugins. The plugins parameter should be dict mapping model to plugin. Just calls a register_plugin for every such a pair. ''' for model in plugins: cls.register_plugin(model, plugins[model])
python
def register_plugins(cls, plugins): ''' Reguster plugins. The plugins parameter should be dict mapping model to plugin. Just calls a register_plugin for every such a pair. ''' for model in plugins: cls.register_plugin(model, plugins[model])
[ "def", "register_plugins", "(", "cls", ",", "plugins", ")", ":", "for", "model", "in", "plugins", ":", "cls", ".", "register_plugin", "(", "model", ",", "plugins", "[", "model", "]", ")" ]
Reguster plugins. The plugins parameter should be dict mapping model to plugin. Just calls a register_plugin for every such a pair.
[ "Reguster", "plugins", ".", "The", "plugins", "parameter", "should", "be", "dict", "mapping", "model", "to", "plugin", "." ]
2e8b72830b1092652ca63125a8309189d70ad584
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/managers.py#L28-L35
train
60,944
nnseva/django-access
access/managers.py
AccessManager.register_plugin
def register_plugin(cls, model, plugin): ''' Reguster a plugin for the model. The only one plugin can be registered. If you want to combine plugins, use CompoundPlugin. ''' logger.info("Plugin registered for %s: %s", model, plugin) cls.plugins[model] = plugin
python
def register_plugin(cls, model, plugin): ''' Reguster a plugin for the model. The only one plugin can be registered. If you want to combine plugins, use CompoundPlugin. ''' logger.info("Plugin registered for %s: %s", model, plugin) cls.plugins[model] = plugin
[ "def", "register_plugin", "(", "cls", ",", "model", ",", "plugin", ")", ":", "logger", ".", "info", "(", "\"Plugin registered for %s: %s\"", ",", "model", ",", "plugin", ")", "cls", ".", "plugins", "[", "model", "]", "=", "plugin" ]
Reguster a plugin for the model. The only one plugin can be registered. If you want to combine plugins, use CompoundPlugin.
[ "Reguster", "a", "plugin", "for", "the", "model", "." ]
2e8b72830b1092652ca63125a8309189d70ad584
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/managers.py#L38-L45
train
60,945
nnseva/django-access
access/managers.py
AccessManager.get_default_plugin
def get_default_plugin(cls): ''' Return a default plugin. ''' from importlib import import_module from django.conf import settings default_plugin = getattr(settings, 'ACCESS_DEFAULT_PLUGIN', "access.plugins.DjangoAccessPlugin") if default_plugin not in cls.default...
python
def get_default_plugin(cls): ''' Return a default plugin. ''' from importlib import import_module from django.conf import settings default_plugin = getattr(settings, 'ACCESS_DEFAULT_PLUGIN', "access.plugins.DjangoAccessPlugin") if default_plugin not in cls.default...
[ "def", "get_default_plugin", "(", "cls", ")", ":", "from", "importlib", "import", "import_module", "from", "django", ".", "conf", "import", "settings", "default_plugin", "=", "getattr", "(", "settings", ",", "'ACCESS_DEFAULT_PLUGIN'", ",", "\"access.plugins.DjangoAcce...
Return a default plugin.
[ "Return", "a", "default", "plugin", "." ]
2e8b72830b1092652ca63125a8309189d70ad584
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/managers.py#L66-L80
train
60,946
nnseva/django-access
access/managers.py
AccessManager.plugin_for
def plugin_for(cls, model): ''' Find and return a plugin for this model. Uses inheritance to find a model where the plugin is registered. ''' logger.debug("Getting a plugin for: %s", model) if not issubclass(model, Model): return if model in cls.plugins: ...
python
def plugin_for(cls, model): ''' Find and return a plugin for this model. Uses inheritance to find a model where the plugin is registered. ''' logger.debug("Getting a plugin for: %s", model) if not issubclass(model, Model): return if model in cls.plugins: ...
[ "def", "plugin_for", "(", "cls", ",", "model", ")", ":", "logger", ".", "debug", "(", "\"Getting a plugin for: %s\"", ",", "model", ")", "if", "not", "issubclass", "(", "model", ",", "Model", ")", ":", "return", "if", "model", "in", "cls", ".", "plugins"...
Find and return a plugin for this model. Uses inheritance to find a model where the plugin is registered.
[ "Find", "and", "return", "a", "plugin", "for", "this", "model", ".", "Uses", "inheritance", "to", "find", "a", "model", "where", "the", "plugin", "is", "registered", "." ]
2e8b72830b1092652ca63125a8309189d70ad584
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/managers.py#L83-L95
train
60,947
nnseva/django-access
access/managers.py
AccessManager.visible
def visible(self, request): ''' Checks the both, check_visible and apply_visible, against the owned model and it's instance set ''' return self.apply_visible(self.get_queryset(), request) if self.check_visible(self.model, request) is not False else self.get_queryset().none()
python
def visible(self, request): ''' Checks the both, check_visible and apply_visible, against the owned model and it's instance set ''' return self.apply_visible(self.get_queryset(), request) if self.check_visible(self.model, request) is not False else self.get_queryset().none()
[ "def", "visible", "(", "self", ",", "request", ")", ":", "return", "self", ".", "apply_visible", "(", "self", ".", "get_queryset", "(", ")", ",", "request", ")", "if", "self", ".", "check_visible", "(", "self", ".", "model", ",", "request", ")", "is", ...
Checks the both, check_visible and apply_visible, against the owned model and it's instance set
[ "Checks", "the", "both", "check_visible", "and", "apply_visible", "against", "the", "owned", "model", "and", "it", "s", "instance", "set" ]
2e8b72830b1092652ca63125a8309189d70ad584
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/managers.py#L172-L176
train
60,948
nnseva/django-access
access/managers.py
AccessManager.changeable
def changeable(self, request): ''' Checks the both, check_changeable and apply_changeable, against the owned model and it's instance set ''' return self.apply_changeable(self.get_queryset(), request) if self.check_changeable(self.model, request) is not False else self.get_queryset().none...
python
def changeable(self, request): ''' Checks the both, check_changeable and apply_changeable, against the owned model and it's instance set ''' return self.apply_changeable(self.get_queryset(), request) if self.check_changeable(self.model, request) is not False else self.get_queryset().none...
[ "def", "changeable", "(", "self", ",", "request", ")", ":", "return", "self", ".", "apply_changeable", "(", "self", ".", "get_queryset", "(", ")", ",", "request", ")", "if", "self", ".", "check_changeable", "(", "self", ".", "model", ",", "request", ")",...
Checks the both, check_changeable and apply_changeable, against the owned model and it's instance set
[ "Checks", "the", "both", "check_changeable", "and", "apply_changeable", "against", "the", "owned", "model", "and", "it", "s", "instance", "set" ]
2e8b72830b1092652ca63125a8309189d70ad584
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/managers.py#L178-L182
train
60,949
nnseva/django-access
access/managers.py
AccessManager.deleteable
def deleteable(self, request): ''' Checks the both, check_deleteable and apply_deleteable, against the owned model and it's instance set ''' return self.apply_deleteable(self.get_queryset(), request) if self.check_deleteable(self.model, request) is not False else self.get_queryset().none...
python
def deleteable(self, request): ''' Checks the both, check_deleteable and apply_deleteable, against the owned model and it's instance set ''' return self.apply_deleteable(self.get_queryset(), request) if self.check_deleteable(self.model, request) is not False else self.get_queryset().none...
[ "def", "deleteable", "(", "self", ",", "request", ")", ":", "return", "self", ".", "apply_deleteable", "(", "self", ".", "get_queryset", "(", ")", ",", "request", ")", "if", "self", ".", "check_deleteable", "(", "self", ".", "model", ",", "request", ")",...
Checks the both, check_deleteable and apply_deleteable, against the owned model and it's instance set
[ "Checks", "the", "both", "check_deleteable", "and", "apply_deleteable", "against", "the", "owned", "model", "and", "it", "s", "instance", "set" ]
2e8b72830b1092652ca63125a8309189d70ad584
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/managers.py#L184-L188
train
60,950
krischer/django-plugins
djangoplugins/utils.py
get_plugin_from_string
def get_plugin_from_string(plugin_name): """ Returns plugin or plugin point class from given ``plugin_name`` string. Example of ``plugin_name``:: 'my_app.MyPlugin' """ modulename, classname = plugin_name.rsplit('.', 1) module = import_module(modulename) return getattr(module, clas...
python
def get_plugin_from_string(plugin_name): """ Returns plugin or plugin point class from given ``plugin_name`` string. Example of ``plugin_name``:: 'my_app.MyPlugin' """ modulename, classname = plugin_name.rsplit('.', 1) module = import_module(modulename) return getattr(module, clas...
[ "def", "get_plugin_from_string", "(", "plugin_name", ")", ":", "modulename", ",", "classname", "=", "plugin_name", ".", "rsplit", "(", "'.'", ",", "1", ")", "module", "=", "import_module", "(", "modulename", ")", "return", "getattr", "(", "module", ",", "cla...
Returns plugin or plugin point class from given ``plugin_name`` string. Example of ``plugin_name``:: 'my_app.MyPlugin'
[ "Returns", "plugin", "or", "plugin", "point", "class", "from", "given", "plugin_name", "string", "." ]
0064e3306a7ed7af83f1ff51231acdf7478215fe
https://github.com/krischer/django-plugins/blob/0064e3306a7ed7af83f1ff51231acdf7478215fe/djangoplugins/utils.py#L14-L25
train
60,951
RealTimeWeb/datasets
builder/languages/detect_distribution.py
make_pdf
def make_pdf(dist, params, size=10000): """Generate distributions's Propbability Distribution Function """ # Separate parts of parameters arg = params[:-2] loc = params[-2] scale = params[-1] # Get sane start and end points of distribution start = dist.ppf(0.01, *arg, loc=loc, scale=scale)...
python
def make_pdf(dist, params, size=10000): """Generate distributions's Propbability Distribution Function """ # Separate parts of parameters arg = params[:-2] loc = params[-2] scale = params[-1] # Get sane start and end points of distribution start = dist.ppf(0.01, *arg, loc=loc, scale=scale)...
[ "def", "make_pdf", "(", "dist", ",", "params", ",", "size", "=", "10000", ")", ":", "# Separate parts of parameters", "arg", "=", "params", "[", ":", "-", "2", "]", "loc", "=", "params", "[", "-", "2", "]", "scale", "=", "params", "[", "-", "1", "]...
Generate distributions's Propbability Distribution Function
[ "Generate", "distributions", "s", "Propbability", "Distribution", "Function" ]
2fe5befd251c783744d000bd4763e277616a152f
https://github.com/RealTimeWeb/datasets/blob/2fe5befd251c783744d000bd4763e277616a152f/builder/languages/detect_distribution.py#L79-L96
train
60,952
RealTimeWeb/datasets
preprocess/earthquakes/earthquakes.py
urlencode
def urlencode(query, params): """ Correctly convert the given query and parameters into a full query+query string, ensuring the order of the params. """ return query + '?' + "&".join(key+'='+quote_plus(str(value)) for key, value in params)
python
def urlencode(query, params): """ Correctly convert the given query and parameters into a full query+query string, ensuring the order of the params. """ return query + '?' + "&".join(key+'='+quote_plus(str(value)) for key, value in params)
[ "def", "urlencode", "(", "query", ",", "params", ")", ":", "return", "query", "+", "'?'", "+", "\"&\"", ".", "join", "(", "key", "+", "'='", "+", "quote_plus", "(", "str", "(", "value", ")", ")", "for", "key", ",", "value", "in", "params", ")" ]
Correctly convert the given query and parameters into a full query+query string, ensuring the order of the params.
[ "Correctly", "convert", "the", "given", "query", "and", "parameters", "into", "a", "full", "query", "+", "query", "string", "ensuring", "the", "order", "of", "the", "params", "." ]
2fe5befd251c783744d000bd4763e277616a152f
https://github.com/RealTimeWeb/datasets/blob/2fe5befd251c783744d000bd4763e277616a152f/preprocess/earthquakes/earthquakes.py#L32-L38
train
60,953
RealTimeWeb/datasets
preprocess/earthquakes/earthquakes.py
_load_from_string
def _load_from_string(data): '''Loads the cache from the string''' global _CACHE if PYTHON_3: data = json.loads(data.decode("utf-8")) else: data = json.loads(data) _CACHE = _recursively_convert_unicode_to_str(data)['data']
python
def _load_from_string(data): '''Loads the cache from the string''' global _CACHE if PYTHON_3: data = json.loads(data.decode("utf-8")) else: data = json.loads(data) _CACHE = _recursively_convert_unicode_to_str(data)['data']
[ "def", "_load_from_string", "(", "data", ")", ":", "global", "_CACHE", "if", "PYTHON_3", ":", "data", "=", "json", ".", "loads", "(", "data", ".", "decode", "(", "\"utf-8\"", ")", ")", "else", ":", "data", "=", "json", ".", "loads", "(", "data", ")",...
Loads the cache from the string
[ "Loads", "the", "cache", "from", "the", "string" ]
2fe5befd251c783744d000bd4763e277616a152f
https://github.com/RealTimeWeb/datasets/blob/2fe5befd251c783744d000bd4763e277616a152f/preprocess/earthquakes/earthquakes.py#L139-L146
train
60,954
krischer/django-plugins
djangoplugins/point.py
PluginPoint.get_model
def get_model(cls, name=None, status=ENABLED): """ Returns model instance of plugin point or plugin, depending from which class this methos is called. Example:: plugin_model_instance = MyPlugin.get_model() plugin_model_instance = MyPluginPoint.get_model('plugin-...
python
def get_model(cls, name=None, status=ENABLED): """ Returns model instance of plugin point or plugin, depending from which class this methos is called. Example:: plugin_model_instance = MyPlugin.get_model() plugin_model_instance = MyPluginPoint.get_model('plugin-...
[ "def", "get_model", "(", "cls", ",", "name", "=", "None", ",", "status", "=", "ENABLED", ")", ":", "ppath", "=", "cls", ".", "get_pythonpath", "(", ")", "if", "is_plugin_point", "(", "cls", ")", ":", "if", "name", "is", "not", "None", ":", "kwargs", ...
Returns model instance of plugin point or plugin, depending from which class this methos is called. Example:: plugin_model_instance = MyPlugin.get_model() plugin_model_instance = MyPluginPoint.get_model('plugin-name') plugin_point_model_instance = MyPluginPoint.get_...
[ "Returns", "model", "instance", "of", "plugin", "point", "or", "plugin", "depending", "from", "which", "class", "this", "methos", "is", "called", "." ]
0064e3306a7ed7af83f1ff51231acdf7478215fe
https://github.com/krischer/django-plugins/blob/0064e3306a7ed7af83f1ff51231acdf7478215fe/djangoplugins/point.py#L63-L86
train
60,955
krischer/django-plugins
djangoplugins/point.py
PluginPoint.get_point_model
def get_point_model(cls): """ Returns plugin point model instance. Only used from plugin classes. """ if is_plugin_point(cls): raise Exception(_('This method is only available to plugin ' 'classes.')) else: return PluginPointM...
python
def get_point_model(cls): """ Returns plugin point model instance. Only used from plugin classes. """ if is_plugin_point(cls): raise Exception(_('This method is only available to plugin ' 'classes.')) else: return PluginPointM...
[ "def", "get_point_model", "(", "cls", ")", ":", "if", "is_plugin_point", "(", "cls", ")", ":", "raise", "Exception", "(", "_", "(", "'This method is only available to plugin '", "'classes.'", ")", ")", "else", ":", "return", "PluginPointModel", ".", "objects", "...
Returns plugin point model instance. Only used from plugin classes.
[ "Returns", "plugin", "point", "model", "instance", ".", "Only", "used", "from", "plugin", "classes", "." ]
0064e3306a7ed7af83f1ff51231acdf7478215fe
https://github.com/krischer/django-plugins/blob/0064e3306a7ed7af83f1ff51231acdf7478215fe/djangoplugins/point.py#L104-L113
train
60,956
krischer/django-plugins
djangoplugins/point.py
PluginPoint.get_plugins
def get_plugins(cls): """ Returns all plugin instances of plugin point, passing all args and kwargs to plugin constructor. """ # Django >= 1.9 changed something with the migration logic causing # plugins to be executed before the corresponding database tables # ex...
python
def get_plugins(cls): """ Returns all plugin instances of plugin point, passing all args and kwargs to plugin constructor. """ # Django >= 1.9 changed something with the migration logic causing # plugins to be executed before the corresponding database tables # ex...
[ "def", "get_plugins", "(", "cls", ")", ":", "# Django >= 1.9 changed something with the migration logic causing", "# plugins to be executed before the corresponding database tables", "# exist. This method will only return something if the database", "# tables have already been created.", "# XXX:...
Returns all plugin instances of plugin point, passing all args and kwargs to plugin constructor.
[ "Returns", "all", "plugin", "instances", "of", "plugin", "point", "passing", "all", "args", "and", "kwargs", "to", "plugin", "constructor", "." ]
0064e3306a7ed7af83f1ff51231acdf7478215fe
https://github.com/krischer/django-plugins/blob/0064e3306a7ed7af83f1ff51231acdf7478215fe/djangoplugins/point.py#L116-L136
train
60,957
krischer/django-plugins
djangoplugins/point.py
PluginPoint.get_plugins_qs
def get_plugins_qs(cls): """ Returns query set of all plugins belonging to plugin point. Example:: for plugin_instance in MyPluginPoint.get_plugins_qs(): print(plugin_instance.get_plugin().name) """ if is_plugin_point(cls): point_pythonp...
python
def get_plugins_qs(cls): """ Returns query set of all plugins belonging to plugin point. Example:: for plugin_instance in MyPluginPoint.get_plugins_qs(): print(plugin_instance.get_plugin().name) """ if is_plugin_point(cls): point_pythonp...
[ "def", "get_plugins_qs", "(", "cls", ")", ":", "if", "is_plugin_point", "(", "cls", ")", ":", "point_pythonpath", "=", "cls", ".", "get_pythonpath", "(", ")", "return", "Plugin", ".", "objects", ".", "filter", "(", "point__pythonpath", "=", "point_pythonpath",...
Returns query set of all plugins belonging to plugin point. Example:: for plugin_instance in MyPluginPoint.get_plugins_qs(): print(plugin_instance.get_plugin().name)
[ "Returns", "query", "set", "of", "all", "plugins", "belonging", "to", "plugin", "point", "." ]
0064e3306a7ed7af83f1ff51231acdf7478215fe
https://github.com/krischer/django-plugins/blob/0064e3306a7ed7af83f1ff51231acdf7478215fe/djangoplugins/point.py#L139-L156
train
60,958
RealTimeWeb/datasets
preprocess/classics/process_rdf.py
safeunicode
def safeunicode(arg, *args, **kwargs): """Coerce argument to unicode, if it's not already.""" return arg if isinstance(arg, unicode) else unicode(arg, *args, **kwargs)
python
def safeunicode(arg, *args, **kwargs): """Coerce argument to unicode, if it's not already.""" return arg if isinstance(arg, unicode) else unicode(arg, *args, **kwargs)
[ "def", "safeunicode", "(", "arg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "arg", "if", "isinstance", "(", "arg", ",", "unicode", ")", "else", "unicode", "(", "arg", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Coerce argument to unicode, if it's not already.
[ "Coerce", "argument", "to", "unicode", "if", "it", "s", "not", "already", "." ]
2fe5befd251c783744d000bd4763e277616a152f
https://github.com/RealTimeWeb/datasets/blob/2fe5befd251c783744d000bd4763e277616a152f/preprocess/classics/process_rdf.py#L194-L196
train
60,959
RealTimeWeb/datasets
datasets/python/energy/energy.py
get_reports
def get_reports(): """ Returns energy data from 1960 to 2014 across various factors. """ if False: # If there was a Test version of this method, it would go here. But alas. pass else: rows = _Constants._DATABASE.execute("SELECT data FROM energy".format( hardw...
python
def get_reports(): """ Returns energy data from 1960 to 2014 across various factors. """ if False: # If there was a Test version of this method, it would go here. But alas. pass else: rows = _Constants._DATABASE.execute("SELECT data FROM energy".format( hardw...
[ "def", "get_reports", "(", ")", ":", "if", "False", ":", "# If there was a Test version of this method, it would go here. But alas.", "pass", "else", ":", "rows", "=", "_Constants", ".", "_DATABASE", ".", "execute", "(", "\"SELECT data FROM energy\"", ".", "format", "("...
Returns energy data from 1960 to 2014 across various factors.
[ "Returns", "energy", "data", "from", "1960", "to", "2014", "across", "various", "factors", "." ]
2fe5befd251c783744d000bd4763e277616a152f
https://github.com/RealTimeWeb/datasets/blob/2fe5befd251c783744d000bd4763e277616a152f/datasets/python/energy/energy.py#L237-L251
train
60,960
krischer/django-plugins
djangoplugins/management/commands/syncplugins.py
SyncPlugins.available
def available(self, src, dst, model): """ Iterate over all registered plugins or plugin points and prepare to add them to database. """ for name, point in six.iteritems(src): inst = dst.pop(name, None) if inst is None: self.print_(1, "Regis...
python
def available(self, src, dst, model): """ Iterate over all registered plugins or plugin points and prepare to add them to database. """ for name, point in six.iteritems(src): inst = dst.pop(name, None) if inst is None: self.print_(1, "Regis...
[ "def", "available", "(", "self", ",", "src", ",", "dst", ",", "model", ")", ":", "for", "name", ",", "point", "in", "six", ".", "iteritems", "(", "src", ")", ":", "inst", "=", "dst", ".", "pop", "(", "name", ",", "None", ")", "if", "inst", "is"...
Iterate over all registered plugins or plugin points and prepare to add them to database.
[ "Iterate", "over", "all", "registered", "plugins", "or", "plugin", "points", "and", "prepare", "to", "add", "them", "to", "database", "." ]
0064e3306a7ed7af83f1ff51231acdf7478215fe
https://github.com/krischer/django-plugins/blob/0064e3306a7ed7af83f1ff51231acdf7478215fe/djangoplugins/management/commands/syncplugins.py#L68-L83
train
60,961
krischer/django-plugins
djangoplugins/management/commands/syncplugins.py
SyncPlugins.missing
def missing(self, dst): """ Mark all missing plugins, that exists in database, but are not registered. """ for inst in six.itervalues(dst): if inst.status != REMOVED: inst.status = REMOVED inst.save()
python
def missing(self, dst): """ Mark all missing plugins, that exists in database, but are not registered. """ for inst in six.itervalues(dst): if inst.status != REMOVED: inst.status = REMOVED inst.save()
[ "def", "missing", "(", "self", ",", "dst", ")", ":", "for", "inst", "in", "six", ".", "itervalues", "(", "dst", ")", ":", "if", "inst", ".", "status", "!=", "REMOVED", ":", "inst", ".", "status", "=", "REMOVED", "inst", ".", "save", "(", ")" ]
Mark all missing plugins, that exists in database, but are not registered.
[ "Mark", "all", "missing", "plugins", "that", "exists", "in", "database", "but", "are", "not", "registered", "." ]
0064e3306a7ed7af83f1ff51231acdf7478215fe
https://github.com/krischer/django-plugins/blob/0064e3306a7ed7af83f1ff51231acdf7478215fe/djangoplugins/management/commands/syncplugins.py#L85-L93
train
60,962
krischer/django-plugins
djangoplugins/management/commands/syncplugins.py
SyncPlugins.all
def all(self): """ Synchronize all registered plugins and plugin points to database. """ # Django >= 1.9 changed something with the migration logic causing # plugins to be executed before the corresponding database tables # exist. This method will only return something if...
python
def all(self): """ Synchronize all registered plugins and plugin points to database. """ # Django >= 1.9 changed something with the migration logic causing # plugins to be executed before the corresponding database tables # exist. This method will only return something if...
[ "def", "all", "(", "self", ")", ":", "# Django >= 1.9 changed something with the migration logic causing", "# plugins to be executed before the corresponding database tables", "# exist. This method will only return something if the database", "# tables have already been created.", "# XXX: I don'...
Synchronize all registered plugins and plugin points to database.
[ "Synchronize", "all", "registered", "plugins", "and", "plugin", "points", "to", "database", "." ]
0064e3306a7ed7af83f1ff51231acdf7478215fe
https://github.com/krischer/django-plugins/blob/0064e3306a7ed7af83f1ff51231acdf7478215fe/djangoplugins/management/commands/syncplugins.py#L131-L145
train
60,963
RealTimeWeb/datasets
datasets/python/weather/weather.py
get_weather
def get_weather(test=False): """ Returns weather reports from the dataset. """ if _Constants._TEST or test: rows = _Constants._DATABASE.execute("SELECT data FROM weather LIMIT {hardware}".format( hardware=_Constants._HARDWARE)) data = [r[0] for r in rows] data = ...
python
def get_weather(test=False): """ Returns weather reports from the dataset. """ if _Constants._TEST or test: rows = _Constants._DATABASE.execute("SELECT data FROM weather LIMIT {hardware}".format( hardware=_Constants._HARDWARE)) data = [r[0] for r in rows] data = ...
[ "def", "get_weather", "(", "test", "=", "False", ")", ":", "if", "_Constants", ".", "_TEST", "or", "test", ":", "rows", "=", "_Constants", ".", "_DATABASE", ".", "execute", "(", "\"SELECT data FROM weather LIMIT {hardware}\"", ".", "format", "(", "hardware", "...
Returns weather reports from the dataset.
[ "Returns", "weather", "reports", "from", "the", "dataset", "." ]
2fe5befd251c783744d000bd4763e277616a152f
https://github.com/RealTimeWeb/datasets/blob/2fe5befd251c783744d000bd4763e277616a152f/datasets/python/weather/weather.py#L152-L171
train
60,964
joealcorn/xbox
xbox/client.py
Client._get
def _get(self, url, **kw): ''' Makes a GET request, setting Authorization header by default ''' headers = kw.pop('headers', {}) headers.setdefault('Content-Type', 'application/json') headers.setdefault('Accept', 'application/json') headers.setdefault('Auth...
python
def _get(self, url, **kw): ''' Makes a GET request, setting Authorization header by default ''' headers = kw.pop('headers', {}) headers.setdefault('Content-Type', 'application/json') headers.setdefault('Accept', 'application/json') headers.setdefault('Auth...
[ "def", "_get", "(", "self", ",", "url", ",", "*", "*", "kw", ")", ":", "headers", "=", "kw", ".", "pop", "(", "'headers'", ",", "{", "}", ")", "headers", ".", "setdefault", "(", "'Content-Type'", ",", "'application/json'", ")", "headers", ".", "setde...
Makes a GET request, setting Authorization header by default
[ "Makes", "a", "GET", "request", "setting", "Authorization", "header", "by", "default" ]
3d2aeba10244dcb58d714d76fc88487c74bd1510
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/client.py#L42-L54
train
60,965
joealcorn/xbox
xbox/client.py
Client._post
def _post(self, url, **kw): ''' Makes a POST request, setting Authorization header by default ''' headers = kw.pop('headers', {}) headers.setdefault('Authorization', self.AUTHORIZATION_HEADER) kw['headers'] = headers resp = self.session.post(url, **kw) ...
python
def _post(self, url, **kw): ''' Makes a POST request, setting Authorization header by default ''' headers = kw.pop('headers', {}) headers.setdefault('Authorization', self.AUTHORIZATION_HEADER) kw['headers'] = headers resp = self.session.post(url, **kw) ...
[ "def", "_post", "(", "self", ",", "url", ",", "*", "*", "kw", ")", ":", "headers", "=", "kw", ".", "pop", "(", "'headers'", ",", "{", "}", ")", "headers", ".", "setdefault", "(", "'Authorization'", ",", "self", ".", "AUTHORIZATION_HEADER", ")", "kw",...
Makes a POST request, setting Authorization header by default
[ "Makes", "a", "POST", "request", "setting", "Authorization", "header", "by", "default" ]
3d2aeba10244dcb58d714d76fc88487c74bd1510
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/client.py#L56-L66
train
60,966
joealcorn/xbox
xbox/client.py
Client._post_json
def _post_json(self, url, data, **kw): ''' Makes a POST request, setting Authorization and Content-Type headers by default ''' data = json.dumps(data) headers = kw.pop('headers', {}) headers.setdefault('Content-Type', 'application/json') headers.setdefault...
python
def _post_json(self, url, data, **kw): ''' Makes a POST request, setting Authorization and Content-Type headers by default ''' data = json.dumps(data) headers = kw.pop('headers', {}) headers.setdefault('Content-Type', 'application/json') headers.setdefault...
[ "def", "_post_json", "(", "self", ",", "url", ",", "data", ",", "*", "*", "kw", ")", ":", "data", "=", "json", ".", "dumps", "(", "data", ")", "headers", "=", "kw", ".", "pop", "(", "'headers'", ",", "{", "}", ")", "headers", ".", "setdefault", ...
Makes a POST request, setting Authorization and Content-Type headers by default
[ "Makes", "a", "POST", "request", "setting", "Authorization", "and", "Content", "-", "Type", "headers", "by", "default" ]
3d2aeba10244dcb58d714d76fc88487c74bd1510
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/client.py#L68-L80
train
60,967
joealcorn/xbox
xbox/client.py
Client.authenticate
def authenticate(self, login=None, password=None): ''' Authenticated this client instance. ``login`` and ``password`` default to the environment variables ``MS_LOGIN`` and ``MS_PASSWD`` respectively. :param login: Email address associated with a microsoft account :para...
python
def authenticate(self, login=None, password=None): ''' Authenticated this client instance. ``login`` and ``password`` default to the environment variables ``MS_LOGIN`` and ``MS_PASSWD`` respectively. :param login: Email address associated with a microsoft account :para...
[ "def", "authenticate", "(", "self", ",", "login", "=", "None", ",", "password", "=", "None", ")", ":", "if", "login", "is", "None", ":", "login", "=", "os", ".", "environ", ".", "get", "(", "'MS_LOGIN'", ")", "if", "password", "is", "None", ":", "p...
Authenticated this client instance. ``login`` and ``password`` default to the environment variables ``MS_LOGIN`` and ``MS_PASSWD`` respectively. :param login: Email address associated with a microsoft account :param password: Matching password :raises: :class:`~xbox.exception...
[ "Authenticated", "this", "client", "instance", "." ]
3d2aeba10244dcb58d714d76fc88487c74bd1510
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/client.py#L82-L198
train
60,968
joealcorn/xbox
xbox/resource.py
GamerProfile.from_xuid
def from_xuid(cls, xuid): ''' Instantiates an instance of ``GamerProfile`` from an xuid :param xuid: Xuid to look up :raises: :class:`~xbox.exceptions.GamertagNotFound` :returns: :class:`~xbox.GamerProfile` instance ''' url = 'https://profile.xboxlive....
python
def from_xuid(cls, xuid): ''' Instantiates an instance of ``GamerProfile`` from an xuid :param xuid: Xuid to look up :raises: :class:`~xbox.exceptions.GamertagNotFound` :returns: :class:`~xbox.GamerProfile` instance ''' url = 'https://profile.xboxlive....
[ "def", "from_xuid", "(", "cls", ",", "xuid", ")", ":", "url", "=", "'https://profile.xboxlive.com/users/xuid(%s)/profile/settings'", "%", "xuid", "try", ":", "return", "cls", ".", "_fetch", "(", "url", ")", "except", "(", "GamertagNotFound", ",", "InvalidRequest",...
Instantiates an instance of ``GamerProfile`` from an xuid :param xuid: Xuid to look up :raises: :class:`~xbox.exceptions.GamertagNotFound` :returns: :class:`~xbox.GamerProfile` instance
[ "Instantiates", "an", "instance", "of", "GamerProfile", "from", "an", "xuid" ]
3d2aeba10244dcb58d714d76fc88487c74bd1510
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/resource.py#L33-L51
train
60,969
joealcorn/xbox
xbox/resource.py
GamerProfile.from_gamertag
def from_gamertag(cls, gamertag): ''' Instantiates an instance of ``GamerProfile`` from a gamertag :param gamertag: Gamertag to look up :raises: :class:`~xbox.exceptions.GamertagNotFound` :returns: :class:`~xbox.GamerProfile` instance ''' url = 'https:/...
python
def from_gamertag(cls, gamertag): ''' Instantiates an instance of ``GamerProfile`` from a gamertag :param gamertag: Gamertag to look up :raises: :class:`~xbox.exceptions.GamertagNotFound` :returns: :class:`~xbox.GamerProfile` instance ''' url = 'https:/...
[ "def", "from_gamertag", "(", "cls", ",", "gamertag", ")", ":", "url", "=", "'https://profile.xboxlive.com/users/gt(%s)/profile/settings'", "%", "gamertag", "try", ":", "return", "cls", ".", "_fetch", "(", "url", ")", "except", "GamertagNotFound", ":", "raise", "Ga...
Instantiates an instance of ``GamerProfile`` from a gamertag :param gamertag: Gamertag to look up :raises: :class:`~xbox.exceptions.GamertagNotFound` :returns: :class:`~xbox.GamerProfile` instance
[ "Instantiates", "an", "instance", "of", "GamerProfile", "from", "a", "gamertag" ]
3d2aeba10244dcb58d714d76fc88487c74bd1510
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/resource.py#L54-L69
train
60,970
joealcorn/xbox
xbox/resource.py
Clip.get
def get(cls, xuid, scid, clip_id): ''' Gets a specific game clip :param xuid: xuid of an xbox live user :param scid: scid of a clip :param clip_id: id of a clip ''' url = ( 'https://gameclipsmetadata.xboxlive.com/users' '/xuid(%(xuid)s)/sc...
python
def get(cls, xuid, scid, clip_id): ''' Gets a specific game clip :param xuid: xuid of an xbox live user :param scid: scid of a clip :param clip_id: id of a clip ''' url = ( 'https://gameclipsmetadata.xboxlive.com/users' '/xuid(%(xuid)s)/sc...
[ "def", "get", "(", "cls", ",", "xuid", ",", "scid", ",", "clip_id", ")", ":", "url", "=", "(", "'https://gameclipsmetadata.xboxlive.com/users'", "'/xuid(%(xuid)s)/scids/%(scid)s/clips/%(clip_id)s'", "%", "{", "'xuid'", ":", "xuid", ",", "'scid'", ":", "scid", ",",...
Gets a specific game clip :param xuid: xuid of an xbox live user :param scid: scid of a clip :param clip_id: id of a clip
[ "Gets", "a", "specific", "game", "clip" ]
3d2aeba10244dcb58d714d76fc88487c74bd1510
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/resource.py#L201-L234
train
60,971
joealcorn/xbox
xbox/resource.py
Clip.saved_from_user
def saved_from_user(cls, user, include_pending=False): ''' Gets all clips 'saved' by a user. :param user: :class:`~xbox.GamerProfile` instance :param bool include_pending: whether to ignore clips that are not yet uploaded. These clips will have thumbnails and media_url ...
python
def saved_from_user(cls, user, include_pending=False): ''' Gets all clips 'saved' by a user. :param user: :class:`~xbox.GamerProfile` instance :param bool include_pending: whether to ignore clips that are not yet uploaded. These clips will have thumbnails and media_url ...
[ "def", "saved_from_user", "(", "cls", ",", "user", ",", "include_pending", "=", "False", ")", ":", "url", "=", "'https://gameclipsmetadata.xboxlive.com/users/xuid(%s)/clips/saved'", "resp", "=", "xbox", ".", "client", ".", "_get", "(", "url", "%", "user", ".", "...
Gets all clips 'saved' by a user. :param user: :class:`~xbox.GamerProfile` instance :param bool include_pending: whether to ignore clips that are not yet uploaded. These clips will have thumbnails and media_url set to ``None`` :returns: Iterator of :class:`~xbox.Clip` in...
[ "Gets", "all", "clips", "saved", "by", "a", "user", "." ]
3d2aeba10244dcb58d714d76fc88487c74bd1510
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/resource.py#L238-L254
train
60,972
joealcorn/xbox
xbox/vendor/requests/models.py
PreparedRequest.prepare_url
def prepare_url(self, url, params): """Prepares the given HTTP URL.""" url = to_native_string(url) # Don't do any URL preparation for non-HTTP schemes like `mailto`, # `data` etc to work around exceptions from `url_parse`, which # handles RFC 3986 only. if ':' in url and...
python
def prepare_url(self, url, params): """Prepares the given HTTP URL.""" url = to_native_string(url) # Don't do any URL preparation for non-HTTP schemes like `mailto`, # `data` etc to work around exceptions from `url_parse`, which # handles RFC 3986 only. if ':' in url and...
[ "def", "prepare_url", "(", "self", ",", "url", ",", "params", ")", ":", "url", "=", "to_native_string", "(", "url", ")", "# Don't do any URL preparation for non-HTTP schemes like `mailto`,", "# `data` etc to work around exceptions from `url_parse`, which", "# handles RFC 3986 onl...
Prepares the given HTTP URL.
[ "Prepares", "the", "given", "HTTP", "URL", "." ]
3d2aeba10244dcb58d714d76fc88487c74bd1510
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/vendor/requests/models.py#L326-L385
train
60,973
joealcorn/xbox
xbox/vendor/requests/packages/chardet/chardetect.py
description_of
def description_of(file, name='stdin'): """Return a string describing the probable encoding of a file.""" u = UniversalDetector() for line in file: u.feed(line) u.close() result = u.result if result['encoding']: return '%s: %s with confidence %s' % (name, ...
python
def description_of(file, name='stdin'): """Return a string describing the probable encoding of a file.""" u = UniversalDetector() for line in file: u.feed(line) u.close() result = u.result if result['encoding']: return '%s: %s with confidence %s' % (name, ...
[ "def", "description_of", "(", "file", ",", "name", "=", "'stdin'", ")", ":", "u", "=", "UniversalDetector", "(", ")", "for", "line", "in", "file", ":", "u", ".", "feed", "(", "line", ")", "u", ".", "close", "(", ")", "result", "=", "u", ".", "res...
Return a string describing the probable encoding of a file.
[ "Return", "a", "string", "describing", "the", "probable", "encoding", "of", "a", "file", "." ]
3d2aeba10244dcb58d714d76fc88487c74bd1510
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/vendor/requests/packages/chardet/chardetect.py#L21-L33
train
60,974
JakeWharton/py-videodownloader
videodownloader/providers/__init__.py
Provider.run
def run(self): ''' Download the video. ''' #Callback self._debug('Provider', 'run', 'Running pre-download callback.') self._pre_download() url = None out = None success = False try: url = Provider._download(self.get_download_u...
python
def run(self): ''' Download the video. ''' #Callback self._debug('Provider', 'run', 'Running pre-download callback.') self._pre_download() url = None out = None success = False try: url = Provider._download(self.get_download_u...
[ "def", "run", "(", "self", ")", ":", "#Callback", "self", ".", "_debug", "(", "'Provider'", ",", "'run'", ",", "'Running pre-download callback.'", ")", "self", ".", "_pre_download", "(", ")", "url", "=", "None", "out", "=", "None", "success", "=", "False",...
Download the video.
[ "Download", "the", "video", "." ]
787e88ad46280288f559e728598fcb2a8487129c
https://github.com/JakeWharton/py-videodownloader/blob/787e88ad46280288f559e728598fcb2a8487129c/videodownloader/providers/__init__.py#L82-L127
train
60,975
vaidik/commentjson
commentjson/commentjson.py
dumps
def dumps(obj, **kwargs): ''' Serialize `obj` to a JSON formatted `str`. Accepts the same arguments as `json` module in stdlib. :param obj: a JSON serializable Python object. :param kwargs: all the arguments that `json.dumps <http://docs.python.org/ 2/library/json.html#json.dumps>`_ ...
python
def dumps(obj, **kwargs): ''' Serialize `obj` to a JSON formatted `str`. Accepts the same arguments as `json` module in stdlib. :param obj: a JSON serializable Python object. :param kwargs: all the arguments that `json.dumps <http://docs.python.org/ 2/library/json.html#json.dumps>`_ ...
[ "def", "dumps", "(", "obj", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "json", ".", "dumps", "(", "obj", ",", "*", "*", "kwargs", ")", "except", "Exception", "as", "e", ":", "raise", "JSONLibraryException", "(", "e", ")" ]
Serialize `obj` to a JSON formatted `str`. Accepts the same arguments as `json` module in stdlib. :param obj: a JSON serializable Python object. :param kwargs: all the arguments that `json.dumps <http://docs.python.org/ 2/library/json.html#json.dumps>`_ accepts. :raises: commentjson....
[ "Serialize", "obj", "to", "a", "JSON", "formatted", "str", ".", "Accepts", "the", "same", "arguments", "as", "json", "module", "in", "stdlib", "." ]
7ef01ea6939f046b48f812b30a6df6610015a4af
https://github.com/vaidik/commentjson/blob/7ef01ea6939f046b48f812b30a6df6610015a4af/commentjson/commentjson.py#L86-L100
train
60,976
dennisv/django-storage-swift
swift/storage.py
prepend_name_prefix
def prepend_name_prefix(func): """ Decorator that wraps instance methods to prepend the instance's filename prefix to the beginning of the referenced filename. Must only be used on instance methods where the first parameter after `self` is `name` or a comparable parameter of a different name. ""...
python
def prepend_name_prefix(func): """ Decorator that wraps instance methods to prepend the instance's filename prefix to the beginning of the referenced filename. Must only be used on instance methods where the first parameter after `self` is `name` or a comparable parameter of a different name. ""...
[ "def", "prepend_name_prefix", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "prepend_prefix", "(", "self", ",", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "name", "=", "self", ".", "name_prefix", "+", "name", "return...
Decorator that wraps instance methods to prepend the instance's filename prefix to the beginning of the referenced filename. Must only be used on instance methods where the first parameter after `self` is `name` or a comparable parameter of a different name.
[ "Decorator", "that", "wraps", "instance", "methods", "to", "prepend", "the", "instance", "s", "filename", "prefix", "to", "the", "beginning", "of", "the", "referenced", "filename", ".", "Must", "only", "be", "used", "on", "instance", "methods", "where", "the",...
d7c0e8a256c241f429c464c487a14e21629acd7a
https://github.com/dennisv/django-storage-swift/blob/d7c0e8a256c241f429c464c487a14e21629acd7a/swift/storage.py#L103-L114
train
60,977
anthonyalmarza/chalk
chalk/logging.py
get_chalk
def get_chalk(level): """Gets the appropriate piece of chalk for the logging level """ if level >= logging.ERROR: _chalk = chalk.red elif level >= logging.WARNING: _chalk = chalk.yellow elif level >= logging.INFO: _chalk = chalk.blue elif level >= logging.DEBUG: _...
python
def get_chalk(level): """Gets the appropriate piece of chalk for the logging level """ if level >= logging.ERROR: _chalk = chalk.red elif level >= logging.WARNING: _chalk = chalk.yellow elif level >= logging.INFO: _chalk = chalk.blue elif level >= logging.DEBUG: _...
[ "def", "get_chalk", "(", "level", ")", ":", "if", "level", ">=", "logging", ".", "ERROR", ":", "_chalk", "=", "chalk", ".", "red", "elif", "level", ">=", "logging", ".", "WARNING", ":", "_chalk", "=", "chalk", ".", "yellow", "elif", "level", ">=", "l...
Gets the appropriate piece of chalk for the logging level
[ "Gets", "the", "appropriate", "piece", "of", "chalk", "for", "the", "logging", "level" ]
0f562c4ae7e0412f7a47d7b44778979761b380cc
https://github.com/anthonyalmarza/chalk/blob/0f562c4ae7e0412f7a47d7b44778979761b380cc/chalk/logging.py#L7-L20
train
60,978
anthonyalmarza/chalk
chalk/utils.py
to_str
def to_str(obj): """Attempts to convert given object to a string object """ if not isinstance(obj, str) and PY3 and isinstance(obj, bytes): obj = obj.decode('utf-8') return obj if isinstance(obj, string_types) else str(obj)
python
def to_str(obj): """Attempts to convert given object to a string object """ if not isinstance(obj, str) and PY3 and isinstance(obj, bytes): obj = obj.decode('utf-8') return obj if isinstance(obj, string_types) else str(obj)
[ "def", "to_str", "(", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "str", ")", "and", "PY3", "and", "isinstance", "(", "obj", ",", "bytes", ")", ":", "obj", "=", "obj", ".", "decode", "(", "'utf-8'", ")", "return", "obj", "if", "i...
Attempts to convert given object to a string object
[ "Attempts", "to", "convert", "given", "object", "to", "a", "string", "object" ]
0f562c4ae7e0412f7a47d7b44778979761b380cc
https://github.com/anthonyalmarza/chalk/blob/0f562c4ae7e0412f7a47d7b44778979761b380cc/chalk/utils.py#L256-L261
train
60,979
anthonyalmarza/chalk
chalk/utils.py
Color.get_color
def get_color(self, value): """Helper method to validate and map values used in the instantiation of of the Color object to the correct unicode value. """ if value in COLOR_SET: value = COLOR_MAP[value] else: try: value = int(value) ...
python
def get_color(self, value): """Helper method to validate and map values used in the instantiation of of the Color object to the correct unicode value. """ if value in COLOR_SET: value = COLOR_MAP[value] else: try: value = int(value) ...
[ "def", "get_color", "(", "self", ",", "value", ")", ":", "if", "value", "in", "COLOR_SET", ":", "value", "=", "COLOR_MAP", "[", "value", "]", "else", ":", "try", ":", "value", "=", "int", "(", "value", ")", "if", "value", ">=", "8", ":", "raise", ...
Helper method to validate and map values used in the instantiation of of the Color object to the correct unicode value.
[ "Helper", "method", "to", "validate", "and", "map", "values", "used", "in", "the", "instantiation", "of", "of", "the", "Color", "object", "to", "the", "correct", "unicode", "value", "." ]
0f562c4ae7e0412f7a47d7b44778979761b380cc
https://github.com/anthonyalmarza/chalk/blob/0f562c4ae7e0412f7a47d7b44778979761b380cc/chalk/utils.py#L124-L140
train
60,980
icoxfog417/mlimages
mlimages/model.py
LabelFile.shuffle
def shuffle(self, overwrite=False): """ This method creates new shuffled file. """ if overwrite: shuffled = self.path else: shuffled = FileAPI.add_ext_name(self.path, "_shuffled") lines = open(self.path).readlines() random.shuffle(lines) ...
python
def shuffle(self, overwrite=False): """ This method creates new shuffled file. """ if overwrite: shuffled = self.path else: shuffled = FileAPI.add_ext_name(self.path, "_shuffled") lines = open(self.path).readlines() random.shuffle(lines) ...
[ "def", "shuffle", "(", "self", ",", "overwrite", "=", "False", ")", ":", "if", "overwrite", ":", "shuffled", "=", "self", ".", "path", "else", ":", "shuffled", "=", "FileAPI", ".", "add_ext_name", "(", "self", ".", "path", ",", "\"_shuffled\"", ")", "l...
This method creates new shuffled file.
[ "This", "method", "creates", "new", "shuffled", "file", "." ]
724ce145e95a2e2c3597db43327f6e69babb83e2
https://github.com/icoxfog417/mlimages/blob/724ce145e95a2e2c3597db43327f6e69babb83e2/mlimages/model.py#L44-L57
train
60,981
biocore-ntnu/epic
epic/run/run_epic.py
multiple_files_count_reads_in_windows
def multiple_files_count_reads_in_windows(bed_files, args): # type: (Iterable[str], Namespace) -> OrderedDict[str, List[pd.DataFrame]] """Use count_reads on multiple files and store result in dict. Untested since does the same thing as count reads.""" bed_windows = OrderedDict() # type: OrderedDict[st...
python
def multiple_files_count_reads_in_windows(bed_files, args): # type: (Iterable[str], Namespace) -> OrderedDict[str, List[pd.DataFrame]] """Use count_reads on multiple files and store result in dict. Untested since does the same thing as count reads.""" bed_windows = OrderedDict() # type: OrderedDict[st...
[ "def", "multiple_files_count_reads_in_windows", "(", "bed_files", ",", "args", ")", ":", "# type: (Iterable[str], Namespace) -> OrderedDict[str, List[pd.DataFrame]]", "bed_windows", "=", "OrderedDict", "(", ")", "# type: OrderedDict[str, List[pd.DataFrame]]", "for", "bed_file", "in...
Use count_reads on multiple files and store result in dict. Untested since does the same thing as count reads.
[ "Use", "count_reads", "on", "multiple", "files", "and", "store", "result", "in", "dict", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/run/run_epic.py#L129-L144
train
60,982
biocore-ntnu/epic
epic/run/run_epic.py
_merge_files
def _merge_files(windows, nb_cpu): # type: (Iterable[pd.DataFrame], int) -> pd.DataFrame """Merge lists of chromosome bin df chromosome-wise. windows is an OrderedDict where the keys are files, the values are lists of dfs, one per chromosome. Returns a list of dataframes, one per chromosome, with ...
python
def _merge_files(windows, nb_cpu): # type: (Iterable[pd.DataFrame], int) -> pd.DataFrame """Merge lists of chromosome bin df chromosome-wise. windows is an OrderedDict where the keys are files, the values are lists of dfs, one per chromosome. Returns a list of dataframes, one per chromosome, with ...
[ "def", "_merge_files", "(", "windows", ",", "nb_cpu", ")", ":", "# type: (Iterable[pd.DataFrame], int) -> pd.DataFrame", "# windows is a list of chromosome dfs per file", "windows", "=", "iter", "(", "windows", ")", "# can iterate over because it is odict_values", "merged", "=", ...
Merge lists of chromosome bin df chromosome-wise. windows is an OrderedDict where the keys are files, the values are lists of dfs, one per chromosome. Returns a list of dataframes, one per chromosome, with the collective count per bin for all files. TODO: is it faster to merge all in one command?
[ "Merge", "lists", "of", "chromosome", "bin", "df", "chromosome", "-", "wise", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/run/run_epic.py#L147-L169
train
60,983
kvesteri/intervals
intervals/interval.py
py2round
def py2round(value): """Round values as in Python 2, for Python 3 compatibility. All x.5 values are rounded away from zero. In Python 3, this has changed to avoid bias: when x is even, rounding is towards zero, when x is odd, rounding is away from zero. Thus, in Python 3, round(2.5) results in 2, ...
python
def py2round(value): """Round values as in Python 2, for Python 3 compatibility. All x.5 values are rounded away from zero. In Python 3, this has changed to avoid bias: when x is even, rounding is towards zero, when x is odd, rounding is away from zero. Thus, in Python 3, round(2.5) results in 2, ...
[ "def", "py2round", "(", "value", ")", ":", "if", "value", ">", "0", ":", "return", "float", "(", "floor", "(", "float", "(", "value", ")", "+", "0.5", ")", ")", "else", ":", "return", "float", "(", "ceil", "(", "float", "(", "value", ")", "-", ...
Round values as in Python 2, for Python 3 compatibility. All x.5 values are rounded away from zero. In Python 3, this has changed to avoid bias: when x is even, rounding is towards zero, when x is odd, rounding is away from zero. Thus, in Python 3, round(2.5) results in 2, round(3.5) is 4. Py...
[ "Round", "values", "as", "in", "Python", "2", "for", "Python", "3", "compatibility", "." ]
964c9c19826aaa4a6277a584c2427f18d8102542
https://github.com/kvesteri/intervals/blob/964c9c19826aaa4a6277a584c2427f18d8102542/intervals/interval.py#L30-L45
train
60,984
kvesteri/intervals
intervals/interval.py
canonicalize
def canonicalize(interval, lower_inc=True, upper_inc=False): """ Convert equivalent discrete intervals to different representations. """ if not interval.discrete: raise TypeError('Only discrete ranges can be canonicalized') if interval.empty: return interval lower, lower_inc = ...
python
def canonicalize(interval, lower_inc=True, upper_inc=False): """ Convert equivalent discrete intervals to different representations. """ if not interval.discrete: raise TypeError('Only discrete ranges can be canonicalized') if interval.empty: return interval lower, lower_inc = ...
[ "def", "canonicalize", "(", "interval", ",", "lower_inc", "=", "True", ",", "upper_inc", "=", "False", ")", ":", "if", "not", "interval", ".", "discrete", ":", "raise", "TypeError", "(", "'Only discrete ranges can be canonicalized'", ")", "if", "interval", ".", ...
Convert equivalent discrete intervals to different representations.
[ "Convert", "equivalent", "discrete", "intervals", "to", "different", "representations", "." ]
964c9c19826aaa4a6277a584c2427f18d8102542
https://github.com/kvesteri/intervals/blob/964c9c19826aaa4a6277a584c2427f18d8102542/intervals/interval.py#L66-L83
train
60,985
kvesteri/intervals
intervals/interval.py
AbstractInterval.glb
def glb(self, other): """ Return the greatest lower bound for given intervals. :param other: AbstractInterval instance """ return self.__class__( [ min(self.lower, other.lower), min(self.upper, other.upper) ], l...
python
def glb(self, other): """ Return the greatest lower bound for given intervals. :param other: AbstractInterval instance """ return self.__class__( [ min(self.lower, other.lower), min(self.upper, other.upper) ], l...
[ "def", "glb", "(", "self", ",", "other", ")", ":", "return", "self", ".", "__class__", "(", "[", "min", "(", "self", ".", "lower", ",", "other", ".", "lower", ")", ",", "min", "(", "self", ".", "upper", ",", "other", ".", "upper", ")", "]", ","...
Return the greatest lower bound for given intervals. :param other: AbstractInterval instance
[ "Return", "the", "greatest", "lower", "bound", "for", "given", "intervals", "." ]
964c9c19826aaa4a6277a584c2427f18d8102542
https://github.com/kvesteri/intervals/blob/964c9c19826aaa4a6277a584c2427f18d8102542/intervals/interval.py#L542-L555
train
60,986
kvesteri/intervals
intervals/interval.py
AbstractInterval.lub
def lub(self, other): """ Return the least upper bound for given intervals. :param other: AbstractInterval instance """ return self.__class__( [ max(self.lower, other.lower), max(self.upper, other.upper), ], low...
python
def lub(self, other): """ Return the least upper bound for given intervals. :param other: AbstractInterval instance """ return self.__class__( [ max(self.lower, other.lower), max(self.upper, other.upper), ], low...
[ "def", "lub", "(", "self", ",", "other", ")", ":", "return", "self", ".", "__class__", "(", "[", "max", "(", "self", ".", "lower", ",", "other", ".", "lower", ")", ",", "max", "(", "self", ".", "upper", ",", "other", ".", "upper", ")", ",", "]"...
Return the least upper bound for given intervals. :param other: AbstractInterval instance
[ "Return", "the", "least", "upper", "bound", "for", "given", "intervals", "." ]
964c9c19826aaa4a6277a584c2427f18d8102542
https://github.com/kvesteri/intervals/blob/964c9c19826aaa4a6277a584c2427f18d8102542/intervals/interval.py#L558-L571
train
60,987
biocore-ntnu/epic
epic/statistics/compute_values_needed_for_recurrence.py
compute_enriched_threshold
def compute_enriched_threshold(average_window_readcount): # type: (float) -> int """ Computes the minimum number of tags required in window for an island to be enriched. """ current_threshold, survival_function = 0, 1 for current_threshold in count(start=0, step=1): survival_function -=...
python
def compute_enriched_threshold(average_window_readcount): # type: (float) -> int """ Computes the minimum number of tags required in window for an island to be enriched. """ current_threshold, survival_function = 0, 1 for current_threshold in count(start=0, step=1): survival_function -=...
[ "def", "compute_enriched_threshold", "(", "average_window_readcount", ")", ":", "# type: (float) -> int", "current_threshold", ",", "survival_function", "=", "0", ",", "1", "for", "current_threshold", "in", "count", "(", "start", "=", "0", ",", "step", "=", "1", "...
Computes the minimum number of tags required in window for an island to be enriched.
[ "Computes", "the", "minimum", "number", "of", "tags", "required", "in", "window", "for", "an", "island", "to", "be", "enriched", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/statistics/compute_values_needed_for_recurrence.py#L7-L22
train
60,988
biocore-ntnu/epic
epic/statistics/compute_poisson.py
_factln
def _factln(num): # type: (int) -> float """ Computes logfactorial regularly for tractable numbers, uses Ramanujans approximation otherwise. """ if num < 20: log_factorial = log(factorial(num)) else: log_factorial = num * log(num) - num + log(num * (1 + 4 * num * ( 1...
python
def _factln(num): # type: (int) -> float """ Computes logfactorial regularly for tractable numbers, uses Ramanujans approximation otherwise. """ if num < 20: log_factorial = log(factorial(num)) else: log_factorial = num * log(num) - num + log(num * (1 + 4 * num * ( 1...
[ "def", "_factln", "(", "num", ")", ":", "# type: (int) -> float", "if", "num", "<", "20", ":", "log_factorial", "=", "log", "(", "factorial", "(", "num", ")", ")", "else", ":", "log_factorial", "=", "num", "*", "log", "(", "num", ")", "-", "num", "+"...
Computes logfactorial regularly for tractable numbers, uses Ramanujans approximation otherwise.
[ "Computes", "logfactorial", "regularly", "for", "tractable", "numbers", "uses", "Ramanujans", "approximation", "otherwise", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/statistics/compute_poisson.py#L6-L18
train
60,989
biocore-ntnu/epic
epic/merge/merge_helpers.py
add_new_enriched_bins_matrixes
def add_new_enriched_bins_matrixes(region_files, dfs, bin_size): """Add enriched bins based on bed files. There is no way to find the correspondence between region file and matrix file, but it does not matter.""" dfs = _remove_epic_enriched(dfs) names = ["Enriched_" + os.path.basename(r) for r i...
python
def add_new_enriched_bins_matrixes(region_files, dfs, bin_size): """Add enriched bins based on bed files. There is no way to find the correspondence between region file and matrix file, but it does not matter.""" dfs = _remove_epic_enriched(dfs) names = ["Enriched_" + os.path.basename(r) for r i...
[ "def", "add_new_enriched_bins_matrixes", "(", "region_files", ",", "dfs", ",", "bin_size", ")", ":", "dfs", "=", "_remove_epic_enriched", "(", "dfs", ")", "names", "=", "[", "\"Enriched_\"", "+", "os", ".", "path", ".", "basename", "(", "r", ")", "for", "r...
Add enriched bins based on bed files. There is no way to find the correspondence between region file and matrix file, but it does not matter.
[ "Add", "enriched", "bins", "based", "on", "bed", "files", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/merge/merge_helpers.py#L51-L75
train
60,990
biocore-ntnu/epic
epic/windows/count/merge_chromosome_dfs.py
merge_chromosome_dfs
def merge_chromosome_dfs(df_tuple): # type: (Tuple[pd.DataFrame, pd.DataFrame]) -> pd.DataFrame """Merges data from the two strands into strand-agnostic counts.""" plus_df, minus_df = df_tuple index_cols = "Chromosome Bin".split() count_column = plus_df.columns[0] if plus_df.empty: ret...
python
def merge_chromosome_dfs(df_tuple): # type: (Tuple[pd.DataFrame, pd.DataFrame]) -> pd.DataFrame """Merges data from the two strands into strand-agnostic counts.""" plus_df, minus_df = df_tuple index_cols = "Chromosome Bin".split() count_column = plus_df.columns[0] if plus_df.empty: ret...
[ "def", "merge_chromosome_dfs", "(", "df_tuple", ")", ":", "# type: (Tuple[pd.DataFrame, pd.DataFrame]) -> pd.DataFrame", "plus_df", ",", "minus_df", "=", "df_tuple", "index_cols", "=", "\"Chromosome Bin\"", ".", "split", "(", ")", "count_column", "=", "plus_df", ".", "c...
Merges data from the two strands into strand-agnostic counts.
[ "Merges", "data", "from", "the", "two", "strands", "into", "strand", "-", "agnostic", "counts", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/windows/count/merge_chromosome_dfs.py#L5-L32
train
60,991
biocore-ntnu/epic
epic/bigwig/create_bigwigs.py
create_log2fc_bigwigs
def create_log2fc_bigwigs(matrix, outdir, args): # type: (pd.DataFrame, str, Namespace) -> None """Create bigwigs from matrix.""" call("mkdir -p {}".format(outdir), shell=True) genome_size_dict = args.chromosome_sizes outpaths = [] for bed_file in matrix[args.treatment]: outpath = join...
python
def create_log2fc_bigwigs(matrix, outdir, args): # type: (pd.DataFrame, str, Namespace) -> None """Create bigwigs from matrix.""" call("mkdir -p {}".format(outdir), shell=True) genome_size_dict = args.chromosome_sizes outpaths = [] for bed_file in matrix[args.treatment]: outpath = join...
[ "def", "create_log2fc_bigwigs", "(", "matrix", ",", "outdir", ",", "args", ")", ":", "# type: (pd.DataFrame, str, Namespace) -> None", "call", "(", "\"mkdir -p {}\"", ".", "format", "(", "outdir", ")", ",", "shell", "=", "True", ")", "genome_size_dict", "=", "args...
Create bigwigs from matrix.
[ "Create", "bigwigs", "from", "matrix", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/bigwig/create_bigwigs.py#L33-L47
train
60,992
biocore-ntnu/epic
epic/statistics/add_to_island_expectations.py
add_to_island_expectations_dict
def add_to_island_expectations_dict(average_window_readcount, current_max_scaled_score, island_eligibility_threshold, island_expectations, gap_contribution): # type: ( float, int, float, Dict[int, float], flo...
python
def add_to_island_expectations_dict(average_window_readcount, current_max_scaled_score, island_eligibility_threshold, island_expectations, gap_contribution): # type: ( float, int, float, Dict[int, float], flo...
[ "def", "add_to_island_expectations_dict", "(", "average_window_readcount", ",", "current_max_scaled_score", ",", "island_eligibility_threshold", ",", "island_expectations", ",", "gap_contribution", ")", ":", "# type: ( float, int, float, Dict[int, float], float) -> Dict[int, float]", "...
Can probably be heavily optimized. Time required to run can be seen from logging info.
[ "Can", "probably", "be", "heavily", "optimized", ".", "Time", "required", "to", "run", "can", "be", "seen", "from", "logging", "info", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/statistics/add_to_island_expectations.py#L12-L41
train
60,993
biocore-ntnu/epic
epic/scripts/effective_genome_size.py
effective_genome_size
def effective_genome_size(fasta, read_length, nb_cores, tmpdir="/tmp"): # type: (str, int, int, str) -> None """Compute effective genome size for genome.""" idx = Fasta(fasta) genome_length = sum([len(c) for c in idx]) logging.info("Temporary directory: " + tmpdir) logging.info("File analyzed...
python
def effective_genome_size(fasta, read_length, nb_cores, tmpdir="/tmp"): # type: (str, int, int, str) -> None """Compute effective genome size for genome.""" idx = Fasta(fasta) genome_length = sum([len(c) for c in idx]) logging.info("Temporary directory: " + tmpdir) logging.info("File analyzed...
[ "def", "effective_genome_size", "(", "fasta", ",", "read_length", ",", "nb_cores", ",", "tmpdir", "=", "\"/tmp\"", ")", ":", "# type: (str, int, int, str) -> None", "idx", "=", "Fasta", "(", "fasta", ")", "genome_length", "=", "sum", "(", "[", "len", "(", "c",...
Compute effective genome size for genome.
[ "Compute", "effective", "genome", "size", "for", "genome", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/scripts/effective_genome_size.py#L15-L68
train
60,994
biocore-ntnu/epic
epic/matrixes/matrixes.py
get_island_bins
def get_island_bins(df, window_size, genome, args): # type: (pd.DataFrame, int, str, Namespace) -> Dict[str, Set[int]] """Finds the enriched bins in a df.""" # need these chromos because the df might not have islands in all chromos chromosomes = natsorted(list(args.chromosome_sizes)) chromosome_is...
python
def get_island_bins(df, window_size, genome, args): # type: (pd.DataFrame, int, str, Namespace) -> Dict[str, Set[int]] """Finds the enriched bins in a df.""" # need these chromos because the df might not have islands in all chromos chromosomes = natsorted(list(args.chromosome_sizes)) chromosome_is...
[ "def", "get_island_bins", "(", "df", ",", "window_size", ",", "genome", ",", "args", ")", ":", "# type: (pd.DataFrame, int, str, Namespace) -> Dict[str, Set[int]]", "# need these chromos because the df might not have islands in all chromos", "chromosomes", "=", "natsorted", "(", ...
Finds the enriched bins in a df.
[ "Finds", "the", "enriched", "bins", "in", "a", "df", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/matrixes/matrixes.py#L184-L205
train
60,995
biocore-ntnu/epic
epic/config/genomes.py
create_genome_size_dict
def create_genome_size_dict(genome): # type: (str) -> Dict[str,int] """Creates genome size dict from string containing data.""" size_file = get_genome_size_file(genome) size_lines = open(size_file).readlines() size_dict = {} for line in size_lines: genome, length = line.split() ...
python
def create_genome_size_dict(genome): # type: (str) -> Dict[str,int] """Creates genome size dict from string containing data.""" size_file = get_genome_size_file(genome) size_lines = open(size_file).readlines() size_dict = {} for line in size_lines: genome, length = line.split() ...
[ "def", "create_genome_size_dict", "(", "genome", ")", ":", "# type: (str) -> Dict[str,int]", "size_file", "=", "get_genome_size_file", "(", "genome", ")", "size_lines", "=", "open", "(", "size_file", ")", ".", "readlines", "(", ")", "size_dict", "=", "{", "}", "...
Creates genome size dict from string containing data.
[ "Creates", "genome", "size", "dict", "from", "string", "containing", "data", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/config/genomes.py#L29-L41
train
60,996
biocore-ntnu/epic
epic/statistics/compute_score_threshold.py
compute_score_threshold
def compute_score_threshold(average_window_readcount, island_enriched_threshold, gap_contribution, boundary_contribution, genome_length_in_bins): # type: (float, int, float, float, float) -> float """ What does island_expect...
python
def compute_score_threshold(average_window_readcount, island_enriched_threshold, gap_contribution, boundary_contribution, genome_length_in_bins): # type: (float, int, float, float, float) -> float """ What does island_expect...
[ "def", "compute_score_threshold", "(", "average_window_readcount", ",", "island_enriched_threshold", ",", "gap_contribution", ",", "boundary_contribution", ",", "genome_length_in_bins", ")", ":", "# type: (float, int, float, float, float) -> float", "required_p_value", "=", "poisso...
What does island_expectations do?
[ "What", "does", "island_expectations", "do?" ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/statistics/compute_score_threshold.py#L10-L67
train
60,997
biocore-ntnu/epic
epic/utils/find_readlength.py
find_readlength
def find_readlength(args): # type: (Namespace) -> int """Estimate length of reads based on 10000 first.""" try: bed_file = args.treatment[0] except AttributeError: bed_file = args.infiles[0] filereader = "cat " if bed_file.endswith(".gz") and search("linux", platform, IGNORECAS...
python
def find_readlength(args): # type: (Namespace) -> int """Estimate length of reads based on 10000 first.""" try: bed_file = args.treatment[0] except AttributeError: bed_file = args.infiles[0] filereader = "cat " if bed_file.endswith(".gz") and search("linux", platform, IGNORECAS...
[ "def", "find_readlength", "(", "args", ")", ":", "# type: (Namespace) -> int", "try", ":", "bed_file", "=", "args", ".", "treatment", "[", "0", "]", "except", "AttributeError", ":", "bed_file", "=", "args", ".", "infiles", "[", "0", "]", "filereader", "=", ...
Estimate length of reads based on 10000 first.
[ "Estimate", "length", "of", "reads", "based", "on", "10000", "first", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/utils/find_readlength.py#L16-L55
train
60,998
biocore-ntnu/epic
epic/utils/find_readlength.py
get_closest_readlength
def get_closest_readlength(estimated_readlength): # type: (int) -> int """Find the predefined readlength closest to the estimated readlength. In the case of a tie, choose the shortest readlength.""" readlengths = [36, 50, 75, 100] differences = [abs(r - estimated_readlength) for r in readlengths] ...
python
def get_closest_readlength(estimated_readlength): # type: (int) -> int """Find the predefined readlength closest to the estimated readlength. In the case of a tie, choose the shortest readlength.""" readlengths = [36, 50, 75, 100] differences = [abs(r - estimated_readlength) for r in readlengths] ...
[ "def", "get_closest_readlength", "(", "estimated_readlength", ")", ":", "# type: (int) -> int", "readlengths", "=", "[", "36", ",", "50", ",", "75", ",", "100", "]", "differences", "=", "[", "abs", "(", "r", "-", "estimated_readlength", ")", "for", "r", "in"...
Find the predefined readlength closest to the estimated readlength. In the case of a tie, choose the shortest readlength.
[ "Find", "the", "predefined", "readlength", "closest", "to", "the", "estimated", "readlength", "." ]
ed0024939ec6182a0a39d59d845ff14a4889a6ef
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/utils/find_readlength.py#L58-L71
train
60,999