repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
luismmontielg/pyplotter | pyplotter/pyplotter.py | Graph.__get_stack_id | def __get_stack_id(self, value, values, height):
"""
Returns the index of the column representation of the given value
▁ ▂ ▃ ▄ ▅ ▆ ▇' ...
▁ ▂ ▃ ▄ ▅ ▆ ▇' ▇ ▇ ▇ ▇ ▇ ▇ ▇ ...
▁ ▂ ▃ ▄ ▅ ▆ ▇' ▇ ▇ ... | python | def __get_stack_id(self, value, values, height):
"""
Returns the index of the column representation of the given value
▁ ▂ ▃ ▄ ▅ ▆ ▇' ...
▁ ▂ ▃ ▄ ▅ ▆ ▇' ▇ ▇ ▇ ▇ ▇ ▇ ▇ ...
▁ ▂ ▃ ▄ ▅ ▆ ▇' ▇ ▇ ... | [
"def",
"__get_stack_id",
"(",
"self",
",",
"value",
",",
"values",
",",
"height",
")",
":",
"def",
"step",
"(",
"values",
",",
"height",
")",
":",
"step_range",
"=",
"max",
"(",
"values",
")",
"-",
"min",
"(",
"values",
")",
"return",
"(",
"(",
"("... | Returns the index of the column representation of the given value
▁ ▂ ▃ ▄ ▅ ▆ ▇' ...
▁ ▂ ▃ ▄ ▅ ▆ ▇' ▇ ▇ ▇ ▇ ▇ ▇ ▇ ...
▁ ▂ ▃ ▄ ▅ ▆ ▇' ▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇ ...
0 1 2 3 4 5 6 ... | [
"Returns",
"the",
"index",
"of",
"the",
"column",
"representation",
"of",
"the",
"given",
"value"
] | train | https://github.com/luismmontielg/pyplotter/blob/41a00c7a465113d87c732502fa118893f1376d01/pyplotter/pyplotter.py#L246-L266 |
exa-analytics/exa | exa/util/mpl.py | seaborn_set | def seaborn_set(context='poster', style='white', palette='colorblind',
font_scale=1.3, font='serif', rc=mpl_rc):
"""
Perform `seaborn.set(**kwargs)`.
Additional keyword arguments are passed in using this module's
`attr:mpl_rc` attribute.
"""
sns.set(context="poster", style="whit... | python | def seaborn_set(context='poster', style='white', palette='colorblind',
font_scale=1.3, font='serif', rc=mpl_rc):
"""
Perform `seaborn.set(**kwargs)`.
Additional keyword arguments are passed in using this module's
`attr:mpl_rc` attribute.
"""
sns.set(context="poster", style="whit... | [
"def",
"seaborn_set",
"(",
"context",
"=",
"'poster'",
",",
"style",
"=",
"'white'",
",",
"palette",
"=",
"'colorblind'",
",",
"font_scale",
"=",
"1.3",
",",
"font",
"=",
"'serif'",
",",
"rc",
"=",
"mpl_rc",
")",
":",
"sns",
".",
"set",
"(",
"context",... | Perform `seaborn.set(**kwargs)`.
Additional keyword arguments are passed in using this module's
`attr:mpl_rc` attribute. | [
"Perform",
"seaborn",
".",
"set",
"(",
"**",
"kwargs",
")",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/util/mpl.py#L28-L37 |
exa-analytics/exa | exa/util/mpl.py | _gen_figure | def _gen_figure(nxplot=1, nyplot=1, figargs=None, projection=None,
sharex='none', joinx=False, sharey='none', joiny=False,
x=None, nxlabel=None, xlabels=None, nxdecimal=None, xmin=None, xmax=None,
y=None, nylabel=None, ylabels=None, nydecimal=None, ymin=None, ymax=None,
... | python | def _gen_figure(nxplot=1, nyplot=1, figargs=None, projection=None,
sharex='none', joinx=False, sharey='none', joiny=False,
x=None, nxlabel=None, xlabels=None, nxdecimal=None, xmin=None, xmax=None,
y=None, nylabel=None, ylabels=None, nydecimal=None, ymin=None, ymax=None,
... | [
"def",
"_gen_figure",
"(",
"nxplot",
"=",
"1",
",",
"nyplot",
"=",
"1",
",",
"figargs",
"=",
"None",
",",
"projection",
"=",
"None",
",",
"sharex",
"=",
"'none'",
",",
"joinx",
"=",
"False",
",",
"sharey",
"=",
"'none'",
",",
"joiny",
"=",
"False",
... | Returns a figure object with as much customization as provided. | [
"Returns",
"a",
"figure",
"object",
"with",
"as",
"much",
"customization",
"as",
"provided",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/util/mpl.py#L55-L121 |
exa-analytics/exa | exa/core/numerical.py | check_key | def check_key(data_object, key, cardinal=False):
"""
Update the value of an index key by matching values or getting positionals.
"""
itype = (int, np.int32, np.int64)
if not isinstance(key, itype + (slice, tuple, list, np.ndarray)):
raise KeyError("Unknown key type {} for key {}".format(type... | python | def check_key(data_object, key, cardinal=False):
"""
Update the value of an index key by matching values or getting positionals.
"""
itype = (int, np.int32, np.int64)
if not isinstance(key, itype + (slice, tuple, list, np.ndarray)):
raise KeyError("Unknown key type {} for key {}".format(type... | [
"def",
"check_key",
"(",
"data_object",
",",
"key",
",",
"cardinal",
"=",
"False",
")",
":",
"itype",
"=",
"(",
"int",
",",
"np",
".",
"int32",
",",
"np",
".",
"int64",
")",
"if",
"not",
"isinstance",
"(",
"key",
",",
"itype",
"+",
"(",
"slice",
... | Update the value of an index key by matching values or getting positionals. | [
"Update",
"the",
"value",
"of",
"an",
"index",
"key",
"by",
"matching",
"values",
"or",
"getting",
"positionals",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L371-L391 |
exa-analytics/exa | exa/core/numerical.py | Numerical.slice_naive | def slice_naive(self, key):
"""
Slice a data object based on its index, either by value (.loc) or
position (.iloc).
Args:
key: Single index value, slice, tuple, or list of indices/positionals
Returns:
data: Slice of self
"""
cls = self.__... | python | def slice_naive(self, key):
"""
Slice a data object based on its index, either by value (.loc) or
position (.iloc).
Args:
key: Single index value, slice, tuple, or list of indices/positionals
Returns:
data: Slice of self
"""
cls = self.__... | [
"def",
"slice_naive",
"(",
"self",
",",
"key",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"key",
"=",
"check_key",
"(",
"self",
",",
"key",
")",
"return",
"cls",
"(",
"self",
".",
"loc",
"[",
"key",
"]",
")"
] | Slice a data object based on its index, either by value (.loc) or
position (.iloc).
Args:
key: Single index value, slice, tuple, or list of indices/positionals
Returns:
data: Slice of self | [
"Slice",
"a",
"data",
"object",
"based",
"on",
"its",
"index",
"either",
"by",
"value",
"(",
".",
"loc",
")",
"or",
"position",
"(",
".",
"iloc",
")",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L28-L41 |
exa-analytics/exa | exa/core/numerical.py | BaseDataFrame.cardinal_groupby | def cardinal_groupby(self):
"""
Group this object on it cardinal dimension (_cardinal).
Returns:
grpby: Pandas groupby object (grouped on _cardinal)
"""
g, t = self._cardinal
self[g] = self[g].astype(t)
grpby = self.groupby(g)
self[g] = self[g... | python | def cardinal_groupby(self):
"""
Group this object on it cardinal dimension (_cardinal).
Returns:
grpby: Pandas groupby object (grouped on _cardinal)
"""
g, t = self._cardinal
self[g] = self[g].astype(t)
grpby = self.groupby(g)
self[g] = self[g... | [
"def",
"cardinal_groupby",
"(",
"self",
")",
":",
"g",
",",
"t",
"=",
"self",
".",
"_cardinal",
"self",
"[",
"g",
"]",
"=",
"self",
"[",
"g",
"]",
".",
"astype",
"(",
"t",
")",
"grpby",
"=",
"self",
".",
"groupby",
"(",
"g",
")",
"self",
"[",
... | Group this object on it cardinal dimension (_cardinal).
Returns:
grpby: Pandas groupby object (grouped on _cardinal) | [
"Group",
"this",
"object",
"on",
"it",
"cardinal",
"dimension",
"(",
"_cardinal",
")",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L102-L113 |
exa-analytics/exa | exa/core/numerical.py | BaseDataFrame.slice_cardinal | def slice_cardinal(self, key):
"""
Get the slice of this object by the value or values of the cardinal
dimension.
"""
cls = self.__class__
key = check_key(self, key, cardinal=True)
return cls(self[self[self._cardinal[0]].isin(key)]) | python | def slice_cardinal(self, key):
"""
Get the slice of this object by the value or values of the cardinal
dimension.
"""
cls = self.__class__
key = check_key(self, key, cardinal=True)
return cls(self[self[self._cardinal[0]].isin(key)]) | [
"def",
"slice_cardinal",
"(",
"self",
",",
"key",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"key",
"=",
"check_key",
"(",
"self",
",",
"key",
",",
"cardinal",
"=",
"True",
")",
"return",
"cls",
"(",
"self",
"[",
"self",
"[",
"self",
".",
"_ca... | Get the slice of this object by the value or values of the cardinal
dimension. | [
"Get",
"the",
"slice",
"of",
"this",
"object",
"by",
"the",
"value",
"or",
"values",
"of",
"the",
"cardinal",
"dimension",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L115-L122 |
exa-analytics/exa | exa/core/numerical.py | Series.copy | def copy(self, *args, **kwargs):
"""
Make a copy of this object.
See Also:
For arguments and description of behavior see `pandas docs`_.
.. _pandas docs: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.copy.html
"""
cls = self.__class__ ... | python | def copy(self, *args, **kwargs):
"""
Make a copy of this object.
See Also:
For arguments and description of behavior see `pandas docs`_.
.. _pandas docs: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.copy.html
"""
cls = self.__class__ ... | [
"def",
"copy",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"# Note that type conversion does not perform copy",
"return",
"cls",
"(",
"pd",
".",
"Series",
"(",
"self",
")",
".",
"copy",
"(",
"*"... | Make a copy of this object.
See Also:
For arguments and description of behavior see `pandas docs`_.
.. _pandas docs: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.copy.html | [
"Make",
"a",
"copy",
"of",
"this",
"object",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L146-L156 |
exa-analytics/exa | exa/core/numerical.py | DataFrame.copy | def copy(self, *args, **kwargs):
"""
Make a copy of this object.
See Also:
For arguments and description of behavior see `pandas docs`_.
.. _pandas docs: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.copy.html
"""
cls = self.__class__ ... | python | def copy(self, *args, **kwargs):
"""
Make a copy of this object.
See Also:
For arguments and description of behavior see `pandas docs`_.
.. _pandas docs: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.copy.html
"""
cls = self.__class__ ... | [
"def",
"copy",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"# Note that type conversion does not perform copy",
"return",
"cls",
"(",
"pd",
".",
"DataFrame",
"(",
"self",
")",
".",
"copy",
"(",
... | Make a copy of this object.
See Also:
For arguments and description of behavior see `pandas docs`_.
.. _pandas docs: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.copy.html | [
"Make",
"a",
"copy",
"of",
"this",
"object",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L177-L187 |
exa-analytics/exa | exa/core/numerical.py | DataFrame._revert_categories | def _revert_categories(self):
"""
Inplace conversion to categories.
"""
for column, dtype in self._categories.items():
if column in self.columns:
self[column] = self[column].astype(dtype) | python | def _revert_categories(self):
"""
Inplace conversion to categories.
"""
for column, dtype in self._categories.items():
if column in self.columns:
self[column] = self[column].astype(dtype) | [
"def",
"_revert_categories",
"(",
"self",
")",
":",
"for",
"column",
",",
"dtype",
"in",
"self",
".",
"_categories",
".",
"items",
"(",
")",
":",
"if",
"column",
"in",
"self",
".",
"columns",
":",
"self",
"[",
"column",
"]",
"=",
"self",
"[",
"column... | Inplace conversion to categories. | [
"Inplace",
"conversion",
"to",
"categories",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L189-L195 |
exa-analytics/exa | exa/core/numerical.py | DataFrame._set_categories | def _set_categories(self):
"""
Inplace conversion from categories.
"""
for column, _ in self._categories.items():
if column in self.columns:
self[column] = self[column].astype('category') | python | def _set_categories(self):
"""
Inplace conversion from categories.
"""
for column, _ in self._categories.items():
if column in self.columns:
self[column] = self[column].astype('category') | [
"def",
"_set_categories",
"(",
"self",
")",
":",
"for",
"column",
",",
"_",
"in",
"self",
".",
"_categories",
".",
"items",
"(",
")",
":",
"if",
"column",
"in",
"self",
".",
"columns",
":",
"self",
"[",
"column",
"]",
"=",
"self",
"[",
"column",
"]... | Inplace conversion from categories. | [
"Inplace",
"conversion",
"from",
"categories",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L197-L203 |
exa-analytics/exa | exa/core/numerical.py | Field.copy | def copy(self, *args, **kwargs):
"""
Make a copy of this object.
Note:
Copies both field data and field values.
See Also:
For arguments and description of behavior see `pandas docs`_.
.. _pandas docs: http://pandas.pydata.org/pandas-docs/stable/generate... | python | def copy(self, *args, **kwargs):
"""
Make a copy of this object.
Note:
Copies both field data and field values.
See Also:
For arguments and description of behavior see `pandas docs`_.
.. _pandas docs: http://pandas.pydata.org/pandas-docs/stable/generate... | [
"def",
"copy",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"# Note that type conversion does not perform copy",
"data",
"=",
"pd",
".",
"DataFrame",
"(",
"self",
")",
".",
"copy",
"(",
"*",
"arg... | Make a copy of this object.
Note:
Copies both field data and field values.
See Also:
For arguments and description of behavior see `pandas docs`_.
.. _pandas docs: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.copy.html | [
"Make",
"a",
"copy",
"of",
"this",
"object",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L244-L259 |
exa-analytics/exa | exa/core/numerical.py | Field.memory_usage | def memory_usage(self):
"""
Get the combined memory usage of the field data and field values.
"""
data = super(Field, self).memory_usage()
values = 0
for value in self.field_values:
values += value.memory_usage()
data['field_values'] = values
r... | python | def memory_usage(self):
"""
Get the combined memory usage of the field data and field values.
"""
data = super(Field, self).memory_usage()
values = 0
for value in self.field_values:
values += value.memory_usage()
data['field_values'] = values
r... | [
"def",
"memory_usage",
"(",
"self",
")",
":",
"data",
"=",
"super",
"(",
"Field",
",",
"self",
")",
".",
"memory_usage",
"(",
")",
"values",
"=",
"0",
"for",
"value",
"in",
"self",
".",
"field_values",
":",
"values",
"+=",
"value",
".",
"memory_usage",... | Get the combined memory usage of the field data and field values. | [
"Get",
"the",
"combined",
"memory",
"usage",
"of",
"the",
"field",
"data",
"and",
"field",
"values",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L261-L270 |
exa-analytics/exa | exa/core/numerical.py | Field.slice_naive | def slice_naive(self, key):
"""
Naively (on index) slice the field data and values.
Args:
key: Int, slice, or iterable to select data and values
Returns:
field: Sliced field object
"""
cls = self.__class__
key = check_key(self, key)
... | python | def slice_naive(self, key):
"""
Naively (on index) slice the field data and values.
Args:
key: Int, slice, or iterable to select data and values
Returns:
field: Sliced field object
"""
cls = self.__class__
key = check_key(self, key)
... | [
"def",
"slice_naive",
"(",
"self",
",",
"key",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"key",
"=",
"check_key",
"(",
"self",
",",
"key",
")",
"enum",
"=",
"pd",
".",
"Series",
"(",
"range",
"(",
"len",
"(",
"self",
")",
")",
")",
"enum",
... | Naively (on index) slice the field data and values.
Args:
key: Int, slice, or iterable to select data and values
Returns:
field: Sliced field object | [
"Naively",
"(",
"on",
"index",
")",
"slice",
"the",
"field",
"data",
"and",
"values",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L272-L288 |
pytorn/torn | torn/__init__.py | cli | def cli():
"""Function for cli"""
epilog = ('The actions are:\n'
'\tnew\t\tCreate a new torn app\n'
'\trun\t\tRun the app and start a Web server for development\n'
'\tcontroller\tCreate a new controller\n'
'\tversion\t\treturns the current version of torn\n')
... | python | def cli():
"""Function for cli"""
epilog = ('The actions are:\n'
'\tnew\t\tCreate a new torn app\n'
'\trun\t\tRun the app and start a Web server for development\n'
'\tcontroller\tCreate a new controller\n'
'\tversion\t\treturns the current version of torn\n')
... | [
"def",
"cli",
"(",
")",
":",
"epilog",
"=",
"(",
"'The actions are:\\n'",
"'\\tnew\\t\\tCreate a new torn app\\n'",
"'\\trun\\t\\tRun the app and start a Web server for development\\n'",
"'\\tcontroller\\tCreate a new controller\\n'",
"'\\tversion\\t\\treturns the current version of torn\\n'... | Function for cli | [
"Function",
"for",
"cli"
] | train | https://github.com/pytorn/torn/blob/68ba077173a1d22236d570d933dd99a3e3f0040f/torn/__init__.py#L9-L35 |
cslarsen/lyn | lyn/emit.py | State.release | def release(self):
"""Destroys the state, along with its functions."""
self.clear()
if hasattr(self, "functions"):
del self.functions
if hasattr(self, "lib") and self.lib is not None:
self.lib._jit_destroy_state(self.state)
self.lib = None | python | def release(self):
"""Destroys the state, along with its functions."""
self.clear()
if hasattr(self, "functions"):
del self.functions
if hasattr(self, "lib") and self.lib is not None:
self.lib._jit_destroy_state(self.state)
self.lib = None | [
"def",
"release",
"(",
"self",
")",
":",
"self",
".",
"clear",
"(",
")",
"if",
"hasattr",
"(",
"self",
",",
"\"functions\"",
")",
":",
"del",
"self",
".",
"functions",
"if",
"hasattr",
"(",
"self",
",",
"\"lib\"",
")",
"and",
"self",
".",
"lib",
"i... | Destroys the state, along with its functions. | [
"Destroys",
"the",
"state",
"along",
"with",
"its",
"functions",
"."
] | train | https://github.com/cslarsen/lyn/blob/d615a6a9473083ffc7318a98fcc697cbc28ba5da/lyn/emit.py#L41-L50 |
cslarsen/lyn | lyn/emit.py | State.clear | def clear(self):
"""Clears state so it can be used for generating entirely new
instructions."""
if not self._clear:
self.lib._jit_clear_state(self.state)
self._clear = True | python | def clear(self):
"""Clears state so it can be used for generating entirely new
instructions."""
if not self._clear:
self.lib._jit_clear_state(self.state)
self._clear = True | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_clear",
":",
"self",
".",
"lib",
".",
"_jit_clear_state",
"(",
"self",
".",
"state",
")",
"self",
".",
"_clear",
"=",
"True"
] | Clears state so it can be used for generating entirely new
instructions. | [
"Clears",
"state",
"so",
"it",
"can",
"be",
"used",
"for",
"generating",
"entirely",
"new",
"instructions",
"."
] | train | https://github.com/cslarsen/lyn/blob/d615a6a9473083ffc7318a98fcc697cbc28ba5da/lyn/emit.py#L58-L63 |
cslarsen/lyn | lyn/emit.py | State.emit_function | def emit_function(self, return_type=None, argtypes=[], proxy=True):
"""Compiles code and returns a Python-callable function."""
if argtypes is not None:
make_func = ctypes.CFUNCTYPE(return_type, *argtypes)
else:
make_func = ctypes.CFUNCTYPE(return_type)
# NOTE: ... | python | def emit_function(self, return_type=None, argtypes=[], proxy=True):
"""Compiles code and returns a Python-callable function."""
if argtypes is not None:
make_func = ctypes.CFUNCTYPE(return_type, *argtypes)
else:
make_func = ctypes.CFUNCTYPE(return_type)
# NOTE: ... | [
"def",
"emit_function",
"(",
"self",
",",
"return_type",
"=",
"None",
",",
"argtypes",
"=",
"[",
"]",
",",
"proxy",
"=",
"True",
")",
":",
"if",
"argtypes",
"is",
"not",
"None",
":",
"make_func",
"=",
"ctypes",
".",
"CFUNCTYPE",
"(",
"return_type",
","... | Compiles code and returns a Python-callable function. | [
"Compiles",
"code",
"and",
"returns",
"a",
"Python",
"-",
"callable",
"function",
"."
] | train | https://github.com/cslarsen/lyn/blob/d615a6a9473083ffc7318a98fcc697cbc28ba5da/lyn/emit.py#L65-L96 |
zetaops/pyoko | pyoko/db/connection.py | PyokoMG._worker_method | def _worker_method(self):
"""
The body of the multi-get worker. Loops until
:meth:`_should_quit` returns ``True``, taking tasks off the
input queue, fetching the object, and putting them on the
output queue.
"""
while not self._should_quit():
try:
... | python | def _worker_method(self):
"""
The body of the multi-get worker. Loops until
:meth:`_should_quit` returns ``True``, taking tasks off the
input queue, fetching the object, and putting them on the
output queue.
"""
while not self._should_quit():
try:
... | [
"def",
"_worker_method",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"_should_quit",
"(",
")",
":",
"try",
":",
"task",
"=",
"self",
".",
"_inq",
".",
"get",
"(",
"block",
"=",
"True",
",",
"timeout",
"=",
"0.25",
")",
"except",
"TypeError",
... | The body of the multi-get worker. Loops until
:meth:`_should_quit` returns ``True``, taking tasks off the
input queue, fetching the object, and putting them on the
output queue. | [
"The",
"body",
"of",
"the",
"multi",
"-",
"get",
"worker",
".",
"Loops",
"until",
":",
"meth",
":",
"_should_quit",
"returns",
"True",
"taking",
"tasks",
"off",
"the",
"input",
"queue",
"fetching",
"the",
"object",
"and",
"putting",
"them",
"on",
"the",
... | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/connection.py#L37-L83 |
fp12/achallonge | challonge/attachment.py | Attachment.change_url | async def change_url(self, url: str, description: str = None):
""" change the url of that attachment
|methcoro|
Args:
url: url you want to change
description: *optional* description for your attachment
Raises:
ValueError: url must not be None
... | python | async def change_url(self, url: str, description: str = None):
""" change the url of that attachment
|methcoro|
Args:
url: url you want to change
description: *optional* description for your attachment
Raises:
ValueError: url must not be None
... | [
"async",
"def",
"change_url",
"(",
"self",
",",
"url",
":",
"str",
",",
"description",
":",
"str",
"=",
"None",
")",
":",
"await",
"self",
".",
"_change",
"(",
"url",
"=",
"url",
",",
"description",
"=",
"description",
")"
] | change the url of that attachment
|methcoro|
Args:
url: url you want to change
description: *optional* description for your attachment
Raises:
ValueError: url must not be None
APIException | [
"change",
"the",
"url",
"of",
"that",
"attachment"
] | train | https://github.com/fp12/achallonge/blob/25780b3c48b66400a50ff9f884e4287afd4c89e4/challonge/attachment.py#L42-L56 |
fp12/achallonge | challonge/attachment.py | Attachment.change_file | async def change_file(self, file_path: str, description: str = None):
""" change the file of that attachment
|methcoro|
Warning:
|unstable|
Args:
file_path: path to the file you want to add / modify
description: *optional* description for your attac... | python | async def change_file(self, file_path: str, description: str = None):
""" change the file of that attachment
|methcoro|
Warning:
|unstable|
Args:
file_path: path to the file you want to add / modify
description: *optional* description for your attac... | [
"async",
"def",
"change_file",
"(",
"self",
",",
"file_path",
":",
"str",
",",
"description",
":",
"str",
"=",
"None",
")",
":",
"with",
"open",
"(",
"file_path",
",",
"'rb'",
")",
"as",
"f",
":",
"await",
"self",
".",
"_change",
"(",
"asset",
"=",
... | change the file of that attachment
|methcoro|
Warning:
|unstable|
Args:
file_path: path to the file you want to add / modify
description: *optional* description for your attachment
Raises:
ValueError: file_path must not be None
... | [
"change",
"the",
"file",
"of",
"that",
"attachment"
] | train | https://github.com/fp12/achallonge/blob/25780b3c48b66400a50ff9f884e4287afd4c89e4/challonge/attachment.py#L75-L93 |
stevepeak/debris | debris/tornado/__init__.py | cached | def cached(namespace=None, service="memory", debug=False):
"""
Wrapper for tornado requests. Example
```
class MainHandler(tornado.web.RequestHandler):
@debris.tornado.cached("home-page")
def get(self):
self.write("Hello, world")
```
"""
_service = getattr(debr... | python | def cached(namespace=None, service="memory", debug=False):
"""
Wrapper for tornado requests. Example
```
class MainHandler(tornado.web.RequestHandler):
@debris.tornado.cached("home-page")
def get(self):
self.write("Hello, world")
```
"""
_service = getattr(debr... | [
"def",
"cached",
"(",
"namespace",
"=",
"None",
",",
"service",
"=",
"\"memory\"",
",",
"debug",
"=",
"False",
")",
":",
"_service",
"=",
"getattr",
"(",
"debris",
".",
"services",
",",
"service",
")",
"def",
"wrapper",
"(",
"_f",
")",
":",
"@",
"fun... | Wrapper for tornado requests. Example
```
class MainHandler(tornado.web.RequestHandler):
@debris.tornado.cached("home-page")
def get(self):
self.write("Hello, world")
``` | [
"Wrapper",
"for",
"tornado",
"requests",
".",
"Example"
] | train | https://github.com/stevepeak/debris/blob/62ffde573a880c022bd4876ec836b32953225eea/debris/tornado/__init__.py#L18-L47 |
helgi/python-command | command/core.py | which | def which(program, environ=None):
"""
Find out if an executable exists in the supplied PATH.
If so, the absolute path to the executable is returned.
If not, an exception is raised.
:type string
:param program: Executable to be checked for
:param dict
:param environ: Any additional ENV ... | python | def which(program, environ=None):
"""
Find out if an executable exists in the supplied PATH.
If so, the absolute path to the executable is returned.
If not, an exception is raised.
:type string
:param program: Executable to be checked for
:param dict
:param environ: Any additional ENV ... | [
"def",
"which",
"(",
"program",
",",
"environ",
"=",
"None",
")",
":",
"def",
"is_exe",
"(",
"path",
")",
":",
"\"\"\"\n Helper method to check if a file exists and is executable\n \"\"\"",
"return",
"isfile",
"(",
"path",
")",
"and",
"os",
".",
"acces... | Find out if an executable exists in the supplied PATH.
If so, the absolute path to the executable is returned.
If not, an exception is raised.
:type string
:param program: Executable to be checked for
:param dict
:param environ: Any additional ENV variables required, specifically PATH
:re... | [
"Find",
"out",
"if",
"an",
"executable",
"exists",
"in",
"the",
"supplied",
"PATH",
".",
"If",
"so",
"the",
"absolute",
"path",
"to",
"the",
"executable",
"is",
"returned",
".",
"If",
"not",
"an",
"exception",
"is",
"raised",
"."
] | train | https://github.com/helgi/python-command/blob/c41fb8cdd9074b847c7bc5b5ee7f027508f52d7f/command/core.py#L212-L248 |
helgi/python-command | command/core.py | run | def run(command, timeout=None, cwd=None, env=None, debug=None):
"""
Runs a given command on the system within a set time period, providing an easy way to access
command output as it happens without waiting for the command to finish running.
:type list
:param command: Should be a list that contains ... | python | def run(command, timeout=None, cwd=None, env=None, debug=None):
"""
Runs a given command on the system within a set time period, providing an easy way to access
command output as it happens without waiting for the command to finish running.
:type list
:param command: Should be a list that contains ... | [
"def",
"run",
"(",
"command",
",",
"timeout",
"=",
"None",
",",
"cwd",
"=",
"None",
",",
"env",
"=",
"None",
",",
"debug",
"=",
"None",
")",
":",
"return",
"Command",
".",
"run",
"(",
"command",
",",
"timeout",
"=",
"timeout",
",",
"cwd",
"=",
"c... | Runs a given command on the system within a set time period, providing an easy way to access
command output as it happens without waiting for the command to finish running.
:type list
:param command: Should be a list that contains the command that should be ran on the given
system. The ... | [
"Runs",
"a",
"given",
"command",
"on",
"the",
"system",
"within",
"a",
"set",
"time",
"period",
"providing",
"an",
"easy",
"way",
"to",
"access",
"command",
"output",
"as",
"it",
"happens",
"without",
"waiting",
"for",
"the",
"command",
"to",
"finish",
"ru... | train | https://github.com/helgi/python-command/blob/c41fb8cdd9074b847c7bc5b5ee7f027508f52d7f/command/core.py#L251-L285 |
helgi/python-command | command/core.py | Command.run | def run(cls, command, timeout=None, cwd=None, env=None, debug=None):
"""
Runs a given command on the system within a set time period, providing an easy way to access
command output as it happens without waiting for the command to finish running.
:type list
:param command: Should... | python | def run(cls, command, timeout=None, cwd=None, env=None, debug=None):
"""
Runs a given command on the system within a set time period, providing an easy way to access
command output as it happens without waiting for the command to finish running.
:type list
:param command: Should... | [
"def",
"run",
"(",
"cls",
",",
"command",
",",
"timeout",
"=",
"None",
",",
"cwd",
"=",
"None",
",",
"env",
"=",
"None",
",",
"debug",
"=",
"None",
")",
":",
"# Merge together the system ENV details and the passed in ones if any",
"environ",
"=",
"dict",
"(",
... | Runs a given command on the system within a set time period, providing an easy way to access
command output as it happens without waiting for the command to finish running.
:type list
:param command: Should be a list that contains the command that should be ran on the given
... | [
"Runs",
"a",
"given",
"command",
"on",
"the",
"system",
"within",
"a",
"set",
"time",
"period",
"providing",
"an",
"easy",
"way",
"to",
"access",
"command",
"output",
"as",
"it",
"happens",
"without",
"waiting",
"for",
"the",
"command",
"to",
"finish",
"ru... | train | https://github.com/helgi/python-command/blob/c41fb8cdd9074b847c7bc5b5ee7f027508f52d7f/command/core.py#L37-L176 |
dlancer/django-crispy-contact-form | contact_form/views.py | ContactFormView.form_valid | def form_valid(self, form):
"""This is what's called when the form is valid."""
instance = form.save(commit=False)
if hasattr(self.request, 'user'):
instance.user = self.request.user
if settings.CONTACT_FORM_FILTER_MESSAGE:
instance.message = bleach.clean(
... | python | def form_valid(self, form):
"""This is what's called when the form is valid."""
instance = form.save(commit=False)
if hasattr(self.request, 'user'):
instance.user = self.request.user
if settings.CONTACT_FORM_FILTER_MESSAGE:
instance.message = bleach.clean(
... | [
"def",
"form_valid",
"(",
"self",
",",
"form",
")",
":",
"instance",
"=",
"form",
".",
"save",
"(",
"commit",
"=",
"False",
")",
"if",
"hasattr",
"(",
"self",
".",
"request",
",",
"'user'",
")",
":",
"instance",
".",
"user",
"=",
"self",
".",
"requ... | This is what's called when the form is valid. | [
"This",
"is",
"what",
"s",
"called",
"when",
"the",
"form",
"is",
"valid",
"."
] | train | https://github.com/dlancer/django-crispy-contact-form/blob/3d422556add5aea3607344a034779c214f84da04/contact_form/views.py#L70-L97 |
dlancer/django-crispy-contact-form | contact_form/views.py | ContactFormView.form_invalid | def form_invalid(self, form):
"""This is what's called when the form is invalid."""
ip = get_user_ip(self.request)
if settings.CONTACT_FORM_USE_SIGNALS:
contact_form_invalid.send(
sender=self,
event=self.invalid_event,
ip=ip,
... | python | def form_invalid(self, form):
"""This is what's called when the form is invalid."""
ip = get_user_ip(self.request)
if settings.CONTACT_FORM_USE_SIGNALS:
contact_form_invalid.send(
sender=self,
event=self.invalid_event,
ip=ip,
... | [
"def",
"form_invalid",
"(",
"self",
",",
"form",
")",
":",
"ip",
"=",
"get_user_ip",
"(",
"self",
".",
"request",
")",
"if",
"settings",
".",
"CONTACT_FORM_USE_SIGNALS",
":",
"contact_form_invalid",
".",
"send",
"(",
"sender",
"=",
"self",
",",
"event",
"=... | This is what's called when the form is invalid. | [
"This",
"is",
"what",
"s",
"called",
"when",
"the",
"form",
"is",
"invalid",
"."
] | train | https://github.com/dlancer/django-crispy-contact-form/blob/3d422556add5aea3607344a034779c214f84da04/contact_form/views.py#L99-L112 |
henzk/django-productline | django_productline/template.py | bind_settings | def bind_settings():
"""
Put DJANGO_TEMPLATE_* under the right settings.* name according to django-version
:return:
"""
from django_productline import settings
if settings.TEMPLATE_LOADER_CACHED_ENABLED:
loaders = [
['django.template.loaders.cached.Loader', settings.DJANGO_T... | python | def bind_settings():
"""
Put DJANGO_TEMPLATE_* under the right settings.* name according to django-version
:return:
"""
from django_productline import settings
if settings.TEMPLATE_LOADER_CACHED_ENABLED:
loaders = [
['django.template.loaders.cached.Loader', settings.DJANGO_T... | [
"def",
"bind_settings",
"(",
")",
":",
"from",
"django_productline",
"import",
"settings",
"if",
"settings",
".",
"TEMPLATE_LOADER_CACHED_ENABLED",
":",
"loaders",
"=",
"[",
"[",
"'django.template.loaders.cached.Loader'",
",",
"settings",
".",
"DJANGO_TEMPLATE_LOADERS",
... | Put DJANGO_TEMPLATE_* under the right settings.* name according to django-version
:return: | [
"Put",
"DJANGO_TEMPLATE_",
"*",
"under",
"the",
"right",
"settings",
".",
"*",
"name",
"according",
"to",
"django",
"-",
"version",
":",
"return",
":"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/template.py#L9-L44 |
seibert-media/Highton | highton/call_mixins/create_tag_call_mixin.py | CreateTagCallMixin.add_tag | def add_tag(self, name):
"""
Create a Tag to current object
:param name: the name of the tag
:type name: str
:return: newly created Tag
:rtype: Tag
"""
from highton.models.tag import Tag
created_id = self._post_request(
endpoint=self.E... | python | def add_tag(self, name):
"""
Create a Tag to current object
:param name: the name of the tag
:type name: str
:return: newly created Tag
:rtype: Tag
"""
from highton.models.tag import Tag
created_id = self._post_request(
endpoint=self.E... | [
"def",
"add_tag",
"(",
"self",
",",
"name",
")",
":",
"from",
"highton",
".",
"models",
".",
"tag",
"import",
"Tag",
"created_id",
"=",
"self",
".",
"_post_request",
"(",
"endpoint",
"=",
"self",
".",
"ENDPOINT",
"+",
"'/'",
"+",
"str",
"(",
"self",
... | Create a Tag to current object
:param name: the name of the tag
:type name: str
:return: newly created Tag
:rtype: Tag | [
"Create",
"a",
"Tag",
"to",
"current",
"object"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/call_mixins/create_tag_call_mixin.py#L11-L27 |
ibm-watson-data-lab/ibmseti | ibmseti/dsp.py | time_bins | def time_bins(header):
'''
Returns the time-axis lower bin edge values for the spectrogram.
'''
return np.arange(header['number_of_half_frames'], dtype=np.float64)*constants.bins_per_half_frame\
*(1.0 - header['over_sampling']) / header['subband_spacing_hz'] | python | def time_bins(header):
'''
Returns the time-axis lower bin edge values for the spectrogram.
'''
return np.arange(header['number_of_half_frames'], dtype=np.float64)*constants.bins_per_half_frame\
*(1.0 - header['over_sampling']) / header['subband_spacing_hz'] | [
"def",
"time_bins",
"(",
"header",
")",
":",
"return",
"np",
".",
"arange",
"(",
"header",
"[",
"'number_of_half_frames'",
"]",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
"*",
"constants",
".",
"bins_per_half_frame",
"*",
"(",
"1.0",
"-",
"header",
"[... | Returns the time-axis lower bin edge values for the spectrogram. | [
"Returns",
"the",
"time",
"-",
"axis",
"lower",
"bin",
"edge",
"values",
"for",
"the",
"spectrogram",
"."
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/dsp.py#L23-L28 |
ibm-watson-data-lab/ibmseti | ibmseti/dsp.py | frequency_bins | def frequency_bins(header):
'''
Returnes the frequency-axis lower bin edge values for the spectrogram.
'''
center_frequency = 1.0e6*header['rf_center_frequency']
if header["number_of_subbands"] > 1:
center_frequency += header["subband_spacing_hz"]*(header["number_of_subbands"]/2.0 - 0.5)
return np.ff... | python | def frequency_bins(header):
'''
Returnes the frequency-axis lower bin edge values for the spectrogram.
'''
center_frequency = 1.0e6*header['rf_center_frequency']
if header["number_of_subbands"] > 1:
center_frequency += header["subband_spacing_hz"]*(header["number_of_subbands"]/2.0 - 0.5)
return np.ff... | [
"def",
"frequency_bins",
"(",
"header",
")",
":",
"center_frequency",
"=",
"1.0e6",
"*",
"header",
"[",
"'rf_center_frequency'",
"]",
"if",
"header",
"[",
"\"number_of_subbands\"",
"]",
">",
"1",
":",
"center_frequency",
"+=",
"header",
"[",
"\"subband_spacing_hz\... | Returnes the frequency-axis lower bin edge values for the spectrogram. | [
"Returnes",
"the",
"frequency",
"-",
"axis",
"lower",
"bin",
"edge",
"values",
"for",
"the",
"spectrogram",
"."
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/dsp.py#L30-L42 |
ibm-watson-data-lab/ibmseti | ibmseti/dsp.py | complex_to_fourier | def complex_to_fourier(cdata, over_sampling, norm=None):
'''
cdata: 3D complex data (shaped by subbands and half_frames, as returned from Compamp.complex_data())
over_sampling: The fraction of oversampling across subbands (typically 0.25)
norm: None or "ortho" -- see Numpy FFT Normalization documentation. Defau... | python | def complex_to_fourier(cdata, over_sampling, norm=None):
'''
cdata: 3D complex data (shaped by subbands and half_frames, as returned from Compamp.complex_data())
over_sampling: The fraction of oversampling across subbands (typically 0.25)
norm: None or "ortho" -- see Numpy FFT Normalization documentation. Defau... | [
"def",
"complex_to_fourier",
"(",
"cdata",
",",
"over_sampling",
",",
"norm",
"=",
"None",
")",
":",
"# FFT all blocks separately and rearrange output",
"fftcdata",
"=",
"np",
".",
"fft",
".",
"fftshift",
"(",
"np",
".",
"fft",
".",
"fft",
"(",
"cdata",
",",
... | cdata: 3D complex data (shaped by subbands and half_frames, as returned from Compamp.complex_data())
over_sampling: The fraction of oversampling across subbands (typically 0.25)
norm: None or "ortho" -- see Numpy FFT Normalization documentation. Default is None.
returns the signal in complex fourier space. The o... | [
"cdata",
":",
"3D",
"complex",
"data",
"(",
"shaped",
"by",
"subbands",
"and",
"half_frames",
"as",
"returned",
"from",
"Compamp",
".",
"complex_data",
"()",
")",
"over_sampling",
":",
"The",
"fraction",
"of",
"oversampling",
"across",
"subbands",
"(",
"typica... | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/dsp.py#L44-L62 |
ibm-watson-data-lab/ibmseti | ibmseti/dsp.py | fourier_to_time | def fourier_to_time(fcdata, norm=None):
'''
Converts the data from 2D fourier space signal to a 1D time-series.
fcdata: Complex fourier spectrum as a 2D array, The axis=0 is for each "half frame", and axis=1 contains the
fourier-space data for that half frame. Typically there are 129 "half frames" in the data.... | python | def fourier_to_time(fcdata, norm=None):
'''
Converts the data from 2D fourier space signal to a 1D time-series.
fcdata: Complex fourier spectrum as a 2D array, The axis=0 is for each "half frame", and axis=1 contains the
fourier-space data for that half frame. Typically there are 129 "half frames" in the data.... | [
"def",
"fourier_to_time",
"(",
"fcdata",
",",
"norm",
"=",
"None",
")",
":",
"return",
"np",
".",
"fft",
".",
"ifft",
"(",
"np",
".",
"fft",
".",
"ifftshift",
"(",
"fcdata",
",",
"1",
")",
",",
"norm",
"=",
"norm",
")",
".",
"reshape",
"(",
"fcda... | Converts the data from 2D fourier space signal to a 1D time-series.
fcdata: Complex fourier spectrum as a 2D array, The axis=0 is for each "half frame", and axis=1 contains the
fourier-space data for that half frame. Typically there are 129 "half frames" in the data.
Furthermore, it's assumed that fftshift has ... | [
"Converts",
"the",
"data",
"from",
"2D",
"fourier",
"space",
"signal",
"to",
"a",
"1D",
"time",
"-",
"series",
"."
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/dsp.py#L64-L94 |
ibm-watson-data-lab/ibmseti | ibmseti/dsp.py | complex_to_power | def complex_to_power(cdata, over_sampling):
'''
cdata: 3D complex data (shaped by subbands and half_frames, as returned from Compamp.complex_data())
over_sampling: The fraction of oversampling across subbands (typically 0.25).
returns a 3D spectrogram
Example:
aca = ibmseti.compamp.Compamp(raw_... | python | def complex_to_power(cdata, over_sampling):
'''
cdata: 3D complex data (shaped by subbands and half_frames, as returned from Compamp.complex_data())
over_sampling: The fraction of oversampling across subbands (typically 0.25).
returns a 3D spectrogram
Example:
aca = ibmseti.compamp.Compamp(raw_... | [
"def",
"complex_to_power",
"(",
"cdata",
",",
"over_sampling",
")",
":",
"fftcdata",
"=",
"complex_to_fourier",
"(",
"cdata",
",",
"over_sampling",
")",
"# calculate power, normalize and amplify by factor 15 (what is the factor of 15 for?)",
"fftcdata",
"=",
"np",
".",
"mul... | cdata: 3D complex data (shaped by subbands and half_frames, as returned from Compamp.complex_data())
over_sampling: The fraction of oversampling across subbands (typically 0.25).
returns a 3D spectrogram
Example:
aca = ibmseti.compamp.Compamp(raw_data)
cdata = aca.complex_data()
#can perf... | [
"cdata",
":",
"3D",
"complex",
"data",
"(",
"shaped",
"by",
"subbands",
"and",
"half_frames",
"as",
"returned",
"from",
"Compamp",
".",
"complex_data",
"()",
")",
"over_sampling",
":",
"The",
"fraction",
"of",
"oversampling",
"across",
"subbands",
"(",
"typica... | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/dsp.py#L97-L122 |
ibm-watson-data-lab/ibmseti | ibmseti/dsp.py | reshape_to_2d | def reshape_to_2d(arr):
'''
Assumes a 3D Numpy array, and reshapes like
arr.reshape((arr.shape[0], arr.shape[1]*arr.shape[2]))
This is useful for converting processed data from `complex_to_power`
and from `autocorrelation` into a 2D array for image analysis and display.
'''
return arr.reshape((arr.sh... | python | def reshape_to_2d(arr):
'''
Assumes a 3D Numpy array, and reshapes like
arr.reshape((arr.shape[0], arr.shape[1]*arr.shape[2]))
This is useful for converting processed data from `complex_to_power`
and from `autocorrelation` into a 2D array for image analysis and display.
'''
return arr.reshape((arr.sh... | [
"def",
"reshape_to_2d",
"(",
"arr",
")",
":",
"return",
"arr",
".",
"reshape",
"(",
"(",
"arr",
".",
"shape",
"[",
"0",
"]",
",",
"arr",
".",
"shape",
"[",
"1",
"]",
"*",
"arr",
".",
"shape",
"[",
"2",
"]",
")",
")"
] | Assumes a 3D Numpy array, and reshapes like
arr.reshape((arr.shape[0], arr.shape[1]*arr.shape[2]))
This is useful for converting processed data from `complex_to_power`
and from `autocorrelation` into a 2D array for image analysis and display. | [
"Assumes",
"a",
"3D",
"Numpy",
"array",
"and",
"reshapes",
"like",
"arr",
".",
"reshape",
"((",
"arr",
".",
"shape",
"[",
"0",
"]",
"arr",
".",
"shape",
"[",
"1",
"]",
"*",
"arr",
".",
"shape",
"[",
"2",
"]",
"))"
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/dsp.py#L124-L134 |
ibm-watson-data-lab/ibmseti | ibmseti/dsp.py | compamp_to_spectrogram | def compamp_to_spectrogram(compamp):
'''
Returns spectrogram, with each row containing the measured power spectrum for a XX second time sample.
Using this function is shorthand for:
aca = ibmseti.compamp.Compamp(raw_data)
power = ibmseti.dsp.complex_to_power(aca.complex_data(), aca.header()['over_sam... | python | def compamp_to_spectrogram(compamp):
'''
Returns spectrogram, with each row containing the measured power spectrum for a XX second time sample.
Using this function is shorthand for:
aca = ibmseti.compamp.Compamp(raw_data)
power = ibmseti.dsp.complex_to_power(aca.complex_data(), aca.header()['over_sam... | [
"def",
"compamp_to_spectrogram",
"(",
"compamp",
")",
":",
"power",
"=",
"complex_to_power",
"(",
"compamp",
".",
"complex_data",
"(",
")",
",",
"compamp",
".",
"header",
"(",
")",
"[",
"'over_sampling'",
"]",
")",
"return",
"reshape_to_2d",
"(",
"power",
")... | Returns spectrogram, with each row containing the measured power spectrum for a XX second time sample.
Using this function is shorthand for:
aca = ibmseti.compamp.Compamp(raw_data)
power = ibmseti.dsp.complex_to_power(aca.complex_data(), aca.header()['over_sampling'])
spectrogram = ibmseti.dsp.resh... | [
"Returns",
"spectrogram",
"with",
"each",
"row",
"containing",
"the",
"measured",
"power",
"spectrum",
"for",
"a",
"XX",
"second",
"time",
"sample",
"."
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/dsp.py#L137-L166 |
ibm-watson-data-lab/ibmseti | ibmseti/dsp.py | compamp_to_ac | def compamp_to_ac(compamp, window=np.hanning): # convert single or multi-subband compamps into autocorrelation waterfall
'''
Adapted from Gerry Harp at SETI.
'''
header = compamp.header()
cdata = compamp.complex_data()
#Apply Windowing and Padding
cdata = np.multiply(cdata, window(cdata.shape[2]))... | python | def compamp_to_ac(compamp, window=np.hanning): # convert single or multi-subband compamps into autocorrelation waterfall
'''
Adapted from Gerry Harp at SETI.
'''
header = compamp.header()
cdata = compamp.complex_data()
#Apply Windowing and Padding
cdata = np.multiply(cdata, window(cdata.shape[2]))... | [
"def",
"compamp_to_ac",
"(",
"compamp",
",",
"window",
"=",
"np",
".",
"hanning",
")",
":",
"# convert single or multi-subband compamps into autocorrelation waterfall",
"header",
"=",
"compamp",
".",
"header",
"(",
")",
"cdata",
"=",
"compamp",
".",
"complex_data",
... | Adapted from Gerry Harp at SETI. | [
"Adapted",
"from",
"Gerry",
"Harp",
"at",
"SETI",
"."
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/dsp.py#L176-L202 |
ibm-watson-data-lab/ibmseti | ibmseti/dsp.py | ac_viz | def ac_viz(acdata):
'''
Adapted from Gerry Harp at SETI.
Slightly massages the autocorrelated calculation result for better visualization.
In particular, the natural log of the data are calculated and the
values along the subband edges are set to the maximum value of the data,
and the t=0 delay of the ... | python | def ac_viz(acdata):
'''
Adapted from Gerry Harp at SETI.
Slightly massages the autocorrelated calculation result for better visualization.
In particular, the natural log of the data are calculated and the
values along the subband edges are set to the maximum value of the data,
and the t=0 delay of the ... | [
"def",
"ac_viz",
"(",
"acdata",
")",
":",
"acdata",
"=",
"np",
".",
"log",
"(",
"acdata",
"+",
"0.000001",
")",
"# log to reduce darkening on sides of spectrum, due to AC triangling",
"acdata",
"[",
":",
",",
":",
",",
"acdata",
".",
"shape",
"[",
"2",
"]",
... | Adapted from Gerry Harp at SETI.
Slightly massages the autocorrelated calculation result for better visualization.
In particular, the natural log of the data are calculated and the
values along the subband edges are set to the maximum value of the data,
and the t=0 delay of the autocorrelation result are s... | [
"Adapted",
"from",
"Gerry",
"Harp",
"at",
"SETI",
".",
"Slightly",
"massages",
"the",
"autocorrelated",
"calculation",
"result",
"for",
"better",
"visualization",
"."
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/dsp.py#L204-L223 |
django-blog-zinnia/admin-tools-zinnia | demo_admin_tools_zinnia/views.py | server_error | def server_error(request, template_name='500.html'):
"""
500 error handler.
Templates: `500.html`
Context:
STATIC_URL
Path of static media (e.g. "media.example.org")
"""
t = loader.get_template(template_name)
return HttpResponseServerError(
t.render(Context({'STATIC_URL': s... | python | def server_error(request, template_name='500.html'):
"""
500 error handler.
Templates: `500.html`
Context:
STATIC_URL
Path of static media (e.g. "media.example.org")
"""
t = loader.get_template(template_name)
return HttpResponseServerError(
t.render(Context({'STATIC_URL': s... | [
"def",
"server_error",
"(",
"request",
",",
"template_name",
"=",
"'500.html'",
")",
":",
"t",
"=",
"loader",
".",
"get_template",
"(",
"template_name",
")",
"return",
"HttpResponseServerError",
"(",
"t",
".",
"render",
"(",
"Context",
"(",
"{",
"'STATIC_URL'"... | 500 error handler.
Templates: `500.html`
Context:
STATIC_URL
Path of static media (e.g. "media.example.org") | [
"500",
"error",
"handler",
".",
"Templates",
":",
"500",
".",
"html",
"Context",
":",
"STATIC_URL",
"Path",
"of",
"static",
"media",
"(",
"e",
".",
"g",
".",
"media",
".",
"example",
".",
"org",
")"
] | train | https://github.com/django-blog-zinnia/admin-tools-zinnia/blob/f370e6b05dfc62eab0a9739ebf5b17fd13ebf7dc/demo_admin_tools_zinnia/views.py#L8-L18 |
SetBased/py-etlt | etlt/helper/Allen.py | Allen.relation | def relation(x_start, x_end, y_start, y_end):
"""
Returns the relation between two intervals.
:param int x_start: The start point of the first interval.
:param int x_end: The end point of the first interval.
:param int y_start: The start point of the second interval.
:pa... | python | def relation(x_start, x_end, y_start, y_end):
"""
Returns the relation between two intervals.
:param int x_start: The start point of the first interval.
:param int x_end: The end point of the first interval.
:param int y_start: The start point of the second interval.
:pa... | [
"def",
"relation",
"(",
"x_start",
",",
"x_end",
",",
"y_start",
",",
"y_end",
")",
":",
"if",
"(",
"x_end",
"-",
"x_start",
")",
"<",
"0",
"or",
"(",
"y_end",
"-",
"y_start",
")",
"<",
"0",
":",
"return",
"None",
"diff_end",
"=",
"y_end",
"-",
"... | Returns the relation between two intervals.
:param int x_start: The start point of the first interval.
:param int x_end: The end point of the first interval.
:param int y_start: The start point of the second interval.
:param int y_end: The end point of the second interval.
:rty... | [
"Returns",
"the",
"relation",
"between",
"two",
"intervals",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/helper/Allen.py#L31-L76 |
ionelmc/python-cogen | cogen/web/wsgi.py | server_factory | def server_factory(global_conf, host, port, **options):
"""Server factory for paste.
Options are:
* proactor: class name to use from cogen.core.proactors
(default: DefaultProactor - best available proactor for current platform)
* proactor_resolution: float
* sched_default_priority: int (se... | python | def server_factory(global_conf, host, port, **options):
"""Server factory for paste.
Options are:
* proactor: class name to use from cogen.core.proactors
(default: DefaultProactor - best available proactor for current platform)
* proactor_resolution: float
* sched_default_priority: int (se... | [
"def",
"server_factory",
"(",
"global_conf",
",",
"host",
",",
"port",
",",
"*",
"*",
"options",
")",
":",
"port",
"=",
"int",
"(",
"port",
")",
"try",
":",
"import",
"paste",
".",
"util",
".",
"threadinglocal",
"as",
"pastelocal",
"pastelocal",
".",
"... | Server factory for paste.
Options are:
* proactor: class name to use from cogen.core.proactors
(default: DefaultProactor - best available proactor for current platform)
* proactor_resolution: float
* sched_default_priority: int (see cogen.core.util.priority)
* sched_default_timeout: floa... | [
"Server",
"factory",
"for",
"paste",
".",
"Options",
"are",
":",
"*",
"proactor",
":",
"class",
"name",
"to",
"use",
"from",
"cogen",
".",
"core",
".",
"proactors",
"(",
"default",
":",
"DefaultProactor",
"-",
"best",
"available",
"proactor",
"for",
"curre... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/web/wsgi.py#L769-L797 |
ionelmc/python-cogen | cogen/web/wsgi.py | WSGIConnection.start_response | def start_response(self, status, headers, exc_info = None):
"""WSGI callable to begin the HTTP response."""
if self.started_response:
if not exc_info:
raise AssertionError("WSGI start_response called a second "
"time with no exc_info.")
else:
try:
... | python | def start_response(self, status, headers, exc_info = None):
"""WSGI callable to begin the HTTP response."""
if self.started_response:
if not exc_info:
raise AssertionError("WSGI start_response called a second "
"time with no exc_info.")
else:
try:
... | [
"def",
"start_response",
"(",
"self",
",",
"status",
",",
"headers",
",",
"exc_info",
"=",
"None",
")",
":",
"if",
"self",
".",
"started_response",
":",
"if",
"not",
"exc_info",
":",
"raise",
"AssertionError",
"(",
"\"WSGI start_response called a second \"",
"\"... | WSGI callable to begin the HTTP response. | [
"WSGI",
"callable",
"to",
"begin",
"the",
"HTTP",
"response",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/web/wsgi.py#L163-L178 |
ionelmc/python-cogen | cogen/web/wsgi.py | WSGIConnection.simple_response | def simple_response(self, status, msg=""):
"""Return a operation for writing simple response back to the client."""
status = str(status)
buf = ["%s %s\r\n" % (self.environ['ACTUAL_SERVER_PROTOCOL'], status),
"Content-Length: %s\r\n" % len(msg),
"Content-Type: text/plain\r\n"]
i... | python | def simple_response(self, status, msg=""):
"""Return a operation for writing simple response back to the client."""
status = str(status)
buf = ["%s %s\r\n" % (self.environ['ACTUAL_SERVER_PROTOCOL'], status),
"Content-Length: %s\r\n" % len(msg),
"Content-Type: text/plain\r\n"]
i... | [
"def",
"simple_response",
"(",
"self",
",",
"status",
",",
"msg",
"=",
"\"\"",
")",
":",
"status",
"=",
"str",
"(",
"status",
")",
"buf",
"=",
"[",
"\"%s %s\\r\\n\"",
"%",
"(",
"self",
".",
"environ",
"[",
"'ACTUAL_SERVER_PROTOCOL'",
"]",
",",
"status",
... | Return a operation for writing simple response back to the client. | [
"Return",
"a",
"operation",
"for",
"writing",
"simple",
"response",
"back",
"to",
"the",
"client",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/web/wsgi.py#L230-L245 |
ionelmc/python-cogen | cogen/web/wsgi.py | WSGIConnection.run | def run(self):
"""A bit bulky atm..."""
self.close_connection = False
try:
while True:
self.started_response = False
self.status = ""
self.outheaders = []
self.sent_headers = False
self.chunked_write = False
self.write_buffer = StringIO.Strin... | python | def run(self):
"""A bit bulky atm..."""
self.close_connection = False
try:
while True:
self.started_response = False
self.status = ""
self.outheaders = []
self.sent_headers = False
self.chunked_write = False
self.write_buffer = StringIO.Strin... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"close_connection",
"=",
"False",
"try",
":",
"while",
"True",
":",
"self",
".",
"started_response",
"=",
"False",
"self",
".",
"status",
"=",
"\"\"",
"self",
".",
"outheaders",
"=",
"[",
"]",
"self",
... | A bit bulky atm... | [
"A",
"bit",
"bulky",
"atm",
"..."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/web/wsgi.py#L250-L533 |
ionelmc/python-cogen | cogen/web/wsgi.py | WSGIServer.serve | def serve(self):
"""Run the server forever."""
# We don't have to trap KeyboardInterrupt or SystemExit here,
# Select the appropriate socket
if isinstance(self.bind_addr, basestring):
# AF_UNIX socket
# So we can reuse the socket...
try: os.unlink(self.bind_addr)
exce... | python | def serve(self):
"""Run the server forever."""
# We don't have to trap KeyboardInterrupt or SystemExit here,
# Select the appropriate socket
if isinstance(self.bind_addr, basestring):
# AF_UNIX socket
# So we can reuse the socket...
try: os.unlink(self.bind_addr)
exce... | [
"def",
"serve",
"(",
"self",
")",
":",
"# We don't have to trap KeyboardInterrupt or SystemExit here,\r",
"# Select the appropriate socket\r",
"if",
"isinstance",
"(",
"self",
".",
"bind_addr",
",",
"basestring",
")",
":",
"# AF_UNIX socket\r",
"# So we can reuse the socket...\... | Run the server forever. | [
"Run",
"the",
"server",
"forever",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/web/wsgi.py#L638-L721 |
ionelmc/python-cogen | cogen/web/wsgi.py | WSGIServer.bind | def bind(self, family, type, proto=0):
"""Create (or recreate) the actual socket object."""
self.socket = sockets.Socket(family, type, proto)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.socket.setblocking(0)
#~ self.socket.setsockopt(socket.SOL_SOCKET, socket.TCP_NODE... | python | def bind(self, family, type, proto=0):
"""Create (or recreate) the actual socket object."""
self.socket = sockets.Socket(family, type, proto)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.socket.setblocking(0)
#~ self.socket.setsockopt(socket.SOL_SOCKET, socket.TCP_NODE... | [
"def",
"bind",
"(",
"self",
",",
"family",
",",
"type",
",",
"proto",
"=",
"0",
")",
":",
"self",
".",
"socket",
"=",
"sockets",
".",
"Socket",
"(",
"family",
",",
"type",
",",
"proto",
")",
"self",
".",
"socket",
".",
"setsockopt",
"(",
"socket",
... | Create (or recreate) the actual socket object. | [
"Create",
"(",
"or",
"recreate",
")",
"the",
"actual",
"socket",
"object",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/web/wsgi.py#L723-L729 |
cslarsen/lyn | lyn/lyn.py | Lightning.load | def load(self, name):
"""Loads and returns foreign library."""
name = ctypes.util.find_library(name)
return ctypes.cdll.LoadLibrary(name) | python | def load(self, name):
"""Loads and returns foreign library."""
name = ctypes.util.find_library(name)
return ctypes.cdll.LoadLibrary(name) | [
"def",
"load",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"ctypes",
".",
"util",
".",
"find_library",
"(",
"name",
")",
"return",
"ctypes",
".",
"cdll",
".",
"LoadLibrary",
"(",
"name",
")"
] | Loads and returns foreign library. | [
"Loads",
"and",
"returns",
"foreign",
"library",
"."
] | train | https://github.com/cslarsen/lyn/blob/d615a6a9473083ffc7318a98fcc697cbc28ba5da/lyn/lyn.py#L83-L86 |
cslarsen/lyn | lyn/lyn.py | Lightning._set_signatures | def _set_signatures(self):
"""Sets return and parameter types for the foreign C functions."""
# We currently pass structs as void pointers.
code_t = ctypes.c_int
gpr_t = ctypes.c_int32
int32_t = ctypes.c_int32
node_p = ctypes.c_void_p
pointer_t = ctypes.c_void_p
... | python | def _set_signatures(self):
"""Sets return and parameter types for the foreign C functions."""
# We currently pass structs as void pointers.
code_t = ctypes.c_int
gpr_t = ctypes.c_int32
int32_t = ctypes.c_int32
node_p = ctypes.c_void_p
pointer_t = ctypes.c_void_p
... | [
"def",
"_set_signatures",
"(",
"self",
")",
":",
"# We currently pass structs as void pointers.",
"code_t",
"=",
"ctypes",
".",
"c_int",
"gpr_t",
"=",
"ctypes",
".",
"c_int32",
"int32_t",
"=",
"ctypes",
".",
"c_int32",
"node_p",
"=",
"ctypes",
".",
"c_void_p",
"... | Sets return and parameter types for the foreign C functions. | [
"Sets",
"return",
"and",
"parameter",
"types",
"for",
"the",
"foreign",
"C",
"functions",
"."
] | train | https://github.com/cslarsen/lyn/blob/d615a6a9473083ffc7318a98fcc697cbc28ba5da/lyn/lyn.py#L100-L159 |
cslarsen/lyn | lyn/lyn.py | Lightning.state | def state(self):
"""Returns a new JIT state. You have to clean up by calling .destroy()
afterwards.
"""
return Emitter(weakref.proxy(self.lib), self.lib.jit_new_state()) | python | def state(self):
"""Returns a new JIT state. You have to clean up by calling .destroy()
afterwards.
"""
return Emitter(weakref.proxy(self.lib), self.lib.jit_new_state()) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"Emitter",
"(",
"weakref",
".",
"proxy",
"(",
"self",
".",
"lib",
")",
",",
"self",
".",
"lib",
".",
"jit_new_state",
"(",
")",
")"
] | Returns a new JIT state. You have to clean up by calling .destroy()
afterwards. | [
"Returns",
"a",
"new",
"JIT",
"state",
".",
"You",
"have",
"to",
"clean",
"up",
"by",
"calling",
".",
"destroy",
"()",
"afterwards",
"."
] | train | https://github.com/cslarsen/lyn/blob/d615a6a9473083ffc7318a98fcc697cbc28ba5da/lyn/lyn.py#L161-L165 |
yatiml/yatiml | yatiml/constructors.py | Constructor.__to_plain_containers | def __to_plain_containers(self,
container: Union[CommentedSeq, CommentedMap]
) -> Union[OrderedDict, list]:
"""Converts any sequence or mapping to list or OrderedDict
Stops at anything that isn't a sequence or a mapping.
One day, we'l... | python | def __to_plain_containers(self,
container: Union[CommentedSeq, CommentedMap]
) -> Union[OrderedDict, list]:
"""Converts any sequence or mapping to list or OrderedDict
Stops at anything that isn't a sequence or a mapping.
One day, we'l... | [
"def",
"__to_plain_containers",
"(",
"self",
",",
"container",
":",
"Union",
"[",
"CommentedSeq",
",",
"CommentedMap",
"]",
")",
"->",
"Union",
"[",
"OrderedDict",
",",
"list",
"]",
":",
"if",
"isinstance",
"(",
"container",
",",
"CommentedMap",
")",
":",
... | Converts any sequence or mapping to list or OrderedDict
Stops at anything that isn't a sequence or a mapping.
One day, we'll extract the comments and formatting and store \
them out-of-band.
Args:
mapping: The mapping of constructed subobjects to edit | [
"Converts",
"any",
"sequence",
"or",
"mapping",
"to",
"list",
"or",
"OrderedDict"
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/constructors.py#L109-L139 |
yatiml/yatiml | yatiml/constructors.py | Constructor.__split_off_extra_attributes | def __split_off_extra_attributes(self, mapping: CommentedMap,
known_attrs: List[str]) -> CommentedMap:
"""Separates the extra attributes in mapping into yatiml_extra.
This returns a mapping containing all key-value pairs from \
mapping whose key is in known_... | python | def __split_off_extra_attributes(self, mapping: CommentedMap,
known_attrs: List[str]) -> CommentedMap:
"""Separates the extra attributes in mapping into yatiml_extra.
This returns a mapping containing all key-value pairs from \
mapping whose key is in known_... | [
"def",
"__split_off_extra_attributes",
"(",
"self",
",",
"mapping",
":",
"CommentedMap",
",",
"known_attrs",
":",
"List",
"[",
"str",
"]",
")",
"->",
"CommentedMap",
":",
"attr_names",
"=",
"list",
"(",
"mapping",
".",
"keys",
"(",
")",
")",
"main_attrs",
... | Separates the extra attributes in mapping into yatiml_extra.
This returns a mapping containing all key-value pairs from \
mapping whose key is in known_attrs, and an additional key \
yatiml_extra which maps to a dict containing the remaining \
key-value pairs.
Args:
... | [
"Separates",
"the",
"extra",
"attributes",
"in",
"mapping",
"into",
"yatiml_extra",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/constructors.py#L141-L167 |
yatiml/yatiml | yatiml/constructors.py | Constructor.__type_matches | def __type_matches(self, obj: Any, type_: Type) -> bool:
"""Checks that the object matches the given type.
Like isinstance(), but will work with union types using Union, \
Dict and List.
Args:
obj: The object to check
type_: The type to check against
Re... | python | def __type_matches(self, obj: Any, type_: Type) -> bool:
"""Checks that the object matches the given type.
Like isinstance(), but will work with union types using Union, \
Dict and List.
Args:
obj: The object to check
type_: The type to check against
Re... | [
"def",
"__type_matches",
"(",
"self",
",",
"obj",
":",
"Any",
",",
"type_",
":",
"Type",
")",
"->",
"bool",
":",
"if",
"is_generic_union",
"(",
"type_",
")",
":",
"for",
"t",
"in",
"generic_type_args",
"(",
"type_",
")",
":",
"if",
"self",
".",
"__ty... | Checks that the object matches the given type.
Like isinstance(), but will work with union types using Union, \
Dict and List.
Args:
obj: The object to check
type_: The type to check against
Returns:
True iff obj is of type type_ | [
"Checks",
"that",
"the",
"object",
"matches",
"the",
"given",
"type",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/constructors.py#L169-L204 |
yatiml/yatiml | yatiml/constructors.py | Constructor.__check_no_missing_attributes | def __check_no_missing_attributes(self, node: yaml.Node,
mapping: CommentedMap) -> None:
"""Checks that all required attributes are present.
Also checks that they're of the correct type.
Args:
mapping: The mapping with subobjects of this object... | python | def __check_no_missing_attributes(self, node: yaml.Node,
mapping: CommentedMap) -> None:
"""Checks that all required attributes are present.
Also checks that they're of the correct type.
Args:
mapping: The mapping with subobjects of this object... | [
"def",
"__check_no_missing_attributes",
"(",
"self",
",",
"node",
":",
"yaml",
".",
"Node",
",",
"mapping",
":",
"CommentedMap",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"'Checking presence of required attributes'",
")",
"for",
"name",
",",
"type_",
... | Checks that all required attributes are present.
Also checks that they're of the correct type.
Args:
mapping: The mapping with subobjects of this object.
Raises:
RecognitionError: if an attribute is missing or the type \
is incorrect. | [
"Checks",
"that",
"all",
"required",
"attributes",
"are",
"present",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/constructors.py#L206-L231 |
yatiml/yatiml | yatiml/constructors.py | Constructor.__type_check_attributes | def __type_check_attributes(self, node: yaml.Node, mapping: CommentedMap,
argspec: inspect.FullArgSpec) -> None:
"""Ensure all attributes have a matching constructor argument.
This checks that there is a constructor argument with a \
matching type for each existi... | python | def __type_check_attributes(self, node: yaml.Node, mapping: CommentedMap,
argspec: inspect.FullArgSpec) -> None:
"""Ensure all attributes have a matching constructor argument.
This checks that there is a constructor argument with a \
matching type for each existi... | [
"def",
"__type_check_attributes",
"(",
"self",
",",
"node",
":",
"yaml",
".",
"Node",
",",
"mapping",
":",
"CommentedMap",
",",
"argspec",
":",
"inspect",
".",
"FullArgSpec",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"'Checking for extraneous attrib... | Ensure all attributes have a matching constructor argument.
This checks that there is a constructor argument with a \
matching type for each existing attribute.
If the class has a yatiml_extra attribute, then extra \
attributes are okay and no error will be raised if they exist.
... | [
"Ensure",
"all",
"attributes",
"have",
"a",
"matching",
"constructor",
"argument",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/constructors.py#L233-L269 |
yatiml/yatiml | yatiml/constructors.py | Constructor.__strip_extra_attributes | def __strip_extra_attributes(self, node: yaml.Node,
known_attrs: List[str]) -> None:
"""Strips tags from extra attributes.
This prevents nodes under attributes that are not part of our \
data model from being converted to objects. They'll be plain \
Comm... | python | def __strip_extra_attributes(self, node: yaml.Node,
known_attrs: List[str]) -> None:
"""Strips tags from extra attributes.
This prevents nodes under attributes that are not part of our \
data model from being converted to objects. They'll be plain \
Comm... | [
"def",
"__strip_extra_attributes",
"(",
"self",
",",
"node",
":",
"yaml",
".",
"Node",
",",
"known_attrs",
":",
"List",
"[",
"str",
"]",
")",
"->",
"None",
":",
"known_keys",
"=",
"list",
"(",
"known_attrs",
")",
"known_keys",
".",
"remove",
"(",
"'self'... | Strips tags from extra attributes.
This prevents nodes under attributes that are not part of our \
data model from being converted to objects. They'll be plain \
CommentedMaps instead, which then get converted to OrderedDicts \
for the user.
Args:
node: The node to ... | [
"Strips",
"tags",
"from",
"extra",
"attributes",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/constructors.py#L271-L297 |
yatiml/yatiml | yatiml/constructors.py | Constructor.__strip_tags | def __strip_tags(self, node: yaml.Node) -> None:
"""Strips tags from mappings in the tree headed by node.
This keeps yaml from constructing any objects in this tree.
Args:
node: Head of the tree to strip
"""
if isinstance(node, yaml.SequenceNode):
for su... | python | def __strip_tags(self, node: yaml.Node) -> None:
"""Strips tags from mappings in the tree headed by node.
This keeps yaml from constructing any objects in this tree.
Args:
node: Head of the tree to strip
"""
if isinstance(node, yaml.SequenceNode):
for su... | [
"def",
"__strip_tags",
"(",
"self",
",",
"node",
":",
"yaml",
".",
"Node",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"node",
",",
"yaml",
".",
"SequenceNode",
")",
":",
"for",
"subnode",
"in",
"node",
".",
"value",
":",
"self",
".",
"__strip_t... | Strips tags from mappings in the tree headed by node.
This keeps yaml from constructing any objects in this tree.
Args:
node: Head of the tree to strip | [
"Strips",
"tags",
"from",
"mappings",
"in",
"the",
"tree",
"headed",
"by",
"node",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/constructors.py#L299-L314 |
ionelmc/python-cogen | cogen/core/pubsub.py | PublishSubscribeQueue.publish | def publish(self, message, key=None, **kws):
"""Put a message in the queue and updates any coroutine wating with
fetch. *works as a coroutine operation*"""
return PSPut(self, message, key, **kws) | python | def publish(self, message, key=None, **kws):
"""Put a message in the queue and updates any coroutine wating with
fetch. *works as a coroutine operation*"""
return PSPut(self, message, key, **kws) | [
"def",
"publish",
"(",
"self",
",",
"message",
",",
"key",
"=",
"None",
",",
"*",
"*",
"kws",
")",
":",
"return",
"PSPut",
"(",
"self",
",",
"message",
",",
"key",
",",
"*",
"*",
"kws",
")"
] | Put a message in the queue and updates any coroutine wating with
fetch. *works as a coroutine operation* | [
"Put",
"a",
"message",
"in",
"the",
"queue",
"and",
"updates",
"any",
"coroutine",
"wating",
"with",
"fetch",
".",
"*",
"works",
"as",
"a",
"coroutine",
"operation",
"*"
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/pubsub.py#L108-L111 |
ionelmc/python-cogen | cogen/core/pubsub.py | PublishSubscribeQueue.compact | def compact(self):
"""Compacts the queue: removes all the messages from the queue that
have been fetched by all the subscribed coroutines.
Returns the number of messages that have been removed."""
if self.subscribers:
level = min(self.subscribers.itervalues())
... | python | def compact(self):
"""Compacts the queue: removes all the messages from the queue that
have been fetched by all the subscribed coroutines.
Returns the number of messages that have been removed."""
if self.subscribers:
level = min(self.subscribers.itervalues())
... | [
"def",
"compact",
"(",
"self",
")",
":",
"if",
"self",
".",
"subscribers",
":",
"level",
"=",
"min",
"(",
"self",
".",
"subscribers",
".",
"itervalues",
"(",
")",
")",
"if",
"level",
":",
"del",
"self",
".",
"messages",
"[",
":",
"level",
"]",
"ret... | Compacts the queue: removes all the messages from the queue that
have been fetched by all the subscribed coroutines.
Returns the number of messages that have been removed. | [
"Compacts",
"the",
"queue",
":",
"removes",
"all",
"the",
"messages",
"from",
"the",
"queue",
"that",
"have",
"been",
"fetched",
"by",
"all",
"the",
"subscribed",
"coroutines",
".",
"Returns",
"the",
"number",
"of",
"messages",
"that",
"have",
"been",
"remov... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/pubsub.py#L129-L141 |
jkwill87/mapi | mapi/providers.py | has_provider_support | def has_provider_support(provider, media_type):
""" Verifies if API provider has support for requested media type
"""
if provider.lower() not in API_ALL:
return False
provider_const = "API_" + media_type.upper()
return provider in globals().get(provider_const, {}) | python | def has_provider_support(provider, media_type):
""" Verifies if API provider has support for requested media type
"""
if provider.lower() not in API_ALL:
return False
provider_const = "API_" + media_type.upper()
return provider in globals().get(provider_const, {}) | [
"def",
"has_provider_support",
"(",
"provider",
",",
"media_type",
")",
":",
"if",
"provider",
".",
"lower",
"(",
")",
"not",
"in",
"API_ALL",
":",
"return",
"False",
"provider_const",
"=",
"\"API_\"",
"+",
"media_type",
".",
"upper",
"(",
")",
"return",
"... | Verifies if API provider has support for requested media type | [
"Verifies",
"if",
"API",
"provider",
"has",
"support",
"for",
"requested",
"media",
"type"
] | train | https://github.com/jkwill87/mapi/blob/730bf57c12aecaf49e18c15bf2b35af7f554b3cc/mapi/providers.py#L32-L38 |
jkwill87/mapi | mapi/providers.py | provider_factory | def provider_factory(provider, **options):
""" Factory function for DB Provider Concrete Classes
"""
try:
return {"tmdb": TMDb, "tvdb": TVDb}[provider.lower()](**options)
except KeyError:
msg = "Attempted to initialize non-existing DB Provider"
log.error(msg)
raise MapiEx... | python | def provider_factory(provider, **options):
""" Factory function for DB Provider Concrete Classes
"""
try:
return {"tmdb": TMDb, "tvdb": TVDb}[provider.lower()](**options)
except KeyError:
msg = "Attempted to initialize non-existing DB Provider"
log.error(msg)
raise MapiEx... | [
"def",
"provider_factory",
"(",
"provider",
",",
"*",
"*",
"options",
")",
":",
"try",
":",
"return",
"{",
"\"tmdb\"",
":",
"TMDb",
",",
"\"tvdb\"",
":",
"TVDb",
"}",
"[",
"provider",
".",
"lower",
"(",
")",
"]",
"(",
"*",
"*",
"options",
")",
"exc... | Factory function for DB Provider Concrete Classes | [
"Factory",
"function",
"for",
"DB",
"Provider",
"Concrete",
"Classes"
] | train | https://github.com/jkwill87/mapi/blob/730bf57c12aecaf49e18c15bf2b35af7f554b3cc/mapi/providers.py#L41-L49 |
jkwill87/mapi | mapi/providers.py | Provider._year_expand | def _year_expand(s):
""" Parses a year or dash-delimeted year range
"""
regex = r"^((?:19|20)\d{2})?(\s*-\s*)?((?:19|20)\d{2})?$"
try:
start, dash, end = match(regex, ustr(s)).groups()
start = start or 1900
end = end or 2099
except AttributeErr... | python | def _year_expand(s):
""" Parses a year or dash-delimeted year range
"""
regex = r"^((?:19|20)\d{2})?(\s*-\s*)?((?:19|20)\d{2})?$"
try:
start, dash, end = match(regex, ustr(s)).groups()
start = start or 1900
end = end or 2099
except AttributeErr... | [
"def",
"_year_expand",
"(",
"s",
")",
":",
"regex",
"=",
"r\"^((?:19|20)\\d{2})?(\\s*-\\s*)?((?:19|20)\\d{2})?$\"",
"try",
":",
"start",
",",
"dash",
",",
"end",
"=",
"match",
"(",
"regex",
",",
"ustr",
"(",
"s",
")",
")",
".",
"groups",
"(",
")",
"start",... | Parses a year or dash-delimeted year range | [
"Parses",
"a",
"year",
"or",
"dash",
"-",
"delimeted",
"year",
"range"
] | train | https://github.com/jkwill87/mapi/blob/730bf57c12aecaf49e18c15bf2b35af7f554b3cc/mapi/providers.py#L68-L78 |
jkwill87/mapi | mapi/providers.py | TMDb.search | def search(self, id_key=None, **parameters):
""" Searches TMDb for movie metadata
"""
id_tmdb = parameters.get("id_tmdb") or id_key
id_imdb = parameters.get("id_imdb")
title = parameters.get("title")
year = parameters.get("year")
if id_tmdb:
yield sel... | python | def search(self, id_key=None, **parameters):
""" Searches TMDb for movie metadata
"""
id_tmdb = parameters.get("id_tmdb") or id_key
id_imdb = parameters.get("id_imdb")
title = parameters.get("title")
year = parameters.get("year")
if id_tmdb:
yield sel... | [
"def",
"search",
"(",
"self",
",",
"id_key",
"=",
"None",
",",
"*",
"*",
"parameters",
")",
":",
"id_tmdb",
"=",
"parameters",
".",
"get",
"(",
"\"id_tmdb\"",
")",
"or",
"id_key",
"id_imdb",
"=",
"parameters",
".",
"get",
"(",
"\"id_imdb\"",
")",
"titl... | Searches TMDb for movie metadata | [
"Searches",
"TMDb",
"for",
"movie",
"metadata"
] | train | https://github.com/jkwill87/mapi/blob/730bf57c12aecaf49e18c15bf2b35af7f554b3cc/mapi/providers.py#L102-L118 |
jkwill87/mapi | mapi/providers.py | TVDb.search | def search(self, id_key=None, **parameters):
""" Searches TVDb for movie metadata
TODO: Consider making parameters for episode ids
"""
episode = parameters.get("episode")
id_tvdb = parameters.get("id_tvdb") or id_key
id_imdb = parameters.get("id_imdb")
season = p... | python | def search(self, id_key=None, **parameters):
""" Searches TVDb for movie metadata
TODO: Consider making parameters for episode ids
"""
episode = parameters.get("episode")
id_tvdb = parameters.get("id_tvdb") or id_key
id_imdb = parameters.get("id_imdb")
season = p... | [
"def",
"search",
"(",
"self",
",",
"id_key",
"=",
"None",
",",
"*",
"*",
"parameters",
")",
":",
"episode",
"=",
"parameters",
".",
"get",
"(",
"\"episode\"",
")",
"id_tvdb",
"=",
"parameters",
".",
"get",
"(",
"\"id_tvdb\"",
")",
"or",
"id_key",
"id_i... | Searches TVDb for movie metadata
TODO: Consider making parameters for episode ids | [
"Searches",
"TVDb",
"for",
"movie",
"metadata"
] | train | https://github.com/jkwill87/mapi/blob/730bf57c12aecaf49e18c15bf2b35af7f554b3cc/mapi/providers.py#L189-L219 |
fhcrc/nestly | nestly/core.py | _mkdirs | def _mkdirs(d):
"""
Make all directories up to d.
No exception is raised if d exists.
"""
try:
os.makedirs(d)
except OSError as e:
if e.errno != errno.EEXIST:
raise | python | def _mkdirs(d):
"""
Make all directories up to d.
No exception is raised if d exists.
"""
try:
os.makedirs(d)
except OSError as e:
if e.errno != errno.EEXIST:
raise | [
"def",
"_mkdirs",
"(",
"d",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"d",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"!=",
"errno",
".",
"EEXIST",
":",
"raise"
] | Make all directories up to d.
No exception is raised if d exists. | [
"Make",
"all",
"directories",
"up",
"to",
"d",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/core.py#L29-L39 |
fhcrc/nestly | nestly/core.py | _templated | def _templated(fn):
"""
Return a function which applies ``str.format(**ctl)`` to all results of
``fn(ctl)``.
"""
@functools.wraps(fn)
def inner(ctl):
return [i.format(**ctl) for i in fn(ctl)]
return inner | python | def _templated(fn):
"""
Return a function which applies ``str.format(**ctl)`` to all results of
``fn(ctl)``.
"""
@functools.wraps(fn)
def inner(ctl):
return [i.format(**ctl) for i in fn(ctl)]
return inner | [
"def",
"_templated",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"inner",
"(",
"ctl",
")",
":",
"return",
"[",
"i",
".",
"format",
"(",
"*",
"*",
"ctl",
")",
"for",
"i",
"in",
"fn",
"(",
"ctl",
")",
"]",
"retur... | Return a function which applies ``str.format(**ctl)`` to all results of
``fn(ctl)``. | [
"Return",
"a",
"function",
"which",
"applies",
"str",
".",
"format",
"(",
"**",
"ctl",
")",
"to",
"all",
"results",
"of",
"fn",
"(",
"ctl",
")",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/core.py#L60-L68 |
fhcrc/nestly | nestly/core.py | nest_map | def nest_map(control_iter, map_fn):
"""
Apply ``map_fn`` to the directories defined by ``control_iter``
For each control file in control_iter, map_fn is called with the directory
and control file contents as arguments.
Example::
>>> list(nest_map(['run1/control.json', 'run2/control.json']... | python | def nest_map(control_iter, map_fn):
"""
Apply ``map_fn`` to the directories defined by ``control_iter``
For each control file in control_iter, map_fn is called with the directory
and control file contents as arguments.
Example::
>>> list(nest_map(['run1/control.json', 'run2/control.json']... | [
"def",
"nest_map",
"(",
"control_iter",
",",
"map_fn",
")",
":",
"def",
"fn",
"(",
"control_path",
")",
":",
"\"\"\"\n Read the control file, return the result of calling map_fn\n \"\"\"",
"with",
"open",
"(",
"control_path",
")",
"as",
"fp",
":",
"control... | Apply ``map_fn`` to the directories defined by ``control_iter``
For each control file in control_iter, map_fn is called with the directory
and control file contents as arguments.
Example::
>>> list(nest_map(['run1/control.json', 'run2/control.json'],
... lambda d, c: c['run_... | [
"Apply",
"map_fn",
"to",
"the",
"directories",
"defined",
"by",
"control_iter"
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/core.py#L202-L232 |
fhcrc/nestly | nestly/core.py | control_iter | def control_iter(base_dir, control_name=CONTROL_NAME):
"""
Generate the names of all control files under base_dir
"""
controls = (os.path.join(p, control_name) for p, _, fs in os.walk(base_dir)
if control_name in fs)
return controls | python | def control_iter(base_dir, control_name=CONTROL_NAME):
"""
Generate the names of all control files under base_dir
"""
controls = (os.path.join(p, control_name) for p, _, fs in os.walk(base_dir)
if control_name in fs)
return controls | [
"def",
"control_iter",
"(",
"base_dir",
",",
"control_name",
"=",
"CONTROL_NAME",
")",
":",
"controls",
"=",
"(",
"os",
".",
"path",
".",
"join",
"(",
"p",
",",
"control_name",
")",
"for",
"p",
",",
"_",
",",
"fs",
"in",
"os",
".",
"walk",
"(",
"ba... | Generate the names of all control files under base_dir | [
"Generate",
"the",
"names",
"of",
"all",
"control",
"files",
"under",
"base_dir"
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/core.py#L234-L240 |
fhcrc/nestly | nestly/core.py | Nest.iter | def iter(self, root=None):
"""
Create an iterator of (directory, control_dict) tuples for all valid
parameter choices in this :class:`Nest`.
:param root: Root directory
:rtype: Generator of ``(directory, control_dictionary)`` tuples.
"""
if root is None:
... | python | def iter(self, root=None):
"""
Create an iterator of (directory, control_dict) tuples for all valid
parameter choices in this :class:`Nest`.
:param root: Root directory
:rtype: Generator of ``(directory, control_dictionary)`` tuples.
"""
if root is None:
... | [
"def",
"iter",
"(",
"self",
",",
"root",
"=",
"None",
")",
":",
"if",
"root",
"is",
"None",
":",
"return",
"iter",
"(",
"self",
".",
"_controls",
")",
"return",
"(",
"(",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"outdir",
")",
",",
"co... | Create an iterator of (directory, control_dict) tuples for all valid
parameter choices in this :class:`Nest`.
:param root: Root directory
:rtype: Generator of ``(directory, control_dictionary)`` tuples. | [
"Create",
"an",
"iterator",
"of",
"(",
"directory",
"control_dict",
")",
"tuples",
"for",
"all",
"valid",
"parameter",
"choices",
"in",
"this",
":",
"class",
":",
"Nest",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/core.py#L104-L115 |
fhcrc/nestly | nestly/core.py | Nest.build | def build(self, root="runs"):
"""
Build a nested directory structure, starting in ``root``
:param root: Root directory for structure
"""
for d, control in self.iter(root):
_mkdirs(d)
with open(os.path.join(d, self.control_name), 'w') as fp:
... | python | def build(self, root="runs"):
"""
Build a nested directory structure, starting in ``root``
:param root: Root directory for structure
"""
for d, control in self.iter(root):
_mkdirs(d)
with open(os.path.join(d, self.control_name), 'w') as fp:
... | [
"def",
"build",
"(",
"self",
",",
"root",
"=",
"\"runs\"",
")",
":",
"for",
"d",
",",
"control",
"in",
"self",
".",
"iter",
"(",
"root",
")",
":",
"_mkdirs",
"(",
"d",
")",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"d",
",",
"... | Build a nested directory structure, starting in ``root``
:param root: Root directory for structure | [
"Build",
"a",
"nested",
"directory",
"structure",
"starting",
"in",
"root"
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/core.py#L123-L135 |
fhcrc/nestly | nestly/core.py | Nest.add | def add(self, name, nestable, create_dir=True, update=False,
label_func=str, template_subs=False):
"""
Add a level to the nest
:param string name: Name of the level. Forms the key in the output
dictionary.
:param nestable: Either an iterable object containing val... | python | def add(self, name, nestable, create_dir=True, update=False,
label_func=str, template_subs=False):
"""
Add a level to the nest
:param string name: Name of the level. Forms the key in the output
dictionary.
:param nestable: Either an iterable object containing val... | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"nestable",
",",
"create_dir",
"=",
"True",
",",
"update",
"=",
"False",
",",
"label_func",
"=",
"str",
",",
"template_subs",
"=",
"False",
")",
":",
"# Convert everything to functions",
"if",
"not",
"callable",
... | Add a level to the nest
:param string name: Name of the level. Forms the key in the output
dictionary.
:param nestable: Either an iterable object containing values, _or_ a
function which takes a single argument (the control dictionary)
and returns an iterable object ... | [
"Add",
"a",
"level",
"to",
"the",
"nest"
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/core.py#L137-L199 |
exa-analytics/exa | exa/core/composer.py | Composer.compose | def compose(self, *args, **kwargs):
"""
Generate a file from the current template and given arguments.
Warning:
Make certain to check the formatted editor for correctness!
Args:
args: Positional arguments to update the template
kwargs: Keywo... | python | def compose(self, *args, **kwargs):
"""
Generate a file from the current template and given arguments.
Warning:
Make certain to check the formatted editor for correctness!
Args:
args: Positional arguments to update the template
kwargs: Keywo... | [
"def",
"compose",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"linebreak",
"=",
"kwargs",
".",
"pop",
"(",
"\"linebreak\"",
",",
"\"\\n\"",
")",
"# Update the internally stored args/kwargs from which formatting arguments come\r",
"if",
"len",
... | Generate a file from the current template and given arguments.
Warning:
Make certain to check the formatted editor for correctness!
Args:
args: Positional arguments to update the template
kwargs: Keyword arguments to update the template
Returns:
... | [
"Generate",
"a",
"file",
"from",
"the",
"current",
"template",
"and",
"given",
"arguments",
".",
"Warning",
":",
"Make",
"certain",
"to",
"check",
"the",
"formatted",
"editor",
"for",
"correctness!",
"Args",
":",
"args",
":",
"Positional",
"arguments",
"to",
... | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/composer.py#L65-L114 |
exa-analytics/exa | exa/core/composer.py | Composer.get_kwargs | def get_kwargs(self):
"""Return kwargs from attached attributes."""
return {k: v for k, v in vars(self).items() if k not in self._ignored} | python | def get_kwargs(self):
"""Return kwargs from attached attributes."""
return {k: v for k, v in vars(self).items() if k not in self._ignored} | [
"def",
"get_kwargs",
"(",
"self",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"vars",
"(",
"self",
")",
".",
"items",
"(",
")",
"if",
"k",
"not",
"in",
"self",
".",
"_ignored",
"}"
] | Return kwargs from attached attributes. | [
"Return",
"kwargs",
"from",
"attached",
"attributes",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/composer.py#L116-L118 |
seibert-media/Highton | highton/models/task.py | Task.complete | def complete(self):
"""
Complete current task
:return:
:rtype: requests.models.Response
"""
return self._post_request(
data='',
endpoint=self.ENDPOINT + '/' + str(self.id) + '/complete'
) | python | def complete(self):
"""
Complete current task
:return:
:rtype: requests.models.Response
"""
return self._post_request(
data='',
endpoint=self.ENDPOINT + '/' + str(self.id) + '/complete'
) | [
"def",
"complete",
"(",
"self",
")",
":",
"return",
"self",
".",
"_post_request",
"(",
"data",
"=",
"''",
",",
"endpoint",
"=",
"self",
".",
"ENDPOINT",
"+",
"'/'",
"+",
"str",
"(",
"self",
".",
"id",
")",
"+",
"'/complete'",
")"
] | Complete current task
:return:
:rtype: requests.models.Response | [
"Complete",
"current",
"task",
":",
"return",
":",
":",
"rtype",
":",
"requests",
".",
"models",
".",
"Response"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/models/task.py#L59-L68 |
seibert-media/Highton | highton/models/task.py | Task.list_upcoming | def list_upcoming(cls):
"""
Returns a collection of upcoming tasks (tasks that have not yet been completed,
regardless of whether they’re overdue) for the authenticated user
:return:
:rtype: list
"""
return fields.ListField(name=cls.ENDPOINT, init_class=cls).deco... | python | def list_upcoming(cls):
"""
Returns a collection of upcoming tasks (tasks that have not yet been completed,
regardless of whether they’re overdue) for the authenticated user
:return:
:rtype: list
"""
return fields.ListField(name=cls.ENDPOINT, init_class=cls).deco... | [
"def",
"list_upcoming",
"(",
"cls",
")",
":",
"return",
"fields",
".",
"ListField",
"(",
"name",
"=",
"cls",
".",
"ENDPOINT",
",",
"init_class",
"=",
"cls",
")",
".",
"decode",
"(",
"cls",
".",
"element_from_string",
"(",
"cls",
".",
"_get_request",
"(",... | Returns a collection of upcoming tasks (tasks that have not yet been completed,
regardless of whether they’re overdue) for the authenticated user
:return:
:rtype: list | [
"Returns",
"a",
"collection",
"of",
"upcoming",
"tasks",
"(",
"tasks",
"that",
"have",
"not",
"yet",
"been",
"completed",
"regardless",
"of",
"whether",
"they’re",
"overdue",
")",
"for",
"the",
"authenticated",
"user"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/models/task.py#L71-L83 |
moonso/vcftoolbox | vcftoolbox/prints.py | print_headers | def print_headers(head, outfile=None, silent=False):
"""
Print the vcf headers.
If a result file is provided headers will be printed here, otherwise
they are printed to stdout.
Args:
head (HeaderParser): A vcf header object
outfile (FileHandle): A file handle
silent... | python | def print_headers(head, outfile=None, silent=False):
"""
Print the vcf headers.
If a result file is provided headers will be printed here, otherwise
they are printed to stdout.
Args:
head (HeaderParser): A vcf header object
outfile (FileHandle): A file handle
silent... | [
"def",
"print_headers",
"(",
"head",
",",
"outfile",
"=",
"None",
",",
"silent",
"=",
"False",
")",
":",
"for",
"header_line",
"in",
"head",
".",
"print_header",
"(",
")",
":",
"if",
"outfile",
":",
"outfile",
".",
"write",
"(",
"header_line",
"+",
"'\... | Print the vcf headers.
If a result file is provided headers will be printed here, otherwise
they are printed to stdout.
Args:
head (HeaderParser): A vcf header object
outfile (FileHandle): A file handle
silent (Bool): If nothing should be printed. | [
"Print",
"the",
"vcf",
"headers",
".",
"If",
"a",
"result",
"file",
"is",
"provided",
"headers",
"will",
"be",
"printed",
"here",
"otherwise",
"they",
"are",
"printed",
"to",
"stdout",
".",
"Args",
":",
"head",
"(",
"HeaderParser",
")",
":",
"A",
"vcf",
... | train | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/prints.py#L16-L36 |
moonso/vcftoolbox | vcftoolbox/prints.py | print_variant | def print_variant(variant_line, outfile=None, silent=False):
"""
Print a variant.
If a result file is provided the variante will be appended to the file,
otherwise they are printed to stdout.
Args:
variants_file (str): A string with the path to a file
outfile (FileHandle):... | python | def print_variant(variant_line, outfile=None, silent=False):
"""
Print a variant.
If a result file is provided the variante will be appended to the file,
otherwise they are printed to stdout.
Args:
variants_file (str): A string with the path to a file
outfile (FileHandle):... | [
"def",
"print_variant",
"(",
"variant_line",
",",
"outfile",
"=",
"None",
",",
"silent",
"=",
"False",
")",
":",
"variant_line",
"=",
"variant_line",
".",
"rstrip",
"(",
")",
"if",
"not",
"variant_line",
".",
"startswith",
"(",
"'#'",
")",
":",
"if",
"ou... | Print a variant.
If a result file is provided the variante will be appended to the file,
otherwise they are printed to stdout.
Args:
variants_file (str): A string with the path to a file
outfile (FileHandle): An opened file_handle
silent (bool): Bool. If nothing should be ... | [
"Print",
"a",
"variant",
".",
"If",
"a",
"result",
"file",
"is",
"provided",
"the",
"variante",
"will",
"be",
"appended",
"to",
"the",
"file",
"otherwise",
"they",
"are",
"printed",
"to",
"stdout",
".",
"Args",
":",
"variants_file",
"(",
"str",
")",
":",... | train | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/prints.py#L38-L58 |
exa-analytics/exa | exa/core/editor.py | lines_from_file | def lines_from_file(path, as_interned=False, encoding=None):
"""
Create a list of file lines from a given filepath.
Args:
path (str): File path
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list
"""
lines = None
wi... | python | def lines_from_file(path, as_interned=False, encoding=None):
"""
Create a list of file lines from a given filepath.
Args:
path (str): File path
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list
"""
lines = None
wi... | [
"def",
"lines_from_file",
"(",
"path",
",",
"as_interned",
"=",
"False",
",",
"encoding",
"=",
"None",
")",
":",
"lines",
"=",
"None",
"with",
"io",
".",
"open",
"(",
"path",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f",
":",
"if",
"as_interned",
... | Create a list of file lines from a given filepath.
Args:
path (str): File path
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list | [
"Create",
"a",
"list",
"of",
"file",
"lines",
"from",
"a",
"given",
"filepath",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L435-L452 |
exa-analytics/exa | exa/core/editor.py | lines_from_stream | def lines_from_stream(f, as_interned=False):
"""
Create a list of file lines from a given file stream.
Args:
f (io.TextIOWrapper): File stream
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list
"""
if as_interned:
... | python | def lines_from_stream(f, as_interned=False):
"""
Create a list of file lines from a given file stream.
Args:
f (io.TextIOWrapper): File stream
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list
"""
if as_interned:
... | [
"def",
"lines_from_stream",
"(",
"f",
",",
"as_interned",
"=",
"False",
")",
":",
"if",
"as_interned",
":",
"return",
"[",
"sys",
".",
"intern",
"(",
"line",
")",
"for",
"line",
"in",
"f",
".",
"read",
"(",
")",
".",
"splitlines",
"(",
")",
"]",
"r... | Create a list of file lines from a given file stream.
Args:
f (io.TextIOWrapper): File stream
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list | [
"Create",
"a",
"list",
"of",
"file",
"lines",
"from",
"a",
"given",
"file",
"stream",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L455-L468 |
exa-analytics/exa | exa/core/editor.py | lines_from_string | def lines_from_string(string, as_interned=False):
"""
Create a list of file lines from a given string.
Args:
string (str): File string
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list
"""
if as_interned:
retu... | python | def lines_from_string(string, as_interned=False):
"""
Create a list of file lines from a given string.
Args:
string (str): File string
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list
"""
if as_interned:
retu... | [
"def",
"lines_from_string",
"(",
"string",
",",
"as_interned",
"=",
"False",
")",
":",
"if",
"as_interned",
":",
"return",
"[",
"sys",
".",
"intern",
"(",
"line",
")",
"for",
"line",
"in",
"string",
".",
"splitlines",
"(",
")",
"]",
"return",
"string",
... | Create a list of file lines from a given string.
Args:
string (str): File string
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list | [
"Create",
"a",
"list",
"of",
"file",
"lines",
"from",
"a",
"given",
"string",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L471-L484 |
exa-analytics/exa | exa/core/editor.py | Editor.write | def write(self, path=None, *args, **kwargs):
"""
Perform formatting and write the formatted string to a file or stdout.
Optional arguments can be used to format the editor's contents. If no
file path is given, prints to standard output.
Args:
path (str): Full file p... | python | def write(self, path=None, *args, **kwargs):
"""
Perform formatting and write the formatted string to a file or stdout.
Optional arguments can be used to format the editor's contents. If no
file path is given, prints to standard output.
Args:
path (str): Full file p... | [
"def",
"write",
"(",
"self",
",",
"path",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"path",
"is",
"None",
":",
"print",
"(",
"self",
".",
"format",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")",
"else",
":"... | Perform formatting and write the formatted string to a file or stdout.
Optional arguments can be used to format the editor's contents. If no
file path is given, prints to standard output.
Args:
path (str): Full file path (default None, prints to stdout)
*args: Positiona... | [
"Perform",
"formatting",
"and",
"write",
"the",
"formatted",
"string",
"to",
"a",
"file",
"or",
"stdout",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L58-L74 |
exa-analytics/exa | exa/core/editor.py | Editor.format | def format(self, *args, **kwargs):
"""
Format the string representation of the editor.
Args:
inplace (bool): If True, overwrite editor's contents with formatted contents
"""
inplace = kwargs.pop("inplace", False)
if not inplace:
return str(self).f... | python | def format(self, *args, **kwargs):
"""
Format the string representation of the editor.
Args:
inplace (bool): If True, overwrite editor's contents with formatted contents
"""
inplace = kwargs.pop("inplace", False)
if not inplace:
return str(self).f... | [
"def",
"format",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"inplace",
"=",
"kwargs",
".",
"pop",
"(",
"\"inplace\"",
",",
"False",
")",
"if",
"not",
"inplace",
":",
"return",
"str",
"(",
"self",
")",
".",
"format",
"(",
"*... | Format the string representation of the editor.
Args:
inplace (bool): If True, overwrite editor's contents with formatted contents | [
"Format",
"the",
"string",
"representation",
"of",
"the",
"editor",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L76-L86 |
exa-analytics/exa | exa/core/editor.py | Editor.head | def head(self, n=10):
"""
Display the top of the file.
Args:
n (int): Number of lines to display
"""
r = self.__repr__().split('\n')
print('\n'.join(r[:n]), end=' ') | python | def head(self, n=10):
"""
Display the top of the file.
Args:
n (int): Number of lines to display
"""
r = self.__repr__().split('\n')
print('\n'.join(r[:n]), end=' ') | [
"def",
"head",
"(",
"self",
",",
"n",
"=",
"10",
")",
":",
"r",
"=",
"self",
".",
"__repr__",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
"print",
"(",
"'\\n'",
".",
"join",
"(",
"r",
"[",
":",
"n",
"]",
")",
",",
"end",
"=",
"' '",
")"
] | Display the top of the file.
Args:
n (int): Number of lines to display | [
"Display",
"the",
"top",
"of",
"the",
"file",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L88-L96 |
exa-analytics/exa | exa/core/editor.py | Editor.append | def append(self, lines):
"""
Args:
lines (list): List of line strings to append to the end of the editor
"""
if isinstance(lines, list):
self._lines = self._lines + lines
elif isinstance(lines, str):
lines = lines.split('\n')
self._... | python | def append(self, lines):
"""
Args:
lines (list): List of line strings to append to the end of the editor
"""
if isinstance(lines, list):
self._lines = self._lines + lines
elif isinstance(lines, str):
lines = lines.split('\n')
self._... | [
"def",
"append",
"(",
"self",
",",
"lines",
")",
":",
"if",
"isinstance",
"(",
"lines",
",",
"list",
")",
":",
"self",
".",
"_lines",
"=",
"self",
".",
"_lines",
"+",
"lines",
"elif",
"isinstance",
"(",
"lines",
",",
"str",
")",
":",
"lines",
"=",
... | Args:
lines (list): List of line strings to append to the end of the editor | [
"Args",
":",
"lines",
"(",
"list",
")",
":",
"List",
"of",
"line",
"strings",
"to",
"append",
"to",
"the",
"end",
"of",
"the",
"editor"
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L108-L119 |
exa-analytics/exa | exa/core/editor.py | Editor.insert | def insert(self, lines=None):
"""
Insert lines into the editor.
Note:
To insert before the first line, use :func:`~exa.core.editor.Editor.preappend`
(or key 0); to insert after the last line use :func:`~exa.core.editor.Editor.append`.
Args:
lines (di... | python | def insert(self, lines=None):
"""
Insert lines into the editor.
Note:
To insert before the first line, use :func:`~exa.core.editor.Editor.preappend`
(or key 0); to insert after the last line use :func:`~exa.core.editor.Editor.append`.
Args:
lines (di... | [
"def",
"insert",
"(",
"self",
",",
"lines",
"=",
"None",
")",
":",
"for",
"i",
",",
"(",
"key",
",",
"line",
")",
"in",
"enumerate",
"(",
"lines",
".",
"items",
"(",
")",
")",
":",
"n",
"=",
"key",
"+",
"i",
"first_half",
"=",
"self",
".",
"_... | Insert lines into the editor.
Note:
To insert before the first line, use :func:`~exa.core.editor.Editor.preappend`
(or key 0); to insert after the last line use :func:`~exa.core.editor.Editor.append`.
Args:
lines (dict): Dictionary of lines of form (lineno, string) ... | [
"Insert",
"lines",
"into",
"the",
"editor",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L134-L149 |
exa-analytics/exa | exa/core/editor.py | Editor.remove_blank_lines | def remove_blank_lines(self):
"""Remove all blank lines (blank lines are those with zero characters)."""
to_remove = []
for i, line in enumerate(self):
ln = line.strip()
if ln == '':
to_remove.append(i)
self.delete_lines(to_remove) | python | def remove_blank_lines(self):
"""Remove all blank lines (blank lines are those with zero characters)."""
to_remove = []
for i, line in enumerate(self):
ln = line.strip()
if ln == '':
to_remove.append(i)
self.delete_lines(to_remove) | [
"def",
"remove_blank_lines",
"(",
"self",
")",
":",
"to_remove",
"=",
"[",
"]",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"self",
")",
":",
"ln",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"ln",
"==",
"''",
":",
"to_remove",
".",
"append",
... | Remove all blank lines (blank lines are those with zero characters). | [
"Remove",
"all",
"blank",
"lines",
"(",
"blank",
"lines",
"are",
"those",
"with",
"zero",
"characters",
")",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L151-L158 |
exa-analytics/exa | exa/core/editor.py | Editor._data | def _data(self, copy=False):
"""
Get all data associated with the container as key value pairs.
"""
data = {}
for key, obj in self.__dict__.items():
if isinstance(obj, (pd.Series, pd.DataFrame, pd.SparseSeries, pd.SparseDataFrame)):
if copy:
... | python | def _data(self, copy=False):
"""
Get all data associated with the container as key value pairs.
"""
data = {}
for key, obj in self.__dict__.items():
if isinstance(obj, (pd.Series, pd.DataFrame, pd.SparseSeries, pd.SparseDataFrame)):
if copy:
... | [
"def",
"_data",
"(",
"self",
",",
"copy",
"=",
"False",
")",
":",
"data",
"=",
"{",
"}",
"for",
"key",
",",
"obj",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"pd",
".",
"Series",
",",
... | Get all data associated with the container as key value pairs. | [
"Get",
"all",
"data",
"associated",
"with",
"the",
"container",
"as",
"key",
"value",
"pairs",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L160-L171 |
exa-analytics/exa | exa/core/editor.py | Editor.delete_lines | def delete_lines(self, lines):
"""
Delete all lines with given line numbers.
Args:
lines (list): List of integers corresponding to line numbers to delete
"""
for k, i in enumerate(lines):
del self[i-k] | python | def delete_lines(self, lines):
"""
Delete all lines with given line numbers.
Args:
lines (list): List of integers corresponding to line numbers to delete
"""
for k, i in enumerate(lines):
del self[i-k] | [
"def",
"delete_lines",
"(",
"self",
",",
"lines",
")",
":",
"for",
"k",
",",
"i",
"in",
"enumerate",
"(",
"lines",
")",
":",
"del",
"self",
"[",
"i",
"-",
"k",
"]"
] | Delete all lines with given line numbers.
Args:
lines (list): List of integers corresponding to line numbers to delete | [
"Delete",
"all",
"lines",
"with",
"given",
"line",
"numbers",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L173-L181 |
exa-analytics/exa | exa/core/editor.py | Editor.find | def find(self, *strings, **kwargs):
"""
Search the entire editor for lines that match the string.
.. code-block:: Python
string = '''word one
word two
three'''
ed = Editor(string)
ed.find('word') # [(0, "word one"), (1, "word... | python | def find(self, *strings, **kwargs):
"""
Search the entire editor for lines that match the string.
.. code-block:: Python
string = '''word one
word two
three'''
ed = Editor(string)
ed.find('word') # [(0, "word one"), (1, "word... | [
"def",
"find",
"(",
"self",
",",
"*",
"strings",
",",
"*",
"*",
"kwargs",
")",
":",
"start",
"=",
"kwargs",
".",
"pop",
"(",
"\"start\"",
",",
"0",
")",
"stop",
"=",
"kwargs",
".",
"pop",
"(",
"\"stop\"",
",",
"None",
")",
"keys_only",
"=",
"kwar... | Search the entire editor for lines that match the string.
.. code-block:: Python
string = '''word one
word two
three'''
ed = Editor(string)
ed.find('word') # [(0, "word one"), (1, "word two")]
ed.find('word', 'three') # {'word': ... | [
"Search",
"the",
"entire",
"editor",
"for",
"lines",
"that",
"match",
"the",
"string",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L183-L219 |
exa-analytics/exa | exa/core/editor.py | Editor.find_next | def find_next(self, *strings, **kwargs):
"""
From the editor's current cursor position find the next instance of the
given string.
Args:
strings (iterable): String or strings to search for
Returns:
tup (tuple): Tuple of cursor position and line or None i... | python | def find_next(self, *strings, **kwargs):
"""
From the editor's current cursor position find the next instance of the
given string.
Args:
strings (iterable): String or strings to search for
Returns:
tup (tuple): Tuple of cursor position and line or None i... | [
"def",
"find_next",
"(",
"self",
",",
"*",
"strings",
",",
"*",
"*",
"kwargs",
")",
":",
"start",
"=",
"kwargs",
".",
"pop",
"(",
"\"start\"",
",",
"None",
")",
"keys_only",
"=",
"kwargs",
".",
"pop",
"(",
"\"keys_only\"",
",",
"False",
")",
"staht",... | From the editor's current cursor position find the next instance of the
given string.
Args:
strings (iterable): String or strings to search for
Returns:
tup (tuple): Tuple of cursor position and line or None if not found
Note:
This function cycles t... | [
"From",
"the",
"editor",
"s",
"current",
"cursor",
"position",
"find",
"the",
"next",
"instance",
"of",
"the",
"given",
"string",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L221-L246 |
exa-analytics/exa | exa/core/editor.py | Editor.regex | def regex(self, *patterns, **kwargs):
"""
Search the editor for lines matching the regular expression.
re.MULTILINE is not currently supported.
Args:
\*patterns: Regular expressions to search each line for
keys_only (bool): Only return keys
flags (re.... | python | def regex(self, *patterns, **kwargs):
"""
Search the editor for lines matching the regular expression.
re.MULTILINE is not currently supported.
Args:
\*patterns: Regular expressions to search each line for
keys_only (bool): Only return keys
flags (re.... | [
"def",
"regex",
"(",
"self",
",",
"*",
"patterns",
",",
"*",
"*",
"kwargs",
")",
":",
"start",
"=",
"kwargs",
".",
"pop",
"(",
"\"start\"",
",",
"0",
")",
"stop",
"=",
"kwargs",
".",
"pop",
"(",
"\"stop\"",
",",
"None",
")",
"keys_only",
"=",
"kw... | Search the editor for lines matching the regular expression.
re.MULTILINE is not currently supported.
Args:
\*patterns: Regular expressions to search each line for
keys_only (bool): Only return keys
flags (re.FLAG): flags passed to re.search
Returns:
... | [
"Search",
"the",
"editor",
"for",
"lines",
"matching",
"the",
"regular",
"expression",
".",
"re",
".",
"MULTILINE",
"is",
"not",
"currently",
"supported",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L248-L279 |
exa-analytics/exa | exa/core/editor.py | Editor.replace | def replace(self, pattern, replacement):
"""
Replace all instances of a pattern with a replacement.
Args:
pattern (str): Pattern to replace
replacement (str): Text to insert
"""
for i, line in enumerate(self):
if pattern in line:
... | python | def replace(self, pattern, replacement):
"""
Replace all instances of a pattern with a replacement.
Args:
pattern (str): Pattern to replace
replacement (str): Text to insert
"""
for i, line in enumerate(self):
if pattern in line:
... | [
"def",
"replace",
"(",
"self",
",",
"pattern",
",",
"replacement",
")",
":",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"self",
")",
":",
"if",
"pattern",
"in",
"line",
":",
"self",
"[",
"i",
"]",
"=",
"line",
".",
"replace",
"(",
"pattern",
... | Replace all instances of a pattern with a replacement.
Args:
pattern (str): Pattern to replace
replacement (str): Text to insert | [
"Replace",
"all",
"instances",
"of",
"a",
"pattern",
"with",
"a",
"replacement",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L281-L291 |
exa-analytics/exa | exa/core/editor.py | Editor.pandas_dataframe | def pandas_dataframe(self, start, stop, ncol, **kwargs):
"""
Returns the result of tab-separated pandas.read_csv on
a subset of the file.
Args:
start (int): line number where structured data starts
stop (int): line number where structured data stops
n... | python | def pandas_dataframe(self, start, stop, ncol, **kwargs):
"""
Returns the result of tab-separated pandas.read_csv on
a subset of the file.
Args:
start (int): line number where structured data starts
stop (int): line number where structured data stops
n... | [
"def",
"pandas_dataframe",
"(",
"self",
",",
"start",
",",
"stop",
",",
"ncol",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"int",
"(",
"start",
")",
"int",
"(",
"stop",
")",
"except",
"TypeError",
":",
"print",
"(",
"'start and stop must be ints'",
... | Returns the result of tab-separated pandas.read_csv on
a subset of the file.
Args:
start (int): line number where structured data starts
stop (int): line number where structured data stops
ncol (int or list): the number of columns in the structured
da... | [
"Returns",
"the",
"result",
"of",
"tab",
"-",
"separated",
"pandas",
".",
"read_csv",
"on",
"a",
"subset",
"of",
"the",
"file",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L293-L320 |
exa-analytics/exa | exa/core/editor.py | Editor.variables | def variables(self):
"""
Display a list of templatable variables present in the file.
Templating is accomplished by creating a bracketed object in the same
way that Python performs `string formatting`_. The editor is able to
replace the placeholder value of the template. Integer... | python | def variables(self):
"""
Display a list of templatable variables present in the file.
Templating is accomplished by creating a bracketed object in the same
way that Python performs `string formatting`_. The editor is able to
replace the placeholder value of the template. Integer... | [
"def",
"variables",
"(",
"self",
")",
":",
"string",
"=",
"str",
"(",
"self",
")",
"constants",
"=",
"[",
"match",
"[",
"1",
":",
"-",
"1",
"]",
"for",
"match",
"in",
"re",
".",
"findall",
"(",
"'{{[A-z0-9]}}'",
",",
"string",
")",
"]",
"variables"... | Display a list of templatable variables present in the file.
Templating is accomplished by creating a bracketed object in the same
way that Python performs `string formatting`_. The editor is able to
replace the placeholder value of the template. Integer templates are
positional argumen... | [
"Display",
"a",
"list",
"of",
"templatable",
"variables",
"present",
"in",
"the",
"file",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L327-L341 |
exa-analytics/exa | exa/core/editor.py | Editor.from_file | def from_file(cls, path, **kwargs):
"""Create an editor instance from a file on disk."""
lines = lines_from_file(path)
if 'meta' not in kwargs:
kwargs['meta'] = {'from': 'file'}
kwargs['meta']['filepath'] = path
return cls(lines, **kwargs) | python | def from_file(cls, path, **kwargs):
"""Create an editor instance from a file on disk."""
lines = lines_from_file(path)
if 'meta' not in kwargs:
kwargs['meta'] = {'from': 'file'}
kwargs['meta']['filepath'] = path
return cls(lines, **kwargs) | [
"def",
"from_file",
"(",
"cls",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"lines",
"=",
"lines_from_file",
"(",
"path",
")",
"if",
"'meta'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'meta'",
"]",
"=",
"{",
"'from'",
":",
"'file'",
"}",
"kw... | Create an editor instance from a file on disk. | [
"Create",
"an",
"editor",
"instance",
"from",
"a",
"file",
"on",
"disk",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L344-L350 |
exa-analytics/exa | exa/core/editor.py | Editor.from_stream | def from_stream(cls, f, **kwargs):
"""Create an editor instance from a file stream."""
lines = lines_from_stream(f)
if 'meta' not in kwargs:
kwargs['meta'] = {'from': 'stream'}
kwargs['meta']['filepath'] = f.name if hasattr(f, 'name') else None
return cls(lines, **kwa... | python | def from_stream(cls, f, **kwargs):
"""Create an editor instance from a file stream."""
lines = lines_from_stream(f)
if 'meta' not in kwargs:
kwargs['meta'] = {'from': 'stream'}
kwargs['meta']['filepath'] = f.name if hasattr(f, 'name') else None
return cls(lines, **kwa... | [
"def",
"from_stream",
"(",
"cls",
",",
"f",
",",
"*",
"*",
"kwargs",
")",
":",
"lines",
"=",
"lines_from_stream",
"(",
"f",
")",
"if",
"'meta'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'meta'",
"]",
"=",
"{",
"'from'",
":",
"'stream'",
"}",
"kw... | Create an editor instance from a file stream. | [
"Create",
"an",
"editor",
"instance",
"from",
"a",
"file",
"stream",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L353-L359 |
yatiml/yatiml | yatiml/util.py | is_generic_list | def is_generic_list(type_: Type) -> bool:
"""Determines whether a type is a List[...].
How to do this varies for different Python versions, due to the
typing library not having a stable API. This functions smooths
over the differences.
Args:
type_: The type to check.
Returns:
... | python | def is_generic_list(type_: Type) -> bool:
"""Determines whether a type is a List[...].
How to do this varies for different Python versions, due to the
typing library not having a stable API. This functions smooths
over the differences.
Args:
type_: The type to check.
Returns:
... | [
"def",
"is_generic_list",
"(",
"type_",
":",
"Type",
")",
"->",
"bool",
":",
"if",
"hasattr",
"(",
"typing",
",",
"'_GenericAlias'",
")",
":",
"# 3.7",
"return",
"(",
"isinstance",
"(",
"type_",
",",
"typing",
".",
"_GenericAlias",
")",
"and",
"# type: ign... | Determines whether a type is a List[...].
How to do this varies for different Python versions, due to the
typing library not having a stable API. This functions smooths
over the differences.
Args:
type_: The type to check.
Returns:
True iff it's a List[...something...]. | [
"Determines",
"whether",
"a",
"type",
"is",
"a",
"List",
"[",
"...",
"]",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/util.py#L22-L42 |
yatiml/yatiml | yatiml/util.py | is_generic_dict | def is_generic_dict(type_: Type) -> bool:
"""Determines whether a type is a Dict[...].
How to do this varies for different Python versions, due to the
typing library not having a stable API. This functions smooths
over the differences.
Args:
type_: The type to check.
Returns:
... | python | def is_generic_dict(type_: Type) -> bool:
"""Determines whether a type is a Dict[...].
How to do this varies for different Python versions, due to the
typing library not having a stable API. This functions smooths
over the differences.
Args:
type_: The type to check.
Returns:
... | [
"def",
"is_generic_dict",
"(",
"type_",
":",
"Type",
")",
"->",
"bool",
":",
"if",
"hasattr",
"(",
"typing",
",",
"'_GenericAlias'",
")",
":",
"# 3.7",
"return",
"(",
"isinstance",
"(",
"type_",
",",
"typing",
".",
"_GenericAlias",
")",
"and",
"# type: ign... | Determines whether a type is a Dict[...].
How to do this varies for different Python versions, due to the
typing library not having a stable API. This functions smooths
over the differences.
Args:
type_: The type to check.
Returns:
True iff it's a Dict[...something...]. | [
"Determines",
"whether",
"a",
"type",
"is",
"a",
"Dict",
"[",
"...",
"]",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/util.py#L45-L65 |
yatiml/yatiml | yatiml/util.py | is_generic_union | def is_generic_union(type_: Type) -> bool:
"""Determines whether a type is a Union[...].
How to do this varies for different Python versions, due to the
typing library not having a stable API. This functions smooths
over the differences.
Args:
type_: The type to check.
Returns:
... | python | def is_generic_union(type_: Type) -> bool:
"""Determines whether a type is a Union[...].
How to do this varies for different Python versions, due to the
typing library not having a stable API. This functions smooths
over the differences.
Args:
type_: The type to check.
Returns:
... | [
"def",
"is_generic_union",
"(",
"type_",
":",
"Type",
")",
"->",
"bool",
":",
"if",
"hasattr",
"(",
"typing",
",",
"'_GenericAlias'",
")",
":",
"# 3.7",
"return",
"(",
"isinstance",
"(",
"type_",
",",
"typing",
".",
"_GenericAlias",
")",
"and",
"# type: ig... | Determines whether a type is a Union[...].
How to do this varies for different Python versions, due to the
typing library not having a stable API. This functions smooths
over the differences.
Args:
type_: The type to check.
Returns:
True iff it's a Union[...something...]. | [
"Determines",
"whether",
"a",
"type",
"is",
"a",
"Union",
"[",
"...",
"]",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/util.py#L68-L93 |
yatiml/yatiml | yatiml/util.py | generic_type_args | def generic_type_args(type_: Type) -> List[Type]:
"""Gets the type argument list for the given generic type.
If you give this function List[int], it will return [int], and
if you give it Union[int, str] it will give you [int, str]. Note
that on Python < 3.7, Union[int, bool] collapses to Union[int] and... | python | def generic_type_args(type_: Type) -> List[Type]:
"""Gets the type argument list for the given generic type.
If you give this function List[int], it will return [int], and
if you give it Union[int, str] it will give you [int, str]. Note
that on Python < 3.7, Union[int, bool] collapses to Union[int] and... | [
"def",
"generic_type_args",
"(",
"type_",
":",
"Type",
")",
"->",
"List",
"[",
"Type",
"]",
":",
"if",
"hasattr",
"(",
"type_",
",",
"'__union_params__'",
")",
":",
"# 3.5 Union",
"return",
"list",
"(",
"type_",
".",
"__union_params__",
")",
"return",
"lis... | Gets the type argument list for the given generic type.
If you give this function List[int], it will return [int], and
if you give it Union[int, str] it will give you [int, str]. Note
that on Python < 3.7, Union[int, bool] collapses to Union[int] and
then to int; this is already done by the time this f... | [
"Gets",
"the",
"type",
"argument",
"list",
"for",
"the",
"given",
"generic",
"type",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/util.py#L96-L114 |
yatiml/yatiml | yatiml/util.py | type_to_desc | def type_to_desc(type_: Type) -> str:
"""Convert a type to a human-readable description.
This is used for generating nice error messages. We want users \
to see a nice readable text, rather than something like \
"typing.List<~T>[str]".
Args:
type_: The type to represent.
Returns:
... | python | def type_to_desc(type_: Type) -> str:
"""Convert a type to a human-readable description.
This is used for generating nice error messages. We want users \
to see a nice readable text, rather than something like \
"typing.List<~T>[str]".
Args:
type_: The type to represent.
Returns:
... | [
"def",
"type_to_desc",
"(",
"type_",
":",
"Type",
")",
"->",
"str",
":",
"scalar_type_to_str",
"=",
"{",
"str",
":",
"'string'",
",",
"int",
":",
"'int'",
",",
"float",
":",
"'float'",
",",
"bool",
":",
"'boolean'",
",",
"None",
":",
"'null value'",
",... | Convert a type to a human-readable description.
This is used for generating nice error messages. We want users \
to see a nice readable text, rather than something like \
"typing.List<~T>[str]".
Args:
type_: The type to represent.
Returns:
A human-readable description. | [
"Convert",
"a",
"type",
"to",
"a",
"human",
"-",
"readable",
"description",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/util.py#L117-L153 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.