repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
StagPython/StagPy | stagpy/processing.py | advth | def advth(step):
"""Theoretical advection.
This compute the theoretical profile of total advection as function of
radius.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
tuple of :class:`numpy.array` and None: the theoretical ad... | python | def advth(step):
"""Theoretical advection.
This compute the theoretical profile of total advection as function of
radius.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
tuple of :class:`numpy.array` and None: the theoretical ad... | [
"def",
"advth",
"(",
"step",
")",
":",
"rbot",
",",
"rtop",
"=",
"misc",
".",
"get_rbounds",
"(",
"step",
")",
"rmean",
"=",
"0.5",
"*",
"(",
"rbot",
"+",
"rtop",
")",
"rad",
"=",
"step",
".",
"rprof",
"[",
"'r'",
"]",
".",
"values",
"+",
"rbot... | Theoretical advection.
This compute the theoretical profile of total advection as function of
radius.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
tuple of :class:`numpy.array` and None: the theoretical advection.
The sec... | [
"Theoretical",
"advection",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/processing.py#L258-L281 |
StagPython/StagPy | stagpy/processing.py | init_c_overturn | def init_c_overturn(step):
"""Initial concentration.
This compute the resulting composition profile if fractional
crystallization of a SMO is assumed.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
tuple of :class:`numpy.array`... | python | def init_c_overturn(step):
"""Initial concentration.
This compute the resulting composition profile if fractional
crystallization of a SMO is assumed.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
tuple of :class:`numpy.array`... | [
"def",
"init_c_overturn",
"(",
"step",
")",
":",
"rbot",
",",
"rtop",
"=",
"misc",
".",
"get_rbounds",
"(",
"step",
")",
"xieut",
"=",
"step",
".",
"sdat",
".",
"par",
"[",
"'tracersin'",
"]",
"[",
"'fe_eut'",
"]",
"k_fe",
"=",
"step",
".",
"sdat",
... | Initial concentration.
This compute the resulting composition profile if fractional
crystallization of a SMO is assumed.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
tuple of :class:`numpy.array`: the composition and the radial p... | [
"Initial",
"concentration",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/processing.py#L284-L315 |
StagPython/StagPy | stagpy/processing.py | c_overturned | def c_overturned(step):
"""Theoretical overturned concentration.
This compute the resulting composition profile if fractional
crystallization of a SMO is assumed and then a purely radial
overturn happens.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
in... | python | def c_overturned(step):
"""Theoretical overturned concentration.
This compute the resulting composition profile if fractional
crystallization of a SMO is assumed and then a purely radial
overturn happens.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
in... | [
"def",
"c_overturned",
"(",
"step",
")",
":",
"rbot",
",",
"rtop",
"=",
"misc",
".",
"get_rbounds",
"(",
"step",
")",
"cinit",
",",
"rad",
"=",
"init_c_overturn",
"(",
"step",
")",
"radf",
"=",
"(",
"rtop",
"**",
"3",
"+",
"rbot",
"**",
"3",
"-",
... | Theoretical overturned concentration.
This compute the resulting composition profile if fractional
crystallization of a SMO is assumed and then a purely radial
overturn happens.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
tu... | [
"Theoretical",
"overturned",
"concentration",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/processing.py#L318-L335 |
StagPython/StagPy | stagpy/processing.py | stream_function | def stream_function(step):
"""Stream function.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
:class:`numpy.array`: the stream function field, with four dimensions:
x-direction, y-direction, z-direction and block.
"""
if... | python | def stream_function(step):
"""Stream function.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
:class:`numpy.array`: the stream function field, with four dimensions:
x-direction, y-direction, z-direction and block.
"""
if... | [
"def",
"stream_function",
"(",
"step",
")",
":",
"if",
"step",
".",
"geom",
".",
"twod_yz",
":",
"x_coord",
"=",
"step",
".",
"geom",
".",
"y_coord",
"v_x",
"=",
"step",
".",
"fields",
"[",
"'v2'",
"]",
"[",
"0",
",",
":",
",",
":",
",",
"0",
"... | Stream function.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
:class:`numpy.array`: the stream function field, with four dimensions:
x-direction, y-direction, z-direction and block. | [
"Stream",
"function",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/processing.py#L338-L390 |
StagPython/StagPy | stagpy/stagyydata.py | _Steps.last | def last(self):
"""Last time step available.
Example:
>>> sdat = StagyyData('path/to/run')
>>> assert(sdat.steps.last is sdat.steps[-1])
"""
if self._last is UNDETERMINED:
# not necessarily the last one...
self._last = self.sdat.tseries.in... | python | def last(self):
"""Last time step available.
Example:
>>> sdat = StagyyData('path/to/run')
>>> assert(sdat.steps.last is sdat.steps[-1])
"""
if self._last is UNDETERMINED:
# not necessarily the last one...
self._last = self.sdat.tseries.in... | [
"def",
"last",
"(",
"self",
")",
":",
"if",
"self",
".",
"_last",
"is",
"UNDETERMINED",
":",
"# not necessarily the last one...",
"self",
".",
"_last",
"=",
"self",
".",
"sdat",
".",
"tseries",
".",
"index",
"[",
"-",
"1",
"]",
"return",
"self",
"[",
"... | Last time step available.
Example:
>>> sdat = StagyyData('path/to/run')
>>> assert(sdat.steps.last is sdat.steps[-1]) | [
"Last",
"time",
"step",
"available",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L160-L170 |
StagPython/StagPy | stagpy/stagyydata.py | _Snaps.bind | def bind(self, isnap, istep):
"""Register the isnap / istep correspondence.
Users of :class:`StagyyData` should not use this method.
Args:
isnap (int): snapshot index.
istep (int): time step index.
"""
self._isteps[isnap] = istep
self.sdat.steps[... | python | def bind(self, isnap, istep):
"""Register the isnap / istep correspondence.
Users of :class:`StagyyData` should not use this method.
Args:
isnap (int): snapshot index.
istep (int): time step index.
"""
self._isteps[isnap] = istep
self.sdat.steps[... | [
"def",
"bind",
"(",
"self",
",",
"isnap",
",",
"istep",
")",
":",
"self",
".",
"_isteps",
"[",
"isnap",
"]",
"=",
"istep",
"self",
".",
"sdat",
".",
"steps",
"[",
"istep",
"]",
".",
"isnap",
"=",
"isnap"
] | Register the isnap / istep correspondence.
Users of :class:`StagyyData` should not use this method.
Args:
isnap (int): snapshot index.
istep (int): time step index. | [
"Register",
"the",
"isnap",
"/",
"istep",
"correspondence",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L251-L261 |
StagPython/StagPy | stagpy/stagyydata.py | _StepsView._pass | def _pass(self, step):
"""Check whether a :class:`~stagpy._step.Step` passes the filters."""
okf = True
okf = okf and (not self._flt['snap'] or step.isnap is not None)
okf = okf and (not self._flt['rprof'] or step.rprof is not None)
okf = okf and all(f in step.fields for f in sel... | python | def _pass(self, step):
"""Check whether a :class:`~stagpy._step.Step` passes the filters."""
okf = True
okf = okf and (not self._flt['snap'] or step.isnap is not None)
okf = okf and (not self._flt['rprof'] or step.rprof is not None)
okf = okf and all(f in step.fields for f in sel... | [
"def",
"_pass",
"(",
"self",
",",
"step",
")",
":",
"okf",
"=",
"True",
"okf",
"=",
"okf",
"and",
"(",
"not",
"self",
".",
"_flt",
"[",
"'snap'",
"]",
"or",
"step",
".",
"isnap",
"is",
"not",
"None",
")",
"okf",
"=",
"okf",
"and",
"(",
"not",
... | Check whether a :class:`~stagpy._step.Step` passes the filters. | [
"Check",
"whether",
"a",
":",
"class",
":",
"~stagpy",
".",
"_step",
".",
"Step",
"passes",
"the",
"filters",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L314-L321 |
StagPython/StagPy | stagpy/stagyydata.py | _StepsView.filter | def filter(self, **filters):
"""Update filters with provided arguments.
Note that filters are only resolved when the view is iterated, and
hence they do not compose. Each call to filter merely updates the
relevant filters. For example, with this code::
view = sdat.steps[500... | python | def filter(self, **filters):
"""Update filters with provided arguments.
Note that filters are only resolved when the view is iterated, and
hence they do not compose. Each call to filter merely updates the
relevant filters. For example, with this code::
view = sdat.steps[500... | [
"def",
"filter",
"(",
"self",
",",
"*",
"*",
"filters",
")",
":",
"for",
"flt",
",",
"val",
"in",
"self",
".",
"_flt",
".",
"items",
"(",
")",
":",
"self",
".",
"_flt",
"[",
"flt",
"]",
"=",
"filters",
".",
"pop",
"(",
"flt",
",",
"val",
")",... | Update filters with provided arguments.
Note that filters are only resolved when the view is iterated, and
hence they do not compose. Each call to filter merely updates the
relevant filters. For example, with this code::
view = sdat.steps[500:].filter(rprof=True, fields=['T'])
... | [
"Update",
"filters",
"with",
"provided",
"arguments",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L323-L352 |
StagPython/StagPy | stagpy/stagyydata.py | StagyyData.hdf5 | def hdf5(self):
"""Path of output hdf5 folder if relevant, None otherwise."""
if self._rundir['hdf5'] is UNDETERMINED:
h5_folder = self.path / self.par['ioin']['hdf5_output_folder']
if (h5_folder / 'Data.xmf').is_file():
self._rundir['hdf5'] = h5_folder
... | python | def hdf5(self):
"""Path of output hdf5 folder if relevant, None otherwise."""
if self._rundir['hdf5'] is UNDETERMINED:
h5_folder = self.path / self.par['ioin']['hdf5_output_folder']
if (h5_folder / 'Data.xmf').is_file():
self._rundir['hdf5'] = h5_folder
... | [
"def",
"hdf5",
"(",
"self",
")",
":",
"if",
"self",
".",
"_rundir",
"[",
"'hdf5'",
"]",
"is",
"UNDETERMINED",
":",
"h5_folder",
"=",
"self",
".",
"path",
"/",
"self",
".",
"par",
"[",
"'ioin'",
"]",
"[",
"'hdf5_output_folder'",
"]",
"if",
"(",
"h5_fo... | Path of output hdf5 folder if relevant, None otherwise. | [
"Path",
"of",
"output",
"hdf5",
"folder",
"if",
"relevant",
"None",
"otherwise",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L431-L439 |
StagPython/StagPy | stagpy/stagyydata.py | StagyyData.tseries | def tseries(self):
"""Time series data.
This is a :class:`pandas.DataFrame` with istep as index and variable
names as columns.
"""
if self._stagdat['tseries'] is UNDETERMINED:
timefile = self.filename('TimeSeries.h5')
self._stagdat['tseries'] = stagyypars... | python | def tseries(self):
"""Time series data.
This is a :class:`pandas.DataFrame` with istep as index and variable
names as columns.
"""
if self._stagdat['tseries'] is UNDETERMINED:
timefile = self.filename('TimeSeries.h5')
self._stagdat['tseries'] = stagyypars... | [
"def",
"tseries",
"(",
"self",
")",
":",
"if",
"self",
".",
"_stagdat",
"[",
"'tseries'",
"]",
"is",
"UNDETERMINED",
":",
"timefile",
"=",
"self",
".",
"filename",
"(",
"'TimeSeries.h5'",
")",
"self",
".",
"_stagdat",
"[",
"'tseries'",
"]",
"=",
"stagyyp... | Time series data.
This is a :class:`pandas.DataFrame` with istep as index and variable
names as columns. | [
"Time",
"series",
"data",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L451-L469 |
StagPython/StagPy | stagpy/stagyydata.py | StagyyData.files | def files(self):
"""Set of found binary files output by StagYY."""
if self._rundir['ls'] is UNDETERMINED:
out_stem = pathlib.Path(self.par['ioin']['output_file_stem'] + '_')
out_dir = self.path / out_stem.parent
if out_dir.is_dir():
self._rundir['ls'] ... | python | def files(self):
"""Set of found binary files output by StagYY."""
if self._rundir['ls'] is UNDETERMINED:
out_stem = pathlib.Path(self.par['ioin']['output_file_stem'] + '_')
out_dir = self.path / out_stem.parent
if out_dir.is_dir():
self._rundir['ls'] ... | [
"def",
"files",
"(",
"self",
")",
":",
"if",
"self",
".",
"_rundir",
"[",
"'ls'",
"]",
"is",
"UNDETERMINED",
":",
"out_stem",
"=",
"pathlib",
".",
"Path",
"(",
"self",
".",
"par",
"[",
"'ioin'",
"]",
"[",
"'output_file_stem'",
"]",
"+",
"'_'",
")",
... | Set of found binary files output by StagYY. | [
"Set",
"of",
"found",
"binary",
"files",
"output",
"by",
"StagYY",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L505-L514 |
StagPython/StagPy | stagpy/stagyydata.py | StagyyData.walk | def walk(self):
"""Return view on configured steps slice.
Other Parameters:
conf.core.snapshots: the slice of snapshots.
conf.core.timesteps: the slice of timesteps.
"""
if conf.core.snapshots is not None:
return self.snaps[conf.core.snapshots]
... | python | def walk(self):
"""Return view on configured steps slice.
Other Parameters:
conf.core.snapshots: the slice of snapshots.
conf.core.timesteps: the slice of timesteps.
"""
if conf.core.snapshots is not None:
return self.snaps[conf.core.snapshots]
... | [
"def",
"walk",
"(",
"self",
")",
":",
"if",
"conf",
".",
"core",
".",
"snapshots",
"is",
"not",
"None",
":",
"return",
"self",
".",
"snaps",
"[",
"conf",
".",
"core",
".",
"snapshots",
"]",
"elif",
"conf",
".",
"core",
".",
"timesteps",
"is",
"not"... | Return view on configured steps slice.
Other Parameters:
conf.core.snapshots: the slice of snapshots.
conf.core.timesteps: the slice of timesteps. | [
"Return",
"view",
"on",
"configured",
"steps",
"slice",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L517-L528 |
StagPython/StagPy | stagpy/stagyydata.py | StagyyData.scale | def scale(self, data, unit):
"""Scales quantity to obtain dimensionful quantity.
Args:
data (numpy.array): the quantity that should be scaled.
dim (str): the dimension of data as defined in phyvars.
Return:
(float, str): scaling factor and unit string.
... | python | def scale(self, data, unit):
"""Scales quantity to obtain dimensionful quantity.
Args:
data (numpy.array): the quantity that should be scaled.
dim (str): the dimension of data as defined in phyvars.
Return:
(float, str): scaling factor and unit string.
... | [
"def",
"scale",
"(",
"self",
",",
"data",
",",
"unit",
")",
":",
"if",
"self",
".",
"par",
"[",
"'switches'",
"]",
"[",
"'dimensional_units'",
"]",
"or",
"not",
"conf",
".",
"scaling",
".",
"dimensional",
"or",
"unit",
"==",
"'1'",
":",
"return",
"da... | Scales quantity to obtain dimensionful quantity.
Args:
data (numpy.array): the quantity that should be scaled.
dim (str): the dimension of data as defined in phyvars.
Return:
(float, str): scaling factor and unit string.
Other Parameters:
conf.sca... | [
"Scales",
"quantity",
"to",
"obtain",
"dimensionful",
"quantity",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L530-L557 |
StagPython/StagPy | stagpy/stagyydata.py | StagyyData.tseries_between | def tseries_between(self, tstart=None, tend=None):
"""Return time series data between requested times.
Args:
tstart (float): starting time. Set to None to start at the
beginning of available data.
tend (float): ending time. Set to None to stop at the end of
... | python | def tseries_between(self, tstart=None, tend=None):
"""Return time series data between requested times.
Args:
tstart (float): starting time. Set to None to start at the
beginning of available data.
tend (float): ending time. Set to None to stop at the end of
... | [
"def",
"tseries_between",
"(",
"self",
",",
"tstart",
"=",
"None",
",",
"tend",
"=",
"None",
")",
":",
"if",
"self",
".",
"tseries",
"is",
"None",
":",
"return",
"None",
"ndat",
"=",
"self",
".",
"tseries",
".",
"shape",
"[",
"0",
"]",
"if",
"tstar... | Return time series data between requested times.
Args:
tstart (float): starting time. Set to None to start at the
beginning of available data.
tend (float): ending time. Set to None to stop at the end of
available data.
Returns:
:class... | [
"Return",
"time",
"series",
"data",
"between",
"requested",
"times",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L559-L601 |
StagPython/StagPy | stagpy/stagyydata.py | StagyyData.filename | def filename(self, fname, timestep=None, suffix='', force_legacy=False):
"""Return name of StagYY output file.
Args:
fname (str): name stem.
timestep (int): snapshot number, set to None if this is not
relevant.
suffix (str): optional suffix of file na... | python | def filename(self, fname, timestep=None, suffix='', force_legacy=False):
"""Return name of StagYY output file.
Args:
fname (str): name stem.
timestep (int): snapshot number, set to None if this is not
relevant.
suffix (str): optional suffix of file na... | [
"def",
"filename",
"(",
"self",
",",
"fname",
",",
"timestep",
"=",
"None",
",",
"suffix",
"=",
"''",
",",
"force_legacy",
"=",
"False",
")",
":",
"if",
"timestep",
"is",
"not",
"None",
":",
"fname",
"+=",
"'{:05d}'",
".",
"format",
"(",
"timestep",
... | Return name of StagYY output file.
Args:
fname (str): name stem.
timestep (int): snapshot number, set to None if this is not
relevant.
suffix (str): optional suffix of file name.
force_legacy (bool): force returning the legacy output path.
... | [
"Return",
"name",
"of",
"StagYY",
"output",
"file",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L603-L624 |
StagPython/StagPy | stagpy/stagyydata.py | StagyyData.binfiles_set | def binfiles_set(self, isnap):
"""Set of existing binary files at a given snap.
Args:
isnap (int): snapshot index.
Returns:
set of pathlib.Path: the set of output files available for this
snapshot number.
"""
possible_files = set(self.filename... | python | def binfiles_set(self, isnap):
"""Set of existing binary files at a given snap.
Args:
isnap (int): snapshot index.
Returns:
set of pathlib.Path: the set of output files available for this
snapshot number.
"""
possible_files = set(self.filename... | [
"def",
"binfiles_set",
"(",
"self",
",",
"isnap",
")",
":",
"possible_files",
"=",
"set",
"(",
"self",
".",
"filename",
"(",
"fstem",
",",
"isnap",
",",
"force_legacy",
"=",
"True",
")",
"for",
"fstem",
"in",
"phyvars",
".",
"FIELD_FILES",
")",
"return",... | Set of existing binary files at a given snap.
Args:
isnap (int): snapshot index.
Returns:
set of pathlib.Path: the set of output files available for this
snapshot number. | [
"Set",
"of",
"existing",
"binary",
"files",
"at",
"a",
"given",
"snap",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyydata.py#L626-L637 |
StagPython/StagPy | stagpy/stagyyparsers.py | _tidy_names | def _tidy_names(names, nnames, extra_names=None):
"""Truncate or extend names so that its len is nnames.
The list is modified, this function returns nothing.
Args:
names (list): list of names.
nnames (int): desired number of names.
extra_names (list of str): list of names to be use... | python | def _tidy_names(names, nnames, extra_names=None):
"""Truncate or extend names so that its len is nnames.
The list is modified, this function returns nothing.
Args:
names (list): list of names.
nnames (int): desired number of names.
extra_names (list of str): list of names to be use... | [
"def",
"_tidy_names",
"(",
"names",
",",
"nnames",
",",
"extra_names",
"=",
"None",
")",
":",
"if",
"len",
"(",
"names",
")",
"<",
"nnames",
"and",
"extra_names",
"is",
"not",
"None",
":",
"names",
".",
"extend",
"(",
"extra_names",
")",
"names",
".",
... | Truncate or extend names so that its len is nnames.
The list is modified, this function returns nothing.
Args:
names (list): list of names.
nnames (int): desired number of names.
extra_names (list of str): list of names to be used to extend the list
if needed. If this list ... | [
"Truncate",
"or",
"extend",
"names",
"so",
"that",
"its",
"len",
"is",
"nnames",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L21-L35 |
StagPython/StagPy | stagpy/stagyyparsers.py | time_series | def time_series(timefile, colnames):
"""Read temporal series text file.
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional numeric column names from 0 to N-1 will be attributed to the N
extra columns present in :data:`timefile`.
Args:
timefile (:class:`pa... | python | def time_series(timefile, colnames):
"""Read temporal series text file.
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional numeric column names from 0 to N-1 will be attributed to the N
extra columns present in :data:`timefile`.
Args:
timefile (:class:`pa... | [
"def",
"time_series",
"(",
"timefile",
",",
"colnames",
")",
":",
"if",
"not",
"timefile",
".",
"is_file",
"(",
")",
":",
"return",
"None",
"data",
"=",
"pd",
".",
"read_csv",
"(",
"timefile",
",",
"delim_whitespace",
"=",
"True",
",",
"dtype",
"=",
"s... | Read temporal series text file.
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional numeric column names from 0 to N-1 will be attributed to the N
extra columns present in :data:`timefile`.
Args:
timefile (:class:`pathlib.Path`): path of the time.dat file.
... | [
"Read",
"temporal",
"series",
"text",
"file",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L38-L80 |
StagPython/StagPy | stagpy/stagyyparsers.py | time_series_h5 | def time_series_h5(timefile, colnames):
"""Read temporal series HDF5 file.
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional column names will be deduced from the content of the file.
Args:
timefile (:class:`pathlib.Path`): path of the TimeSeries.h5 file.
... | python | def time_series_h5(timefile, colnames):
"""Read temporal series HDF5 file.
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional column names will be deduced from the content of the file.
Args:
timefile (:class:`pathlib.Path`): path of the TimeSeries.h5 file.
... | [
"def",
"time_series_h5",
"(",
"timefile",
",",
"colnames",
")",
":",
"if",
"not",
"timefile",
".",
"is_file",
"(",
")",
":",
"return",
"None",
"with",
"h5py",
".",
"File",
"(",
"timefile",
",",
"'r'",
")",
"as",
"h5f",
":",
"dset",
"=",
"h5f",
"[",
... | Read temporal series HDF5 file.
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional column names will be deduced from the content of the file.
Args:
timefile (:class:`pathlib.Path`): path of the TimeSeries.h5 file.
colnames (list of names): names of the va... | [
"Read",
"temporal",
"series",
"HDF5",
"file",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L83-L109 |
StagPython/StagPy | stagpy/stagyyparsers.py | _extract_rsnap_isteps | def _extract_rsnap_isteps(rproffile):
"""Extract istep and compute list of rows to delete"""
step_regex = re.compile(r'^\*+step:\s*(\d+) ; time =\s*(\S+)')
isteps = [] # list of (istep, time, nz)
rows_to_del = set()
line = ' '
with rproffile.open() as stream:
while line[0] != '*':
... | python | def _extract_rsnap_isteps(rproffile):
"""Extract istep and compute list of rows to delete"""
step_regex = re.compile(r'^\*+step:\s*(\d+) ; time =\s*(\S+)')
isteps = [] # list of (istep, time, nz)
rows_to_del = set()
line = ' '
with rproffile.open() as stream:
while line[0] != '*':
... | [
"def",
"_extract_rsnap_isteps",
"(",
"rproffile",
")",
":",
"step_regex",
"=",
"re",
".",
"compile",
"(",
"r'^\\*+step:\\s*(\\d+) ; time =\\s*(\\S+)'",
")",
"isteps",
"=",
"[",
"]",
"# list of (istep, time, nz)",
"rows_to_del",
"=",
"set",
"(",
")",
"line",
"=",
"... | Extract istep and compute list of rows to delete | [
"Extract",
"istep",
"and",
"compute",
"list",
"of",
"rows",
"to",
"delete"
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L112-L143 |
StagPython/StagPy | stagpy/stagyyparsers.py | rprof | def rprof(rproffile, colnames):
"""Extract radial profiles data
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional numeric column names from 0 to N-1 will be attributed to the N
extra columns present in :data:`timefile`.
Args:
rproffile (:class:`pathlib.P... | python | def rprof(rproffile, colnames):
"""Extract radial profiles data
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional numeric column names from 0 to N-1 will be attributed to the N
extra columns present in :data:`timefile`.
Args:
rproffile (:class:`pathlib.P... | [
"def",
"rprof",
"(",
"rproffile",
",",
"colnames",
")",
":",
"if",
"not",
"rproffile",
".",
"is_file",
"(",
")",
":",
"return",
"None",
",",
"None",
"data",
"=",
"pd",
".",
"read_csv",
"(",
"rproffile",
",",
"delim_whitespace",
"=",
"True",
",",
"dtype... | Extract radial profiles data
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional numeric column names from 0 to N-1 will be attributed to the N
extra columns present in :data:`timefile`.
Args:
rproffile (:class:`pathlib.Path`): path of the rprof.dat file.
... | [
"Extract",
"radial",
"profiles",
"data"
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L146-L192 |
StagPython/StagPy | stagpy/stagyyparsers.py | rprof_h5 | def rprof_h5(rproffile, colnames):
"""Extract radial profiles data
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional column names will be deduced from the content of the file.
Args:
rproffile (:class:`pathlib.Path`): path of the rprof.dat file.
colna... | python | def rprof_h5(rproffile, colnames):
"""Extract radial profiles data
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional column names will be deduced from the content of the file.
Args:
rproffile (:class:`pathlib.Path`): path of the rprof.dat file.
colna... | [
"def",
"rprof_h5",
"(",
"rproffile",
",",
"colnames",
")",
":",
"if",
"not",
"rproffile",
".",
"is_file",
"(",
")",
":",
"return",
"None",
",",
"None",
"isteps",
"=",
"[",
"]",
"with",
"h5py",
".",
"File",
"(",
"rproffile",
")",
"as",
"h5f",
":",
"... | Extract radial profiles data
If :data:`colnames` is too long, it will be truncated. If it is too short,
additional column names will be deduced from the content of the file.
Args:
rproffile (:class:`pathlib.Path`): path of the rprof.dat file.
colnames (list of names): names of the variable... | [
"Extract",
"radial",
"profiles",
"data"
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L195-L238 |
StagPython/StagPy | stagpy/stagyyparsers.py | _readbin | def _readbin(fid, fmt='i', nwords=1, file64=False, unpack=True):
"""Read n words of 4 or 8 bytes with fmt format.
fmt: 'i' or 'f' or 'b' (integer or float or bytes)
4 or 8 bytes: depends on header
Return an array of elements if more than one element.
Default: read 1 word formatted as an integer.
... | python | def _readbin(fid, fmt='i', nwords=1, file64=False, unpack=True):
"""Read n words of 4 or 8 bytes with fmt format.
fmt: 'i' or 'f' or 'b' (integer or float or bytes)
4 or 8 bytes: depends on header
Return an array of elements if more than one element.
Default: read 1 word formatted as an integer.
... | [
"def",
"_readbin",
"(",
"fid",
",",
"fmt",
"=",
"'i'",
",",
"nwords",
"=",
"1",
",",
"file64",
"=",
"False",
",",
"unpack",
"=",
"True",
")",
":",
"if",
"fmt",
"in",
"'if'",
":",
"fmt",
"+=",
"'8'",
"if",
"file64",
"else",
"'4'",
"elts",
"=",
"... | Read n words of 4 or 8 bytes with fmt format.
fmt: 'i' or 'f' or 'b' (integer or float or bytes)
4 or 8 bytes: depends on header
Return an array of elements if more than one element.
Default: read 1 word formatted as an integer. | [
"Read",
"n",
"words",
"of",
"4",
"or",
"8",
"bytes",
"with",
"fmt",
"format",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L241-L256 |
StagPython/StagPy | stagpy/stagyyparsers.py | fields | def fields(fieldfile, only_header=False, only_istep=False):
"""Extract fields data.
Args:
fieldfile (:class:`pathlib.Path`): path of the binary field file.
only_header (bool): when True (and :data:`only_istep` is False), only
:data:`header` is returned.
only_istep (bool): wh... | python | def fields(fieldfile, only_header=False, only_istep=False):
"""Extract fields data.
Args:
fieldfile (:class:`pathlib.Path`): path of the binary field file.
only_header (bool): when True (and :data:`only_istep` is False), only
:data:`header` is returned.
only_istep (bool): wh... | [
"def",
"fields",
"(",
"fieldfile",
",",
"only_header",
"=",
"False",
",",
"only_istep",
"=",
"False",
")",
":",
"# something to skip header?",
"if",
"not",
"fieldfile",
".",
"is_file",
"(",
")",
":",
"return",
"None",
"header",
"=",
"{",
"}",
"with",
"fiel... | Extract fields data.
Args:
fieldfile (:class:`pathlib.Path`): path of the binary field file.
only_header (bool): when True (and :data:`only_istep` is False), only
:data:`header` is returned.
only_istep (bool): when True, only :data:`istep` is returned.
Returns:
depe... | [
"Extract",
"fields",
"data",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L259-L386 |
StagPython/StagPy | stagpy/stagyyparsers.py | tracers | def tracers(tracersfile):
"""Extract tracers data.
Args:
tracersfile (:class:`pathlib.Path`): path of the binary tracers file.
Returns:
dict of list of numpy.array:
Tracers data organized by attribute and block.
"""
if not tracersfile.is_file():
return None
... | python | def tracers(tracersfile):
"""Extract tracers data.
Args:
tracersfile (:class:`pathlib.Path`): path of the binary tracers file.
Returns:
dict of list of numpy.array:
Tracers data organized by attribute and block.
"""
if not tracersfile.is_file():
return None
... | [
"def",
"tracers",
"(",
"tracersfile",
")",
":",
"if",
"not",
"tracersfile",
".",
"is_file",
"(",
")",
":",
"return",
"None",
"tra",
"=",
"{",
"}",
"with",
"tracersfile",
".",
"open",
"(",
"'rb'",
")",
"as",
"fid",
":",
"readbin",
"=",
"partial",
"(",... | Extract tracers data.
Args:
tracersfile (:class:`pathlib.Path`): path of the binary tracers file.
Returns:
dict of list of numpy.array:
Tracers data organized by attribute and block. | [
"Extract",
"tracers",
"data",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L389-L434 |
StagPython/StagPy | stagpy/stagyyparsers.py | _read_group_h5 | def _read_group_h5(filename, groupname):
"""Return group content.
Args:
filename (:class:`pathlib.Path`): path of hdf5 file.
groupname (str): name of group to read.
Returns:
:class:`numpy.array`: content of group.
"""
with h5py.File(filename, 'r') as h5f:
data = h5f[... | python | def _read_group_h5(filename, groupname):
"""Return group content.
Args:
filename (:class:`pathlib.Path`): path of hdf5 file.
groupname (str): name of group to read.
Returns:
:class:`numpy.array`: content of group.
"""
with h5py.File(filename, 'r') as h5f:
data = h5f[... | [
"def",
"_read_group_h5",
"(",
"filename",
",",
"groupname",
")",
":",
"with",
"h5py",
".",
"File",
"(",
"filename",
",",
"'r'",
")",
"as",
"h5f",
":",
"data",
"=",
"h5f",
"[",
"groupname",
"]",
"[",
"(",
")",
"]",
"return",
"data"
] | Return group content.
Args:
filename (:class:`pathlib.Path`): path of hdf5 file.
groupname (str): name of group to read.
Returns:
:class:`numpy.array`: content of group. | [
"Return",
"group",
"content",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L437-L448 |
StagPython/StagPy | stagpy/stagyyparsers.py | _make_3d | def _make_3d(field, twod):
"""Add a dimension to field if necessary.
Args:
field (numpy.array): the field that need to be 3d.
twod (str): 'XZ', 'YZ' or None depending on what is relevant.
Returns:
numpy.array: reshaped field.
"""
shp = list(field.shape)
if twod and 'X' i... | python | def _make_3d(field, twod):
"""Add a dimension to field if necessary.
Args:
field (numpy.array): the field that need to be 3d.
twod (str): 'XZ', 'YZ' or None depending on what is relevant.
Returns:
numpy.array: reshaped field.
"""
shp = list(field.shape)
if twod and 'X' i... | [
"def",
"_make_3d",
"(",
"field",
",",
"twod",
")",
":",
"shp",
"=",
"list",
"(",
"field",
".",
"shape",
")",
"if",
"twod",
"and",
"'X'",
"in",
"twod",
":",
"shp",
".",
"insert",
"(",
"1",
",",
"1",
")",
"elif",
"twod",
":",
"shp",
".",
"insert"... | Add a dimension to field if necessary.
Args:
field (numpy.array): the field that need to be 3d.
twod (str): 'XZ', 'YZ' or None depending on what is relevant.
Returns:
numpy.array: reshaped field. | [
"Add",
"a",
"dimension",
"to",
"field",
"if",
"necessary",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L451-L465 |
StagPython/StagPy | stagpy/stagyyparsers.py | _ncores | def _ncores(meshes, twod):
"""Compute number of nodes in each direction."""
nnpb = len(meshes) # number of nodes per block
nns = [1, 1, 1] # number of nodes in x, y, z directions
if twod is None or 'X' in twod:
while (nnpb > 1 and
meshes[nns[0]]['X'][0, 0, 0] ==
m... | python | def _ncores(meshes, twod):
"""Compute number of nodes in each direction."""
nnpb = len(meshes) # number of nodes per block
nns = [1, 1, 1] # number of nodes in x, y, z directions
if twod is None or 'X' in twod:
while (nnpb > 1 and
meshes[nns[0]]['X'][0, 0, 0] ==
m... | [
"def",
"_ncores",
"(",
"meshes",
",",
"twod",
")",
":",
"nnpb",
"=",
"len",
"(",
"meshes",
")",
"# number of nodes per block",
"nns",
"=",
"[",
"1",
",",
"1",
",",
"1",
"]",
"# number of nodes in x, y, z directions",
"if",
"twod",
"is",
"None",
"or",
"'X'"... | Compute number of nodes in each direction. | [
"Compute",
"number",
"of",
"nodes",
"in",
"each",
"direction",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L468-L491 |
StagPython/StagPy | stagpy/stagyyparsers.py | _conglomerate_meshes | def _conglomerate_meshes(meshin, header):
"""Conglomerate meshes from several cores into one."""
meshout = {}
npc = header['nts'] // header['ncs']
shp = [val + 1 if val != 1 else 1 for val in header['nts']]
x_p = int(shp[0] != 1)
y_p = int(shp[1] != 1)
for coord in meshin[0]:
meshout... | python | def _conglomerate_meshes(meshin, header):
"""Conglomerate meshes from several cores into one."""
meshout = {}
npc = header['nts'] // header['ncs']
shp = [val + 1 if val != 1 else 1 for val in header['nts']]
x_p = int(shp[0] != 1)
y_p = int(shp[1] != 1)
for coord in meshin[0]:
meshout... | [
"def",
"_conglomerate_meshes",
"(",
"meshin",
",",
"header",
")",
":",
"meshout",
"=",
"{",
"}",
"npc",
"=",
"header",
"[",
"'nts'",
"]",
"//",
"header",
"[",
"'ncs'",
"]",
"shp",
"=",
"[",
"val",
"+",
"1",
"if",
"val",
"!=",
"1",
"else",
"1",
"f... | Conglomerate meshes from several cores into one. | [
"Conglomerate",
"meshes",
"from",
"several",
"cores",
"into",
"one",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L494-L510 |
StagPython/StagPy | stagpy/stagyyparsers.py | _read_coord_h5 | def _read_coord_h5(files, shapes, header, twod):
"""Read all coord hdf5 files of a snapshot.
Args:
files (list of pathlib.Path): list of NodeCoordinates files of
a snapshot.
shapes (list of (int,int)): shape of mesh grids.
header (dict): geometry info.
twod (str): 'X... | python | def _read_coord_h5(files, shapes, header, twod):
"""Read all coord hdf5 files of a snapshot.
Args:
files (list of pathlib.Path): list of NodeCoordinates files of
a snapshot.
shapes (list of (int,int)): shape of mesh grids.
header (dict): geometry info.
twod (str): 'X... | [
"def",
"_read_coord_h5",
"(",
"files",
",",
"shapes",
",",
"header",
",",
"twod",
")",
":",
"meshes",
"=",
"[",
"]",
"for",
"h5file",
",",
"shape",
"in",
"zip",
"(",
"files",
",",
"shapes",
")",
":",
"meshes",
".",
"append",
"(",
"{",
"}",
")",
"... | Read all coord hdf5 files of a snapshot.
Args:
files (list of pathlib.Path): list of NodeCoordinates files of
a snapshot.
shapes (list of (int,int)): shape of mesh grids.
header (dict): geometry info.
twod (str): 'XZ', 'YZ' or None depending on what is relevant. | [
"Read",
"all",
"coord",
"hdf5",
"files",
"of",
"a",
"snapshot",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L513-L568 |
StagPython/StagPy | stagpy/stagyyparsers.py | _get_field | def _get_field(xdmf_file, data_item):
"""Extract field from data item."""
shp = _get_dim(data_item)
h5file, group = data_item.text.strip().split(':/', 1)
icore = int(group.split('_')[-2]) - 1
fld = _read_group_h5(xdmf_file.parent / h5file, group).reshape(shp)
return icore, fld | python | def _get_field(xdmf_file, data_item):
"""Extract field from data item."""
shp = _get_dim(data_item)
h5file, group = data_item.text.strip().split(':/', 1)
icore = int(group.split('_')[-2]) - 1
fld = _read_group_h5(xdmf_file.parent / h5file, group).reshape(shp)
return icore, fld | [
"def",
"_get_field",
"(",
"xdmf_file",
",",
"data_item",
")",
":",
"shp",
"=",
"_get_dim",
"(",
"data_item",
")",
"h5file",
",",
"group",
"=",
"data_item",
".",
"text",
".",
"strip",
"(",
")",
".",
"split",
"(",
"':/'",
",",
"1",
")",
"icore",
"=",
... | Extract field from data item. | [
"Extract",
"field",
"from",
"data",
"item",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L576-L582 |
StagPython/StagPy | stagpy/stagyyparsers.py | _maybe_get | def _maybe_get(elt, item, info, conversion=None):
"""Extract and convert info if item is present."""
maybe_item = elt.find(item)
if maybe_item is not None:
maybe_item = maybe_item.get(info)
if conversion is not None:
maybe_item = conversion(maybe_item)
return maybe_item | python | def _maybe_get(elt, item, info, conversion=None):
"""Extract and convert info if item is present."""
maybe_item = elt.find(item)
if maybe_item is not None:
maybe_item = maybe_item.get(info)
if conversion is not None:
maybe_item = conversion(maybe_item)
return maybe_item | [
"def",
"_maybe_get",
"(",
"elt",
",",
"item",
",",
"info",
",",
"conversion",
"=",
"None",
")",
":",
"maybe_item",
"=",
"elt",
".",
"find",
"(",
"item",
")",
"if",
"maybe_item",
"is",
"not",
"None",
":",
"maybe_item",
"=",
"maybe_item",
".",
"get",
"... | Extract and convert info if item is present. | [
"Extract",
"and",
"convert",
"info",
"if",
"item",
"is",
"present",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L585-L592 |
StagPython/StagPy | stagpy/stagyyparsers.py | read_geom_h5 | def read_geom_h5(xdmf_file, snapshot):
"""Extract geometry information from hdf5 files.
Args:
xdmf_file (:class:`pathlib.Path`): path of the xdmf file.
snapshot (int): snapshot number.
Returns:
(dict, root): geometry information and root of xdmf document.
"""
header = {}
... | python | def read_geom_h5(xdmf_file, snapshot):
"""Extract geometry information from hdf5 files.
Args:
xdmf_file (:class:`pathlib.Path`): path of the xdmf file.
snapshot (int): snapshot number.
Returns:
(dict, root): geometry information and root of xdmf document.
"""
header = {}
... | [
"def",
"read_geom_h5",
"(",
"xdmf_file",
",",
"snapshot",
")",
":",
"header",
"=",
"{",
"}",
"xdmf_root",
"=",
"xmlET",
".",
"parse",
"(",
"str",
"(",
"xdmf_file",
")",
")",
".",
"getroot",
"(",
")",
"if",
"snapshot",
"is",
"None",
":",
"return",
"No... | Extract geometry information from hdf5 files.
Args:
xdmf_file (:class:`pathlib.Path`): path of the xdmf file.
snapshot (int): snapshot number.
Returns:
(dict, root): geometry information and root of xdmf document. | [
"Extract",
"geometry",
"information",
"from",
"hdf5",
"files",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L595-L636 |
StagPython/StagPy | stagpy/stagyyparsers.py | _to_spherical | def _to_spherical(flds, header):
"""Convert vector field to spherical."""
cth = np.cos(header['t_mesh'][:, :, :-1])
sth = np.sin(header['t_mesh'][:, :, :-1])
cph = np.cos(header['p_mesh'][:, :, :-1])
sph = np.sin(header['p_mesh'][:, :, :-1])
fout = np.copy(flds)
fout[0] = cth * cph * flds[0]... | python | def _to_spherical(flds, header):
"""Convert vector field to spherical."""
cth = np.cos(header['t_mesh'][:, :, :-1])
sth = np.sin(header['t_mesh'][:, :, :-1])
cph = np.cos(header['p_mesh'][:, :, :-1])
sph = np.sin(header['p_mesh'][:, :, :-1])
fout = np.copy(flds)
fout[0] = cth * cph * flds[0]... | [
"def",
"_to_spherical",
"(",
"flds",
",",
"header",
")",
":",
"cth",
"=",
"np",
".",
"cos",
"(",
"header",
"[",
"'t_mesh'",
"]",
"[",
":",
",",
":",
",",
":",
"-",
"1",
"]",
")",
"sth",
"=",
"np",
".",
"sin",
"(",
"header",
"[",
"'t_mesh'",
"... | Convert vector field to spherical. | [
"Convert",
"vector",
"field",
"to",
"spherical",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L639-L649 |
StagPython/StagPy | stagpy/stagyyparsers.py | _flds_shape | def _flds_shape(fieldname, header):
"""Compute shape of flds variable."""
shp = list(header['nts'])
shp.append(header['ntb'])
# probably a better way to handle this
if fieldname == 'Velocity':
shp.insert(0, 3)
# extra points
header['xp'] = int(header['nts'][0] != 1)
s... | python | def _flds_shape(fieldname, header):
"""Compute shape of flds variable."""
shp = list(header['nts'])
shp.append(header['ntb'])
# probably a better way to handle this
if fieldname == 'Velocity':
shp.insert(0, 3)
# extra points
header['xp'] = int(header['nts'][0] != 1)
s... | [
"def",
"_flds_shape",
"(",
"fieldname",
",",
"header",
")",
":",
"shp",
"=",
"list",
"(",
"header",
"[",
"'nts'",
"]",
")",
"shp",
".",
"append",
"(",
"header",
"[",
"'ntb'",
"]",
")",
"# probably a better way to handle this",
"if",
"fieldname",
"==",
"'Ve... | Compute shape of flds variable. | [
"Compute",
"shape",
"of",
"flds",
"variable",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L652-L672 |
StagPython/StagPy | stagpy/stagyyparsers.py | _post_read_flds | def _post_read_flds(flds, header):
"""Process flds to handle sphericity."""
if flds.shape[0] >= 3 and header['rcmb'] > 0:
# spherical vector
header['p_mesh'] = np.roll(
np.arctan2(header['y_mesh'], header['x_mesh']), -1, 1)
for ibk in range(header['ntb']):
flds[..... | python | def _post_read_flds(flds, header):
"""Process flds to handle sphericity."""
if flds.shape[0] >= 3 and header['rcmb'] > 0:
# spherical vector
header['p_mesh'] = np.roll(
np.arctan2(header['y_mesh'], header['x_mesh']), -1, 1)
for ibk in range(header['ntb']):
flds[..... | [
"def",
"_post_read_flds",
"(",
"flds",
",",
"header",
")",
":",
"if",
"flds",
".",
"shape",
"[",
"0",
"]",
">=",
"3",
"and",
"header",
"[",
"'rcmb'",
"]",
">",
"0",
":",
"# spherical vector",
"header",
"[",
"'p_mesh'",
"]",
"=",
"np",
".",
"roll",
... | Process flds to handle sphericity. | [
"Process",
"flds",
"to",
"handle",
"sphericity",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L675-L685 |
StagPython/StagPy | stagpy/stagyyparsers.py | read_field_h5 | def read_field_h5(xdmf_file, fieldname, snapshot, header=None):
"""Extract field data from hdf5 files.
Args:
xdmf_file (:class:`pathlib.Path`): path of the xdmf file.
fieldname (str): name of field to extract.
snapshot (int): snapshot number.
header (dict): geometry information.... | python | def read_field_h5(xdmf_file, fieldname, snapshot, header=None):
"""Extract field data from hdf5 files.
Args:
xdmf_file (:class:`pathlib.Path`): path of the xdmf file.
fieldname (str): name of field to extract.
snapshot (int): snapshot number.
header (dict): geometry information.... | [
"def",
"read_field_h5",
"(",
"xdmf_file",
",",
"fieldname",
",",
"snapshot",
",",
"header",
"=",
"None",
")",
":",
"if",
"header",
"is",
"None",
":",
"header",
",",
"xdmf_root",
"=",
"read_geom_h5",
"(",
"xdmf_file",
",",
"snapshot",
")",
"else",
":",
"x... | Extract field data from hdf5 files.
Args:
xdmf_file (:class:`pathlib.Path`): path of the xdmf file.
fieldname (str): name of field to extract.
snapshot (int): snapshot number.
header (dict): geometry information.
Returns:
(dict, numpy.array): geometry information and fie... | [
"Extract",
"field",
"data",
"from",
"hdf5",
"files",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L688-L741 |
StagPython/StagPy | stagpy/stagyyparsers.py | read_tracers_h5 | def read_tracers_h5(xdmf_file, infoname, snapshot, position):
"""Extract tracers data from hdf5 files.
Args:
xdmf_file (:class:`pathlib.Path`): path of the xdmf file.
infoname (str): name of information to extract.
snapshot (int): snapshot number.
position (bool): whether to ext... | python | def read_tracers_h5(xdmf_file, infoname, snapshot, position):
"""Extract tracers data from hdf5 files.
Args:
xdmf_file (:class:`pathlib.Path`): path of the xdmf file.
infoname (str): name of information to extract.
snapshot (int): snapshot number.
position (bool): whether to ext... | [
"def",
"read_tracers_h5",
"(",
"xdmf_file",
",",
"infoname",
",",
"snapshot",
",",
"position",
")",
":",
"xdmf_root",
"=",
"xmlET",
".",
"parse",
"(",
"str",
"(",
"xdmf_file",
")",
")",
".",
"getroot",
"(",
")",
"tra",
"=",
"{",
"}",
"tra",
"[",
"inf... | Extract tracers data from hdf5 files.
Args:
xdmf_file (:class:`pathlib.Path`): path of the xdmf file.
infoname (str): name of information to extract.
snapshot (int): snapshot number.
position (bool): whether to extract position of tracers.
Returns:
dict of list of numpy.... | [
"Extract",
"tracers",
"data",
"from",
"hdf5",
"files",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L744-L780 |
StagPython/StagPy | stagpy/stagyyparsers.py | read_time_h5 | def read_time_h5(h5folder):
"""Iterate through (isnap, istep) recorded in h5folder/'time_botT.h5'.
Args:
h5folder (:class:`pathlib.Path`): directory of HDF5 output files.
Yields:
tuple of int: (isnap, istep).
"""
with h5py.File(h5folder / 'time_botT.h5', 'r') as h5f:
for nam... | python | def read_time_h5(h5folder):
"""Iterate through (isnap, istep) recorded in h5folder/'time_botT.h5'.
Args:
h5folder (:class:`pathlib.Path`): directory of HDF5 output files.
Yields:
tuple of int: (isnap, istep).
"""
with h5py.File(h5folder / 'time_botT.h5', 'r') as h5f:
for nam... | [
"def",
"read_time_h5",
"(",
"h5folder",
")",
":",
"with",
"h5py",
".",
"File",
"(",
"h5folder",
"/",
"'time_botT.h5'",
",",
"'r'",
")",
"as",
"h5f",
":",
"for",
"name",
",",
"dset",
"in",
"h5f",
".",
"items",
"(",
")",
":",
"yield",
"int",
"(",
"na... | Iterate through (isnap, istep) recorded in h5folder/'time_botT.h5'.
Args:
h5folder (:class:`pathlib.Path`): directory of HDF5 output files.
Yields:
tuple of int: (isnap, istep). | [
"Iterate",
"through",
"(",
"isnap",
"istep",
")",
"recorded",
"in",
"h5folder",
"/",
"time_botT",
".",
"h5",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L783-L793 |
StagPython/StagPy | stagpy/_step.py | _Geometry._init_shape | def _init_shape(self):
"""Determine shape of geometry"""
shape = self._par['geometry']['shape'].lower()
aspect = self._header['aspect']
if self.rcmb is not None and self.rcmb >= 0:
# curvilinear
self._shape['cyl'] = self.twod_xz and (shape == 'cylindrical' or
... | python | def _init_shape(self):
"""Determine shape of geometry"""
shape = self._par['geometry']['shape'].lower()
aspect = self._header['aspect']
if self.rcmb is not None and self.rcmb >= 0:
# curvilinear
self._shape['cyl'] = self.twod_xz and (shape == 'cylindrical' or
... | [
"def",
"_init_shape",
"(",
"self",
")",
":",
"shape",
"=",
"self",
".",
"_par",
"[",
"'geometry'",
"]",
"[",
"'shape'",
"]",
".",
"lower",
"(",
")",
"aspect",
"=",
"self",
".",
"_header",
"[",
"'aspect'",
"]",
"if",
"self",
".",
"rcmb",
"is",
"not"... | Determine shape of geometry | [
"Determine",
"shape",
"of",
"geometry"
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/_step.py#L103-L120 |
StagPython/StagPy | stagpy/_step.py | _Fields._get_raw_data | def _get_raw_data(self, name):
"""Find file holding data and return its content."""
# try legacy first, then hdf5
filestem = ''
for filestem, list_fvar in self._files.items():
if name in list_fvar:
break
fieldfile = self.step.sdat.filename(filestem, se... | python | def _get_raw_data(self, name):
"""Find file holding data and return its content."""
# try legacy first, then hdf5
filestem = ''
for filestem, list_fvar in self._files.items():
if name in list_fvar:
break
fieldfile = self.step.sdat.filename(filestem, se... | [
"def",
"_get_raw_data",
"(",
"self",
",",
"name",
")",
":",
"# try legacy first, then hdf5",
"filestem",
"=",
"''",
"for",
"filestem",
",",
"list_fvar",
"in",
"self",
".",
"_files",
".",
"items",
"(",
")",
":",
"if",
"name",
"in",
"list_fvar",
":",
"break"... | Find file holding data and return its content. | [
"Find",
"file",
"holding",
"data",
"and",
"return",
"its",
"content",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/_step.py#L241-L261 |
StagPython/StagPy | stagpy/_step.py | _Fields.geom | def geom(self):
"""Geometry information.
:class:`_Geometry` instance holding geometry information. It is
issued from binary files holding field information. It is set to
None if not available for this time step.
"""
if self._header is UNDETERMINED:
binfiles =... | python | def geom(self):
"""Geometry information.
:class:`_Geometry` instance holding geometry information. It is
issued from binary files holding field information. It is set to
None if not available for this time step.
"""
if self._header is UNDETERMINED:
binfiles =... | [
"def",
"geom",
"(",
"self",
")",
":",
"if",
"self",
".",
"_header",
"is",
"UNDETERMINED",
":",
"binfiles",
"=",
"self",
".",
"step",
".",
"sdat",
".",
"binfiles_set",
"(",
"self",
".",
"step",
".",
"isnap",
")",
"if",
"binfiles",
":",
"self",
".",
... | Geometry information.
:class:`_Geometry` instance holding geometry information. It is
issued from binary files holding field information. It is set to
None if not available for this time step. | [
"Geometry",
"information",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/_step.py#L276-L299 |
StagPython/StagPy | stagpy/_step.py | Step.timeinfo | def timeinfo(self):
"""Time series data of the time step.
Set to None if no time series data is available for this time step.
"""
if self.istep not in self.sdat.tseries.index:
return None
return self.sdat.tseries.loc[self.istep] | python | def timeinfo(self):
"""Time series data of the time step.
Set to None if no time series data is available for this time step.
"""
if self.istep not in self.sdat.tseries.index:
return None
return self.sdat.tseries.loc[self.istep] | [
"def",
"timeinfo",
"(",
"self",
")",
":",
"if",
"self",
".",
"istep",
"not",
"in",
"self",
".",
"sdat",
".",
"tseries",
".",
"index",
":",
"return",
"None",
"return",
"self",
".",
"sdat",
".",
"tseries",
".",
"loc",
"[",
"self",
".",
"istep",
"]"
] | Time series data of the time step.
Set to None if no time series data is available for this time step. | [
"Time",
"series",
"data",
"of",
"the",
"time",
"step",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/_step.py#L403-L410 |
StagPython/StagPy | stagpy/_step.py | Step.rprof | def rprof(self):
"""Radial profiles data of the time step.
Set to None if no radial profiles data is available for this time step.
"""
if self.istep not in self.sdat.rprof.index.levels[0]:
return None
return self.sdat.rprof.loc[self.istep] | python | def rprof(self):
"""Radial profiles data of the time step.
Set to None if no radial profiles data is available for this time step.
"""
if self.istep not in self.sdat.rprof.index.levels[0]:
return None
return self.sdat.rprof.loc[self.istep] | [
"def",
"rprof",
"(",
"self",
")",
":",
"if",
"self",
".",
"istep",
"not",
"in",
"self",
".",
"sdat",
".",
"rprof",
".",
"index",
".",
"levels",
"[",
"0",
"]",
":",
"return",
"None",
"return",
"self",
".",
"sdat",
".",
"rprof",
".",
"loc",
"[",
... | Radial profiles data of the time step.
Set to None if no radial profiles data is available for this time step. | [
"Radial",
"profiles",
"data",
"of",
"the",
"time",
"step",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/_step.py#L413-L420 |
StagPython/StagPy | stagpy/_step.py | Step.isnap | def isnap(self):
"""Snapshot index corresponding to time step.
It is set to None if no snapshot exists for the time step.
"""
if self._isnap is UNDETERMINED:
istep = None
isnap = -1
# could be more efficient if do 0 and -1 then bisection
#... | python | def isnap(self):
"""Snapshot index corresponding to time step.
It is set to None if no snapshot exists for the time step.
"""
if self._isnap is UNDETERMINED:
istep = None
isnap = -1
# could be more efficient if do 0 and -1 then bisection
#... | [
"def",
"isnap",
"(",
"self",
")",
":",
"if",
"self",
".",
"_isnap",
"is",
"UNDETERMINED",
":",
"istep",
"=",
"None",
"isnap",
"=",
"-",
"1",
"# could be more efficient if do 0 and -1 then bisection",
"# (but loose intermediate <- would probably use too much",
"# memory fo... | Snapshot index corresponding to time step.
It is set to None if no snapshot exists for the time step. | [
"Snapshot",
"index",
"corresponding",
"to",
"time",
"step",
"."
] | train | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/_step.py#L423-L441 |
data61/clkhash | clkhash/schema.py | convert_v1_to_v2 | def convert_v1_to_v2(
dict # type: Dict[str, Any]
):
# type: (...) -> Dict[str, Any]
"""
Convert v1 schema dict to v2 schema dict.
:param dict: v1 schema dict
:return: v2 schema dict
"""
version = dict['version']
if version != 1:
raise ValueError('Version {} not 1'.f... | python | def convert_v1_to_v2(
dict # type: Dict[str, Any]
):
# type: (...) -> Dict[str, Any]
"""
Convert v1 schema dict to v2 schema dict.
:param dict: v1 schema dict
:return: v2 schema dict
"""
version = dict['version']
if version != 1:
raise ValueError('Version {} not 1'.f... | [
"def",
"convert_v1_to_v2",
"(",
"dict",
"# type: Dict[str, Any]",
")",
":",
"# type: (...) -> Dict[str, Any]",
"version",
"=",
"dict",
"[",
"'version'",
"]",
"if",
"version",
"!=",
"1",
":",
"raise",
"ValueError",
"(",
"'Version {} not 1'",
".",
"format",
"(",
"ve... | Convert v1 schema dict to v2 schema dict.
:param dict: v1 schema dict
:return: v2 schema dict | [
"Convert",
"v1",
"schema",
"dict",
"to",
"v2",
"schema",
"dict",
".",
":",
"param",
"dict",
":",
"v1",
"schema",
"dict",
":",
"return",
":",
"v2",
"schema",
"dict"
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/schema.py#L81-L129 |
data61/clkhash | clkhash/schema.py | from_json_dict | def from_json_dict(dct, validate=True):
# type: (Dict[str, Any], bool) -> Schema
""" Create a Schema for v1 or v2 according to dct
:param dct: This dictionary must have a `'features'`
key specifying the columns of the dataset. It must have
a `'version'` key containing the master sch... | python | def from_json_dict(dct, validate=True):
# type: (Dict[str, Any], bool) -> Schema
""" Create a Schema for v1 or v2 according to dct
:param dct: This dictionary must have a `'features'`
key specifying the columns of the dataset. It must have
a `'version'` key containing the master sch... | [
"def",
"from_json_dict",
"(",
"dct",
",",
"validate",
"=",
"True",
")",
":",
"# type: (Dict[str, Any], bool) -> Schema",
"if",
"validate",
":",
"# This raises iff the schema is invalid.",
"validate_schema_dict",
"(",
"dct",
")",
"version",
"=",
"dct",
"[",
"'version'",
... | Create a Schema for v1 or v2 according to dct
:param dct: This dictionary must have a `'features'`
key specifying the columns of the dataset. It must have
a `'version'` key containing the master schema version
that this schema conforms to. It must have a `'hash'`
key... | [
"Create",
"a",
"Schema",
"for",
"v1",
"or",
"v2",
"according",
"to",
"dct"
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/schema.py#L132-L178 |
data61/clkhash | clkhash/schema.py | from_json_file | def from_json_file(schema_file, validate=True):
# type: (TextIO, bool) -> Schema
""" Load a Schema object from a json file.
:param schema_file: A JSON file containing the schema.
:param validate: (default True) Raise an exception if the
schema does not conform to the master schema.
... | python | def from_json_file(schema_file, validate=True):
# type: (TextIO, bool) -> Schema
""" Load a Schema object from a json file.
:param schema_file: A JSON file containing the schema.
:param validate: (default True) Raise an exception if the
schema does not conform to the master schema.
... | [
"def",
"from_json_file",
"(",
"schema_file",
",",
"validate",
"=",
"True",
")",
":",
"# type: (TextIO, bool) -> Schema",
"try",
":",
"schema_dict",
"=",
"json",
".",
"load",
"(",
"schema_file",
")",
"except",
"ValueError",
"as",
"e",
":",
"# In Python 3 we can be ... | Load a Schema object from a json file.
:param schema_file: A JSON file containing the schema.
:param validate: (default True) Raise an exception if the
schema does not conform to the master schema.
:raises SchemaError: When the schema is invalid.
:return: the Schema | [
"Load",
"a",
"Schema",
"object",
"from",
"a",
"json",
"file",
".",
":",
"param",
"schema_file",
":",
"A",
"JSON",
"file",
"containing",
"the",
"schema",
".",
":",
"param",
"validate",
":",
"(",
"default",
"True",
")",
"Raise",
"an",
"exception",
"if",
... | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/schema.py#L181-L198 |
data61/clkhash | clkhash/schema.py | _get_master_schema | def _get_master_schema(version):
# type: (Hashable) -> bytes
""" Loads the master schema of given version as bytes.
:param version: The version of the master schema whose path we
wish to retrieve.
:raises SchemaError: When the schema version is unknown. This
usually mean... | python | def _get_master_schema(version):
# type: (Hashable) -> bytes
""" Loads the master schema of given version as bytes.
:param version: The version of the master schema whose path we
wish to retrieve.
:raises SchemaError: When the schema version is unknown. This
usually mean... | [
"def",
"_get_master_schema",
"(",
"version",
")",
":",
"# type: (Hashable) -> bytes",
"try",
":",
"file_name",
"=",
"MASTER_SCHEMA_FILE_NAMES",
"[",
"version",
"]",
"except",
"(",
"TypeError",
",",
"KeyError",
")",
"as",
"e",
":",
"msg",
"=",
"(",
"'Schema versi... | Loads the master schema of given version as bytes.
:param version: The version of the master schema whose path we
wish to retrieve.
:raises SchemaError: When the schema version is unknown. This
usually means that either (a) clkhash is out of date, or (b)
the schema v... | [
"Loads",
"the",
"master",
"schema",
"of",
"given",
"version",
"as",
"bytes",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/schema.py#L201-L233 |
data61/clkhash | clkhash/schema.py | validate_schema_dict | def validate_schema_dict(schema):
# type: (Dict[str, Any]) -> None
""" Validate the schema.
This raises iff either the schema or the master schema are
invalid. If it's successful, it returns nothing.
:param schema: The schema to validate, as parsed by `json`.
:raises SchemaErro... | python | def validate_schema_dict(schema):
# type: (Dict[str, Any]) -> None
""" Validate the schema.
This raises iff either the schema or the master schema are
invalid. If it's successful, it returns nothing.
:param schema: The schema to validate, as parsed by `json`.
:raises SchemaErro... | [
"def",
"validate_schema_dict",
"(",
"schema",
")",
":",
"# type: (Dict[str, Any]) -> None",
"if",
"not",
"isinstance",
"(",
"schema",
",",
"dict",
")",
":",
"msg",
"=",
"(",
"'The top level of the schema file is a {}, whereas a dict is '",
"'expected.'",
".",
"format",
... | Validate the schema.
This raises iff either the schema or the master schema are
invalid. If it's successful, it returns nothing.
:param schema: The schema to validate, as parsed by `json`.
:raises SchemaError: When the schema is invalid.
:raises MasterSchemaError: When the mast... | [
"Validate",
"the",
"schema",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/schema.py#L236-L274 |
data61/clkhash | clkhash/serialization.py | deserialize_bitarray | def deserialize_bitarray(ser):
# type: (str) -> bitarray
"""Deserialize a base 64 encoded string to a bitarray (bloomfilter)
"""
ba = bitarray()
ba.frombytes(base64.b64decode(ser.encode(encoding='UTF-8', errors='strict')))
return ba | python | def deserialize_bitarray(ser):
# type: (str) -> bitarray
"""Deserialize a base 64 encoded string to a bitarray (bloomfilter)
"""
ba = bitarray()
ba.frombytes(base64.b64decode(ser.encode(encoding='UTF-8', errors='strict')))
return ba | [
"def",
"deserialize_bitarray",
"(",
"ser",
")",
":",
"# type: (str) -> bitarray",
"ba",
"=",
"bitarray",
"(",
")",
"ba",
".",
"frombytes",
"(",
"base64",
".",
"b64decode",
"(",
"ser",
".",
"encode",
"(",
"encoding",
"=",
"'UTF-8'",
",",
"errors",
"=",
"'st... | Deserialize a base 64 encoded string to a bitarray (bloomfilter) | [
"Deserialize",
"a",
"base",
"64",
"encoded",
"string",
"to",
"a",
"bitarray",
"(",
"bloomfilter",
")"
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/serialization.py#L18-L25 |
IndicoDataSolutions/IndicoIo-python | indicoio/multi/analyze_image.py | analyze_image | def analyze_image(image, apis=DEFAULT_APIS, **kwargs):
"""
Given input image, returns the results of specified image apis. Possible apis
include: ['fer', 'facial_features', 'image_features']
Example usage:
.. code-block:: python
>>> import indicoio
>>> import numpy as np
... | python | def analyze_image(image, apis=DEFAULT_APIS, **kwargs):
"""
Given input image, returns the results of specified image apis. Possible apis
include: ['fer', 'facial_features', 'image_features']
Example usage:
.. code-block:: python
>>> import indicoio
>>> import numpy as np
... | [
"def",
"analyze_image",
"(",
"image",
",",
"apis",
"=",
"DEFAULT_APIS",
",",
"*",
"*",
"kwargs",
")",
":",
"cloud",
"=",
"kwargs",
".",
"pop",
"(",
"'cloud'",
",",
"None",
")",
"batch",
"=",
"kwargs",
".",
"pop",
"(",
"'batch'",
",",
"False",
")",
... | Given input image, returns the results of specified image apis. Possible apis
include: ['fer', 'facial_features', 'image_features']
Example usage:
.. code-block:: python
>>> import indicoio
>>> import numpy as np
>>> face = np.zeros((48,48)).tolist()
>>> results = in... | [
"Given",
"input",
"image",
"returns",
"the",
"results",
"of",
"specified",
"image",
"apis",
".",
"Possible",
"apis",
"include",
":",
"[",
"fer",
"facial_features",
"image_features",
"]",
"Example",
"usage",
":",
"..",
"code",
"-",
"block",
"::",
"python",
">... | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/multi/analyze_image.py#L9-L44 |
data61/clkhash | clkhash/benchmark.py | compute_hash_speed | def compute_hash_speed(num, quiet=False):
# type: (int, bool) -> float
""" Hash time.
"""
namelist = NameList(num)
os_fd, tmpfile_name = tempfile.mkstemp(text=True)
schema = NameList.SCHEMA
header_row = ','.join([f.identifier for f in schema.fields])
with open(tmpfile_name, 'wt') as f... | python | def compute_hash_speed(num, quiet=False):
# type: (int, bool) -> float
""" Hash time.
"""
namelist = NameList(num)
os_fd, tmpfile_name = tempfile.mkstemp(text=True)
schema = NameList.SCHEMA
header_row = ','.join([f.identifier for f in schema.fields])
with open(tmpfile_name, 'wt') as f... | [
"def",
"compute_hash_speed",
"(",
"num",
",",
"quiet",
"=",
"False",
")",
":",
"# type: (int, bool) -> float",
"namelist",
"=",
"NameList",
"(",
"num",
")",
"os_fd",
",",
"tmpfile_name",
"=",
"tempfile",
".",
"mkstemp",
"(",
"text",
"=",
"True",
")",
"schema... | Hash time. | [
"Hash",
"time",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/benchmark.py#L12-L40 |
data61/clkhash | clkhash/cli.py | hash | def hash(pii_csv, keys, schema, clk_json, quiet, no_header, check_header, validate):
"""Process data to create CLKs
Given a file containing CSV data as PII_CSV, and a JSON
document defining the expected schema, verify the schema, then
hash the data to create CLKs writing them as JSON to CLK_JSON. Note ... | python | def hash(pii_csv, keys, schema, clk_json, quiet, no_header, check_header, validate):
"""Process data to create CLKs
Given a file containing CSV data as PII_CSV, and a JSON
document defining the expected schema, verify the schema, then
hash the data to create CLKs writing them as JSON to CLK_JSON. Note ... | [
"def",
"hash",
"(",
"pii_csv",
",",
"keys",
",",
"schema",
",",
"clk_json",
",",
"quiet",
",",
"no_header",
",",
"check_header",
",",
"validate",
")",
":",
"schema_object",
"=",
"clkhash",
".",
"schema",
".",
"from_json_file",
"(",
"schema_file",
"=",
"sch... | Process data to create CLKs
Given a file containing CSV data as PII_CSV, and a JSON
document defining the expected schema, verify the schema, then
hash the data to create CLKs writing them as JSON to CLK_JSON. Note the CSV
file should contain a header row - however this row is not used
by this tool... | [
"Process",
"data",
"to",
"create",
"CLKs"
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/cli.py#L56-L92 |
data61/clkhash | clkhash/cli.py | status | def status(server, output, verbose):
"""Connect to an entity matching server and check the service status.
Use "-" to output status to stdout.
"""
if verbose:
log("Connecting to Entity Matching Server: {}".format(server))
service_status = server_get_status(server)
if verbose:
l... | python | def status(server, output, verbose):
"""Connect to an entity matching server and check the service status.
Use "-" to output status to stdout.
"""
if verbose:
log("Connecting to Entity Matching Server: {}".format(server))
service_status = server_get_status(server)
if verbose:
l... | [
"def",
"status",
"(",
"server",
",",
"output",
",",
"verbose",
")",
":",
"if",
"verbose",
":",
"log",
"(",
"\"Connecting to Entity Matching Server: {}\"",
".",
"format",
"(",
"server",
")",
")",
"service_status",
"=",
"server_get_status",
"(",
"server",
")",
"... | Connect to an entity matching server and check the service status.
Use "-" to output status to stdout. | [
"Connect",
"to",
"an",
"entity",
"matching",
"server",
"and",
"check",
"the",
"service",
"status",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/cli.py#L99-L110 |
data61/clkhash | clkhash/cli.py | create_project | def create_project(type, schema, server, name, output, verbose):
"""Create a new project on an entity matching server.
See entity matching service documentation for details on mapping type and schema
Returns authentication details for the created project.
"""
if verbose:
log("Entity Matchin... | python | def create_project(type, schema, server, name, output, verbose):
"""Create a new project on an entity matching server.
See entity matching service documentation for details on mapping type and schema
Returns authentication details for the created project.
"""
if verbose:
log("Entity Matchin... | [
"def",
"create_project",
"(",
"type",
",",
"schema",
",",
"server",
",",
"name",
",",
"output",
",",
"verbose",
")",
":",
"if",
"verbose",
":",
"log",
"(",
"\"Entity Matching Server: {}\"",
".",
"format",
"(",
"server",
")",
")",
"if",
"schema",
"is",
"n... | Create a new project on an entity matching server.
See entity matching service documentation for details on mapping type and schema
Returns authentication details for the created project. | [
"Create",
"a",
"new",
"project",
"on",
"an",
"entity",
"matching",
"server",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/cli.py#L143-L171 |
data61/clkhash | clkhash/cli.py | create | def create(server, name, project, apikey, output, threshold, verbose):
"""Create a new run on an entity matching server.
See entity matching service documentation for details on threshold.
Returns details for the created run.
"""
if verbose:
log("Entity Matching Server: {}".format(server))... | python | def create(server, name, project, apikey, output, threshold, verbose):
"""Create a new run on an entity matching server.
See entity matching service documentation for details on threshold.
Returns details for the created run.
"""
if verbose:
log("Entity Matching Server: {}".format(server))... | [
"def",
"create",
"(",
"server",
",",
"name",
",",
"project",
",",
"apikey",
",",
"output",
",",
"threshold",
",",
"verbose",
")",
":",
"if",
"verbose",
":",
"log",
"(",
"\"Entity Matching Server: {}\"",
".",
"format",
"(",
"server",
")",
")",
"if",
"thre... | Create a new run on an entity matching server.
See entity matching service documentation for details on threshold.
Returns details for the created run. | [
"Create",
"a",
"new",
"run",
"on",
"an",
"entity",
"matching",
"server",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/cli.py#L182-L202 |
data61/clkhash | clkhash/cli.py | upload | def upload(clk_json, project, apikey, server, output, verbose):
"""Upload CLK data to entity matching server.
Given a json file containing hashed clk data as CLK_JSON, upload to
the entity resolution service.
Use "-" to read from stdin.
"""
if verbose:
log("Uploading CLK data from {}".... | python | def upload(clk_json, project, apikey, server, output, verbose):
"""Upload CLK data to entity matching server.
Given a json file containing hashed clk data as CLK_JSON, upload to
the entity resolution service.
Use "-" to read from stdin.
"""
if verbose:
log("Uploading CLK data from {}".... | [
"def",
"upload",
"(",
"clk_json",
",",
"project",
",",
"apikey",
",",
"server",
",",
"output",
",",
"verbose",
")",
":",
"if",
"verbose",
":",
"log",
"(",
"\"Uploading CLK data from {}\"",
".",
"format",
"(",
"clk_json",
".",
"name",
")",
")",
"log",
"("... | Upload CLK data to entity matching server.
Given a json file containing hashed clk data as CLK_JSON, upload to
the entity resolution service.
Use "-" to read from stdin. | [
"Upload",
"CLK",
"data",
"to",
"entity",
"matching",
"server",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/cli.py#L212-L231 |
data61/clkhash | clkhash/cli.py | results | def results(project, apikey, run, watch, server, output):
"""
Check to see if results are available for a particular mapping
and if so download.
Authentication is carried out using the --apikey option which
must be provided. Depending on the server operating mode this
may return a mask, a linka... | python | def results(project, apikey, run, watch, server, output):
"""
Check to see if results are available for a particular mapping
and if so download.
Authentication is carried out using the --apikey option which
must be provided. Depending on the server operating mode this
may return a mask, a linka... | [
"def",
"results",
"(",
"project",
",",
"apikey",
",",
"run",
",",
"watch",
",",
"server",
",",
"output",
")",
":",
"status",
"=",
"run_get_status",
"(",
"server",
",",
"project",
",",
"run",
",",
"apikey",
")",
"log",
"(",
"format_run_status",
"(",
"st... | Check to see if results are available for a particular mapping
and if so download.
Authentication is carried out using the --apikey option which
must be provided. Depending on the server operating mode this
may return a mask, a linkage table, or a permutation. Consult
the entity service documentati... | [
"Check",
"to",
"see",
"if",
"results",
"are",
"available",
"for",
"a",
"particular",
"mapping",
"and",
"if",
"so",
"download",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/cli.py#L241-L268 |
data61/clkhash | clkhash/cli.py | generate | def generate(size, output, schema):
"""Generate fake PII data for testing"""
pii_data = randomnames.NameList(size)
if schema is not None:
raise NotImplementedError
randomnames.save_csv(
pii_data.names,
[f.identifier for f in pii_data.SCHEMA.fields],
output) | python | def generate(size, output, schema):
"""Generate fake PII data for testing"""
pii_data = randomnames.NameList(size)
if schema is not None:
raise NotImplementedError
randomnames.save_csv(
pii_data.names,
[f.identifier for f in pii_data.SCHEMA.fields],
output) | [
"def",
"generate",
"(",
"size",
",",
"output",
",",
"schema",
")",
":",
"pii_data",
"=",
"randomnames",
".",
"NameList",
"(",
"size",
")",
"if",
"schema",
"is",
"not",
"None",
":",
"raise",
"NotImplementedError",
"randomnames",
".",
"save_csv",
"(",
"pii_d... | Generate fake PII data for testing | [
"Generate",
"fake",
"PII",
"data",
"for",
"testing"
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/cli.py#L288-L298 |
data61/clkhash | clkhash/cli.py | generate_default_schema | def generate_default_schema(output):
"""Get default schema for fake PII"""
original_path = os.path.join(os.path.dirname(__file__),
'data',
'randomnames-schema.json')
shutil.copyfile(original_path, output) | python | def generate_default_schema(output):
"""Get default schema for fake PII"""
original_path = os.path.join(os.path.dirname(__file__),
'data',
'randomnames-schema.json')
shutil.copyfile(original_path, output) | [
"def",
"generate_default_schema",
"(",
"output",
")",
":",
"original_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'data'",
",",
"'randomnames-schema.json'",
")",
"shutil",
".",
"copyfile",
... | Get default schema for fake PII | [
"Get",
"default",
"schema",
"for",
"fake",
"PII"
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/cli.py#L306-L311 |
IndicoDataSolutions/IndicoIo-python | indicoio/docx/docx_extraction.py | docx_extraction | def docx_extraction(docx, cloud=None, batch=False, api_key=None, version=None, **kwargs):
"""
Given a .docx file, returns the raw text associated with the given .docx file.
The .docx file may be provided as base64 encoded data or as a filepath.
Example usage:
.. code-block:: python
>>> fro... | python | def docx_extraction(docx, cloud=None, batch=False, api_key=None, version=None, **kwargs):
"""
Given a .docx file, returns the raw text associated with the given .docx file.
The .docx file may be provided as base64 encoded data or as a filepath.
Example usage:
.. code-block:: python
>>> fro... | [
"def",
"docx_extraction",
"(",
"docx",
",",
"cloud",
"=",
"None",
",",
"batch",
"=",
"False",
",",
"api_key",
"=",
"None",
",",
"version",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"docx",
"=",
"docx_preprocess",
"(",
"docx",
",",
"batch",
"=",... | Given a .docx file, returns the raw text associated with the given .docx file.
The .docx file may be provided as base64 encoded data or as a filepath.
Example usage:
.. code-block:: python
>>> from indicoio import docx_extraction
>>> results = docx_extraction(docx_file)
:param docx: Th... | [
"Given",
"a",
".",
"docx",
"file",
"returns",
"the",
"raw",
"text",
"associated",
"with",
"the",
"given",
".",
"docx",
"file",
".",
"The",
".",
"docx",
"file",
"may",
"be",
"provided",
"as",
"base64",
"encoded",
"data",
"or",
"as",
"a",
"filepath",
"."... | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/docx/docx_extraction.py#L6-L25 |
IndicoDataSolutions/IndicoIo-python | indicoio/image/facial_features.py | facial_features | def facial_features(image, cloud=None, batch=False, api_key=None, version=None, **kwargs):
"""
Given an grayscale input image of a face, returns a 48 dimensional feature vector explaining that face.
Useful as a form of feature engineering for face oriented tasks.
Input should be in a list of list fo... | python | def facial_features(image, cloud=None, batch=False, api_key=None, version=None, **kwargs):
"""
Given an grayscale input image of a face, returns a 48 dimensional feature vector explaining that face.
Useful as a form of feature engineering for face oriented tasks.
Input should be in a list of list fo... | [
"def",
"facial_features",
"(",
"image",
",",
"cloud",
"=",
"None",
",",
"batch",
"=",
"False",
",",
"api_key",
"=",
"None",
",",
"version",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"image",
"=",
"data_preprocess",
"(",
"image",
",",
"batch",
"... | Given an grayscale input image of a face, returns a 48 dimensional feature vector explaining that face.
Useful as a form of feature engineering for face oriented tasks.
Input should be in a list of list format, resizing will be attempted internally but for best
performance, images should be already sized... | [
"Given",
"an",
"grayscale",
"input",
"image",
"of",
"a",
"face",
"returns",
"a",
"48",
"dimensional",
"feature",
"vector",
"explaining",
"that",
"face",
".",
"Useful",
"as",
"a",
"form",
"of",
"feature",
"engineering",
"for",
"face",
"oriented",
"tasks",
"."... | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/image/facial_features.py#L6-L30 |
data61/clkhash | clkhash/rest_client.py | wait_for_run | def wait_for_run(server, project, run, apikey, timeout=None, update_period=1):
"""
Monitor a linkage run and return the final status updates. If a timeout is provided and the
run hasn't entered a terminal state (error or completed) when the timeout is reached a
TimeoutError will be raised.
:param s... | python | def wait_for_run(server, project, run, apikey, timeout=None, update_period=1):
"""
Monitor a linkage run and return the final status updates. If a timeout is provided and the
run hasn't entered a terminal state (error or completed) when the timeout is reached a
TimeoutError will be raised.
:param s... | [
"def",
"wait_for_run",
"(",
"server",
",",
"project",
",",
"run",
",",
"apikey",
",",
"timeout",
"=",
"None",
",",
"update_period",
"=",
"1",
")",
":",
"for",
"status",
"in",
"watch_run_status",
"(",
"server",
",",
"project",
",",
"run",
",",
"apikey",
... | Monitor a linkage run and return the final status updates. If a timeout is provided and the
run hasn't entered a terminal state (error or completed) when the timeout is reached a
TimeoutError will be raised.
:param server: Base url of the upstream server.
:param project:
:param run:
:param apik... | [
"Monitor",
"a",
"linkage",
"run",
"and",
"return",
"the",
"final",
"status",
"updates",
".",
"If",
"a",
"timeout",
"is",
"provided",
"and",
"the",
"run",
"hasn",
"t",
"entered",
"a",
"terminal",
"state",
"(",
"error",
"or",
"completed",
")",
"when",
"the... | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/rest_client.py#L116-L132 |
data61/clkhash | clkhash/rest_client.py | watch_run_status | def watch_run_status(server, project, run, apikey, timeout=None, update_period=1):
"""
Monitor a linkage run and yield status updates. Will immediately yield an update and then
only yield further updates when the status object changes. If a timeout is provided and the
run hasn't entered a terminal state... | python | def watch_run_status(server, project, run, apikey, timeout=None, update_period=1):
"""
Monitor a linkage run and yield status updates. Will immediately yield an update and then
only yield further updates when the status object changes. If a timeout is provided and the
run hasn't entered a terminal state... | [
"def",
"watch_run_status",
"(",
"server",
",",
"project",
",",
"run",
",",
"apikey",
",",
"timeout",
"=",
"None",
",",
"update_period",
"=",
"1",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"status",
"=",
"old_status",
"=",
"run_get_statu... | Monitor a linkage run and yield status updates. Will immediately yield an update and then
only yield further updates when the status object changes. If a timeout is provided and the
run hasn't entered a terminal state (error or completed) when the timeout is reached,
updates will cease and a TimeoutError wi... | [
"Monitor",
"a",
"linkage",
"run",
"and",
"yield",
"status",
"updates",
".",
"Will",
"immediately",
"yield",
"an",
"update",
"and",
"then",
"only",
"yield",
"further",
"updates",
"when",
"the",
"status",
"object",
"changes",
".",
"If",
"a",
"timeout",
"is",
... | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/rest_client.py#L135-L176 |
IndicoDataSolutions/IndicoIo-python | indicoio/utils/docx.py | docx_preprocess | def docx_preprocess(docx, batch=False):
"""
Load docx files from local filepath if not already b64 encoded
"""
if batch:
return [docx_preprocess(doc, batch=False) for doc in docx]
if os.path.isfile(docx):
# a filepath is provided, read and encode
return b64encode(open(docx, ... | python | def docx_preprocess(docx, batch=False):
"""
Load docx files from local filepath if not already b64 encoded
"""
if batch:
return [docx_preprocess(doc, batch=False) for doc in docx]
if os.path.isfile(docx):
# a filepath is provided, read and encode
return b64encode(open(docx, ... | [
"def",
"docx_preprocess",
"(",
"docx",
",",
"batch",
"=",
"False",
")",
":",
"if",
"batch",
":",
"return",
"[",
"docx_preprocess",
"(",
"doc",
",",
"batch",
"=",
"False",
")",
"for",
"doc",
"in",
"docx",
"]",
"if",
"os",
".",
"path",
".",
"isfile",
... | Load docx files from local filepath if not already b64 encoded | [
"Load",
"docx",
"files",
"from",
"local",
"filepath",
"if",
"not",
"already",
"b64",
"encoded"
] | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/utils/docx.py#L5-L17 |
IndicoDataSolutions/IndicoIo-python | indicoio/text/relevance.py | relevance | def relevance(data, queries, cloud=None, batch=False, api_key=None, version=None, **kwargs):
"""
Given input text and a list of query terms / phrases, returns how relevant the query is
to the input text.
Example usage:
.. code-block:: python
>>> import indicoio
>>> text = 'On Monday... | python | def relevance(data, queries, cloud=None, batch=False, api_key=None, version=None, **kwargs):
"""
Given input text and a list of query terms / phrases, returns how relevant the query is
to the input text.
Example usage:
.. code-block:: python
>>> import indicoio
>>> text = 'On Monday... | [
"def",
"relevance",
"(",
"data",
",",
"queries",
",",
"cloud",
"=",
"None",
",",
"batch",
"=",
"False",
",",
"api_key",
"=",
"None",
",",
"version",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"url_params",
"=",
"{",
"\"batch\"",
":",
"batch",
... | Given input text and a list of query terms / phrases, returns how relevant the query is
to the input text.
Example usage:
.. code-block:: python
>>> import indicoio
>>> text = 'On Monday, president Barack Obama will be giving his keynote address at...'
>>> relevance = indicoio.releva... | [
"Given",
"input",
"text",
"and",
"a",
"list",
"of",
"query",
"terms",
"/",
"phrases",
"returns",
"how",
"relevant",
"the",
"query",
"is",
"to",
"the",
"input",
"text",
"."
] | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/text/relevance.py#L6-L29 |
ambv/flake8-pyi | pyi.py | PyiAwareFlakesChecker.ASSIGN | def ASSIGN(self, node):
"""This is a custom implementation of ASSIGN derived from
handleChildren() in pyflakes 1.3.0.
The point here is that on module level, there's type aliases that we
want to bind eagerly, but defer computation of the values of the
assignments (the type alias... | python | def ASSIGN(self, node):
"""This is a custom implementation of ASSIGN derived from
handleChildren() in pyflakes 1.3.0.
The point here is that on module level, there's type aliases that we
want to bind eagerly, but defer computation of the values of the
assignments (the type alias... | [
"def",
"ASSIGN",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"scope",
",",
"ModuleScope",
")",
":",
"return",
"super",
"(",
")",
".",
"ASSIGN",
"(",
"node",
")",
"for",
"target",
"in",
"node",
".",
"targets",
":... | This is a custom implementation of ASSIGN derived from
handleChildren() in pyflakes 1.3.0.
The point here is that on module level, there's type aliases that we
want to bind eagerly, but defer computation of the values of the
assignments (the type aliases might have forward references). | [
"This",
"is",
"a",
"custom",
"implementation",
"of",
"ASSIGN",
"derived",
"from",
"handleChildren",
"()",
"in",
"pyflakes",
"1",
".",
"3",
".",
"0",
"."
] | train | https://github.com/ambv/flake8-pyi/blob/19e8028b44b6305dff1bfb9a51a23a029c546993/pyi.py#L29-L43 |
ambv/flake8-pyi | pyi.py | PyiAwareFlakesChecker.ANNASSIGN | def ANNASSIGN(self, node):
"""
Annotated assignments don't have annotations evaluated on function
scope, hence the custom implementation. Compared to the pyflakes
version, we defer evaluation of the annotations (and values on
module level).
"""
if node.value:
... | python | def ANNASSIGN(self, node):
"""
Annotated assignments don't have annotations evaluated on function
scope, hence the custom implementation. Compared to the pyflakes
version, we defer evaluation of the annotations (and values on
module level).
"""
if node.value:
... | [
"def",
"ANNASSIGN",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"value",
":",
"# Only bind the *target* if the assignment has value.",
"# Otherwise it's not really ast.Store and shouldn't silence",
"# UndefinedLocal warnings.",
"self",
".",
"handleNode",
"(",
"node... | Annotated assignments don't have annotations evaluated on function
scope, hence the custom implementation. Compared to the pyflakes
version, we defer evaluation of the annotations (and values on
module level). | [
"Annotated",
"assignments",
"don",
"t",
"have",
"annotations",
"evaluated",
"on",
"function",
"scope",
"hence",
"the",
"custom",
"implementation",
".",
"Compared",
"to",
"the",
"pyflakes",
"version",
"we",
"defer",
"evaluation",
"of",
"the",
"annotations",
"(",
... | train | https://github.com/ambv/flake8-pyi/blob/19e8028b44b6305dff1bfb9a51a23a029c546993/pyi.py#L45-L66 |
ambv/flake8-pyi | pyi.py | PyiAwareFlakesChecker.LAMBDA | def LAMBDA(self, node):
"""This is likely very brittle, currently works for pyflakes 1.3.0.
Deferring annotation handling depends on the fact that during calls
to LAMBDA visiting the function's body is already deferred and the
only eager calls to `handleNode` are for annotations.
... | python | def LAMBDA(self, node):
"""This is likely very brittle, currently works for pyflakes 1.3.0.
Deferring annotation handling depends on the fact that during calls
to LAMBDA visiting the function's body is already deferred and the
only eager calls to `handleNode` are for annotations.
... | [
"def",
"LAMBDA",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"handleNode",
",",
"self",
".",
"deferHandleNode",
"=",
"self",
".",
"deferHandleNode",
",",
"self",
".",
"handleNode",
"super",
"(",
")",
".",
"LAMBDA",
"(",
"node",
")",
"self",
".",
... | This is likely very brittle, currently works for pyflakes 1.3.0.
Deferring annotation handling depends on the fact that during calls
to LAMBDA visiting the function's body is already deferred and the
only eager calls to `handleNode` are for annotations. | [
"This",
"is",
"likely",
"very",
"brittle",
"currently",
"works",
"for",
"pyflakes",
"1",
".",
"3",
".",
"0",
"."
] | train | https://github.com/ambv/flake8-pyi/blob/19e8028b44b6305dff1bfb9a51a23a029c546993/pyi.py#L68-L77 |
data61/clkhash | clkhash/bloomfilter.py | double_hash_encode_ngrams | def double_hash_encode_ngrams(ngrams, # type: Iterable[str]
keys, # type: Sequence[bytes]
ks, # type: Sequence[int]
l, # type: int
encoding # type: str
... | python | def double_hash_encode_ngrams(ngrams, # type: Iterable[str]
keys, # type: Sequence[bytes]
ks, # type: Sequence[int]
l, # type: int
encoding # type: str
... | [
"def",
"double_hash_encode_ngrams",
"(",
"ngrams",
",",
"# type: Iterable[str]",
"keys",
",",
"# type: Sequence[bytes]",
"ks",
",",
"# type: Sequence[int]",
"l",
",",
"# type: int",
"encoding",
"# type: str",
")",
":",
"# type: (...) -> bitarray",
"key_sha1",
",",
"key_md... | Computes the double hash encoding of the ngrams with the given keys.
Using the method from:
Schnell, R., Bachteler, T., & Reiher, J. (2011).
A Novel Error-Tolerant Anonymous Linking Code.
http://grlc.german-microsimulation.de/wp-content/uploads/2017/05/downloadwp-grlc-20... | [
"Computes",
"the",
"double",
"hash",
"encoding",
"of",
"the",
"ngrams",
"with",
"the",
"given",
"keys",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/bloomfilter.py#L29-L66 |
data61/clkhash | clkhash/bloomfilter.py | double_hash_encode_ngrams_non_singular | def double_hash_encode_ngrams_non_singular(ngrams, # type: Iterable[str]
keys, # type: Sequence[bytes]
ks, # type: Sequence[int]
l, # type: int
... | python | def double_hash_encode_ngrams_non_singular(ngrams, # type: Iterable[str]
keys, # type: Sequence[bytes]
ks, # type: Sequence[int]
l, # type: int
... | [
"def",
"double_hash_encode_ngrams_non_singular",
"(",
"ngrams",
",",
"# type: Iterable[str]",
"keys",
",",
"# type: Sequence[bytes]",
"ks",
",",
"# type: Sequence[int]",
"l",
",",
"# type: int",
"encoding",
"# type: str",
")",
":",
"# type: (...) -> bitarray.bitarray",
"key_s... | computes the double hash encoding of the n-grams with the given keys.
The original construction of [Schnell2011]_ displays an abnormality for
certain inputs:
An n-gram can be encoded into just one bit irrespective of the number
of k.
Their construction goes as follows:... | [
"computes",
"the",
"double",
"hash",
"encoding",
"of",
"the",
"n",
"-",
"grams",
"with",
"the",
"given",
"keys",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/bloomfilter.py#L69-L137 |
data61/clkhash | clkhash/bloomfilter.py | blake_encode_ngrams | def blake_encode_ngrams(ngrams, # type: Iterable[str]
keys, # type: Sequence[bytes]
ks, # type: Sequence[int]
l, # type: int
encoding # type: str
):
# type: (...) -> bitarray.b... | python | def blake_encode_ngrams(ngrams, # type: Iterable[str]
keys, # type: Sequence[bytes]
ks, # type: Sequence[int]
l, # type: int
encoding # type: str
):
# type: (...) -> bitarray.b... | [
"def",
"blake_encode_ngrams",
"(",
"ngrams",
",",
"# type: Iterable[str]",
"keys",
",",
"# type: Sequence[bytes]",
"ks",
",",
"# type: Sequence[int]",
"l",
",",
"# type: int",
"encoding",
"# type: str",
")",
":",
"# type: (...) -> bitarray.bitarray",
"key",
",",
"=",
"k... | Computes the encoding of the ngrams using the BLAKE2 hash function.
We deliberately do not use the double hashing scheme as proposed in [
Schnell2011]_, because this
would introduce an exploitable structure into the Bloom filter. For more
details on the
weakness, see [Kroll2015]... | [
"Computes",
"the",
"encoding",
"of",
"the",
"ngrams",
"using",
"the",
"BLAKE2",
"hash",
"function",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/bloomfilter.py#L140-L235 |
data61/clkhash | clkhash/bloomfilter.py | hashing_function_from_properties | def hashing_function_from_properties(
fhp # type: FieldHashingProperties
):
# type: (...) -> Callable[[Iterable[str], Sequence[bytes], Sequence[int], int, str], bitarray]
""" Get the hashing function for this field
:param fhp: hashing properties for this field
:return: the hashi... | python | def hashing_function_from_properties(
fhp # type: FieldHashingProperties
):
# type: (...) -> Callable[[Iterable[str], Sequence[bytes], Sequence[int], int, str], bitarray]
""" Get the hashing function for this field
:param fhp: hashing properties for this field
:return: the hashi... | [
"def",
"hashing_function_from_properties",
"(",
"fhp",
"# type: FieldHashingProperties",
")",
":",
"# type: (...) -> Callable[[Iterable[str], Sequence[bytes], Sequence[int], int, str], bitarray]",
"if",
"fhp",
".",
"hash_type",
"==",
"'doubleHash'",
":",
"if",
"fhp",
".",
"preven... | Get the hashing function for this field
:param fhp: hashing properties for this field
:return: the hashing function | [
"Get",
"the",
"hashing",
"function",
"for",
"this",
"field",
":",
"param",
"fhp",
":",
"hashing",
"properties",
"for",
"this",
"field",
":",
"return",
":",
"the",
"hashing",
"function"
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/bloomfilter.py#L238-L255 |
data61/clkhash | clkhash/bloomfilter.py | fold_xor | def fold_xor(bloomfilter, # type: bitarray
folds # type: int
):
# type: (...) -> bitarray
""" Performs XOR folding on a Bloom filter.
If the length of the original Bloom filter is n and we perform
r folds, then the length of the resulting filter is n / 2 ** r.... | python | def fold_xor(bloomfilter, # type: bitarray
folds # type: int
):
# type: (...) -> bitarray
""" Performs XOR folding on a Bloom filter.
If the length of the original Bloom filter is n and we perform
r folds, then the length of the resulting filter is n / 2 ** r.... | [
"def",
"fold_xor",
"(",
"bloomfilter",
",",
"# type: bitarray",
"folds",
"# type: int",
")",
":",
"# type: (...) -> bitarray",
"if",
"len",
"(",
"bloomfilter",
")",
"%",
"2",
"**",
"folds",
"!=",
"0",
":",
"msg",
"=",
"(",
"'The length of the bloom filter is {leng... | Performs XOR folding on a Bloom filter.
If the length of the original Bloom filter is n and we perform
r folds, then the length of the resulting filter is n / 2 ** r.
:param bloomfilter: Bloom filter to fold
:param folds: number of folds
:return: folded bloom filter | [
"Performs",
"XOR",
"folding",
"on",
"a",
"Bloom",
"filter",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/bloomfilter.py#L258-L286 |
data61/clkhash | clkhash/bloomfilter.py | crypto_bloom_filter | def crypto_bloom_filter(record, # type: Sequence[Text]
tokenizers, # type: List[Callable[[Text, Optional[Text]], Iterable[Text]]]
schema, # type: Schema
keys # type: Sequence[Sequence[bytes]]
):
# type... | python | def crypto_bloom_filter(record, # type: Sequence[Text]
tokenizers, # type: List[Callable[[Text, Optional[Text]], Iterable[Text]]]
schema, # type: Schema
keys # type: Sequence[Sequence[bytes]]
):
# type... | [
"def",
"crypto_bloom_filter",
"(",
"record",
",",
"# type: Sequence[Text]",
"tokenizers",
",",
"# type: List[Callable[[Text, Optional[Text]], Iterable[Text]]]",
"schema",
",",
"# type: Schema",
"keys",
"# type: Sequence[Sequence[bytes]]",
")",
":",
"# type: (...) -> Tuple[bitarray, T... | Computes the composite Bloom filter encoding of a record.
Using the method from
http://www.record-linkage.de/-download=wp-grlc-2011-02.pdf
:param record: plaintext record tuple. E.g. (index, name, dob, gender)
:param tokenizers: A list of tokenizers. A tokenizer is a function that
... | [
"Computes",
"the",
"composite",
"Bloom",
"filter",
"encoding",
"of",
"a",
"record",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/bloomfilter.py#L289-L329 |
data61/clkhash | clkhash/bloomfilter.py | stream_bloom_filters | def stream_bloom_filters(dataset, # type: Iterable[Sequence[Text]]
keys, # type: Sequence[Sequence[bytes]]
schema # type: Schema
):
# type: (...) -> Iterable[Tuple[bitarray, Text, int]]
""" Compute composite Bloom filters (CLKs) ... | python | def stream_bloom_filters(dataset, # type: Iterable[Sequence[Text]]
keys, # type: Sequence[Sequence[bytes]]
schema # type: Schema
):
# type: (...) -> Iterable[Tuple[bitarray, Text, int]]
""" Compute composite Bloom filters (CLKs) ... | [
"def",
"stream_bloom_filters",
"(",
"dataset",
",",
"# type: Iterable[Sequence[Text]]",
"keys",
",",
"# type: Sequence[Sequence[bytes]]",
"schema",
"# type: Schema",
")",
":",
"# type: (...) -> Iterable[Tuple[bitarray, Text, int]]",
"tokenizers",
"=",
"[",
"tokenizer",
".",
"ge... | Compute composite Bloom filters (CLKs) for every record in an
iterable dataset.
:param dataset: An iterable of indexable records.
:param schema: An instantiated Schema instance
:param keys: A tuple of two lists of secret keys used in the HMAC.
:return: Generator yielding bloom f... | [
"Compute",
"composite",
"Bloom",
"filters",
"(",
"CLKs",
")",
"for",
"every",
"record",
"in",
"an",
"iterable",
"dataset",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/bloomfilter.py#L332-L348 |
data61/clkhash | clkhash/backports.py | re_compile_full | def re_compile_full(pattern, flags=0):
# type: (AnyStr, int) -> Pattern
""" Create compiled regular expression such that it matches the
entire string. Calling re.match on the output of this function
is equivalent to calling re.fullmatch on its input.
This is needed to support Python 2. ... | python | def re_compile_full(pattern, flags=0):
# type: (AnyStr, int) -> Pattern
""" Create compiled regular expression such that it matches the
entire string. Calling re.match on the output of this function
is equivalent to calling re.fullmatch on its input.
This is needed to support Python 2. ... | [
"def",
"re_compile_full",
"(",
"pattern",
",",
"flags",
"=",
"0",
")",
":",
"# type: (AnyStr, int) -> Pattern",
"# Don't worry, this short-circuits.",
"assert",
"type",
"(",
"pattern",
")",
"is",
"str",
"or",
"type",
"(",
"pattern",
")",
"is",
"unicode",
"# type: ... | Create compiled regular expression such that it matches the
entire string. Calling re.match on the output of this function
is equivalent to calling re.fullmatch on its input.
This is needed to support Python 2. (On Python 3, we would just
call re.fullmatch.)
Kudos: https://stack... | [
"Create",
"compiled",
"regular",
"expression",
"such",
"that",
"it",
"matches",
"the",
"entire",
"string",
".",
"Calling",
"re",
".",
"match",
"on",
"the",
"output",
"of",
"this",
"function",
"is",
"equivalent",
"to",
"calling",
"re",
".",
"fullmatch",
"on",... | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/backports.py#L53-L72 |
data61/clkhash | clkhash/backports.py | _p2_unicode_reader | def _p2_unicode_reader(unicode_csv_data, dialect=csv.excel, **kwargs):
""" Encode Unicode as UTF-8 and parse as CSV.
This is needed since Python 2's `csv` doesn't do Unicode.
Kudos: https://docs.python.org/2/library/csv.html#examples
:param unicode_csv_data: The Unicode stream to parse.
... | python | def _p2_unicode_reader(unicode_csv_data, dialect=csv.excel, **kwargs):
""" Encode Unicode as UTF-8 and parse as CSV.
This is needed since Python 2's `csv` doesn't do Unicode.
Kudos: https://docs.python.org/2/library/csv.html#examples
:param unicode_csv_data: The Unicode stream to parse.
... | [
"def",
"_p2_unicode_reader",
"(",
"unicode_csv_data",
",",
"dialect",
"=",
"csv",
".",
"excel",
",",
"*",
"*",
"kwargs",
")",
":",
"# Encode temporarily as UTF-8:",
"utf8_csv_data",
"=",
"_utf_8_encoder",
"(",
"unicode_csv_data",
")",
"# Now we can parse!",
"csv_reade... | Encode Unicode as UTF-8 and parse as CSV.
This is needed since Python 2's `csv` doesn't do Unicode.
Kudos: https://docs.python.org/2/library/csv.html#examples
:param unicode_csv_data: The Unicode stream to parse.
:param dialect: The CSV dialect to use.
:param kwargs: Any other... | [
"Encode",
"Unicode",
"as",
"UTF",
"-",
"8",
"and",
"parse",
"as",
"CSV",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/backports.py#L79-L99 |
IndicoDataSolutions/IndicoIo-python | indicoio/utils/preprocessing.py | file_exists | def file_exists(filename):
"""
Check if a file exists (and don't error out on unicode inputs)
"""
try:
return os.path.isfile(filename)
except (UnicodeDecodeError, UnicodeEncodeError, ValueError):
return False | python | def file_exists(filename):
"""
Check if a file exists (and don't error out on unicode inputs)
"""
try:
return os.path.isfile(filename)
except (UnicodeDecodeError, UnicodeEncodeError, ValueError):
return False | [
"def",
"file_exists",
"(",
"filename",
")",
":",
"try",
":",
"return",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
"except",
"(",
"UnicodeDecodeError",
",",
"UnicodeEncodeError",
",",
"ValueError",
")",
":",
"return",
"False"
] | Check if a file exists (and don't error out on unicode inputs) | [
"Check",
"if",
"a",
"file",
"exists",
"(",
"and",
"don",
"t",
"error",
"out",
"on",
"unicode",
"inputs",
")"
] | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/utils/preprocessing.py#L15-L22 |
IndicoDataSolutions/IndicoIo-python | indicoio/utils/preprocessing.py | data_preprocess | def data_preprocess(data, size=None, min_axis=None, batch=False):
"""
Takes data and prepares it for sending to the api including
resizing and image data/structure standardizing.
"""
if batch:
return [data_preprocess(el, size=size, min_axis=min_axis, batch=False) for el in data]
if isin... | python | def data_preprocess(data, size=None, min_axis=None, batch=False):
"""
Takes data and prepares it for sending to the api including
resizing and image data/structure standardizing.
"""
if batch:
return [data_preprocess(el, size=size, min_axis=min_axis, batch=False) for el in data]
if isin... | [
"def",
"data_preprocess",
"(",
"data",
",",
"size",
"=",
"None",
",",
"min_axis",
"=",
"None",
",",
"batch",
"=",
"False",
")",
":",
"if",
"batch",
":",
"return",
"[",
"data_preprocess",
"(",
"el",
",",
"size",
"=",
"size",
",",
"min_axis",
"=",
"min... | Takes data and prepares it for sending to the api including
resizing and image data/structure standardizing. | [
"Takes",
"data",
"and",
"prepares",
"it",
"for",
"sending",
"to",
"the",
"api",
"including",
"resizing",
"and",
"image",
"data",
"/",
"structure",
"standardizing",
"."
] | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/utils/preprocessing.py#L25-L78 |
IndicoDataSolutions/IndicoIo-python | indicoio/utils/preprocessing.py | get_list_dimensions | def get_list_dimensions(_list):
"""
Takes a nested list and returns the size of each dimension followed
by the element type in the list
"""
if isinstance(_list, list) or isinstance(_list, tuple):
return [len(_list)] + get_list_dimensions(_list[0])
return [] | python | def get_list_dimensions(_list):
"""
Takes a nested list and returns the size of each dimension followed
by the element type in the list
"""
if isinstance(_list, list) or isinstance(_list, tuple):
return [len(_list)] + get_list_dimensions(_list[0])
return [] | [
"def",
"get_list_dimensions",
"(",
"_list",
")",
":",
"if",
"isinstance",
"(",
"_list",
",",
"list",
")",
"or",
"isinstance",
"(",
"_list",
",",
"tuple",
")",
":",
"return",
"[",
"len",
"(",
"_list",
")",
"]",
"+",
"get_list_dimensions",
"(",
"_list",
... | Takes a nested list and returns the size of each dimension followed
by the element type in the list | [
"Takes",
"a",
"nested",
"list",
"and",
"returns",
"the",
"size",
"of",
"each",
"dimension",
"followed",
"by",
"the",
"element",
"type",
"in",
"the",
"list"
] | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/utils/preprocessing.py#L99-L106 |
IndicoDataSolutions/IndicoIo-python | indicoio/utils/preprocessing.py | get_element_type | def get_element_type(_list, dimens):
"""
Given the dimensions of a nested list and the list, returns the type of the
elements in the inner list.
"""
elem = _list
for _ in range(len(dimens)):
elem = elem[0]
return type(elem) | python | def get_element_type(_list, dimens):
"""
Given the dimensions of a nested list and the list, returns the type of the
elements in the inner list.
"""
elem = _list
for _ in range(len(dimens)):
elem = elem[0]
return type(elem) | [
"def",
"get_element_type",
"(",
"_list",
",",
"dimens",
")",
":",
"elem",
"=",
"_list",
"for",
"_",
"in",
"range",
"(",
"len",
"(",
"dimens",
")",
")",
":",
"elem",
"=",
"elem",
"[",
"0",
"]",
"return",
"type",
"(",
"elem",
")"
] | Given the dimensions of a nested list and the list, returns the type of the
elements in the inner list. | [
"Given",
"the",
"dimensions",
"of",
"a",
"nested",
"list",
"and",
"the",
"list",
"returns",
"the",
"type",
"of",
"the",
"elements",
"in",
"the",
"inner",
"list",
"."
] | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/utils/preprocessing.py#L109-L117 |
IndicoDataSolutions/IndicoIo-python | indicoio/image/image_recognition.py | image_recognition | def image_recognition(image, cloud=None, batch=False, api_key=None, version=None, **kwargs):
"""
Given an input image, returns a dictionary of image classifications with associated scores
* Input can be either grayscale or rgb color and should either be a numpy array or nested list format.
* Input data... | python | def image_recognition(image, cloud=None, batch=False, api_key=None, version=None, **kwargs):
"""
Given an input image, returns a dictionary of image classifications with associated scores
* Input can be either grayscale or rgb color and should either be a numpy array or nested list format.
* Input data... | [
"def",
"image_recognition",
"(",
"image",
",",
"cloud",
"=",
"None",
",",
"batch",
"=",
"False",
",",
"api_key",
"=",
"None",
",",
"version",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"image",
"=",
"data_preprocess",
"(",
"image",
",",
"batch",
... | Given an input image, returns a dictionary of image classifications with associated scores
* Input can be either grayscale or rgb color and should either be a numpy array or nested list format.
* Input data should be either uint8 0-255 range values or floating point between 0 and 1.
* Large images (i.e. 10... | [
"Given",
"an",
"input",
"image",
"returns",
"a",
"dictionary",
"of",
"image",
"classifications",
"with",
"associated",
"scores"
] | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/image/image_recognition.py#L7-L29 |
IndicoDataSolutions/IndicoIo-python | indicoio/multi/utils.py | multi | def multi(data, datatype, apis, accepted_apis, batch=False,**kwargs):
"""
Helper to make multi requests of different types.
:param data: Data to be sent in API request
:param datatype: String type of API request
:param apis: List of apis to use.
:param batch: Is this a batch request?
... | python | def multi(data, datatype, apis, accepted_apis, batch=False,**kwargs):
"""
Helper to make multi requests of different types.
:param data: Data to be sent in API request
:param datatype: String type of API request
:param apis: List of apis to use.
:param batch: Is this a batch request?
... | [
"def",
"multi",
"(",
"data",
",",
"datatype",
",",
"apis",
",",
"accepted_apis",
",",
"batch",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Client side api name checking - strictly only accept func name api\r",
"invalid_apis",
"=",
"[",
"api",
"for",
"api",... | Helper to make multi requests of different types.
:param data: Data to be sent in API request
:param datatype: String type of API request
:param apis: List of apis to use.
:param batch: Is this a batch request?
:rtype: Dictionary of api responses | [
"Helper",
"to",
"make",
"multi",
"requests",
"of",
"different",
"types",
".",
":",
"param",
"data",
":",
"Data",
"to",
"be",
"sent",
"in",
"API",
"request",
":",
"param",
"datatype",
":",
"String",
"type",
"of",
"API",
"request",
":",
"param",
"apis",
... | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/multi/utils.py#L12-L42 |
IndicoDataSolutions/IndicoIo-python | indicoio/multi/analyze_text.py | analyze_text | def analyze_text(input_text, apis=DEFAULT_APIS, **kwargs):
"""
Given input text, returns the results of specified text apis. Possible apis
include: [ 'text_tags', 'political', 'sentiment', 'language' ]
Example usage:
.. code-block:: python
>>> import indicoio
>>> text = 'M... | python | def analyze_text(input_text, apis=DEFAULT_APIS, **kwargs):
"""
Given input text, returns the results of specified text apis. Possible apis
include: [ 'text_tags', 'political', 'sentiment', 'language' ]
Example usage:
.. code-block:: python
>>> import indicoio
>>> text = 'M... | [
"def",
"analyze_text",
"(",
"input_text",
",",
"apis",
"=",
"DEFAULT_APIS",
",",
"*",
"*",
"kwargs",
")",
":",
"cloud",
"=",
"kwargs",
".",
"pop",
"(",
"'cloud'",
",",
"None",
")",
"batch",
"=",
"kwargs",
".",
"pop",
"(",
"'batch'",
",",
"False",
")"... | Given input text, returns the results of specified text apis. Possible apis
include: [ 'text_tags', 'political', 'sentiment', 'language' ]
Example usage:
.. code-block:: python
>>> import indicoio
>>> text = 'Monday: Delightful with mostly sunny skies. Highs in the low 70s.'
... | [
"Given",
"input",
"text",
"returns",
"the",
"results",
"of",
"specified",
"text",
"apis",
".",
"Possible",
"apis",
"include",
":",
"[",
"text_tags",
"political",
"sentiment",
"language",
"]",
"Example",
"usage",
":",
"..",
"code",
"-",
"block",
"::",
"python... | train | https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/multi/analyze_text.py#L7-L41 |
data61/clkhash | clkhash/field_formats.py | fhp_from_json_dict | def fhp_from_json_dict(
json_dict # type: Dict[str, Any]
):
# type: (...) -> FieldHashingProperties
"""
Make a :class:`FieldHashingProperties` object from a dictionary.
:param dict json_dict:
The dictionary must have have an 'ngram' key
and one of k or num_bits.... | python | def fhp_from_json_dict(
json_dict # type: Dict[str, Any]
):
# type: (...) -> FieldHashingProperties
"""
Make a :class:`FieldHashingProperties` object from a dictionary.
:param dict json_dict:
The dictionary must have have an 'ngram' key
and one of k or num_bits.... | [
"def",
"fhp_from_json_dict",
"(",
"json_dict",
"# type: Dict[str, Any]",
")",
":",
"# type: (...) -> FieldHashingProperties",
"h",
"=",
"json_dict",
".",
"get",
"(",
"'hash'",
",",
"{",
"'type'",
":",
"'blakeHash'",
"}",
")",
"num_bits",
"=",
"json_dict",
".",
"ge... | Make a :class:`FieldHashingProperties` object from a dictionary.
:param dict json_dict:
The dictionary must have have an 'ngram' key
and one of k or num_bits. It may have
'positional' key; if missing a default is used.
The encoding is
always set to th... | [
"Make",
"a",
":",
"class",
":",
"FieldHashingProperties",
"object",
"from",
"a",
"dictionary",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L157-L188 |
data61/clkhash | clkhash/field_formats.py | spec_from_json_dict | def spec_from_json_dict(
json_dict # type: Dict[str, Any]
):
# type: (...) -> FieldSpec
""" Turns a dictionary into the appropriate object.
:param dict json_dict: A dictionary with properties.
:returns: An initialised instance of the appropriate FieldSpec
subclass.
"""
... | python | def spec_from_json_dict(
json_dict # type: Dict[str, Any]
):
# type: (...) -> FieldSpec
""" Turns a dictionary into the appropriate object.
:param dict json_dict: A dictionary with properties.
:returns: An initialised instance of the appropriate FieldSpec
subclass.
"""
... | [
"def",
"spec_from_json_dict",
"(",
"json_dict",
"# type: Dict[str, Any]",
")",
":",
"# type: (...) -> FieldSpec",
"if",
"'ignored'",
"in",
"json_dict",
":",
"return",
"Ignore",
"(",
"json_dict",
"[",
"'identifier'",
"]",
")",
"type_str",
"=",
"json_dict",
"[",
"'for... | Turns a dictionary into the appropriate object.
:param dict json_dict: A dictionary with properties.
:returns: An initialised instance of the appropriate FieldSpec
subclass. | [
"Turns",
"a",
"dictionary",
"into",
"the",
"appropriate",
"object",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L842-L856 |
data61/clkhash | clkhash/field_formats.py | FieldHashingProperties.ks | def ks(self, num_ngrams):
# type (int) -> [int]
"""
Provide a k for each ngram in the field value.
:param num_ngrams: number of ngrams in the field value
:return: [ k, ... ] a k value for each of num_ngrams such that the sum is exactly num_bits
"""
if self.num_bit... | python | def ks(self, num_ngrams):
# type (int) -> [int]
"""
Provide a k for each ngram in the field value.
:param num_ngrams: number of ngrams in the field value
:return: [ k, ... ] a k value for each of num_ngrams such that the sum is exactly num_bits
"""
if self.num_bit... | [
"def",
"ks",
"(",
"self",
",",
"num_ngrams",
")",
":",
"# type (int) -> [int]",
"if",
"self",
".",
"num_bits",
":",
"k",
"=",
"int",
"(",
"self",
".",
"num_bits",
"/",
"num_ngrams",
")",
"residue",
"=",
"self",
".",
"num_bits",
"%",
"num_ngrams",
"return... | Provide a k for each ngram in the field value.
:param num_ngrams: number of ngrams in the field value
:return: [ k, ... ] a k value for each of num_ngrams such that the sum is exactly num_bits | [
"Provide",
"a",
"k",
"for",
"each",
"ngram",
"in",
"the",
"field",
"value",
".",
":",
"param",
"num_ngrams",
":",
"number",
"of",
"ngrams",
"in",
"the",
"field",
"value",
":",
"return",
":",
"[",
"k",
"...",
"]",
"a",
"k",
"value",
"for",
"each",
"... | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L126-L138 |
data61/clkhash | clkhash/field_formats.py | FieldHashingProperties.replace_missing_value | def replace_missing_value(self, str_in):
# type: (Text) -> Text
""" returns 'str_in' if it is not equals to the 'sentinel' as
defined in the missingValue section of
the schema. Else it will return the 'replaceWith' value.
:param str_in:
:return: str_in or the missingValu... | python | def replace_missing_value(self, str_in):
# type: (Text) -> Text
""" returns 'str_in' if it is not equals to the 'sentinel' as
defined in the missingValue section of
the schema. Else it will return the 'replaceWith' value.
:param str_in:
:return: str_in or the missingValu... | [
"def",
"replace_missing_value",
"(",
"self",
",",
"str_in",
")",
":",
"# type: (Text) -> Text",
"if",
"self",
".",
"missing_value",
"is",
"None",
":",
"return",
"str_in",
"elif",
"self",
".",
"missing_value",
".",
"sentinel",
"==",
"str_in",
":",
"return",
"se... | returns 'str_in' if it is not equals to the 'sentinel' as
defined in the missingValue section of
the schema. Else it will return the 'replaceWith' value.
:param str_in:
:return: str_in or the missingValue replacement value | [
"returns",
"str_in",
"if",
"it",
"is",
"not",
"equals",
"to",
"the",
"sentinel",
"as",
"defined",
"in",
"the",
"missingValue",
"section",
"of",
"the",
"schema",
".",
"Else",
"it",
"will",
"return",
"the",
"replaceWith",
"value",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L140-L154 |
data61/clkhash | clkhash/field_formats.py | StringSpec.from_json_dict | def from_json_dict(cls,
json_dict # type: Dict[str, Any]
):
# type: (...) -> StringSpec
""" Make a StringSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary must contain an
... | python | def from_json_dict(cls,
json_dict # type: Dict[str, Any]
):
# type: (...) -> StringSpec
""" Make a StringSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary must contain an
... | [
"def",
"from_json_dict",
"(",
"cls",
",",
"json_dict",
"# type: Dict[str, Any]",
")",
":",
"# type: (...) -> StringSpec",
"# noinspection PyCompatibility",
"result",
"=",
"cast",
"(",
"StringSpec",
",",
"# Go away, Mypy.",
"super",
"(",
")",
".",
"from_json_dict",
"(",
... | Make a StringSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary must contain an
`'encoding'` key associated with a Python-conformant
encoding. It must also contain a `'hashing'` key, whose
contents are ... | [
"Make",
"a",
"StringSpec",
"object",
"from",
"a",
"dictionary",
"containing",
"its",
"properties",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L413-L453 |
data61/clkhash | clkhash/field_formats.py | StringSpec.validate | def validate(self, str_in):
# type: (Text) -> None
""" Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff (1) a pattern is part of the
specification of the field and the string does not match
it;... | python | def validate(self, str_in):
# type: (Text) -> None
""" Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff (1) a pattern is part of the
specification of the field and the string does not match
it;... | [
"def",
"validate",
"(",
"self",
",",
"str_in",
")",
":",
"# type: (Text) -> None",
"if",
"self",
".",
"is_missing_value",
"(",
"str_in",
")",
":",
"return",
"# noinspection PyCompatibility",
"super",
"(",
")",
".",
"validate",
"(",
"str_in",
")",
"# Validate enc... | Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff (1) a pattern is part of the
specification of the field and the string does not match
it; (2) the string does not match the provided casing,
minimum... | [
"Validates",
"an",
"entry",
"in",
"the",
"field",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L455-L520 |
data61/clkhash | clkhash/field_formats.py | IntegerSpec.from_json_dict | def from_json_dict(cls,
json_dict # type: Dict[str, Any]
):
# type: (...) -> IntegerSpec
""" Make a IntegerSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary may contain
`... | python | def from_json_dict(cls,
json_dict # type: Dict[str, Any]
):
# type: (...) -> IntegerSpec
""" Make a IntegerSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary may contain
`... | [
"def",
"from_json_dict",
"(",
"cls",
",",
"json_dict",
"# type: Dict[str, Any]",
")",
":",
"# type: (...) -> IntegerSpec",
"# noinspection PyCompatibility",
"result",
"=",
"cast",
"(",
"IntegerSpec",
",",
"# For Mypy.",
"super",
"(",
")",
".",
"from_json_dict",
"(",
"... | Make a IntegerSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary may contain
`'minimum'` and `'maximum'` keys. In addition, it must
contain a `'hashing'` key, whose contents are passed to
:class:`FieldH... | [
"Make",
"a",
"IntegerSpec",
"object",
"from",
"a",
"dictionary",
"containing",
"its",
"properties",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L553-L575 |
data61/clkhash | clkhash/field_formats.py | IntegerSpec.validate | def validate(self, str_in):
# type: (Text) -> None
""" Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff (1) the string does not represent a
base-10 integer; (2) the integer is not between
`self... | python | def validate(self, str_in):
# type: (Text) -> None
""" Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff (1) the string does not represent a
base-10 integer; (2) the integer is not between
`self... | [
"def",
"validate",
"(",
"self",
",",
"str_in",
")",
":",
"# type: (Text) -> None",
"if",
"self",
".",
"is_missing_value",
"(",
"str_in",
")",
":",
"return",
"# noinspection PyCompatibility",
"super",
"(",
")",
".",
"validate",
"(",
"str_in",
")",
"try",
":",
... | Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff (1) the string does not represent a
base-10 integer; (2) the integer is not between
`self.minimum` and `self.maximum`, if those exist; or (3)
the in... | [
"Validates",
"an",
"entry",
"in",
"the",
"field",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L577-L618 |
data61/clkhash | clkhash/field_formats.py | IntegerSpec._format_regular_value | def _format_regular_value(self, str_in):
# type: (Text) -> Text
""" we need to reformat integer strings, as there can be different
strings for the same integer. The
strategy of unification here is to first parse the integer
string to an Integer type. Thus all of
... | python | def _format_regular_value(self, str_in):
# type: (Text) -> Text
""" we need to reformat integer strings, as there can be different
strings for the same integer. The
strategy of unification here is to first parse the integer
string to an Integer type. Thus all of
... | [
"def",
"_format_regular_value",
"(",
"self",
",",
"str_in",
")",
":",
"# type: (Text) -> Text",
"try",
":",
"value",
"=",
"int",
"(",
"str_in",
",",
"base",
"=",
"10",
")",
"return",
"str",
"(",
"value",
")",
"except",
"ValueError",
"as",
"e",
":",
"msg"... | we need to reformat integer strings, as there can be different
strings for the same integer. The
strategy of unification here is to first parse the integer
string to an Integer type. Thus all of
'+13', ' 13', '13' will be parsed to 13. We then convert the
integer ... | [
"we",
"need",
"to",
"reformat",
"integer",
"strings",
"as",
"there",
"can",
"be",
"different",
"strings",
"for",
"the",
"same",
"integer",
".",
"The",
"strategy",
"of",
"unification",
"here",
"is",
"to",
"first",
"parse",
"the",
"integer",
"string",
"to",
... | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L620-L641 |
data61/clkhash | clkhash/field_formats.py | DateSpec.from_json_dict | def from_json_dict(cls,
json_dict # type: Dict[str, Any]
):
# type: (...) -> DateSpec
""" Make a DateSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary must contain a
`'format'` key. In addi... | python | def from_json_dict(cls,
json_dict # type: Dict[str, Any]
):
# type: (...) -> DateSpec
""" Make a DateSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary must contain a
`'format'` key. In addi... | [
"def",
"from_json_dict",
"(",
"cls",
",",
"json_dict",
"# type: Dict[str, Any]",
")",
":",
"# type: (...) -> DateSpec",
"# noinspection PyCompatibility",
"result",
"=",
"cast",
"(",
"DateSpec",
",",
"# For Mypy.",
"super",
"(",
")",
".",
"from_json_dict",
"(",
"json_d... | Make a DateSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary must contain a
`'format'` key. In addition, it must contain a
`'hashing'` key, whose contents are passed to
:class:`FieldHashingProperties`.... | [
"Make",
"a",
"DateSpec",
"object",
"from",
"a",
"dictionary",
"containing",
"its",
"properties",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L676-L697 |
data61/clkhash | clkhash/field_formats.py | DateSpec.validate | def validate(self, str_in):
# type: (Text) -> None
""" Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff (1) the string does not represent a
date in the correct format; or (2) the date it represents
... | python | def validate(self, str_in):
# type: (Text) -> None
""" Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff (1) the string does not represent a
date in the correct format; or (2) the date it represents
... | [
"def",
"validate",
"(",
"self",
",",
"str_in",
")",
":",
"# type: (Text) -> None",
"if",
"self",
".",
"is_missing_value",
"(",
"str_in",
")",
":",
"return",
"# noinspection PyCompatibility",
"super",
"(",
")",
".",
"validate",
"(",
"str_in",
")",
"try",
":",
... | Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff (1) the string does not represent a
date in the correct format; or (2) the date it represents
is invalid (such as 30 February).
:param str str_in: ... | [
"Validates",
"an",
"entry",
"in",
"the",
"field",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L699-L723 |
data61/clkhash | clkhash/field_formats.py | DateSpec._format_regular_value | def _format_regular_value(self, str_in):
# type: (Text) -> Text
""" we overwrite default behaviour as we want to hash the numbers
only, no fillers like '-', or '/'
:param str str_in: date string
:return: str date string with format DateSpec.OUTPUT_FORMAT
"""
try:... | python | def _format_regular_value(self, str_in):
# type: (Text) -> Text
""" we overwrite default behaviour as we want to hash the numbers
only, no fillers like '-', or '/'
:param str str_in: date string
:return: str date string with format DateSpec.OUTPUT_FORMAT
"""
try:... | [
"def",
"_format_regular_value",
"(",
"self",
",",
"str_in",
")",
":",
"# type: (Text) -> Text",
"try",
":",
"dt",
"=",
"datetime",
".",
"strptime",
"(",
"str_in",
",",
"self",
".",
"format",
")",
"return",
"strftime",
"(",
"dt",
",",
"DateSpec",
".",
"OUTP... | we overwrite default behaviour as we want to hash the numbers
only, no fillers like '-', or '/'
:param str str_in: date string
:return: str date string with format DateSpec.OUTPUT_FORMAT | [
"we",
"overwrite",
"default",
"behaviour",
"as",
"we",
"want",
"to",
"hash",
"the",
"numbers",
"only",
"no",
"fillers",
"like",
"-",
"or",
"/"
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L725-L741 |
data61/clkhash | clkhash/field_formats.py | EnumSpec.from_json_dict | def from_json_dict(cls,
json_dict # type: Dict[str, Any]
):
# type: (...) -> EnumSpec
""" Make a EnumSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary must contain an
`'e... | python | def from_json_dict(cls,
json_dict # type: Dict[str, Any]
):
# type: (...) -> EnumSpec
""" Make a EnumSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary must contain an
`'e... | [
"def",
"from_json_dict",
"(",
"cls",
",",
"json_dict",
"# type: Dict[str, Any]",
")",
":",
"# type: (...) -> EnumSpec",
"# noinspection PyCompatibility",
"result",
"=",
"cast",
"(",
"EnumSpec",
",",
"# Appease the gods of Mypy.",
"super",
"(",
")",
".",
"from_json_dict",
... | Make a EnumSpec object from a dictionary containing its
properties.
:param dict json_dict: This dictionary must contain an
`'enum'` key specifying the permitted values. In
addition, it must contain a `'hashing'` key, whose
contents are passed to :... | [
"Make",
"a",
"EnumSpec",
"object",
"from",
"a",
"dictionary",
"containing",
"its",
"properties",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L770-L789 |
data61/clkhash | clkhash/field_formats.py | EnumSpec.validate | def validate(self, str_in):
# type: (Text) -> None
""" Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff it is not one of the permitted
values.
:param str str_in: String to validate.
... | python | def validate(self, str_in):
# type: (Text) -> None
""" Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff it is not one of the permitted
values.
:param str str_in: String to validate.
... | [
"def",
"validate",
"(",
"self",
",",
"str_in",
")",
":",
"# type: (Text) -> None",
"if",
"self",
".",
"is_missing_value",
"(",
"str_in",
")",
":",
"return",
"# noinspection PyCompatibility",
"super",
"(",
")",
".",
"validate",
"(",
"str_in",
")",
"if",
"str_in... | Validates an entry in the field.
Raises `InvalidEntryError` iff the entry is invalid.
An entry is invalid iff it is not one of the permitted
values.
:param str str_in: String to validate.
:raises InvalidEntryError: When entry is invalid. | [
"Validates",
"an",
"entry",
"in",
"the",
"field",
"."
] | train | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/field_formats.py#L791-L813 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.