repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
hydpy-dev/hydpy | hydpy/core/sequencetools.py | IOSequence.average_series | def average_series(self, *args, **kwargs) -> InfoArray:
"""Average the actual time series of the |Variable| object for all
time points.
Method |IOSequence.average_series| works similarly as method
|Variable.average_values| of class |Variable|, from which we
borrow some examples.... | python | def average_series(self, *args, **kwargs) -> InfoArray:
"""Average the actual time series of the |Variable| object for all
time points.
Method |IOSequence.average_series| works similarly as method
|Variable.average_values| of class |Variable|, from which we
borrow some examples.... | [
"def",
"average_series",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"InfoArray",
":",
"try",
":",
"if",
"not",
"self",
".",
"NDIM",
":",
"array",
"=",
"self",
".",
"series",
"else",
":",
"mask",
"=",
"self",
".",
"get_submas... | Average the actual time series of the |Variable| object for all
time points.
Method |IOSequence.average_series| works similarly as method
|Variable.average_values| of class |Variable|, from which we
borrow some examples. However, firstly, we have to prepare a
|Timegrids| object ... | [
"Average",
"the",
"actual",
"time",
"series",
"of",
"the",
"|Variable|",
"object",
"for",
"all",
"time",
"points",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L1158-L1237 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | IOSequence.aggregate_series | def aggregate_series(self, *args, **kwargs) -> InfoArray:
"""Aggregates time series data based on the actual
|FluxSequence.aggregation_ext| attribute of |IOSequence|
subclasses.
We prepare some nodes and elements with the help of
method |prepare_io_example_1| and select a 1-dime... | python | def aggregate_series(self, *args, **kwargs) -> InfoArray:
"""Aggregates time series data based on the actual
|FluxSequence.aggregation_ext| attribute of |IOSequence|
subclasses.
We prepare some nodes and elements with the help of
method |prepare_io_example_1| and select a 1-dime... | [
"def",
"aggregate_series",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"InfoArray",
":",
"mode",
"=",
"self",
".",
"aggregation_ext",
"if",
"mode",
"==",
"'none'",
":",
"return",
"self",
".",
"series",
"elif",
"mode",
"==",
"'mea... | Aggregates time series data based on the actual
|FluxSequence.aggregation_ext| attribute of |IOSequence|
subclasses.
We prepare some nodes and elements with the help of
method |prepare_io_example_1| and select a 1-dimensional
flux sequence of type |lland_fluxes.NKor| as an examp... | [
"Aggregates",
"time",
"series",
"data",
"based",
"on",
"the",
"actual",
"|FluxSequence",
".",
"aggregation_ext|",
"attribute",
"of",
"|IOSequence|",
"subclasses",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L1239-L1296 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | StateSequence.old | def old(self):
"""Assess to the state value(s) at beginning of the time step, which
has been processed most recently. When using *HydPy* in the
normal manner. But it can be helpful for demonstration and debugging
purposes.
"""
value = getattr(self.fastaccess_old, self.n... | python | def old(self):
"""Assess to the state value(s) at beginning of the time step, which
has been processed most recently. When using *HydPy* in the
normal manner. But it can be helpful for demonstration and debugging
purposes.
"""
value = getattr(self.fastaccess_old, self.n... | [
"def",
"old",
"(",
"self",
")",
":",
"value",
"=",
"getattr",
"(",
"self",
".",
"fastaccess_old",
",",
"self",
".",
"name",
",",
"None",
")",
"if",
"value",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'No value/values of sequence %s has/have '",
"'not ... | Assess to the state value(s) at beginning of the time step, which
has been processed most recently. When using *HydPy* in the
normal manner. But it can be helpful for demonstration and debugging
purposes. | [
"Assess",
"to",
"the",
"state",
"value",
"(",
"s",
")",
"at",
"beginning",
"of",
"the",
"time",
"step",
"which",
"has",
"been",
"processed",
"most",
"recently",
".",
"When",
"using",
"*",
"HydPy",
"*",
"in",
"the",
"normal",
"manner",
".",
"But",
"it",... | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L1523-L1538 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | Sim.load_ext | def load_ext(self):
"""Read time series data like method |IOSequence.load_ext| of class
|IOSequence|, but with special handling of missing data.
The method's "special handling" is to convert errors to warnings.
We explain the reasons in the documentation on method |Obs.load_ext|
... | python | def load_ext(self):
"""Read time series data like method |IOSequence.load_ext| of class
|IOSequence|, but with special handling of missing data.
The method's "special handling" is to convert errors to warnings.
We explain the reasons in the documentation on method |Obs.load_ext|
... | [
"def",
"load_ext",
"(",
"self",
")",
":",
"try",
":",
"super",
"(",
")",
".",
"load_ext",
"(",
")",
"except",
"BaseException",
":",
"if",
"hydpy",
".",
"pub",
".",
"options",
".",
"warnmissingsimfile",
":",
"warnings",
".",
"warn",
"(",
"str",
"(",
"... | Read time series data like method |IOSequence.load_ext| of class
|IOSequence|, but with special handling of missing data.
The method's "special handling" is to convert errors to warnings.
We explain the reasons in the documentation on method |Obs.load_ext|
of class |Obs|, from which we ... | [
"Read",
"time",
"series",
"data",
"like",
"method",
"|IOSequence",
".",
"load_ext|",
"of",
"class",
"|IOSequence|",
"but",
"with",
"special",
"handling",
"of",
"missing",
"data",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L1750-L1816 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | Obs.load_ext | def load_ext(self):
"""Read time series data like method |IOSequence.load_ext| of class
|IOSequence|, but with special handling of missing data.
When reading incomplete time series data, *HydPy* usually raises
a |RuntimeError| to prevent from performing erroneous calculations.
F... | python | def load_ext(self):
"""Read time series data like method |IOSequence.load_ext| of class
|IOSequence|, but with special handling of missing data.
When reading incomplete time series data, *HydPy* usually raises
a |RuntimeError| to prevent from performing erroneous calculations.
F... | [
"def",
"load_ext",
"(",
"self",
")",
":",
"try",
":",
"super",
"(",
")",
".",
"load_ext",
"(",
")",
"except",
"OSError",
":",
"del",
"self",
".",
"memoryflag",
"if",
"hydpy",
".",
"pub",
".",
"options",
".",
"warnmissingobsfile",
":",
"warnings",
".",
... | Read time series data like method |IOSequence.load_ext| of class
|IOSequence|, but with special handling of missing data.
When reading incomplete time series data, *HydPy* usually raises
a |RuntimeError| to prevent from performing erroneous calculations.
For instance, this makes sense f... | [
"Read",
"time",
"series",
"data",
"like",
"method",
"|IOSequence",
".",
"load_ext|",
"of",
"class",
"|IOSequence|",
"but",
"with",
"special",
"handling",
"of",
"missing",
"data",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L1823-L1923 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | FastAccess.open_files | def open_files(self, idx):
"""Open all files with an activated disk flag."""
for name in self:
if getattr(self, '_%s_diskflag' % name):
path = getattr(self, '_%s_path' % name)
file_ = open(path, 'rb+')
ndim = getattr(self, '_%s_ndim' % name)
... | python | def open_files(self, idx):
"""Open all files with an activated disk flag."""
for name in self:
if getattr(self, '_%s_diskflag' % name):
path = getattr(self, '_%s_path' % name)
file_ = open(path, 'rb+')
ndim = getattr(self, '_%s_ndim' % name)
... | [
"def",
"open_files",
"(",
"self",
",",
"idx",
")",
":",
"for",
"name",
"in",
"self",
":",
"if",
"getattr",
"(",
"self",
",",
"'_%s_diskflag'",
"%",
"name",
")",
":",
"path",
"=",
"getattr",
"(",
"self",
",",
"'_%s_path'",
"%",
"name",
")",
"file_",
... | Open all files with an activated disk flag. | [
"Open",
"all",
"files",
"with",
"an",
"activated",
"disk",
"flag",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L1985-L1997 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | FastAccess.close_files | def close_files(self):
"""Close all files with an activated disk flag."""
for name in self:
if getattr(self, '_%s_diskflag' % name):
file_ = getattr(self, '_%s_file' % name)
file_.close() | python | def close_files(self):
"""Close all files with an activated disk flag."""
for name in self:
if getattr(self, '_%s_diskflag' % name):
file_ = getattr(self, '_%s_file' % name)
file_.close() | [
"def",
"close_files",
"(",
"self",
")",
":",
"for",
"name",
"in",
"self",
":",
"if",
"getattr",
"(",
"self",
",",
"'_%s_diskflag'",
"%",
"name",
")",
":",
"file_",
"=",
"getattr",
"(",
"self",
",",
"'_%s_file'",
"%",
"name",
")",
"file_",
".",
"close... | Close all files with an activated disk flag. | [
"Close",
"all",
"files",
"with",
"an",
"activated",
"disk",
"flag",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L1999-L2004 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | FastAccess.load_data | def load_data(self, idx):
"""Load the internal data of all sequences. Load from file if the
corresponding disk flag is activated, otherwise load from RAM."""
for name in self:
ndim = getattr(self, '_%s_ndim' % name)
diskflag = getattr(self, '_%s_diskflag' % name)
... | python | def load_data(self, idx):
"""Load the internal data of all sequences. Load from file if the
corresponding disk flag is activated, otherwise load from RAM."""
for name in self:
ndim = getattr(self, '_%s_ndim' % name)
diskflag = getattr(self, '_%s_diskflag' % name)
... | [
"def",
"load_data",
"(",
"self",
",",
"idx",
")",
":",
"for",
"name",
"in",
"self",
":",
"ndim",
"=",
"getattr",
"(",
"self",
",",
"'_%s_ndim'",
"%",
"name",
")",
"diskflag",
"=",
"getattr",
"(",
"self",
",",
"'_%s_diskflag'",
"%",
"name",
")",
"ramf... | Load the internal data of all sequences. Load from file if the
corresponding disk flag is activated, otherwise load from RAM. | [
"Load",
"the",
"internal",
"data",
"of",
"all",
"sequences",
".",
"Load",
"from",
"file",
"if",
"the",
"corresponding",
"disk",
"flag",
"is",
"activated",
"otherwise",
"load",
"from",
"RAM",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L2006-L2034 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | FastAccess.save_data | def save_data(self, idx):
"""Save the internal data of all sequences with an activated flag.
Write to file if the corresponding disk flag is activated; store
in working memory if the corresponding ram flag is activated."""
for name in self:
actual = getattr(self, name)
... | python | def save_data(self, idx):
"""Save the internal data of all sequences with an activated flag.
Write to file if the corresponding disk flag is activated; store
in working memory if the corresponding ram flag is activated."""
for name in self:
actual = getattr(self, name)
... | [
"def",
"save_data",
"(",
"self",
",",
"idx",
")",
":",
"for",
"name",
"in",
"self",
":",
"actual",
"=",
"getattr",
"(",
"self",
",",
"name",
")",
"diskflag",
"=",
"getattr",
"(",
"self",
",",
"'_%s_diskflag'",
"%",
"name",
")",
"ramflag",
"=",
"getat... | Save the internal data of all sequences with an activated flag.
Write to file if the corresponding disk flag is activated; store
in working memory if the corresponding ram flag is activated. | [
"Save",
"the",
"internal",
"data",
"of",
"all",
"sequences",
"with",
"an",
"activated",
"flag",
".",
"Write",
"to",
"file",
"if",
"the",
"corresponding",
"disk",
"flag",
"is",
"activated",
";",
"store",
"in",
"working",
"memory",
"if",
"the",
"corresponding"... | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L2036-L2058 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | FastAccessNode.load_simdata | def load_simdata(self, idx: int) -> None:
"""Load the next sim sequence value (of the given index)."""
if self._sim_ramflag:
self.sim[0] = self._sim_array[idx]
elif self._sim_diskflag:
raw = self._sim_file.read(8)
self.sim[0] = struct.unpack('d', raw) | python | def load_simdata(self, idx: int) -> None:
"""Load the next sim sequence value (of the given index)."""
if self._sim_ramflag:
self.sim[0] = self._sim_array[idx]
elif self._sim_diskflag:
raw = self._sim_file.read(8)
self.sim[0] = struct.unpack('d', raw) | [
"def",
"load_simdata",
"(",
"self",
",",
"idx",
":",
"int",
")",
"->",
"None",
":",
"if",
"self",
".",
"_sim_ramflag",
":",
"self",
".",
"sim",
"[",
"0",
"]",
"=",
"self",
".",
"_sim_array",
"[",
"idx",
"]",
"elif",
"self",
".",
"_sim_diskflag",
":... | Load the next sim sequence value (of the given index). | [
"Load",
"the",
"next",
"sim",
"sequence",
"value",
"(",
"of",
"the",
"given",
"index",
")",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L2100-L2106 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | FastAccessNode.save_simdata | def save_simdata(self, idx: int) -> None:
"""Save the last sim sequence value (of the given index)."""
if self._sim_ramflag:
self._sim_array[idx] = self.sim[0]
elif self._sim_diskflag:
raw = struct.pack('d', self.sim[0])
self._sim_file.write(raw) | python | def save_simdata(self, idx: int) -> None:
"""Save the last sim sequence value (of the given index)."""
if self._sim_ramflag:
self._sim_array[idx] = self.sim[0]
elif self._sim_diskflag:
raw = struct.pack('d', self.sim[0])
self._sim_file.write(raw) | [
"def",
"save_simdata",
"(",
"self",
",",
"idx",
":",
"int",
")",
"->",
"None",
":",
"if",
"self",
".",
"_sim_ramflag",
":",
"self",
".",
"_sim_array",
"[",
"idx",
"]",
"=",
"self",
".",
"sim",
"[",
"0",
"]",
"elif",
"self",
".",
"_sim_diskflag",
":... | Save the last sim sequence value (of the given index). | [
"Save",
"the",
"last",
"sim",
"sequence",
"value",
"(",
"of",
"the",
"given",
"index",
")",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L2108-L2114 | train |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | FastAccessNode.load_obsdata | def load_obsdata(self, idx: int) -> None:
"""Load the next obs sequence value (of the given index)."""
if self._obs_ramflag:
self.obs[0] = self._obs_array[idx]
elif self._obs_diskflag:
raw = self._obs_file.read(8)
self.obs[0] = struct.unpack('d', raw) | python | def load_obsdata(self, idx: int) -> None:
"""Load the next obs sequence value (of the given index)."""
if self._obs_ramflag:
self.obs[0] = self._obs_array[idx]
elif self._obs_diskflag:
raw = self._obs_file.read(8)
self.obs[0] = struct.unpack('d', raw) | [
"def",
"load_obsdata",
"(",
"self",
",",
"idx",
":",
"int",
")",
"->",
"None",
":",
"if",
"self",
".",
"_obs_ramflag",
":",
"self",
".",
"obs",
"[",
"0",
"]",
"=",
"self",
".",
"_obs_array",
"[",
"idx",
"]",
"elif",
"self",
".",
"_obs_diskflag",
":... | Load the next obs sequence value (of the given index). | [
"Load",
"the",
"next",
"obs",
"sequence",
"value",
"(",
"of",
"the",
"given",
"index",
")",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L2116-L2122 | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | AbsFHRU.update | def update(self):
"""Update |AbsFHRU| based on |FT| and |FHRU|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> ft(100.0)
>>> fhru(0.2, 0.8)
>>> derived.absfhru.update()
>>> derived.absfhru
absfh... | python | def update(self):
"""Update |AbsFHRU| based on |FT| and |FHRU|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> ft(100.0)
>>> fhru(0.2, 0.8)
>>> derived.absfhru.update()
>>> derived.absfhru
absfh... | [
"def",
"update",
"(",
"self",
")",
":",
"control",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"control",
".",
"ft",
"*",
"control",
".",
"fhru",
")"
] | Update |AbsFHRU| based on |FT| and |FHRU|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> ft(100.0)
>>> fhru(0.2, 0.8)
>>> derived.absfhru.update()
>>> derived.absfhru
absfhru(20.0, 80.0) | [
"Update",
"|AbsFHRU|",
"based",
"on",
"|FT|",
"and",
"|FHRU|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L21-L35 | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | KInz.update | def update(self):
"""Update |KInz| based on |HInz| and |LAI|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> hinz(0.2)
>>> lai.acker_jun = 1.0
>>> lai.vers_dec = 2.0
>>> derived.kinz.update()
>>> from hydpy import rou... | python | def update(self):
"""Update |KInz| based on |HInz| and |LAI|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> hinz(0.2)
>>> lai.acker_jun = 1.0
>>> lai.vers_dec = 2.0
>>> derived.kinz.update()
>>> from hydpy import rou... | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"con",
".",
"hinz",
"*",
"con",
".",
"lai",
")"
] | Update |KInz| based on |HInz| and |LAI|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> hinz(0.2)
>>> lai.acker_jun = 1.0
>>> lai.vers_dec = 2.0
>>> derived.kinz.update()
>>> from hydpy import round_
>>> round_(derive... | [
"Update",
"|KInz|",
"based",
"on",
"|HInz|",
"and",
"|LAI|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L43-L60 | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | WB.update | def update(self):
"""Update |WB| based on |RelWB| and |NFk|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> relwb(0.2)
>>> nfk(100.0, 200.0)
>>> derived.wb.update()
>>> derived.wb
wb(20.0, 40.0)... | python | def update(self):
"""Update |WB| based on |RelWB| and |NFk|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> relwb(0.2)
>>> nfk(100.0, 200.0)
>>> derived.wb.update()
>>> derived.wb
wb(20.0, 40.0)... | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"con",
".",
"relwb",
"*",
"con",
".",
"nfk",
")"
] | Update |WB| based on |RelWB| and |NFk|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> relwb(0.2)
>>> nfk(100.0, 200.0)
>>> derived.wb.update()
>>> derived.wb
wb(20.0, 40.0) | [
"Update",
"|WB|",
"based",
"on",
"|RelWB|",
"and",
"|NFk|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L68-L82 | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | WZ.update | def update(self):
"""Update |WZ| based on |RelWZ| and |NFk|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> relwz(0.8)
>>> nfk(100.0, 200.0)
>>> derived.wz.update()
>>> derived.wz
wz(80.0, 160.0... | python | def update(self):
"""Update |WZ| based on |RelWZ| and |NFk|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> relwz(0.8)
>>> nfk(100.0, 200.0)
>>> derived.wz.update()
>>> derived.wz
wz(80.0, 160.0... | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"con",
".",
"relwz",
"*",
"con",
".",
"nfk",
")"
] | Update |WZ| based on |RelWZ| and |NFk|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> relwz(0.8)
>>> nfk(100.0, 200.0)
>>> derived.wz.update()
>>> derived.wz
wz(80.0, 160.0) | [
"Update",
"|WZ|",
"based",
"on",
"|RelWZ|",
"and",
"|NFk|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L90-L104 | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | KB.update | def update(self):
"""Update |KB| based on |EQB| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqb(10.0)
>>> tind.value = 10.0
>>> derived.kb.update()
>>> derived.kb
kb(100.0)
"""
con = self.subpars.pars.contr... | python | def update(self):
"""Update |KB| based on |EQB| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqb(10.0)
>>> tind.value = 10.0
>>> derived.kb.update()
>>> derived.kb
kb(100.0)
"""
con = self.subpars.pars.contr... | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"con",
".",
"eqb",
"*",
"con",
".",
"tind",
")"
] | Update |KB| based on |EQB| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqb(10.0)
>>> tind.value = 10.0
>>> derived.kb.update()
>>> derived.kb
kb(100.0) | [
"Update",
"|KB|",
"based",
"on",
"|EQB|",
"and",
"|TInd|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L112-L124 | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | KI1.update | def update(self):
"""Update |KI1| based on |EQI1| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqi1(5.0)
>>> tind.value = 10.0
>>> derived.ki1.update()
>>> derived.ki1
ki1(50.0)
"""
con = self.subpars.pars.c... | python | def update(self):
"""Update |KI1| based on |EQI1| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqi1(5.0)
>>> tind.value = 10.0
>>> derived.ki1.update()
>>> derived.ki1
ki1(50.0)
"""
con = self.subpars.pars.c... | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"con",
".",
"eqi1",
"*",
"con",
".",
"tind",
")"
] | Update |KI1| based on |EQI1| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqi1(5.0)
>>> tind.value = 10.0
>>> derived.ki1.update()
>>> derived.ki1
ki1(50.0) | [
"Update",
"|KI1|",
"based",
"on",
"|EQI1|",
"and",
"|TInd|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L132-L144 | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | KI2.update | def update(self):
"""Update |KI2| based on |EQI2| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqi2(1.0)
>>> tind.value = 10.0
>>> derived.ki2.update()
>>> derived.ki2
ki2(10.0)
"""
con = self.subpars.pars.c... | python | def update(self):
"""Update |KI2| based on |EQI2| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqi2(1.0)
>>> tind.value = 10.0
>>> derived.ki2.update()
>>> derived.ki2
ki2(10.0)
"""
con = self.subpars.pars.c... | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"con",
".",
"eqi2",
"*",
"con",
".",
"tind",
")"
] | Update |KI2| based on |EQI2| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqi2(1.0)
>>> tind.value = 10.0
>>> derived.ki2.update()
>>> derived.ki2
ki2(10.0) | [
"Update",
"|KI2|",
"based",
"on",
"|EQI2|",
"and",
"|TInd|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L152-L164 | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | KD1.update | def update(self):
"""Update |KD1| based on |EQD1| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqd1(0.5)
>>> tind.value = 10.0
>>> derived.kd1.update()
>>> derived.kd1
kd1(5.0)
"""
con = self.subpars.pars.co... | python | def update(self):
"""Update |KD1| based on |EQD1| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqd1(0.5)
>>> tind.value = 10.0
>>> derived.kd1.update()
>>> derived.kd1
kd1(5.0)
"""
con = self.subpars.pars.co... | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"con",
".",
"eqd1",
"*",
"con",
".",
"tind",
")"
] | Update |KD1| based on |EQD1| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqd1(0.5)
>>> tind.value = 10.0
>>> derived.kd1.update()
>>> derived.kd1
kd1(5.0) | [
"Update",
"|KD1|",
"based",
"on",
"|EQD1|",
"and",
"|TInd|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L172-L184 | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | KD2.update | def update(self):
"""Update |KD2| based on |EQD2| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqd2(0.1)
>>> tind.value = 10.0
>>> derived.kd2.update()
>>> derived.kd2
kd2(1.0)
"""
con = self.subpars.pars.co... | python | def update(self):
"""Update |KD2| based on |EQD2| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqd2(0.1)
>>> tind.value = 10.0
>>> derived.kd2.update()
>>> derived.kd2
kd2(1.0)
"""
con = self.subpars.pars.co... | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"con",
".",
"eqd2",
"*",
"con",
".",
"tind",
")"
] | Update |KD2| based on |EQD2| and |TInd|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> eqd2(0.1)
>>> tind.value = 10.0
>>> derived.kd2.update()
>>> derived.kd2
kd2(1.0) | [
"Update",
"|KD2|",
"based",
"on",
"|EQD2|",
"and",
"|TInd|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L192-L204 | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | QFactor.update | def update(self):
"""Update |QFactor| based on |FT| and the current simulation step size.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> simulationstep('1d')
>>> ft(10.0)
>>> derived.qfactor.update()
>>> derived.qfactor
qfactor(0.115741)... | python | def update(self):
"""Update |QFactor| based on |FT| and the current simulation step size.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> simulationstep('1d')
>>> ft(10.0)
>>> derived.qfactor.update()
>>> derived.qfactor
qfactor(0.115741)... | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"con",
".",
"ft",
"*",
"1000.",
"/",
"self",
".",
"simulationstep",
".",
"seconds",
")"
] | Update |QFactor| based on |FT| and the current simulation step size.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> simulationstep('1d')
>>> ft(10.0)
>>> derived.qfactor.update()
>>> derived.qfactor
qfactor(0.115741) | [
"Update",
"|QFactor|",
"based",
"on",
"|FT|",
"and",
"the",
"current",
"simulation",
"step",
"size",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L211-L223 | train |
hydpy-dev/hydpy | hydpy/auxs/networktools.py | RiverBasinNumbers2Selection._router_numbers | def _router_numbers(self):
"""A tuple of the numbers of all "routing" basins."""
return tuple(up for up in self._up2down.keys()
if up in self._up2down.values()) | python | def _router_numbers(self):
"""A tuple of the numbers of all "routing" basins."""
return tuple(up for up in self._up2down.keys()
if up in self._up2down.values()) | [
"def",
"_router_numbers",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"up",
"for",
"up",
"in",
"self",
".",
"_up2down",
".",
"keys",
"(",
")",
"if",
"up",
"in",
"self",
".",
"_up2down",
".",
"values",
"(",
")",
")"
] | A tuple of the numbers of all "routing" basins. | [
"A",
"tuple",
"of",
"the",
"numbers",
"of",
"all",
"routing",
"basins",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/networktools.py#L268-L271 | train |
hydpy-dev/hydpy | hydpy/auxs/networktools.py | RiverBasinNumbers2Selection.supplier_elements | def supplier_elements(self):
"""A |Elements| collection of all "supplying" basins.
(All river basins are assumed to supply something to the downstream
basin.)
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... ... | python | def supplier_elements(self):
"""A |Elements| collection of all "supplying" basins.
(All river basins are assumed to supply something to the downstream
basin.)
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... ... | [
"def",
"supplier_elements",
"(",
"self",
")",
":",
"elements",
"=",
"devicetools",
".",
"Elements",
"(",
")",
"for",
"supplier",
"in",
"self",
".",
"_supplier_numbers",
":",
"element",
"=",
"self",
".",
"_get_suppliername",
"(",
"supplier",
")",
"try",
":",
... | A |Elements| collection of all "supplying" basins.
(All river basins are assumed to supply something to the downstream
basin.)
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... (111, 113, 1129, 11269, 1125... | [
"A",
"|Elements|",
"collection",
"of",
"all",
"supplying",
"basins",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/networktools.py#L283-L340 | train |
hydpy-dev/hydpy | hydpy/auxs/networktools.py | RiverBasinNumbers2Selection.router_elements | def router_elements(self):
"""A |Elements| collection of all "routing" basins.
(Only river basins with a upstream basin are assumed to route
something to the downstream basin.)
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
.... | python | def router_elements(self):
"""A |Elements| collection of all "routing" basins.
(Only river basins with a upstream basin are assumed to route
something to the downstream basin.)
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
.... | [
"def",
"router_elements",
"(",
"self",
")",
":",
"elements",
"=",
"devicetools",
".",
"Elements",
"(",
")",
"for",
"router",
"in",
"self",
".",
"_router_numbers",
":",
"element",
"=",
"self",
".",
"_get_routername",
"(",
"router",
")",
"inlet",
"=",
"self"... | A |Elements| collection of all "routing" basins.
(Only river basins with a upstream basin are assumed to route
something to the downstream basin.)
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... (111, 11... | [
"A",
"|Elements|",
"collection",
"of",
"all",
"routing",
"basins",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/networktools.py#L343-L394 | train |
hydpy-dev/hydpy | hydpy/auxs/networktools.py | RiverBasinNumbers2Selection.nodes | def nodes(self):
"""A |Nodes| collection of all required nodes.
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... (111, 113, 1129, 11269, 1125, 11261,
... 11262, 1123, 1124, 1122... | python | def nodes(self):
"""A |Nodes| collection of all required nodes.
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... (111, 113, 1129, 11269, 1125, 11261,
... 11262, 1123, 1124, 1122... | [
"def",
"nodes",
"(",
"self",
")",
":",
"return",
"(",
"devicetools",
".",
"Nodes",
"(",
"self",
".",
"node_prefix",
"+",
"routers",
"for",
"routers",
"in",
"self",
".",
"_router_numbers",
")",
"+",
"devicetools",
".",
"Node",
"(",
"self",
".",
"last_node... | A |Nodes| collection of all required nodes.
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... (111, 113, 1129, 11269, 1125, 11261,
... 11262, 1123, 1124, 1122, 1121))
Note that ... | [
"A",
"|Nodes|",
"collection",
"of",
"all",
"required",
"nodes",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/networktools.py#L402-L427 | train |
hydpy-dev/hydpy | hydpy/auxs/networktools.py | RiverBasinNumbers2Selection.selection | def selection(self):
"""A complete |Selection| object of all "supplying" and "routing"
elements and required nodes.
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... (111, 113, 1129, 11269, 1125, 11261,
... | python | def selection(self):
"""A complete |Selection| object of all "supplying" and "routing"
elements and required nodes.
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... (111, 113, 1129, 11269, 1125, 11261,
... | [
"def",
"selection",
"(",
"self",
")",
":",
"return",
"selectiontools",
".",
"Selection",
"(",
"self",
".",
"selection_name",
",",
"self",
".",
"nodes",
",",
"self",
".",
"elements",
")"
] | A complete |Selection| object of all "supplying" and "routing"
elements and required nodes.
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... (111, 113, 1129, 11269, 1125, 11261,
... ... | [
"A",
"complete",
"|Selection|",
"object",
"of",
"all",
"supplying",
"and",
"routing",
"elements",
"and",
"required",
"nodes",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/networktools.py#L430-L460 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | str2chars | def str2chars(strings) -> numpy.ndarray:
"""Return |numpy.ndarray| containing the byte characters (second axis)
of all given strings (first axis).
>>> from hydpy.core.netcdftools import str2chars
>>> str2chars(['zeros', 'ones'])
array([[b'z', b'e', b'r', b'o', b's'],
[b'o', b'n', b'e', b... | python | def str2chars(strings) -> numpy.ndarray:
"""Return |numpy.ndarray| containing the byte characters (second axis)
of all given strings (first axis).
>>> from hydpy.core.netcdftools import str2chars
>>> str2chars(['zeros', 'ones'])
array([[b'z', b'e', b'r', b'o', b's'],
[b'o', b'n', b'e', b... | [
"def",
"str2chars",
"(",
"strings",
")",
"->",
"numpy",
".",
"ndarray",
":",
"maxlen",
"=",
"0",
"for",
"name",
"in",
"strings",
":",
"maxlen",
"=",
"max",
"(",
"maxlen",
",",
"len",
"(",
"name",
")",
")",
"# noinspection PyTypeChecker",
"chars",
"=",
... | Return |numpy.ndarray| containing the byte characters (second axis)
of all given strings (first axis).
>>> from hydpy.core.netcdftools import str2chars
>>> str2chars(['zeros', 'ones'])
array([[b'z', b'e', b'r', b'o', b's'],
[b'o', b'n', b'e', b's', b'']],
dtype='|S1')
>>> str2... | [
"Return",
"|numpy",
".",
"ndarray|",
"containing",
"the",
"byte",
"characters",
"(",
"second",
"axis",
")",
"of",
"all",
"given",
"strings",
"(",
"first",
"axis",
")",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L261-L284 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | chars2str | def chars2str(chars) -> List[str]:
"""Inversion function of function |str2chars|.
>>> from hydpy.core.netcdftools import chars2str
>>> chars2str([[b'z', b'e', b'r', b'o', b's'],
... [b'o', b'n', b'e', b's', b'']])
['zeros', 'ones']
>>> chars2str([])
[]
"""
strings = col... | python | def chars2str(chars) -> List[str]:
"""Inversion function of function |str2chars|.
>>> from hydpy.core.netcdftools import chars2str
>>> chars2str([[b'z', b'e', b'r', b'o', b's'],
... [b'o', b'n', b'e', b's', b'']])
['zeros', 'ones']
>>> chars2str([])
[]
"""
strings = col... | [
"def",
"chars2str",
"(",
"chars",
")",
"->",
"List",
"[",
"str",
"]",
":",
"strings",
"=",
"collections",
".",
"deque",
"(",
")",
"for",
"subchars",
"in",
"chars",
":",
"substrings",
"=",
"collections",
".",
"deque",
"(",
")",
"for",
"char",
"in",
"s... | Inversion function of function |str2chars|.
>>> from hydpy.core.netcdftools import chars2str
>>> chars2str([[b'z', b'e', b'r', b'o', b's'],
... [b'o', b'n', b'e', b's', b'']])
['zeros', 'ones']
>>> chars2str([])
[] | [
"Inversion",
"function",
"of",
"function",
"|str2chars|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L287-L308 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | create_dimension | def create_dimension(ncfile, name, length) -> None:
"""Add a new dimension with the given name and length to the given
NetCDF file.
Essentially, |create_dimension| just calls the equally named method
of the NetCDF library, but adds information to possible error messages:
>>> from hydpy import Test... | python | def create_dimension(ncfile, name, length) -> None:
"""Add a new dimension with the given name and length to the given
NetCDF file.
Essentially, |create_dimension| just calls the equally named method
of the NetCDF library, but adds information to possible error messages:
>>> from hydpy import Test... | [
"def",
"create_dimension",
"(",
"ncfile",
",",
"name",
",",
"length",
")",
"->",
"None",
":",
"try",
":",
"ncfile",
".",
"createDimension",
"(",
"name",
",",
"length",
")",
"except",
"BaseException",
":",
"objecttools",
".",
"augment_excmessage",
"(",
"'Whil... | Add a new dimension with the given name and length to the given
NetCDF file.
Essentially, |create_dimension| just calls the equally named method
of the NetCDF library, but adds information to possible error messages:
>>> from hydpy import TestIO
>>> from hydpy.core.netcdftools import netcdf4
>... | [
"Add",
"a",
"new",
"dimension",
"with",
"the",
"given",
"name",
"and",
"length",
"to",
"the",
"given",
"NetCDF",
"file",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L311-L343 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | create_variable | def create_variable(ncfile, name, datatype, dimensions) -> None:
"""Add a new variable with the given name, datatype, and dimensions
to the given NetCDF file.
Essentially, |create_variable| just calls the equally named method
of the NetCDF library, but adds information to possible error messages:
... | python | def create_variable(ncfile, name, datatype, dimensions) -> None:
"""Add a new variable with the given name, datatype, and dimensions
to the given NetCDF file.
Essentially, |create_variable| just calls the equally named method
of the NetCDF library, but adds information to possible error messages:
... | [
"def",
"create_variable",
"(",
"ncfile",
",",
"name",
",",
"datatype",
",",
"dimensions",
")",
"->",
"None",
":",
"default",
"=",
"fillvalue",
"if",
"(",
"datatype",
"==",
"'f8'",
")",
"else",
"None",
"try",
":",
"ncfile",
".",
"createVariable",
"(",
"na... | Add a new variable with the given name, datatype, and dimensions
to the given NetCDF file.
Essentially, |create_variable| just calls the equally named method
of the NetCDF library, but adds information to possible error messages:
>>> from hydpy import TestIO
>>> from hydpy.core.netcdftools import ... | [
"Add",
"a",
"new",
"variable",
"with",
"the",
"given",
"name",
"datatype",
"and",
"dimensions",
"to",
"the",
"given",
"NetCDF",
"file",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L346-L384 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | query_variable | def query_variable(ncfile, name) -> netcdf4.Variable:
"""Return the variable with the given name from the given NetCDF file.
Essentially, |query_variable| just performs a key assess via the
used NetCDF library, but adds information to possible error messages:
>>> from hydpy.core.netcdftools import que... | python | def query_variable(ncfile, name) -> netcdf4.Variable:
"""Return the variable with the given name from the given NetCDF file.
Essentially, |query_variable| just performs a key assess via the
used NetCDF library, but adds information to possible error messages:
>>> from hydpy.core.netcdftools import que... | [
"def",
"query_variable",
"(",
"ncfile",
",",
"name",
")",
"->",
"netcdf4",
".",
"Variable",
":",
"try",
":",
"return",
"ncfile",
"[",
"name",
"]",
"except",
"(",
"IndexError",
",",
"KeyError",
")",
":",
"raise",
"OSError",
"(",
"'NetCDF file `%s` does not co... | Return the variable with the given name from the given NetCDF file.
Essentially, |query_variable| just performs a key assess via the
used NetCDF library, but adds information to possible error messages:
>>> from hydpy.core.netcdftools import query_variable
>>> from hydpy import TestIO
>>> from hyd... | [
"Return",
"the",
"variable",
"with",
"the",
"given",
"name",
"from",
"the",
"given",
"NetCDF",
"file",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L387-L415 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | query_timegrid | def query_timegrid(ncfile) -> timetools.Timegrid:
"""Return the |Timegrid| defined by the given NetCDF file.
>>> from hydpy.core.examples import prepare_full_example_1
>>> prepare_full_example_1()
>>> from hydpy import TestIO
>>> from hydpy.core.netcdftools import netcdf4
>>> from hydpy.core.ne... | python | def query_timegrid(ncfile) -> timetools.Timegrid:
"""Return the |Timegrid| defined by the given NetCDF file.
>>> from hydpy.core.examples import prepare_full_example_1
>>> prepare_full_example_1()
>>> from hydpy import TestIO
>>> from hydpy.core.netcdftools import netcdf4
>>> from hydpy.core.ne... | [
"def",
"query_timegrid",
"(",
"ncfile",
")",
"->",
"timetools",
".",
"Timegrid",
":",
"timepoints",
"=",
"ncfile",
"[",
"varmapping",
"[",
"'timepoints'",
"]",
"]",
"refdate",
"=",
"timetools",
".",
"Date",
".",
"from_cfunits",
"(",
"timepoints",
".",
"units... | Return the |Timegrid| defined by the given NetCDF file.
>>> from hydpy.core.examples import prepare_full_example_1
>>> prepare_full_example_1()
>>> from hydpy import TestIO
>>> from hydpy.core.netcdftools import netcdf4
>>> from hydpy.core.netcdftools import query_timegrid
>>> filepath = 'LahnH... | [
"Return",
"the",
"|Timegrid|",
"defined",
"by",
"the",
"given",
"NetCDF",
"file",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L418-L439 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | query_array | def query_array(ncfile, name) -> numpy.ndarray:
"""Return the data of the variable with the given name from the given
NetCDF file.
The following example shows that |query_array| returns |nan| entries
to represent missing values even when the respective NetCDF variable
defines a different fill value... | python | def query_array(ncfile, name) -> numpy.ndarray:
"""Return the data of the variable with the given name from the given
NetCDF file.
The following example shows that |query_array| returns |nan| entries
to represent missing values even when the respective NetCDF variable
defines a different fill value... | [
"def",
"query_array",
"(",
"ncfile",
",",
"name",
")",
"->",
"numpy",
".",
"ndarray",
":",
"variable",
"=",
"query_variable",
"(",
"ncfile",
",",
"name",
")",
"maskedarray",
"=",
"variable",
"[",
":",
"]",
"fillvalue_",
"=",
"getattr",
"(",
"variable",
"... | Return the data of the variable with the given name from the given
NetCDF file.
The following example shows that |query_array| returns |nan| entries
to represent missing values even when the respective NetCDF variable
defines a different fill value:
>>> from hydpy import TestIO
>>> from hydpy.... | [
"Return",
"the",
"data",
"of",
"the",
"variable",
"with",
"the",
"given",
"name",
"from",
"the",
"given",
"NetCDF",
"file",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L442-L471 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFInterface.log | def log(self, sequence, infoarray) -> None:
"""Prepare a |NetCDFFile| object suitable for the given |IOSequence|
object, when necessary, and pass the given arguments to its
|NetCDFFile.log| method."""
if isinstance(sequence, sequencetools.ModelSequence):
descr = sequence.desc... | python | def log(self, sequence, infoarray) -> None:
"""Prepare a |NetCDFFile| object suitable for the given |IOSequence|
object, when necessary, and pass the given arguments to its
|NetCDFFile.log| method."""
if isinstance(sequence, sequencetools.ModelSequence):
descr = sequence.desc... | [
"def",
"log",
"(",
"self",
",",
"sequence",
",",
"infoarray",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"sequence",
",",
"sequencetools",
".",
"ModelSequence",
")",
":",
"descr",
"=",
"sequence",
".",
"descr_model",
"else",
":",
"descr",
"=",
"'no... | Prepare a |NetCDFFile| object suitable for the given |IOSequence|
object, when necessary, and pass the given arguments to its
|NetCDFFile.log| method. | [
"Prepare",
"a",
"|NetCDFFile|",
"object",
"suitable",
"for",
"the",
"given",
"|IOSequence|",
"object",
"when",
"necessary",
"and",
"pass",
"the",
"given",
"arguments",
"to",
"its",
"|NetCDFFile",
".",
"log|",
"method",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L662-L691 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFInterface.read | def read(self) -> None:
"""Call method |NetCDFFile.read| of all handled |NetCDFFile| objects.
"""
for folder in self.folders.values():
for file_ in folder.values():
file_.read() | python | def read(self) -> None:
"""Call method |NetCDFFile.read| of all handled |NetCDFFile| objects.
"""
for folder in self.folders.values():
for file_ in folder.values():
file_.read() | [
"def",
"read",
"(",
"self",
")",
"->",
"None",
":",
"for",
"folder",
"in",
"self",
".",
"folders",
".",
"values",
"(",
")",
":",
"for",
"file_",
"in",
"folder",
".",
"values",
"(",
")",
":",
"file_",
".",
"read",
"(",
")"
] | Call method |NetCDFFile.read| of all handled |NetCDFFile| objects. | [
"Call",
"method",
"|NetCDFFile",
".",
"read|",
"of",
"all",
"handled",
"|NetCDFFile|",
"objects",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L693-L698 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFInterface.write | def write(self) -> None:
"""Call method |NetCDFFile.write| of all handled |NetCDFFile| objects.
"""
if self.folders:
init = hydpy.pub.timegrids.init
timeunits = init.firstdate.to_cfunits('hours')
timepoints = init.to_timepoints('hours')
for folder ... | python | def write(self) -> None:
"""Call method |NetCDFFile.write| of all handled |NetCDFFile| objects.
"""
if self.folders:
init = hydpy.pub.timegrids.init
timeunits = init.firstdate.to_cfunits('hours')
timepoints = init.to_timepoints('hours')
for folder ... | [
"def",
"write",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"folders",
":",
"init",
"=",
"hydpy",
".",
"pub",
".",
"timegrids",
".",
"init",
"timeunits",
"=",
"init",
".",
"firstdate",
".",
"to_cfunits",
"(",
"'hours'",
")",
"timepoints",
... | Call method |NetCDFFile.write| of all handled |NetCDFFile| objects. | [
"Call",
"method",
"|NetCDFFile",
".",
"write|",
"of",
"all",
"handled",
"|NetCDFFile|",
"objects",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L700-L709 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFInterface.filenames | def filenames(self) -> Tuple[str, ...]:
"""A |tuple| of names of all handled |NetCDFFile| objects."""
return tuple(sorted(set(itertools.chain(
*(_.keys() for _ in self.folders.values()))))) | python | def filenames(self) -> Tuple[str, ...]:
"""A |tuple| of names of all handled |NetCDFFile| objects."""
return tuple(sorted(set(itertools.chain(
*(_.keys() for _ in self.folders.values()))))) | [
"def",
"filenames",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"return",
"tuple",
"(",
"sorted",
"(",
"set",
"(",
"itertools",
".",
"chain",
"(",
"*",
"(",
"_",
".",
"keys",
"(",
")",
"for",
"_",
"in",
"self",
".",
"fold... | A |tuple| of names of all handled |NetCDFFile| objects. | [
"A",
"|tuple|",
"of",
"names",
"of",
"all",
"handled",
"|NetCDFFile|",
"objects",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L718-L721 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFFile.log | def log(self, sequence, infoarray) -> None:
"""Pass the given |IoSequence| to a suitable instance of
a |NetCDFVariableBase| subclass.
When writing data, the second argument should be an |InfoArray|.
When reading data, this argument is ignored. Simply pass |None|.
(1) We prepare... | python | def log(self, sequence, infoarray) -> None:
"""Pass the given |IoSequence| to a suitable instance of
a |NetCDFVariableBase| subclass.
When writing data, the second argument should be an |InfoArray|.
When reading data, this argument is ignored. Simply pass |None|.
(1) We prepare... | [
"def",
"log",
"(",
"self",
",",
"sequence",
",",
"infoarray",
")",
"->",
"None",
":",
"aggregated",
"=",
"(",
"(",
"infoarray",
"is",
"not",
"None",
")",
"and",
"(",
"infoarray",
".",
"info",
"[",
"'type'",
"]",
"!=",
"'unmodified'",
")",
")",
"descr... | Pass the given |IoSequence| to a suitable instance of
a |NetCDFVariableBase| subclass.
When writing data, the second argument should be an |InfoArray|.
When reading data, this argument is ignored. Simply pass |None|.
(1) We prepare some devices handling some sequences by applying
... | [
"Pass",
"the",
"given",
"|IoSequence|",
"to",
"a",
"suitable",
"instance",
"of",
"a",
"|NetCDFVariableBase|",
"subclass",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L845-L970 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFFile.filepath | def filepath(self) -> str:
"""The NetCDF file path."""
return os.path.join(self._dirpath, self.name + '.nc') | python | def filepath(self) -> str:
"""The NetCDF file path."""
return os.path.join(self._dirpath, self.name + '.nc') | [
"def",
"filepath",
"(",
"self",
")",
"->",
"str",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_dirpath",
",",
"self",
".",
"name",
"+",
"'.nc'",
")"
] | The NetCDF file path. | [
"The",
"NetCDF",
"file",
"path",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L973-L975 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFFile.read | def read(self) -> None:
"""Open an existing NetCDF file temporarily and call method
|NetCDFVariableDeep.read| of all handled |NetCDFVariableBase|
objects."""
try:
with netcdf4.Dataset(self.filepath, "r") as ncfile:
timegrid = query_timegrid(ncfile)
... | python | def read(self) -> None:
"""Open an existing NetCDF file temporarily and call method
|NetCDFVariableDeep.read| of all handled |NetCDFVariableBase|
objects."""
try:
with netcdf4.Dataset(self.filepath, "r") as ncfile:
timegrid = query_timegrid(ncfile)
... | [
"def",
"read",
"(",
"self",
")",
"->",
"None",
":",
"try",
":",
"with",
"netcdf4",
".",
"Dataset",
"(",
"self",
".",
"filepath",
",",
"\"r\"",
")",
"as",
"ncfile",
":",
"timegrid",
"=",
"query_timegrid",
"(",
"ncfile",
")",
"for",
"variable",
"in",
"... | Open an existing NetCDF file temporarily and call method
|NetCDFVariableDeep.read| of all handled |NetCDFVariableBase|
objects. | [
"Open",
"an",
"existing",
"NetCDF",
"file",
"temporarily",
"and",
"call",
"method",
"|NetCDFVariableDeep",
".",
"read|",
"of",
"all",
"handled",
"|NetCDFVariableBase|",
"objects",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L977-L988 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFFile.write | def write(self, timeunit, timepoints) -> None:
"""Open a new NetCDF file temporarily and call method
|NetCDFVariableBase.write| of all handled |NetCDFVariableBase|
objects."""
with netcdf4.Dataset(self.filepath, "w") as ncfile:
ncfile.Conventions = 'CF-1.6'
self._... | python | def write(self, timeunit, timepoints) -> None:
"""Open a new NetCDF file temporarily and call method
|NetCDFVariableBase.write| of all handled |NetCDFVariableBase|
objects."""
with netcdf4.Dataset(self.filepath, "w") as ncfile:
ncfile.Conventions = 'CF-1.6'
self._... | [
"def",
"write",
"(",
"self",
",",
"timeunit",
",",
"timepoints",
")",
"->",
"None",
":",
"with",
"netcdf4",
".",
"Dataset",
"(",
"self",
".",
"filepath",
",",
"\"w\"",
")",
"as",
"ncfile",
":",
"ncfile",
".",
"Conventions",
"=",
"'CF-1.6'",
"self",
"."... | Open a new NetCDF file temporarily and call method
|NetCDFVariableBase.write| of all handled |NetCDFVariableBase|
objects. | [
"Open",
"a",
"new",
"NetCDF",
"file",
"temporarily",
"and",
"call",
"method",
"|NetCDFVariableBase",
".",
"write|",
"of",
"all",
"handled",
"|NetCDFVariableBase|",
"objects",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L990-L998 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | Subdevice2Index.get_index | def get_index(self, name_subdevice) -> int:
"""Item access to the wrapped |dict| object with a specialized
error message."""
try:
return self.dict_[name_subdevice]
except KeyError:
raise OSError(
'No data for sequence `%s` and (sub)device `%s` '
... | python | def get_index(self, name_subdevice) -> int:
"""Item access to the wrapped |dict| object with a specialized
error message."""
try:
return self.dict_[name_subdevice]
except KeyError:
raise OSError(
'No data for sequence `%s` and (sub)device `%s` '
... | [
"def",
"get_index",
"(",
"self",
",",
"name_subdevice",
")",
"->",
"int",
":",
"try",
":",
"return",
"self",
".",
"dict_",
"[",
"name_subdevice",
"]",
"except",
"KeyError",
":",
"raise",
"OSError",
"(",
"'No data for sequence `%s` and (sub)device `%s` '",
"'in Net... | Item access to the wrapped |dict| object with a specialized
error message. | [
"Item",
"access",
"to",
"the",
"wrapped",
"|dict|",
"object",
"with",
"a",
"specialized",
"error",
"message",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1046-L1057 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableBase.log | def log(self, sequence, infoarray) -> None:
"""Log the given |IOSequence| object either for reading or writing
data.
The optional `array` argument allows for passing alternative data
in an |InfoArray| object replacing the series of the |IOSequence|
object, which is useful for wr... | python | def log(self, sequence, infoarray) -> None:
"""Log the given |IOSequence| object either for reading or writing
data.
The optional `array` argument allows for passing alternative data
in an |InfoArray| object replacing the series of the |IOSequence|
object, which is useful for wr... | [
"def",
"log",
"(",
"self",
",",
"sequence",
",",
"infoarray",
")",
"->",
"None",
":",
"descr_device",
"=",
"sequence",
".",
"descr_device",
"self",
".",
"sequences",
"[",
"descr_device",
"]",
"=",
"sequence",
"self",
".",
"arrays",
"[",
"descr_device",
"]"... | Log the given |IOSequence| object either for reading or writing
data.
The optional `array` argument allows for passing alternative data
in an |InfoArray| object replacing the series of the |IOSequence|
object, which is useful for writing modified (e.g. spatially
averaged) time s... | [
"Log",
"the",
"given",
"|IOSequence|",
"object",
"either",
"for",
"reading",
"or",
"writing",
"data",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1096-L1130 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableBase.insert_subdevices | def insert_subdevices(self, ncfile) -> None:
"""Insert a variable of the names of the (sub)devices of the logged
sequences into the given NetCDF file
(1) We prepare a |NetCDFVariableBase| subclass with fixed
(sub)device names:
>>> from hydpy.core.netcdftools import NetCDFVariab... | python | def insert_subdevices(self, ncfile) -> None:
"""Insert a variable of the names of the (sub)devices of the logged
sequences into the given NetCDF file
(1) We prepare a |NetCDFVariableBase| subclass with fixed
(sub)device names:
>>> from hydpy.core.netcdftools import NetCDFVariab... | [
"def",
"insert_subdevices",
"(",
"self",
",",
"ncfile",
")",
"->",
"None",
":",
"prefix",
"=",
"self",
".",
"prefix",
"nmb_subdevices",
"=",
"'%s%s'",
"%",
"(",
"prefix",
",",
"dimmapping",
"[",
"'nmb_subdevices'",
"]",
")",
"nmb_characters",
"=",
"'%s%s'",
... | Insert a variable of the names of the (sub)devices of the logged
sequences into the given NetCDF file
(1) We prepare a |NetCDFVariableBase| subclass with fixed
(sub)device names:
>>> from hydpy.core.netcdftools import NetCDFVariableBase, chars2str
>>> from hydpy import make_abc... | [
"Insert",
"a",
"variable",
"of",
"the",
"names",
"of",
"the",
"(",
"sub",
")",
"devices",
"of",
"the",
"logged",
"sequences",
"into",
"the",
"given",
"NetCDF",
"file"
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1168-L1223 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableBase.query_subdevices | def query_subdevices(self, ncfile) -> List[str]:
"""Query the names of the (sub)devices of the logged sequences
from the given NetCDF file
(1) We apply function |NetCDFVariableBase.query_subdevices| on
an empty NetCDF file. The error message shows that the method
tries to query... | python | def query_subdevices(self, ncfile) -> List[str]:
"""Query the names of the (sub)devices of the logged sequences
from the given NetCDF file
(1) We apply function |NetCDFVariableBase.query_subdevices| on
an empty NetCDF file. The error message shows that the method
tries to query... | [
"def",
"query_subdevices",
"(",
"self",
",",
"ncfile",
")",
"->",
"List",
"[",
"str",
"]",
":",
"tests",
"=",
"[",
"'%s%s'",
"%",
"(",
"prefix",
",",
"varmapping",
"[",
"'subdevices'",
"]",
")",
"for",
"prefix",
"in",
"(",
"'%s_'",
"%",
"self",
".",
... | Query the names of the (sub)devices of the logged sequences
from the given NetCDF file
(1) We apply function |NetCDFVariableBase.query_subdevices| on
an empty NetCDF file. The error message shows that the method
tries to query the (sub)device names both under the assumptions
th... | [
"Query",
"the",
"names",
"of",
"the",
"(",
"sub",
")",
"devices",
"of",
"the",
"logged",
"sequences",
"from",
"the",
"given",
"NetCDF",
"file"
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1225-L1274 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableBase.query_subdevice2index | def query_subdevice2index(self, ncfile) -> Subdevice2Index:
"""Return a |Subdevice2Index| that maps the (sub)device names to
their position within the given NetCDF file.
Method |NetCDFVariableBase.query_subdevice2index| is based on
|NetCDFVariableBase.query_subdevices|. The returned
... | python | def query_subdevice2index(self, ncfile) -> Subdevice2Index:
"""Return a |Subdevice2Index| that maps the (sub)device names to
their position within the given NetCDF file.
Method |NetCDFVariableBase.query_subdevice2index| is based on
|NetCDFVariableBase.query_subdevices|. The returned
... | [
"def",
"query_subdevice2index",
"(",
"self",
",",
"ncfile",
")",
"->",
"Subdevice2Index",
":",
"subdevices",
"=",
"self",
".",
"query_subdevices",
"(",
"ncfile",
")",
"self",
".",
"_test_duplicate_exists",
"(",
"ncfile",
",",
"subdevices",
")",
"subdev2index",
"... | Return a |Subdevice2Index| that maps the (sub)device names to
their position within the given NetCDF file.
Method |NetCDFVariableBase.query_subdevice2index| is based on
|NetCDFVariableBase.query_subdevices|. The returned
|Subdevice2Index| object remembers the NetCDF file the
(s... | [
"Return",
"a",
"|Subdevice2Index|",
"that",
"maps",
"the",
"(",
"sub",
")",
"device",
"names",
"to",
"their",
"position",
"within",
"the",
"given",
"NetCDF",
"file",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1276-L1322 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableBase.sort_timeplaceentries | def sort_timeplaceentries(self, timeentry, placeentry) -> Tuple[Any, Any]:
"""Return a |tuple| containing the given `timeentry` and `placeentry`
sorted in agreement with the currently selected `timeaxis`.
>>> from hydpy.core.netcdftools import NetCDFVariableBase
>>> from hydpy import ma... | python | def sort_timeplaceentries(self, timeentry, placeentry) -> Tuple[Any, Any]:
"""Return a |tuple| containing the given `timeentry` and `placeentry`
sorted in agreement with the currently selected `timeaxis`.
>>> from hydpy.core.netcdftools import NetCDFVariableBase
>>> from hydpy import ma... | [
"def",
"sort_timeplaceentries",
"(",
"self",
",",
"timeentry",
",",
"placeentry",
")",
"->",
"Tuple",
"[",
"Any",
",",
"Any",
"]",
":",
"if",
"self",
".",
"_timeaxis",
":",
"return",
"placeentry",
",",
"timeentry",
"return",
"timeentry",
",",
"placeentry"
] | Return a |tuple| containing the given `timeentry` and `placeentry`
sorted in agreement with the currently selected `timeaxis`.
>>> from hydpy.core.netcdftools import NetCDFVariableBase
>>> from hydpy import make_abc_testable
>>> NCVar = make_abc_testable(NetCDFVariableBase)
>>> ... | [
"Return",
"a",
"|tuple|",
"containing",
"the",
"given",
"timeentry",
"and",
"placeentry",
"sorted",
"in",
"agreement",
"with",
"the",
"currently",
"selected",
"timeaxis",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1335-L1351 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableBase.get_timeplaceslice | def get_timeplaceslice(self, placeindex) -> \
Union[Tuple[slice, int], Tuple[int, slice]]:
"""Return a |tuple| for indexing a complete time series of a certain
location available in |NetCDFVariableBase.array|.
>>> from hydpy.core.netcdftools import NetCDFVariableBase
>>> fro... | python | def get_timeplaceslice(self, placeindex) -> \
Union[Tuple[slice, int], Tuple[int, slice]]:
"""Return a |tuple| for indexing a complete time series of a certain
location available in |NetCDFVariableBase.array|.
>>> from hydpy.core.netcdftools import NetCDFVariableBase
>>> fro... | [
"def",
"get_timeplaceslice",
"(",
"self",
",",
"placeindex",
")",
"->",
"Union",
"[",
"Tuple",
"[",
"slice",
",",
"int",
"]",
",",
"Tuple",
"[",
"int",
",",
"slice",
"]",
"]",
":",
"return",
"self",
".",
"sort_timeplaceentries",
"(",
"slice",
"(",
"Non... | Return a |tuple| for indexing a complete time series of a certain
location available in |NetCDFVariableBase.array|.
>>> from hydpy.core.netcdftools import NetCDFVariableBase
>>> from hydpy import make_abc_testable
>>> NCVar = make_abc_testable(NetCDFVariableBase)
>>> ncvar = NCV... | [
"Return",
"a",
"|tuple|",
"for",
"indexing",
"a",
"complete",
"time",
"series",
"of",
"a",
"certain",
"location",
"available",
"in",
"|NetCDFVariableBase",
".",
"array|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1353-L1368 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | DeepAndAggMixin.subdevicenames | def subdevicenames(self) -> Tuple[str, ...]:
"""A |tuple| containing the device names."""
self: NetCDFVariableBase
return tuple(self.sequences.keys()) | python | def subdevicenames(self) -> Tuple[str, ...]:
"""A |tuple| containing the device names."""
self: NetCDFVariableBase
return tuple(self.sequences.keys()) | [
"def",
"subdevicenames",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"self",
":",
"NetCDFVariableBase",
"return",
"tuple",
"(",
"self",
".",
"sequences",
".",
"keys",
"(",
")",
")"
] | A |tuple| containing the device names. | [
"A",
"|tuple|",
"containing",
"the",
"device",
"names",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1396-L1399 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | DeepAndAggMixin.write | def write(self, ncfile) -> None:
"""Write the data to the given NetCDF file.
See the general documentation on classes |NetCDFVariableDeep|
and |NetCDFVariableAgg| for some examples.
"""
self: NetCDFVariableBase
self.insert_subdevices(ncfile)
dimensions = self.dim... | python | def write(self, ncfile) -> None:
"""Write the data to the given NetCDF file.
See the general documentation on classes |NetCDFVariableDeep|
and |NetCDFVariableAgg| for some examples.
"""
self: NetCDFVariableBase
self.insert_subdevices(ncfile)
dimensions = self.dim... | [
"def",
"write",
"(",
"self",
",",
"ncfile",
")",
"->",
"None",
":",
"self",
":",
"NetCDFVariableBase",
"self",
".",
"insert_subdevices",
"(",
"ncfile",
")",
"dimensions",
"=",
"self",
".",
"dimensions",
"array",
"=",
"self",
".",
"array",
"for",
"dimension... | Write the data to the given NetCDF file.
See the general documentation on classes |NetCDFVariableDeep|
and |NetCDFVariableAgg| for some examples. | [
"Write",
"the",
"data",
"to",
"the",
"given",
"NetCDF",
"file",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1401-L1414 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | AggAndFlatMixin.dimensions | def dimensions(self) -> Tuple[str, ...]:
"""The dimension names of the NetCDF variable.
Usually, the string defined by property |IOSequence.descr_sequence|
prefixes the first dimension name related to the location, which
allows storing different sequences types in one NetCDF file:
... | python | def dimensions(self) -> Tuple[str, ...]:
"""The dimension names of the NetCDF variable.
Usually, the string defined by property |IOSequence.descr_sequence|
prefixes the first dimension name related to the location, which
allows storing different sequences types in one NetCDF file:
... | [
"def",
"dimensions",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"self",
":",
"NetCDFVariableBase",
"return",
"self",
".",
"sort_timeplaceentries",
"(",
"dimmapping",
"[",
"'nmb_timepoints'",
"]",
",",
"'%s%s'",
"%",
"(",
"self",
"."... | The dimension names of the NetCDF variable.
Usually, the string defined by property |IOSequence.descr_sequence|
prefixes the first dimension name related to the location, which
allows storing different sequences types in one NetCDF file:
>>> from hydpy.core.examples import prepare_io_e... | [
"The",
"dimension",
"names",
"of",
"the",
"NetCDF",
"variable",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1421-L1455 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableDeep.get_slices | def get_slices(self, idx, shape) -> Tuple[IntOrSlice, ...]:
"""Return a |tuple| of one |int| and some |slice| objects to
accesses all values of a certain device within
|NetCDFVariableDeep.array|.
>>> from hydpy.core.netcdftools import NetCDFVariableDeep
>>> ncvar = NetCDFVariabl... | python | def get_slices(self, idx, shape) -> Tuple[IntOrSlice, ...]:
"""Return a |tuple| of one |int| and some |slice| objects to
accesses all values of a certain device within
|NetCDFVariableDeep.array|.
>>> from hydpy.core.netcdftools import NetCDFVariableDeep
>>> ncvar = NetCDFVariabl... | [
"def",
"get_slices",
"(",
"self",
",",
"idx",
",",
"shape",
")",
"->",
"Tuple",
"[",
"IntOrSlice",
",",
"...",
"]",
":",
"slices",
"=",
"list",
"(",
"self",
".",
"get_timeplaceslice",
"(",
"idx",
")",
")",
"for",
"length",
"in",
"shape",
":",
"slices... | Return a |tuple| of one |int| and some |slice| objects to
accesses all values of a certain device within
|NetCDFVariableDeep.array|.
>>> from hydpy.core.netcdftools import NetCDFVariableDeep
>>> ncvar = NetCDFVariableDeep('test', isolate=False, timeaxis=1)
>>> ncvar.get_slices(2... | [
"Return",
"a",
"|tuple|",
"of",
"one",
"|int|",
"and",
"some",
"|slice|",
"objects",
"to",
"accesses",
"all",
"values",
"of",
"a",
"certain",
"device",
"within",
"|NetCDFVariableDeep",
".",
"array|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1584-L1602 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableDeep.shape | def shape(self) -> Tuple[int, ...]:
"""Required shape of |NetCDFVariableDeep.array|.
For the default configuration, the first axis corresponds to the
number of devices, and the second one to the number of timesteps.
We show this for the 0-dimensional input sequence |lland_inputs.Nied|:
... | python | def shape(self) -> Tuple[int, ...]:
"""Required shape of |NetCDFVariableDeep.array|.
For the default configuration, the first axis corresponds to the
number of devices, and the second one to the number of timesteps.
We show this for the 0-dimensional input sequence |lland_inputs.Nied|:
... | [
"def",
"shape",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"...",
"]",
":",
"nmb_place",
"=",
"len",
"(",
"self",
".",
"sequences",
")",
"nmb_time",
"=",
"len",
"(",
"hydpy",
".",
"pub",
".",
"timegrids",
".",
"init",
")",
"nmb_others",
"=",... | Required shape of |NetCDFVariableDeep.array|.
For the default configuration, the first axis corresponds to the
number of devices, and the second one to the number of timesteps.
We show this for the 0-dimensional input sequence |lland_inputs.Nied|:
>>> from hydpy.core.examples import pr... | [
"Required",
"shape",
"of",
"|NetCDFVariableDeep",
".",
"array|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1605-L1649 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableDeep.array | def array(self) -> numpy.ndarray:
"""The series data of all logged |IOSequence| objects contained
in one single |numpy.ndarray|.
The documentation on |NetCDFVariableDeep.shape| explains how
|NetCDFVariableDeep.array| is structured. The first example
confirms that, for the defau... | python | def array(self) -> numpy.ndarray:
"""The series data of all logged |IOSequence| objects contained
in one single |numpy.ndarray|.
The documentation on |NetCDFVariableDeep.shape| explains how
|NetCDFVariableDeep.array| is structured. The first example
confirms that, for the defau... | [
"def",
"array",
"(",
"self",
")",
"->",
"numpy",
".",
"ndarray",
":",
"array",
"=",
"numpy",
".",
"full",
"(",
"self",
".",
"shape",
",",
"fillvalue",
",",
"dtype",
"=",
"float",
")",
"for",
"idx",
",",
"(",
"descr",
",",
"subarray",
")",
"in",
"... | The series data of all logged |IOSequence| objects contained
in one single |numpy.ndarray|.
The documentation on |NetCDFVariableDeep.shape| explains how
|NetCDFVariableDeep.array| is structured. The first example
confirms that, for the default configuration, the first axis
defi... | [
"The",
"series",
"data",
"of",
"all",
"logged",
"|IOSequence|",
"objects",
"contained",
"in",
"one",
"single",
"|numpy",
".",
"ndarray|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1652-L1705 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableDeep.dimensions | def dimensions(self) -> Tuple[str, ...]:
"""The dimension names of the NetCDF variable.
Usually, the string defined by property |IOSequence.descr_sequence|
prefixes all dimension names except the second one related to time,
which allows storing different sequences in one NetCDF file:
... | python | def dimensions(self) -> Tuple[str, ...]:
"""The dimension names of the NetCDF variable.
Usually, the string defined by property |IOSequence.descr_sequence|
prefixes all dimension names except the second one related to time,
which allows storing different sequences in one NetCDF file:
... | [
"def",
"dimensions",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"nmb_timepoints",
"=",
"dimmapping",
"[",
"'nmb_timepoints'",
"]",
"nmb_subdevices",
"=",
"'%s%s'",
"%",
"(",
"self",
".",
"prefix",
",",
"dimmapping",
"[",
"'nmb_subde... | The dimension names of the NetCDF variable.
Usually, the string defined by property |IOSequence.descr_sequence|
prefixes all dimension names except the second one related to time,
which allows storing different sequences in one NetCDF file:
>>> from hydpy.core.examples import prepare_i... | [
"The",
"dimension",
"names",
"of",
"the",
"NetCDF",
"variable",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1708-L1745 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableDeep.read | def read(self, ncfile, timegrid_data) -> None:
"""Read the data from the given NetCDF file.
The argument `timegrid_data` defines the data period of the
given NetCDF file.
See the general documentation on class |NetCDFVariableDeep|
for some examples.
"""
array = ... | python | def read(self, ncfile, timegrid_data) -> None:
"""Read the data from the given NetCDF file.
The argument `timegrid_data` defines the data period of the
given NetCDF file.
See the general documentation on class |NetCDFVariableDeep|
for some examples.
"""
array = ... | [
"def",
"read",
"(",
"self",
",",
"ncfile",
",",
"timegrid_data",
")",
"->",
"None",
":",
"array",
"=",
"query_array",
"(",
"ncfile",
",",
"self",
".",
"name",
")",
"subdev2index",
"=",
"self",
".",
"query_subdevice2index",
"(",
"ncfile",
")",
"for",
"sub... | Read the data from the given NetCDF file.
The argument `timegrid_data` defines the data period of the
given NetCDF file.
See the general documentation on class |NetCDFVariableDeep|
for some examples. | [
"Read",
"the",
"data",
"from",
"the",
"given",
"NetCDF",
"file",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1747-L1762 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableAgg.shape | def shape(self) -> Tuple[int, int]:
"""Required shape of |NetCDFVariableAgg.array|.
For the default configuration, the first axis corresponds to the
number of devices, and the second one to the number of timesteps.
We show this for the 1-dimensional input sequence |lland_fluxes.NKor|:
... | python | def shape(self) -> Tuple[int, int]:
"""Required shape of |NetCDFVariableAgg.array|.
For the default configuration, the first axis corresponds to the
number of devices, and the second one to the number of timesteps.
We show this for the 1-dimensional input sequence |lland_fluxes.NKor|:
... | [
"def",
"shape",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"int",
"]",
":",
"return",
"self",
".",
"sort_timeplaceentries",
"(",
"len",
"(",
"hydpy",
".",
"pub",
".",
"timegrids",
".",
"init",
")",
",",
"len",
"(",
"self",
".",
"sequences",
... | Required shape of |NetCDFVariableAgg.array|.
For the default configuration, the first axis corresponds to the
number of devices, and the second one to the number of timesteps.
We show this for the 1-dimensional input sequence |lland_fluxes.NKor|:
>>> from hydpy.core.examples import pre... | [
"Required",
"shape",
"of",
"|NetCDFVariableAgg",
".",
"array|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1824-L1850 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableAgg.array | def array(self) -> numpy.ndarray:
"""The aggregated data of all logged |IOSequence| objects contained
in one single |numpy.ndarray| object.
The documentation on |NetCDFVariableAgg.shape| explains how
|NetCDFVariableAgg.array| is structured. This first example
confirms that, und... | python | def array(self) -> numpy.ndarray:
"""The aggregated data of all logged |IOSequence| objects contained
in one single |numpy.ndarray| object.
The documentation on |NetCDFVariableAgg.shape| explains how
|NetCDFVariableAgg.array| is structured. This first example
confirms that, und... | [
"def",
"array",
"(",
"self",
")",
"->",
"numpy",
".",
"ndarray",
":",
"array",
"=",
"numpy",
".",
"full",
"(",
"self",
".",
"shape",
",",
"fillvalue",
",",
"dtype",
"=",
"float",
")",
"for",
"idx",
",",
"subarray",
"in",
"enumerate",
"(",
"self",
"... | The aggregated data of all logged |IOSequence| objects contained
in one single |numpy.ndarray| object.
The documentation on |NetCDFVariableAgg.shape| explains how
|NetCDFVariableAgg.array| is structured. This first example
confirms that, under default configuration (`timeaxis=1`),
... | [
"The",
"aggregated",
"data",
"of",
"all",
"logged",
"|IOSequence|",
"objects",
"contained",
"in",
"one",
"single",
"|numpy",
".",
"ndarray|",
"object",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1853-L1891 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableFlat.shape | def shape(self) -> Tuple[int, int]:
"""Required shape of |NetCDFVariableFlat.array|.
For 0-dimensional sequences like |lland_inputs.Nied| and for the
default configuration (`timeaxis=1`), the first axis corresponds
to the number of devices, and the second one two the number of
t... | python | def shape(self) -> Tuple[int, int]:
"""Required shape of |NetCDFVariableFlat.array|.
For 0-dimensional sequences like |lland_inputs.Nied| and for the
default configuration (`timeaxis=1`), the first axis corresponds
to the number of devices, and the second one two the number of
t... | [
"def",
"shape",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"int",
"]",
":",
"return",
"self",
".",
"sort_timeplaceentries",
"(",
"len",
"(",
"hydpy",
".",
"pub",
".",
"timegrids",
".",
"init",
")",
",",
"sum",
"(",
"len",
"(",
"seq",
")",
... | Required shape of |NetCDFVariableFlat.array|.
For 0-dimensional sequences like |lland_inputs.Nied| and for the
default configuration (`timeaxis=1`), the first axis corresponds
to the number of devices, and the second one two the number of
timesteps:
>>> from hydpy.core.examples... | [
"Required",
"shape",
"of",
"|NetCDFVariableFlat",
".",
"array|",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1979-L2019 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableFlat.array | def array(self) -> numpy.ndarray:
"""The series data of all logged |IOSequence| objects contained in
one single |numpy.ndarray| object.
The documentation on |NetCDFVariableAgg.shape| explains how
|NetCDFVariableAgg.array| is structured. The first example
confirms that, under de... | python | def array(self) -> numpy.ndarray:
"""The series data of all logged |IOSequence| objects contained in
one single |numpy.ndarray| object.
The documentation on |NetCDFVariableAgg.shape| explains how
|NetCDFVariableAgg.array| is structured. The first example
confirms that, under de... | [
"def",
"array",
"(",
"self",
")",
"->",
"numpy",
".",
"ndarray",
":",
"array",
"=",
"numpy",
".",
"full",
"(",
"self",
".",
"shape",
",",
"fillvalue",
",",
"dtype",
"=",
"float",
")",
"idx0",
"=",
"0",
"idxs",
":",
"List",
"[",
"Any",
"]",
"=",
... | The series data of all logged |IOSequence| objects contained in
one single |numpy.ndarray| object.
The documentation on |NetCDFVariableAgg.shape| explains how
|NetCDFVariableAgg.array| is structured. The first example
confirms that, under default configuration (`timeaxis=1`), the
... | [
"The",
"series",
"data",
"of",
"all",
"logged",
"|IOSequence|",
"objects",
"contained",
"in",
"one",
"single",
"|numpy",
".",
"ndarray|",
"object",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L2022-L2081 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableFlat.subdevicenames | def subdevicenames(self) -> Tuple[str, ...]:
"""A |tuple| containing the (sub)device names.
Property |NetCDFVariableFlat.subdevicenames| clarifies which
row of |NetCDFVariableAgg.array| contains which time series.
For 0-dimensional series like |lland_inputs.Nied|, the plain
devi... | python | def subdevicenames(self) -> Tuple[str, ...]:
"""A |tuple| containing the (sub)device names.
Property |NetCDFVariableFlat.subdevicenames| clarifies which
row of |NetCDFVariableAgg.array| contains which time series.
For 0-dimensional series like |lland_inputs.Nied|, the plain
devi... | [
"def",
"subdevicenames",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"stats",
":",
"List",
"[",
"str",
"]",
"=",
"collections",
".",
"deque",
"(",
")",
"for",
"devicename",
",",
"seq",
"in",
"self",
".",
"sequences",
".",
"it... | A |tuple| containing the (sub)device names.
Property |NetCDFVariableFlat.subdevicenames| clarifies which
row of |NetCDFVariableAgg.array| contains which time series.
For 0-dimensional series like |lland_inputs.Nied|, the plain
device names are returned
>>> from hydpy.core.examp... | [
"A",
"|tuple|",
"containing",
"the",
"(",
"sub",
")",
"device",
"names",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L2084-L2123 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableFlat._product | def _product(shape) -> Iterator[Tuple[int, ...]]:
"""Should return all "subdevice index combinations" for sequences
with arbitrary dimensions:
>>> from hydpy.core.netcdftools import NetCDFVariableFlat
>>> _product = NetCDFVariableFlat.__dict__['_product'].__func__
>>> for comb i... | python | def _product(shape) -> Iterator[Tuple[int, ...]]:
"""Should return all "subdevice index combinations" for sequences
with arbitrary dimensions:
>>> from hydpy.core.netcdftools import NetCDFVariableFlat
>>> _product = NetCDFVariableFlat.__dict__['_product'].__func__
>>> for comb i... | [
"def",
"_product",
"(",
"shape",
")",
"->",
"Iterator",
"[",
"Tuple",
"[",
"int",
",",
"...",
"]",
"]",
":",
"return",
"itertools",
".",
"product",
"(",
"*",
"(",
"range",
"(",
"nmb",
")",
"for",
"nmb",
"in",
"shape",
")",
")"
] | Should return all "subdevice index combinations" for sequences
with arbitrary dimensions:
>>> from hydpy.core.netcdftools import NetCDFVariableFlat
>>> _product = NetCDFVariableFlat.__dict__['_product'].__func__
>>> for comb in _product([1, 2, 3]):
... print(comb)
(0... | [
"Should",
"return",
"all",
"subdevice",
"index",
"combinations",
"for",
"sequences",
"with",
"arbitrary",
"dimensions",
":"
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L2126-L2141 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableFlat.read | def read(self, ncfile, timegrid_data) -> None:
"""Read the data from the given NetCDF file.
The argument `timegrid_data` defines the data period of the
given NetCDF file.
See the general documentation on class |NetCDFVariableFlat|
for some examples.
"""
array = ... | python | def read(self, ncfile, timegrid_data) -> None:
"""Read the data from the given NetCDF file.
The argument `timegrid_data` defines the data period of the
given NetCDF file.
See the general documentation on class |NetCDFVariableFlat|
for some examples.
"""
array = ... | [
"def",
"read",
"(",
"self",
",",
"ncfile",
",",
"timegrid_data",
")",
"->",
"None",
":",
"array",
"=",
"query_array",
"(",
"ncfile",
",",
"self",
".",
"name",
")",
"idxs",
":",
"Tuple",
"[",
"Any",
"]",
"=",
"(",
"slice",
"(",
"None",
")",
",",
"... | Read the data from the given NetCDF file.
The argument `timegrid_data` defines the data period of the
given NetCDF file.
See the general documentation on class |NetCDFVariableFlat|
for some examples. | [
"Read",
"the",
"data",
"from",
"the",
"given",
"NetCDF",
"file",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L2143-L2170 | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | NetCDFVariableFlat.write | def write(self, ncfile) -> None:
"""Write the data to the given NetCDF file.
See the general documentation on class |NetCDFVariableFlat|
for some examples.
"""
self.insert_subdevices(ncfile)
create_variable(ncfile, self.name, 'f8', self.dimensions)
ncfile[self.na... | python | def write(self, ncfile) -> None:
"""Write the data to the given NetCDF file.
See the general documentation on class |NetCDFVariableFlat|
for some examples.
"""
self.insert_subdevices(ncfile)
create_variable(ncfile, self.name, 'f8', self.dimensions)
ncfile[self.na... | [
"def",
"write",
"(",
"self",
",",
"ncfile",
")",
"->",
"None",
":",
"self",
".",
"insert_subdevices",
"(",
"ncfile",
")",
"create_variable",
"(",
"ncfile",
",",
"self",
".",
"name",
",",
"'f8'",
",",
"self",
".",
"dimensions",
")",
"ncfile",
"[",
"self... | Write the data to the given NetCDF file.
See the general documentation on class |NetCDFVariableFlat|
for some examples. | [
"Write",
"the",
"data",
"to",
"the",
"given",
"NetCDF",
"file",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L2172-L2180 | train |
hydpy-dev/hydpy | hydpy/models/llake/llake_derived.py | NmbSubsteps.update | def update(self):
"""Determine the number of substeps.
Initialize a llake model and assume a simulation step size of 12 hours:
>>> from hydpy.models.llake import *
>>> parameterstep('1d')
>>> simulationstep('12h')
If the maximum internal step size is also set to 12 hou... | python | def update(self):
"""Determine the number of substeps.
Initialize a llake model and assume a simulation step size of 12 hours:
>>> from hydpy.models.llake import *
>>> parameterstep('1d')
>>> simulationstep('12h')
If the maximum internal step size is also set to 12 hou... | [
"def",
"update",
"(",
"self",
")",
":",
"maxdt",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
".",
"maxdt",
"seconds",
"=",
"self",
".",
"simulationstep",
".",
"seconds",
"self",
".",
"value",
"=",
"numpy",
".",
"ceil",
"(",
"seconds",
"... | Determine the number of substeps.
Initialize a llake model and assume a simulation step size of 12 hours:
>>> from hydpy.models.llake import *
>>> parameterstep('1d')
>>> simulationstep('12h')
If the maximum internal step size is also set to 12 hours, there is
only one... | [
"Determine",
"the",
"number",
"of",
"substeps",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/llake/llake_derived.py#L25-L67 | train |
hydpy-dev/hydpy | hydpy/models/llake/llake_derived.py | VQ.update | def update(self):
"""Calulate the auxilary term.
>>> from hydpy.models.llake import *
>>> parameterstep('1d')
>>> simulationstep('12h')
>>> n(3)
>>> v(0., 1e5, 1e6)
>>> q(_1=[0., 1., 2.], _7=[0., 2., 5.])
>>> maxdt('12h')
>>> derived.seconds.updat... | python | def update(self):
"""Calulate the auxilary term.
>>> from hydpy.models.llake import *
>>> parameterstep('1d')
>>> simulationstep('12h')
>>> n(3)
>>> v(0., 1e5, 1e6)
>>> q(_1=[0., 1., 2.], _7=[0., 2., 5.])
>>> maxdt('12h')
>>> derived.seconds.updat... | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"der",
"=",
"self",
".",
"subpars",
"for",
"(",
"toy",
",",
"qs",
")",
"in",
"con",
".",
"q",
":",
"setattr",
"(",
"self",
",",
"str",
"(",... | Calulate the auxilary term.
>>> from hydpy.models.llake import *
>>> parameterstep('1d')
>>> simulationstep('12h')
>>> n(3)
>>> v(0., 1e5, 1e6)
>>> q(_1=[0., 1., 2.], _7=[0., 2., 5.])
>>> maxdt('12h')
>>> derived.seconds.update()
>>> derived.nmbsu... | [
"Calulate",
"the",
"auxilary",
"term",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/llake/llake_derived.py#L74-L95 | train |
hydpy-dev/hydpy | hydpy/core/examples.py | prepare_io_example_1 | def prepare_io_example_1() -> Tuple[devicetools.Nodes, devicetools.Elements]:
# noinspection PyUnresolvedReferences
"""Prepare an IO example configuration.
>>> from hydpy.core.examples import prepare_io_example_1
>>> nodes, elements = prepare_io_example_1()
(1) Prepares a short initialisation peri... | python | def prepare_io_example_1() -> Tuple[devicetools.Nodes, devicetools.Elements]:
# noinspection PyUnresolvedReferences
"""Prepare an IO example configuration.
>>> from hydpy.core.examples import prepare_io_example_1
>>> nodes, elements = prepare_io_example_1()
(1) Prepares a short initialisation peri... | [
"def",
"prepare_io_example_1",
"(",
")",
"->",
"Tuple",
"[",
"devicetools",
".",
"Nodes",
",",
"devicetools",
".",
"Elements",
"]",
":",
"# noinspection PyUnresolvedReferences",
"from",
"hydpy",
"import",
"TestIO",
"TestIO",
".",
"clear",
"(",
")",
"from",
"hydp... | Prepare an IO example configuration.
>>> from hydpy.core.examples import prepare_io_example_1
>>> nodes, elements = prepare_io_example_1()
(1) Prepares a short initialisation period of five days:
>>> from hydpy import pub
>>> pub.timegrids
Timegrids(Timegrid('2000-01-01 00:00:00',
... | [
"Prepare",
"an",
"IO",
"example",
"configuration",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/examples.py#L17-L156 | train |
hydpy-dev/hydpy | hydpy/core/examples.py | prepare_full_example_1 | def prepare_full_example_1() -> None:
"""Prepare the complete `LahnH` project for testing.
>>> from hydpy.core.examples import prepare_full_example_1
>>> prepare_full_example_1()
>>> from hydpy import TestIO
>>> import os
>>> with TestIO():
... print('root:', *sorted(os.listdir('.')))
... | python | def prepare_full_example_1() -> None:
"""Prepare the complete `LahnH` project for testing.
>>> from hydpy.core.examples import prepare_full_example_1
>>> prepare_full_example_1()
>>> from hydpy import TestIO
>>> import os
>>> with TestIO():
... print('root:', *sorted(os.listdir('.')))
... | [
"def",
"prepare_full_example_1",
"(",
")",
"->",
"None",
":",
"testtools",
".",
"TestIO",
".",
"clear",
"(",
")",
"shutil",
".",
"copytree",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data",
".",
"__path__",
"[",
"0",
"]",
",",
"'LahnH'",
")",
",",
... | Prepare the complete `LahnH` project for testing.
>>> from hydpy.core.examples import prepare_full_example_1
>>> prepare_full_example_1()
>>> from hydpy import TestIO
>>> import os
>>> with TestIO():
... print('root:', *sorted(os.listdir('.')))
... for folder in ('control', 'conditi... | [
"Prepare",
"the",
"complete",
"LahnH",
"project",
"for",
"testing",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/examples.py#L159-L184 | train |
hydpy-dev/hydpy | hydpy/core/examples.py | prepare_full_example_2 | def prepare_full_example_2(lastdate='1996-01-05') -> (
hydpytools.HydPy, hydpy.pub, testtools.TestIO):
"""Prepare the complete `LahnH` project for testing.
|prepare_full_example_2| calls |prepare_full_example_1|, but also
returns a readily prepared |HydPy| instance, as well as module
|pub| and ... | python | def prepare_full_example_2(lastdate='1996-01-05') -> (
hydpytools.HydPy, hydpy.pub, testtools.TestIO):
"""Prepare the complete `LahnH` project for testing.
|prepare_full_example_2| calls |prepare_full_example_1|, but also
returns a readily prepared |HydPy| instance, as well as module
|pub| and ... | [
"def",
"prepare_full_example_2",
"(",
"lastdate",
"=",
"'1996-01-05'",
")",
"->",
"(",
"hydpytools",
".",
"HydPy",
",",
"hydpy",
".",
"pub",
",",
"testtools",
".",
"TestIO",
")",
":",
"prepare_full_example_1",
"(",
")",
"with",
"testtools",
".",
"TestIO",
"(... | Prepare the complete `LahnH` project for testing.
|prepare_full_example_2| calls |prepare_full_example_1|, but also
returns a readily prepared |HydPy| instance, as well as module
|pub| and class |TestIO|, for convenience:
>>> from hydpy.core.examples import prepare_full_example_2
>>> hp, pub, Test... | [
"Prepare",
"the",
"complete",
"LahnH",
"project",
"for",
"testing",
"."
] | 1bc6a82cf30786521d86b36e27900c6717d3348d | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/examples.py#L187-L224 | train |
inkjet/pypostalcode | pypostalcode/__init__.py | PostalCodeDatabase.get_postalcodes_around_radius | def get_postalcodes_around_radius(self, pc, radius):
postalcodes = self.get(pc)
if postalcodes is None:
raise PostalCodeNotFoundException("Could not find postal code you're searching for.")
else:
pc = postalcodes[0]
radius = float(radius)
... | python | def get_postalcodes_around_radius(self, pc, radius):
postalcodes = self.get(pc)
if postalcodes is None:
raise PostalCodeNotFoundException("Could not find postal code you're searching for.")
else:
pc = postalcodes[0]
radius = float(radius)
... | [
"def",
"get_postalcodes_around_radius",
"(",
"self",
",",
"pc",
",",
"radius",
")",
":",
"postalcodes",
"=",
"self",
".",
"get",
"(",
"pc",
")",
"if",
"postalcodes",
"is",
"None",
":",
"raise",
"PostalCodeNotFoundException",
"(",
"\"Could not find postal code you'... | Bounding box calculations updated from pyzipcode | [
"Bounding",
"box",
"calculations",
"updated",
"from",
"pyzipcode"
] | 077c0085a57c2d24a0bb2596af56d701091fb9f4 | https://github.com/inkjet/pypostalcode/blob/077c0085a57c2d24a0bb2596af56d701091fb9f4/pypostalcode/__init__.py#L71-L99 | train |
savvastj/nbashots | nbashots/api.py | get_all_player_ids | def get_all_player_ids(ids="shots"):
"""
Returns a pandas DataFrame containing the player IDs used in the
stats.nba.com API.
Parameters
----------
ids : { "shots" | "all_players" | "all_data" }, optional
Passing in "shots" returns a DataFrame that contains the player IDs of
all ... | python | def get_all_player_ids(ids="shots"):
"""
Returns a pandas DataFrame containing the player IDs used in the
stats.nba.com API.
Parameters
----------
ids : { "shots" | "all_players" | "all_data" }, optional
Passing in "shots" returns a DataFrame that contains the player IDs of
all ... | [
"def",
"get_all_player_ids",
"(",
"ids",
"=",
"\"shots\"",
")",
":",
"url",
"=",
"\"http://stats.nba.com/stats/commonallplayers?IsOnlyCurrentSeason=0&LeagueID=00&Season=2015-16\"",
"# get the web page",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"headers",
"=... | Returns a pandas DataFrame containing the player IDs used in the
stats.nba.com API.
Parameters
----------
ids : { "shots" | "all_players" | "all_data" }, optional
Passing in "shots" returns a DataFrame that contains the player IDs of
all players have shot chart data. It is the default ... | [
"Returns",
"a",
"pandas",
"DataFrame",
"containing",
"the",
"player",
"IDs",
"used",
"in",
"the",
"stats",
".",
"nba",
".",
"com",
"API",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L251-L320 | train |
savvastj/nbashots | nbashots/api.py | get_player_id | def get_player_id(player):
"""
Returns the player ID(s) associated with the player name that is passed in.
There are instances where players have the same name so there are multiple
player IDs associated with it.
Parameters
----------
player : str
The desired player's name in 'Last... | python | def get_player_id(player):
"""
Returns the player ID(s) associated with the player name that is passed in.
There are instances where players have the same name so there are multiple
player IDs associated with it.
Parameters
----------
player : str
The desired player's name in 'Last... | [
"def",
"get_player_id",
"(",
"player",
")",
":",
"players_df",
"=",
"get_all_player_ids",
"(",
"\"all_data\"",
")",
"player",
"=",
"players_df",
"[",
"players_df",
".",
"DISPLAY_LAST_COMMA_FIRST",
"==",
"player",
"]",
"# if there are no plyaers by the given name, raise an... | Returns the player ID(s) associated with the player name that is passed in.
There are instances where players have the same name so there are multiple
player IDs associated with it.
Parameters
----------
player : str
The desired player's name in 'Last Name, First Name' format. Passing in
... | [
"Returns",
"the",
"player",
"ID",
"(",
"s",
")",
"associated",
"with",
"the",
"player",
"name",
"that",
"is",
"passed",
"in",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L323-L350 | train |
savvastj/nbashots | nbashots/api.py | get_all_team_ids | def get_all_team_ids():
"""Returns a pandas DataFrame with all Team IDs"""
df = get_all_player_ids("all_data")
df = pd.DataFrame({"TEAM_NAME": df.TEAM_NAME.unique(),
"TEAM_ID": df.TEAM_ID.unique()})
return df | python | def get_all_team_ids():
"""Returns a pandas DataFrame with all Team IDs"""
df = get_all_player_ids("all_data")
df = pd.DataFrame({"TEAM_NAME": df.TEAM_NAME.unique(),
"TEAM_ID": df.TEAM_ID.unique()})
return df | [
"def",
"get_all_team_ids",
"(",
")",
":",
"df",
"=",
"get_all_player_ids",
"(",
"\"all_data\"",
")",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"{",
"\"TEAM_NAME\"",
":",
"df",
".",
"TEAM_NAME",
".",
"unique",
"(",
")",
",",
"\"TEAM_ID\"",
":",
"df",
".",
... | Returns a pandas DataFrame with all Team IDs | [
"Returns",
"a",
"pandas",
"DataFrame",
"with",
"all",
"Team",
"IDs"
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L353-L358 | train |
savvastj/nbashots | nbashots/api.py | get_team_id | def get_team_id(team_name):
""" Returns the team ID associated with the team name that is passed in.
Parameters
----------
team_name : str
The team name whose ID we want. NOTE: Only pass in the team name
(e.g. "Lakers"), not the city, or city and team name, or the team
abbrevia... | python | def get_team_id(team_name):
""" Returns the team ID associated with the team name that is passed in.
Parameters
----------
team_name : str
The team name whose ID we want. NOTE: Only pass in the team name
(e.g. "Lakers"), not the city, or city and team name, or the team
abbrevia... | [
"def",
"get_team_id",
"(",
"team_name",
")",
":",
"df",
"=",
"get_all_team_ids",
"(",
")",
"df",
"=",
"df",
"[",
"df",
".",
"TEAM_NAME",
"==",
"team_name",
"]",
"if",
"len",
"(",
"df",
")",
"==",
"0",
":",
"er",
"=",
"\"Invalid team name or there is no t... | Returns the team ID associated with the team name that is passed in.
Parameters
----------
team_name : str
The team name whose ID we want. NOTE: Only pass in the team name
(e.g. "Lakers"), not the city, or city and team name, or the team
abbreviation.
Returns
-------
t... | [
"Returns",
"the",
"team",
"ID",
"associated",
"with",
"the",
"team",
"name",
"that",
"is",
"passed",
"in",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L361-L383 | train |
savvastj/nbashots | nbashots/api.py | get_player_img | def get_player_img(player_id):
"""
Returns the image of the player from stats.nba.com as a numpy array and
saves the image as PNG file in the current directory.
Parameters
----------
player_id: int
The player ID used to find the image.
Returns
-------
player_img: ndarray
... | python | def get_player_img(player_id):
"""
Returns the image of the player from stats.nba.com as a numpy array and
saves the image as PNG file in the current directory.
Parameters
----------
player_id: int
The player ID used to find the image.
Returns
-------
player_img: ndarray
... | [
"def",
"get_player_img",
"(",
"player_id",
")",
":",
"url",
"=",
"\"http://stats.nba.com/media/players/230x185/\"",
"+",
"str",
"(",
"player_id",
")",
"+",
"\".png\"",
"img_file",
"=",
"str",
"(",
"player_id",
")",
"+",
"\".png\"",
"pic",
"=",
"urlretrieve",
"("... | Returns the image of the player from stats.nba.com as a numpy array and
saves the image as PNG file in the current directory.
Parameters
----------
player_id: int
The player ID used to find the image.
Returns
-------
player_img: ndarray
The multidimensional numpy array of t... | [
"Returns",
"the",
"image",
"of",
"the",
"player",
"from",
"stats",
".",
"nba",
".",
"com",
"as",
"a",
"numpy",
"array",
"and",
"saves",
"the",
"image",
"as",
"PNG",
"file",
"in",
"the",
"current",
"directory",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L386-L406 | train |
savvastj/nbashots | nbashots/api.py | TeamLog.get_game_logs | def get_game_logs(self):
"""Returns team game logs as a pandas DataFrame"""
logs = self.response.json()['resultSets'][0]['rowSet']
headers = self.response.json()['resultSets'][0]['headers']
df = pd.DataFrame(logs, columns=headers)
df.GAME_DATE = pd.to_datetime(df.GAME_DATE)
... | python | def get_game_logs(self):
"""Returns team game logs as a pandas DataFrame"""
logs = self.response.json()['resultSets'][0]['rowSet']
headers = self.response.json()['resultSets'][0]['headers']
df = pd.DataFrame(logs, columns=headers)
df.GAME_DATE = pd.to_datetime(df.GAME_DATE)
... | [
"def",
"get_game_logs",
"(",
"self",
")",
":",
"logs",
"=",
"self",
".",
"response",
".",
"json",
"(",
")",
"[",
"'resultSets'",
"]",
"[",
"0",
"]",
"[",
"'rowSet'",
"]",
"headers",
"=",
"self",
".",
"response",
".",
"json",
"(",
")",
"[",
"'result... | Returns team game logs as a pandas DataFrame | [
"Returns",
"team",
"game",
"logs",
"as",
"a",
"pandas",
"DataFrame"
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L36-L42 | train |
savvastj/nbashots | nbashots/api.py | TeamLog.get_game_id | def get_game_id(self, date):
"""Returns the Game ID associated with the date that is passed in.
Parameters
----------
date : str
The date associated with the game whose Game ID. The date that is
passed in can take on a numeric format of MM/DD/YY (like "01/06/16"
... | python | def get_game_id(self, date):
"""Returns the Game ID associated with the date that is passed in.
Parameters
----------
date : str
The date associated with the game whose Game ID. The date that is
passed in can take on a numeric format of MM/DD/YY (like "01/06/16"
... | [
"def",
"get_game_id",
"(",
"self",
",",
"date",
")",
":",
"df",
"=",
"self",
".",
"get_game_logs",
"(",
")",
"game_id",
"=",
"df",
"[",
"df",
".",
"GAME_DATE",
"==",
"date",
"]",
".",
"Game_ID",
".",
"values",
"[",
"0",
"]",
"return",
"game_id"
] | Returns the Game ID associated with the date that is passed in.
Parameters
----------
date : str
The date associated with the game whose Game ID. The date that is
passed in can take on a numeric format of MM/DD/YY (like "01/06/16"
or "01/06/2016") or the expa... | [
"Returns",
"the",
"Game",
"ID",
"associated",
"with",
"the",
"date",
"that",
"is",
"passed",
"in",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L44-L62 | train |
savvastj/nbashots | nbashots/api.py | TeamLog.update_params | def update_params(self, parameters):
"""Pass in a dictionary to update url parameters for NBA stats API
Parameters
----------
parameters : dict
A dict containing key, value pairs that correspond with NBA stats
API parameters.
Returns
-------
... | python | def update_params(self, parameters):
"""Pass in a dictionary to update url parameters for NBA stats API
Parameters
----------
parameters : dict
A dict containing key, value pairs that correspond with NBA stats
API parameters.
Returns
-------
... | [
"def",
"update_params",
"(",
"self",
",",
"parameters",
")",
":",
"self",
".",
"url_paramaters",
".",
"update",
"(",
"parameters",
")",
"self",
".",
"response",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"base_url",
",",
"params",
"=",
"self",
".",
... | Pass in a dictionary to update url parameters for NBA stats API
Parameters
----------
parameters : dict
A dict containing key, value pairs that correspond with NBA stats
API parameters.
Returns
-------
self : TeamLog
The TeamLog objec... | [
"Pass",
"in",
"a",
"dictionary",
"to",
"update",
"url",
"parameters",
"for",
"NBA",
"stats",
"API"
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L64-L84 | train |
savvastj/nbashots | nbashots/api.py | Shots.get_shots | def get_shots(self):
"""Returns the shot chart data as a pandas DataFrame."""
shots = self.response.json()['resultSets'][0]['rowSet']
headers = self.response.json()['resultSets'][0]['headers']
return pd.DataFrame(shots, columns=headers) | python | def get_shots(self):
"""Returns the shot chart data as a pandas DataFrame."""
shots = self.response.json()['resultSets'][0]['rowSet']
headers = self.response.json()['resultSets'][0]['headers']
return pd.DataFrame(shots, columns=headers) | [
"def",
"get_shots",
"(",
"self",
")",
":",
"shots",
"=",
"self",
".",
"response",
".",
"json",
"(",
")",
"[",
"'resultSets'",
"]",
"[",
"0",
"]",
"[",
"'rowSet'",
"]",
"headers",
"=",
"self",
".",
"response",
".",
"json",
"(",
")",
"[",
"'resultSet... | Returns the shot chart data as a pandas DataFrame. | [
"Returns",
"the",
"shot",
"chart",
"data",
"as",
"a",
"pandas",
"DataFrame",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L218-L222 | train |
mcuadros/pynats | pynats/connection.py | Connection.connect | def connect(self):
"""
Connect will attempt to connect to the NATS server. The url can
contain username/password semantics.
"""
self._build_socket()
self._connect_socket()
self._build_file_socket()
self._send_connect_msg() | python | def connect(self):
"""
Connect will attempt to connect to the NATS server. The url can
contain username/password semantics.
"""
self._build_socket()
self._connect_socket()
self._build_file_socket()
self._send_connect_msg() | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"_build_socket",
"(",
")",
"self",
".",
"_connect_socket",
"(",
")",
"self",
".",
"_build_file_socket",
"(",
")",
"self",
".",
"_send_connect_msg",
"(",
")"
] | Connect will attempt to connect to the NATS server. The url can
contain username/password semantics. | [
"Connect",
"will",
"attempt",
"to",
"connect",
"to",
"the",
"NATS",
"server",
".",
"The",
"url",
"can",
"contain",
"username",
"/",
"password",
"semantics",
"."
] | afbf0766c5546f9b8e7b54ddc89abd2602883b6c | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L45-L53 | train |
mcuadros/pynats | pynats/connection.py | Connection.subscribe | def subscribe(self, subject, callback, queue=''):
"""
Subscribe will express interest in the given subject. The subject can
have wildcards (partial:*, full:>). Messages will be delivered to the
associated callback.
Args:
subject (string): a string with the subject
... | python | def subscribe(self, subject, callback, queue=''):
"""
Subscribe will express interest in the given subject. The subject can
have wildcards (partial:*, full:>). Messages will be delivered to the
associated callback.
Args:
subject (string): a string with the subject
... | [
"def",
"subscribe",
"(",
"self",
",",
"subject",
",",
"callback",
",",
"queue",
"=",
"''",
")",
":",
"s",
"=",
"Subscription",
"(",
"sid",
"=",
"self",
".",
"_next_sid",
",",
"subject",
"=",
"subject",
",",
"queue",
"=",
"queue",
",",
"callback",
"="... | Subscribe will express interest in the given subject. The subject can
have wildcards (partial:*, full:>). Messages will be delivered to the
associated callback.
Args:
subject (string): a string with the subject
callback (function): callback to be called | [
"Subscribe",
"will",
"express",
"interest",
"in",
"the",
"given",
"subject",
".",
"The",
"subject",
"can",
"have",
"wildcards",
"(",
"partial",
":",
"*",
"full",
":",
">",
")",
".",
"Messages",
"will",
"be",
"delivered",
"to",
"the",
"associated",
"callbac... | afbf0766c5546f9b8e7b54ddc89abd2602883b6c | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L93-L115 | train |
mcuadros/pynats | pynats/connection.py | Connection.unsubscribe | def unsubscribe(self, subscription, max=None):
"""
Unsubscribe will remove interest in the given subject. If max is
provided an automatic Unsubscribe that is processed by the server
when max messages have been received
Args:
subscription (pynats.Subscription): a Subs... | python | def unsubscribe(self, subscription, max=None):
"""
Unsubscribe will remove interest in the given subject. If max is
provided an automatic Unsubscribe that is processed by the server
when max messages have been received
Args:
subscription (pynats.Subscription): a Subs... | [
"def",
"unsubscribe",
"(",
"self",
",",
"subscription",
",",
"max",
"=",
"None",
")",
":",
"if",
"max",
"is",
"None",
":",
"self",
".",
"_send",
"(",
"'UNSUB %d'",
"%",
"subscription",
".",
"sid",
")",
"self",
".",
"_subscriptions",
".",
"pop",
"(",
... | Unsubscribe will remove interest in the given subject. If max is
provided an automatic Unsubscribe that is processed by the server
when max messages have been received
Args:
subscription (pynats.Subscription): a Subscription object
max (int=None): number of messages | [
"Unsubscribe",
"will",
"remove",
"interest",
"in",
"the",
"given",
"subject",
".",
"If",
"max",
"is",
"provided",
"an",
"automatic",
"Unsubscribe",
"that",
"is",
"processed",
"by",
"the",
"server",
"when",
"max",
"messages",
"have",
"been",
"received"
] | afbf0766c5546f9b8e7b54ddc89abd2602883b6c | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L117-L132 | train |
mcuadros/pynats | pynats/connection.py | Connection.publish | def publish(self, subject, msg, reply=None):
"""
Publish publishes the data argument to the given subject.
Args:
subject (string): a string with the subject
msg (string): payload string
reply (string): subject used in the reply
"""
if msg is N... | python | def publish(self, subject, msg, reply=None):
"""
Publish publishes the data argument to the given subject.
Args:
subject (string): a string with the subject
msg (string): payload string
reply (string): subject used in the reply
"""
if msg is N... | [
"def",
"publish",
"(",
"self",
",",
"subject",
",",
"msg",
",",
"reply",
"=",
"None",
")",
":",
"if",
"msg",
"is",
"None",
":",
"msg",
"=",
"''",
"if",
"reply",
"is",
"None",
":",
"command",
"=",
"'PUB %s %d'",
"%",
"(",
"subject",
",",
"len",
"(... | Publish publishes the data argument to the given subject.
Args:
subject (string): a string with the subject
msg (string): payload string
reply (string): subject used in the reply | [
"Publish",
"publishes",
"the",
"data",
"argument",
"to",
"the",
"given",
"subject",
"."
] | afbf0766c5546f9b8e7b54ddc89abd2602883b6c | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L134-L152 | train |
mcuadros/pynats | pynats/connection.py | Connection.request | def request(self, subject, callback, msg=None):
"""
ublish a message with an implicit inbox listener as the reply.
Message is optional.
Args:
subject (string): a string with the subject
callback (function): callback to be called
msg (string=None): pay... | python | def request(self, subject, callback, msg=None):
"""
ublish a message with an implicit inbox listener as the reply.
Message is optional.
Args:
subject (string): a string with the subject
callback (function): callback to be called
msg (string=None): pay... | [
"def",
"request",
"(",
"self",
",",
"subject",
",",
"callback",
",",
"msg",
"=",
"None",
")",
":",
"inbox",
"=",
"self",
".",
"_build_inbox",
"(",
")",
"s",
"=",
"self",
".",
"subscribe",
"(",
"inbox",
",",
"callback",
")",
"self",
".",
"unsubscribe"... | ublish a message with an implicit inbox listener as the reply.
Message is optional.
Args:
subject (string): a string with the subject
callback (function): callback to be called
msg (string=None): payload string | [
"ublish",
"a",
"message",
"with",
"an",
"implicit",
"inbox",
"listener",
"as",
"the",
"reply",
".",
"Message",
"is",
"optional",
"."
] | afbf0766c5546f9b8e7b54ddc89abd2602883b6c | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L154-L169 | train |
mcuadros/pynats | pynats/connection.py | Connection.wait | def wait(self, duration=None, count=0):
"""
Publish publishes the data argument to the given subject.
Args:
duration (float): will wait for the given number of seconds
count (count): stop of wait after n messages from any subject
"""
start = time.time()
... | python | def wait(self, duration=None, count=0):
"""
Publish publishes the data argument to the given subject.
Args:
duration (float): will wait for the given number of seconds
count (count): stop of wait after n messages from any subject
"""
start = time.time()
... | [
"def",
"wait",
"(",
"self",
",",
"duration",
"=",
"None",
",",
"count",
"=",
"0",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"total",
"=",
"0",
"while",
"True",
":",
"type",
",",
"result",
"=",
"self",
".",
"_recv",
"(",
"MSG",
",",... | Publish publishes the data argument to the given subject.
Args:
duration (float): will wait for the given number of seconds
count (count): stop of wait after n messages from any subject | [
"Publish",
"publishes",
"the",
"data",
"argument",
"to",
"the",
"given",
"subject",
"."
] | afbf0766c5546f9b8e7b54ddc89abd2602883b6c | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L175-L199 | train |
savvastj/nbashots | nbashots/charts.py | draw_court | def draw_court(ax=None, color='gray', lw=1, outer_lines=False):
"""Returns an axes with a basketball court drawn onto to it.
This function draws a court based on the x and y-axis values that the NBA
stats API provides for the shot chart data. For example the center of the
hoop is located at the (0,0) ... | python | def draw_court(ax=None, color='gray', lw=1, outer_lines=False):
"""Returns an axes with a basketball court drawn onto to it.
This function draws a court based on the x and y-axis values that the NBA
stats API provides for the shot chart data. For example the center of the
hoop is located at the (0,0) ... | [
"def",
"draw_court",
"(",
"ax",
"=",
"None",
",",
"color",
"=",
"'gray'",
",",
"lw",
"=",
"1",
",",
"outer_lines",
"=",
"False",
")",
":",
"if",
"ax",
"is",
"None",
":",
"ax",
"=",
"plt",
".",
"gca",
"(",
")",
"# Create the various parts of an NBA bask... | Returns an axes with a basketball court drawn onto to it.
This function draws a court based on the x and y-axis values that the NBA
stats API provides for the shot chart data. For example the center of the
hoop is located at the (0,0) coordinate. Twenty-two feet from the left of
the center of the hoo... | [
"Returns",
"an",
"axes",
"with",
"a",
"basketball",
"court",
"drawn",
"onto",
"to",
"it",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L15-L103 | train |
savvastj/nbashots | nbashots/charts.py | shot_chart | def shot_chart(x, y, kind="scatter", title="", color="b", cmap=None,
xlim=(-250, 250), ylim=(422.5, -47.5),
court_color="gray", court_lw=1, outer_lines=False,
flip_court=False, kde_shade=True, gridsize=None, ax=None,
despine=False, **kwargs):
"""
Retur... | python | def shot_chart(x, y, kind="scatter", title="", color="b", cmap=None,
xlim=(-250, 250), ylim=(422.5, -47.5),
court_color="gray", court_lw=1, outer_lines=False,
flip_court=False, kde_shade=True, gridsize=None, ax=None,
despine=False, **kwargs):
"""
Retur... | [
"def",
"shot_chart",
"(",
"x",
",",
"y",
",",
"kind",
"=",
"\"scatter\"",
",",
"title",
"=",
"\"\"",
",",
"color",
"=",
"\"b\"",
",",
"cmap",
"=",
"None",
",",
"xlim",
"=",
"(",
"-",
"250",
",",
"250",
")",
",",
"ylim",
"=",
"(",
"422.5",
",",
... | Returns an Axes object with player shots plotted.
Parameters
----------
x, y : strings or vector
The x and y coordinates of the shots taken. They can be passed in as
vectors (such as a pandas Series) or as columns from the pandas
DataFrame passed into ``data``.
data : DataFrame... | [
"Returns",
"an",
"Axes",
"object",
"with",
"player",
"shots",
"plotted",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L106-L219 | train |
savvastj/nbashots | nbashots/charts.py | shot_chart_jointgrid | def shot_chart_jointgrid(x, y, data=None, joint_type="scatter", title="",
joint_color="b", cmap=None, xlim=(-250, 250),
ylim=(422.5, -47.5), court_color="gray", court_lw=1,
outer_lines=False, flip_court=False,
joint_kde... | python | def shot_chart_jointgrid(x, y, data=None, joint_type="scatter", title="",
joint_color="b", cmap=None, xlim=(-250, 250),
ylim=(422.5, -47.5), court_color="gray", court_lw=1,
outer_lines=False, flip_court=False,
joint_kde... | [
"def",
"shot_chart_jointgrid",
"(",
"x",
",",
"y",
",",
"data",
"=",
"None",
",",
"joint_type",
"=",
"\"scatter\"",
",",
"title",
"=",
"\"\"",
",",
"joint_color",
"=",
"\"b\"",
",",
"cmap",
"=",
"None",
",",
"xlim",
"=",
"(",
"-",
"250",
",",
"250",
... | Returns a JointGrid object containing the shot chart.
This function allows for more flexibility in customizing your shot chart
than the ``shot_chart_jointplot`` function.
Parameters
----------
x, y : strings or vector
The x and y coordinates of the shots taken. They can be passed in as
... | [
"Returns",
"a",
"JointGrid",
"object",
"containing",
"the",
"shot",
"chart",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L222-L398 | train |
savvastj/nbashots | nbashots/charts.py | shot_chart_jointplot | def shot_chart_jointplot(x, y, data=None, kind="scatter", title="", color="b",
cmap=None, xlim=(-250, 250), ylim=(422.5, -47.5),
court_color="gray", court_lw=1, outer_lines=False,
flip_court=False, size=(12, 11), space=0,
... | python | def shot_chart_jointplot(x, y, data=None, kind="scatter", title="", color="b",
cmap=None, xlim=(-250, 250), ylim=(422.5, -47.5),
court_color="gray", court_lw=1, outer_lines=False,
flip_court=False, size=(12, 11), space=0,
... | [
"def",
"shot_chart_jointplot",
"(",
"x",
",",
"y",
",",
"data",
"=",
"None",
",",
"kind",
"=",
"\"scatter\"",
",",
"title",
"=",
"\"\"",
",",
"color",
"=",
"\"b\"",
",",
"cmap",
"=",
"None",
",",
"xlim",
"=",
"(",
"-",
"250",
",",
"250",
")",
","... | Returns a seaborn JointGrid using sns.jointplot
Parameters
----------
x, y : strings or vector
The x and y coordinates of the shots taken. They can be passed in as
vectors (such as a pandas Series) or as column names from the pandas
DataFrame passed into ``data``.
data : DataFr... | [
"Returns",
"a",
"seaborn",
"JointGrid",
"using",
"sns",
".",
"jointplot"
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L401-L514 | train |
savvastj/nbashots | nbashots/charts.py | heatmap | def heatmap(x, y, z, title="", cmap=plt.cm.YlOrRd, bins=20,
xlim=(-250, 250), ylim=(422.5, -47.5),
facecolor='lightgray', facecolor_alpha=0.4,
court_color="black", court_lw=0.5, outer_lines=False,
flip_court=False, ax=None, **kwargs):
"""
Returns an AxesImage obj... | python | def heatmap(x, y, z, title="", cmap=plt.cm.YlOrRd, bins=20,
xlim=(-250, 250), ylim=(422.5, -47.5),
facecolor='lightgray', facecolor_alpha=0.4,
court_color="black", court_lw=0.5, outer_lines=False,
flip_court=False, ax=None, **kwargs):
"""
Returns an AxesImage obj... | [
"def",
"heatmap",
"(",
"x",
",",
"y",
",",
"z",
",",
"title",
"=",
"\"\"",
",",
"cmap",
"=",
"plt",
".",
"cm",
".",
"YlOrRd",
",",
"bins",
"=",
"20",
",",
"xlim",
"=",
"(",
"-",
"250",
",",
"250",
")",
",",
"ylim",
"=",
"(",
"422.5",
",",
... | Returns an AxesImage object that contains a heatmap.
TODO: Redo some code and explain parameters | [
"Returns",
"an",
"AxesImage",
"object",
"that",
"contains",
"a",
"heatmap",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L517-L559 | train |
savvastj/nbashots | nbashots/charts.py | bokeh_draw_court | def bokeh_draw_court(figure, line_color='gray', line_width=1):
"""Returns a figure with the basketball court lines drawn onto it
This function draws a court based on the x and y-axis values that the NBA
stats API provides for the shot chart data. For example the center of the
hoop is located at the (0... | python | def bokeh_draw_court(figure, line_color='gray', line_width=1):
"""Returns a figure with the basketball court lines drawn onto it
This function draws a court based on the x and y-axis values that the NBA
stats API provides for the shot chart data. For example the center of the
hoop is located at the (0... | [
"def",
"bokeh_draw_court",
"(",
"figure",
",",
"line_color",
"=",
"'gray'",
",",
"line_width",
"=",
"1",
")",
":",
"# hoop",
"figure",
".",
"circle",
"(",
"x",
"=",
"0",
",",
"y",
"=",
"0",
",",
"radius",
"=",
"7.5",
",",
"fill_alpha",
"=",
"0",
",... | Returns a figure with the basketball court lines drawn onto it
This function draws a court based on the x and y-axis values that the NBA
stats API provides for the shot chart data. For example the center of the
hoop is located at the (0,0) coordinate. Twenty-two feet from the left of
the center of th... | [
"Returns",
"a",
"figure",
"with",
"the",
"basketball",
"court",
"lines",
"drawn",
"onto",
"it"
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L563-L641 | train |
savvastj/nbashots | nbashots/charts.py | bokeh_shot_chart | def bokeh_shot_chart(data, x="LOC_X", y="LOC_Y", fill_color="#1f77b4",
scatter_size=10, fill_alpha=0.4, line_alpha=0.4,
court_line_color='gray', court_line_width=1,
hover_tool=False, tooltips=None, **kwargs):
# TODO: Settings for hover tooltip
"""
... | python | def bokeh_shot_chart(data, x="LOC_X", y="LOC_Y", fill_color="#1f77b4",
scatter_size=10, fill_alpha=0.4, line_alpha=0.4,
court_line_color='gray', court_line_width=1,
hover_tool=False, tooltips=None, **kwargs):
# TODO: Settings for hover tooltip
"""
... | [
"def",
"bokeh_shot_chart",
"(",
"data",
",",
"x",
"=",
"\"LOC_X\"",
",",
"y",
"=",
"\"LOC_Y\"",
",",
"fill_color",
"=",
"\"#1f77b4\"",
",",
"scatter_size",
"=",
"10",
",",
"fill_alpha",
"=",
"0.4",
",",
"line_alpha",
"=",
"0.4",
",",
"court_line_color",
"=... | Returns a figure with both FGA and basketball court lines drawn onto it.
This function expects data to be a ColumnDataSource with the x and y values
named "LOC_X" and "LOC_Y". Otherwise specify x and y.
Parameters
----------
data : DataFrame
The DataFrame that contains the shot chart dat... | [
"Returns",
"a",
"figure",
"with",
"both",
"FGA",
"and",
"basketball",
"court",
"lines",
"drawn",
"onto",
"it",
"."
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L644-L704 | train |
vmirly/pyclust | pyclust/_kmedoids.py | _update_centers | def _update_centers(X, membs, n_clusters, distance):
""" Update Cluster Centers:
calculate the mean of feature vectors for each cluster.
distance can be a string or callable.
"""
centers = np.empty(shape=(n_clusters, X.shape[1]), dtype=float)
sse = np.empty(shape=n_clusters, dtype=fl... | python | def _update_centers(X, membs, n_clusters, distance):
""" Update Cluster Centers:
calculate the mean of feature vectors for each cluster.
distance can be a string or callable.
"""
centers = np.empty(shape=(n_clusters, X.shape[1]), dtype=float)
sse = np.empty(shape=n_clusters, dtype=fl... | [
"def",
"_update_centers",
"(",
"X",
",",
"membs",
",",
"n_clusters",
",",
"distance",
")",
":",
"centers",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"(",
"n_clusters",
",",
"X",
".",
"shape",
"[",
"1",
"]",
")",
",",
"dtype",
"=",
"float",
")",
... | Update Cluster Centers:
calculate the mean of feature vectors for each cluster.
distance can be a string or callable. | [
"Update",
"Cluster",
"Centers",
":",
"calculate",
"the",
"mean",
"of",
"feature",
"vectors",
"for",
"each",
"cluster",
"."
] | bdb12be4649e70c6c90da2605bc5f4b314e2d07e | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmedoids.py#L8-L27 | train |
vmirly/pyclust | pyclust/_kmedoids.py | _kmedoids_run | def _kmedoids_run(X, n_clusters, distance, max_iter, tol, rng):
""" Run a single trial of k-medoids clustering
on dataset X, and given number of clusters
"""
membs = np.empty(shape=X.shape[0], dtype=int)
centers = kmeans._kmeans_init(X, n_clusters, method='', rng=rng)
sse_last = 9999.9
... | python | def _kmedoids_run(X, n_clusters, distance, max_iter, tol, rng):
""" Run a single trial of k-medoids clustering
on dataset X, and given number of clusters
"""
membs = np.empty(shape=X.shape[0], dtype=int)
centers = kmeans._kmeans_init(X, n_clusters, method='', rng=rng)
sse_last = 9999.9
... | [
"def",
"_kmedoids_run",
"(",
"X",
",",
"n_clusters",
",",
"distance",
",",
"max_iter",
",",
"tol",
",",
"rng",
")",
":",
"membs",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"int",
")",
"center... | Run a single trial of k-medoids clustering
on dataset X, and given number of clusters | [
"Run",
"a",
"single",
"trial",
"of",
"k",
"-",
"medoids",
"clustering",
"on",
"dataset",
"X",
"and",
"given",
"number",
"of",
"clusters"
] | bdb12be4649e70c6c90da2605bc5f4b314e2d07e | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmedoids.py#L31-L49 | train |
vmirly/pyclust | pyclust/_kmedoids.py | KMedoids.fit | def fit(self, X):
""" Apply KMeans Clustering
X: dataset with feature vectors
"""
self.centers_, self.labels_, self.sse_arr_, self.n_iter_ = \
_kmedoids(X, self.n_clusters, self.distance, self.max_iter, self.n_trials, self.tol, self.rng) | python | def fit(self, X):
""" Apply KMeans Clustering
X: dataset with feature vectors
"""
self.centers_, self.labels_, self.sse_arr_, self.n_iter_ = \
_kmedoids(X, self.n_clusters, self.distance, self.max_iter, self.n_trials, self.tol, self.rng) | [
"def",
"fit",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"centers_",
",",
"self",
".",
"labels_",
",",
"self",
".",
"sse_arr_",
",",
"self",
".",
"n_iter_",
"=",
"_kmedoids",
"(",
"X",
",",
"self",
".",
"n_clusters",
",",
"self",
".",
"distance"... | Apply KMeans Clustering
X: dataset with feature vectors | [
"Apply",
"KMeans",
"Clustering",
"X",
":",
"dataset",
"with",
"feature",
"vectors"
] | bdb12be4649e70c6c90da2605bc5f4b314e2d07e | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmedoids.py#L129-L134 | train |
vmirly/pyclust | pyclust/_kernel_kmeans.py | _kernelized_dist2centers | def _kernelized_dist2centers(K, n_clusters, wmemb, kernel_dist):
""" Computin the distance in transformed feature space to
cluster centers.
K is the kernel gram matrix.
wmemb contains cluster assignment. {0,1}
Assume j is the cluster id:
||phi(x_i) - Phi_center_j|| = K_i... | python | def _kernelized_dist2centers(K, n_clusters, wmemb, kernel_dist):
""" Computin the distance in transformed feature space to
cluster centers.
K is the kernel gram matrix.
wmemb contains cluster assignment. {0,1}
Assume j is the cluster id:
||phi(x_i) - Phi_center_j|| = K_i... | [
"def",
"_kernelized_dist2centers",
"(",
"K",
",",
"n_clusters",
",",
"wmemb",
",",
"kernel_dist",
")",
":",
"n_samples",
"=",
"K",
".",
"shape",
"[",
"0",
"]",
"for",
"j",
"in",
"range",
"(",
"n_clusters",
")",
":",
"memb_j",
"=",
"np",
".",
"where",
... | Computin the distance in transformed feature space to
cluster centers.
K is the kernel gram matrix.
wmemb contains cluster assignment. {0,1}
Assume j is the cluster id:
||phi(x_i) - Phi_center_j|| = K_ii - 2 sum w_jh K_ih +
sum_r sum_s ... | [
"Computin",
"the",
"distance",
"in",
"transformed",
"feature",
"space",
"to",
"cluster",
"centers",
".",
"K",
"is",
"the",
"kernel",
"gram",
"matrix",
".",
"wmemb",
"contains",
"cluster",
"assignment",
".",
"{",
"0",
"1",
"}"
] | bdb12be4649e70c6c90da2605bc5f4b314e2d07e | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kernel_kmeans.py#L29-L51 | train |
vmirly/pyclust | pyclust/_gaussian_mixture_model.py | _init_mixture_params | def _init_mixture_params(X, n_mixtures, init_method):
"""
Initialize mixture density parameters with
equal priors
random means
identity covariance matrices
"""
init_priors = np.ones(shape=n_mixtures, dtype=float) / n_mixtures
if init_method == 'kmeans':
km = _km... | python | def _init_mixture_params(X, n_mixtures, init_method):
"""
Initialize mixture density parameters with
equal priors
random means
identity covariance matrices
"""
init_priors = np.ones(shape=n_mixtures, dtype=float) / n_mixtures
if init_method == 'kmeans':
km = _km... | [
"def",
"_init_mixture_params",
"(",
"X",
",",
"n_mixtures",
",",
"init_method",
")",
":",
"init_priors",
"=",
"np",
".",
"ones",
"(",
"shape",
"=",
"n_mixtures",
",",
"dtype",
"=",
"float",
")",
"/",
"n_mixtures",
"if",
"init_method",
"==",
"'kmeans'",
":"... | Initialize mixture density parameters with
equal priors
random means
identity covariance matrices | [
"Initialize",
"mixture",
"density",
"parameters",
"with",
"equal",
"priors",
"random",
"means",
"identity",
"covariance",
"matrices"
] | bdb12be4649e70c6c90da2605bc5f4b314e2d07e | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_gaussian_mixture_model.py#L8-L35 | train |
vmirly/pyclust | pyclust/_gaussian_mixture_model.py | __log_density_single | def __log_density_single(x, mean, covar):
""" This is just a test function to calculate
the normal density at x given mean and covariance matrix.
Note: this function is not efficient, so
_log_multivariate_density is recommended for use.
"""
n_dim = mean.shape[0]
dx = x - ... | python | def __log_density_single(x, mean, covar):
""" This is just a test function to calculate
the normal density at x given mean and covariance matrix.
Note: this function is not efficient, so
_log_multivariate_density is recommended for use.
"""
n_dim = mean.shape[0]
dx = x - ... | [
"def",
"__log_density_single",
"(",
"x",
",",
"mean",
",",
"covar",
")",
":",
"n_dim",
"=",
"mean",
".",
"shape",
"[",
"0",
"]",
"dx",
"=",
"x",
"-",
"mean",
"covar_inv",
"=",
"scipy",
".",
"linalg",
".",
"inv",
"(",
"covar",
")",
"covar_det",
"=",... | This is just a test function to calculate
the normal density at x given mean and covariance matrix.
Note: this function is not efficient, so
_log_multivariate_density is recommended for use. | [
"This",
"is",
"just",
"a",
"test",
"function",
"to",
"calculate",
"the",
"normal",
"density",
"at",
"x",
"given",
"mean",
"and",
"covariance",
"matrix",
"."
] | bdb12be4649e70c6c90da2605bc5f4b314e2d07e | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_gaussian_mixture_model.py#L39-L54 | train |
vmirly/pyclust | pyclust/_gaussian_mixture_model.py | _log_multivariate_density | def _log_multivariate_density(X, means, covars):
"""
Class conditional density:
P(x | mu, Sigma) = 1/((2pi)^d/2 * |Sigma|^1/2) * exp(-1/2 * (x-mu)^T * Sigma^-1 * (x-mu))
log of class conditional density:
log P(x | mu, Sigma) = -1/2*(d*log(2pi) + log(|Sigma|) + (x-mu)^T * Sigma^-1 * (x-m... | python | def _log_multivariate_density(X, means, covars):
"""
Class conditional density:
P(x | mu, Sigma) = 1/((2pi)^d/2 * |Sigma|^1/2) * exp(-1/2 * (x-mu)^T * Sigma^-1 * (x-mu))
log of class conditional density:
log P(x | mu, Sigma) = -1/2*(d*log(2pi) + log(|Sigma|) + (x-mu)^T * Sigma^-1 * (x-m... | [
"def",
"_log_multivariate_density",
"(",
"X",
",",
"means",
",",
"covars",
")",
":",
"n_samples",
",",
"n_dim",
"=",
"X",
".",
"shape",
"n_components",
"=",
"means",
".",
"shape",
"[",
"0",
"]",
"assert",
"(",
"means",
".",
"shape",
"[",
"0",
"]",
"=... | Class conditional density:
P(x | mu, Sigma) = 1/((2pi)^d/2 * |Sigma|^1/2) * exp(-1/2 * (x-mu)^T * Sigma^-1 * (x-mu))
log of class conditional density:
log P(x | mu, Sigma) = -1/2*(d*log(2pi) + log(|Sigma|) + (x-mu)^T * Sigma^-1 * (x-mu)) | [
"Class",
"conditional",
"density",
":",
"P",
"(",
"x",
"|",
"mu",
"Sigma",
")",
"=",
"1",
"/",
"((",
"2pi",
")",
"^d",
"/",
"2",
"*",
"|Sigma|^1",
"/",
"2",
")",
"*",
"exp",
"(",
"-",
"1",
"/",
"2",
"*",
"(",
"x",
"-",
"mu",
")",
"^T",
"*... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_gaussian_mixture_model.py#L57-L90 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.