partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | RiverBasinNumbers2Selection.router_elements | 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... | hydpy/auxs/networktools.py | 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):
"""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(
.... | [
"A",
"|Elements|",
"collection",
"of",
"all",
"routing",
"basins",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/networktools.py#L343-L394 | [
"def",
"router_elements",
"(",
"self",
")",
":",
"elements",
"=",
"devicetools",
".",
"Elements",
"(",
")",
"for",
"router",
"in",
"self",
".",
"_router_numbers",
":",
"element",
"=",
"self",
".",
"_get_routername",
"(",
"router",
")",
"inlet",
"=",
"self"... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | RiverBasinNumbers2Selection.nodes | 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 ... | hydpy/auxs/networktools.py | 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):
"""A |Nodes| collection of all required nodes.
>>> from hydpy import RiverBasinNumbers2Selection
>>> rbns2s = RiverBasinNumbers2Selection(
... (111, 113, 1129, 11269, 1125, 11261,
... 11262, 1123, 1124, 1122... | [
"A",
"|Nodes|",
"collection",
"of",
"all",
"required",
"nodes",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/networktools.py#L402-L427 | [
"def",
"nodes",
"(",
"self",
")",
":",
"return",
"(",
"devicetools",
".",
"Nodes",
"(",
"self",
".",
"node_prefix",
"+",
"routers",
"for",
"routers",
"in",
"self",
".",
"_router_numbers",
")",
"+",
"devicetools",
".",
"Node",
"(",
"self",
".",
"last_node... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | RiverBasinNumbers2Selection.selection | 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,
... ... | hydpy/auxs/networktools.py | 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):
"""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",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/networktools.py#L430-L460 | [
"def",
"selection",
"(",
"self",
")",
":",
"return",
"selectiontools",
".",
"Selection",
"(",
"self",
".",
"selection_name",
",",
"self",
".",
"nodes",
",",
"self",
".",
"elements",
")"
] | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | str2chars | 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... | hydpy/core/netcdftools.py | 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:
"""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... | [
"Return",
"|numpy",
".",
"ndarray|",
"containing",
"the",
"byte",
"characters",
"(",
"second",
"axis",
")",
"of",
"all",
"given",
"strings",
"(",
"first",
"axis",
")",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L261-L284 | [
"def",
"str2chars",
"(",
"strings",
")",
"->",
"numpy",
".",
"ndarray",
":",
"maxlen",
"=",
"0",
"for",
"name",
"in",
"strings",
":",
"maxlen",
"=",
"max",
"(",
"maxlen",
",",
"len",
"(",
"name",
")",
")",
"# noinspection PyTypeChecker",
"chars",
"=",
... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | chars2str | 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([])
[] | hydpy/core/netcdftools.py | 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]:
"""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... | [
"Inversion",
"function",
"of",
"function",
"|str2chars|",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L287-L308 | [
"def",
"chars2str",
"(",
"chars",
")",
"->",
"List",
"[",
"str",
"]",
":",
"strings",
"=",
"collections",
".",
"deque",
"(",
")",
"for",
"subchars",
"in",
"chars",
":",
"substrings",
"=",
"collections",
".",
"deque",
"(",
")",
"for",
"char",
"in",
"s... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | create_dimension | 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
>... | hydpy/core/netcdftools.py | 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:
"""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... | [
"Add",
"a",
"new",
"dimension",
"with",
"the",
"given",
"name",
"and",
"length",
"to",
"the",
"given",
"NetCDF",
"file",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L311-L343 | [
"def",
"create_dimension",
"(",
"ncfile",
",",
"name",
",",
"length",
")",
"->",
"None",
":",
"try",
":",
"ncfile",
".",
"createDimension",
"(",
"name",
",",
"length",
")",
"except",
"BaseException",
":",
"objecttools",
".",
"augment_excmessage",
"(",
"'Whil... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | create_variable | 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 ... | hydpy/core/netcdftools.py | 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:
"""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:
... | [
"Add",
"a",
"new",
"variable",
"with",
"the",
"given",
"name",
"datatype",
"and",
"dimensions",
"to",
"the",
"given",
"NetCDF",
"file",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L346-L384 | [
"def",
"create_variable",
"(",
"ncfile",
",",
"name",
",",
"datatype",
",",
"dimensions",
")",
"->",
"None",
":",
"default",
"=",
"fillvalue",
"if",
"(",
"datatype",
"==",
"'f8'",
")",
"else",
"None",
"try",
":",
"ncfile",
".",
"createVariable",
"(",
"na... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | query_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 query_variable
>>> from hydpy import TestIO
>>> from hyd... | hydpy/core/netcdftools.py | 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:
"""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... | [
"Return",
"the",
"variable",
"with",
"the",
"given",
"name",
"from",
"the",
"given",
"NetCDF",
"file",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L387-L415 | [
"def",
"query_variable",
"(",
"ncfile",
",",
"name",
")",
"->",
"netcdf4",
".",
"Variable",
":",
"try",
":",
"return",
"ncfile",
"[",
"name",
"]",
"except",
"(",
"IndexError",
",",
"KeyError",
")",
":",
"raise",
"OSError",
"(",
"'NetCDF file `%s` does not co... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | query_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.netcdftools import query_timegrid
>>> filepath = 'LahnH... | hydpy/core/netcdftools.py | 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:
"""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... | [
"Return",
"the",
"|Timegrid|",
"defined",
"by",
"the",
"given",
"NetCDF",
"file",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L418-L439 | [
"def",
"query_timegrid",
"(",
"ncfile",
")",
"->",
"timetools",
".",
"Timegrid",
":",
"timepoints",
"=",
"ncfile",
"[",
"varmapping",
"[",
"'timepoints'",
"]",
"]",
"refdate",
"=",
"timetools",
".",
"Date",
".",
"from_cfunits",
"(",
"timepoints",
".",
"units... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | query_array | 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.... | hydpy/core/netcdftools.py | 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:
"""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... | [
"Return",
"the",
"data",
"of",
"the",
"variable",
"with",
"the",
"given",
"name",
"from",
"the",
"given",
"NetCDF",
"file",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L442-L471 | [
"def",
"query_array",
"(",
"ncfile",
",",
"name",
")",
"->",
"numpy",
".",
"ndarray",
":",
"variable",
"=",
"query_variable",
"(",
"ncfile",
",",
"name",
")",
"maskedarray",
"=",
"variable",
"[",
":",
"]",
"fillvalue_",
"=",
"getattr",
"(",
"variable",
"... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFInterface.log | Prepare a |NetCDFFile| object suitable for the given |IOSequence|
object, when necessary, and pass the given arguments to its
|NetCDFFile.log| method. | hydpy/core/netcdftools.py | 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:
"""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... | [
"Prepare",
"a",
"|NetCDFFile|",
"object",
"suitable",
"for",
"the",
"given",
"|IOSequence|",
"object",
"when",
"necessary",
"and",
"pass",
"the",
"given",
"arguments",
"to",
"its",
"|NetCDFFile",
".",
"log|",
"method",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L662-L691 | [
"def",
"log",
"(",
"self",
",",
"sequence",
",",
"infoarray",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"sequence",
",",
"sequencetools",
".",
"ModelSequence",
")",
":",
"descr",
"=",
"sequence",
".",
"descr_model",
"else",
":",
"descr",
"=",
"'no... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFInterface.read | Call method |NetCDFFile.read| of all handled |NetCDFFile| objects. | hydpy/core/netcdftools.py | 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:
"""Call method |NetCDFFile.read| of all handled |NetCDFFile| objects.
"""
for folder in self.folders.values():
for file_ in folder.values():
file_.read() | [
"Call",
"method",
"|NetCDFFile",
".",
"read|",
"of",
"all",
"handled",
"|NetCDFFile|",
"objects",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L693-L698 | [
"def",
"read",
"(",
"self",
")",
"->",
"None",
":",
"for",
"folder",
"in",
"self",
".",
"folders",
".",
"values",
"(",
")",
":",
"for",
"file_",
"in",
"folder",
".",
"values",
"(",
")",
":",
"file_",
".",
"read",
"(",
")"
] | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFInterface.write | Call method |NetCDFFile.write| of all handled |NetCDFFile| objects. | hydpy/core/netcdftools.py | 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:
"""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 ... | [
"Call",
"method",
"|NetCDFFile",
".",
"write|",
"of",
"all",
"handled",
"|NetCDFFile|",
"objects",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L700-L709 | [
"def",
"write",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"folders",
":",
"init",
"=",
"hydpy",
".",
"pub",
".",
"timegrids",
".",
"init",
"timeunits",
"=",
"init",
".",
"firstdate",
".",
"to_cfunits",
"(",
"'hours'",
")",
"timepoints",
... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFInterface.filenames | A |tuple| of names of all handled |NetCDFFile| objects. | hydpy/core/netcdftools.py | 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, ...]:
"""A |tuple| of names of all handled |NetCDFFile| objects."""
return tuple(sorted(set(itertools.chain(
*(_.keys() for _ in self.folders.values()))))) | [
"A",
"|tuple|",
"of",
"names",
"of",
"all",
"handled",
"|NetCDFFile|",
"objects",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L718-L721 | [
"def",
"filenames",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"return",
"tuple",
"(",
"sorted",
"(",
"set",
"(",
"itertools",
".",
"chain",
"(",
"*",
"(",
"_",
".",
"keys",
"(",
")",
"for",
"_",
"in",
"self",
".",
"fold... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFFile.log | 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
... | hydpy/core/netcdftools.py | 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:
"""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... | [
"Pass",
"the",
"given",
"|IoSequence|",
"to",
"a",
"suitable",
"instance",
"of",
"a",
"|NetCDFVariableBase|",
"subclass",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L845-L970 | [
"def",
"log",
"(",
"self",
",",
"sequence",
",",
"infoarray",
")",
"->",
"None",
":",
"aggregated",
"=",
"(",
"(",
"infoarray",
"is",
"not",
"None",
")",
"and",
"(",
"infoarray",
".",
"info",
"[",
"'type'",
"]",
"!=",
"'unmodified'",
")",
")",
"descr... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFFile.filepath | The NetCDF file path. | hydpy/core/netcdftools.py | def filepath(self) -> str:
"""The NetCDF file path."""
return os.path.join(self._dirpath, self.name + '.nc') | def filepath(self) -> str:
"""The NetCDF file path."""
return os.path.join(self._dirpath, self.name + '.nc') | [
"The",
"NetCDF",
"file",
"path",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L973-L975 | [
"def",
"filepath",
"(",
"self",
")",
"->",
"str",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_dirpath",
",",
"self",
".",
"name",
"+",
"'.nc'",
")"
] | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFFile.read | Open an existing NetCDF file temporarily and call method
|NetCDFVariableDeep.read| of all handled |NetCDFVariableBase|
objects. | hydpy/core/netcdftools.py | 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:
"""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)
... | [
"Open",
"an",
"existing",
"NetCDF",
"file",
"temporarily",
"and",
"call",
"method",
"|NetCDFVariableDeep",
".",
"read|",
"of",
"all",
"handled",
"|NetCDFVariableBase|",
"objects",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L977-L988 | [
"def",
"read",
"(",
"self",
")",
"->",
"None",
":",
"try",
":",
"with",
"netcdf4",
".",
"Dataset",
"(",
"self",
".",
"filepath",
",",
"\"r\"",
")",
"as",
"ncfile",
":",
"timegrid",
"=",
"query_timegrid",
"(",
"ncfile",
")",
"for",
"variable",
"in",
"... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFFile.write | Open a new NetCDF file temporarily and call method
|NetCDFVariableBase.write| of all handled |NetCDFVariableBase|
objects. | hydpy/core/netcdftools.py | 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:
"""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._... | [
"Open",
"a",
"new",
"NetCDF",
"file",
"temporarily",
"and",
"call",
"method",
"|NetCDFVariableBase",
".",
"write|",
"of",
"all",
"handled",
"|NetCDFVariableBase|",
"objects",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L990-L998 | [
"def",
"write",
"(",
"self",
",",
"timeunit",
",",
"timepoints",
")",
"->",
"None",
":",
"with",
"netcdf4",
".",
"Dataset",
"(",
"self",
".",
"filepath",
",",
"\"w\"",
")",
"as",
"ncfile",
":",
"ncfile",
".",
"Conventions",
"=",
"'CF-1.6'",
"self",
"."... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | Subdevice2Index.get_index | Item access to the wrapped |dict| object with a specialized
error message. | hydpy/core/netcdftools.py | 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:
"""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` '
... | [
"Item",
"access",
"to",
"the",
"wrapped",
"|dict|",
"object",
"with",
"a",
"specialized",
"error",
"message",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1046-L1057 | [
"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... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableBase.log | 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... | hydpy/core/netcdftools.py | 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:
"""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... | [
"Log",
"the",
"given",
"|IOSequence|",
"object",
"either",
"for",
"reading",
"or",
"writing",
"data",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1096-L1130 | [
"def",
"log",
"(",
"self",
",",
"sequence",
",",
"infoarray",
")",
"->",
"None",
":",
"descr_device",
"=",
"sequence",
".",
"descr_device",
"self",
".",
"sequences",
"[",
"descr_device",
"]",
"=",
"sequence",
"self",
".",
"arrays",
"[",
"descr_device",
"]"... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableBase.insert_subdevices | 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... | hydpy/core/netcdftools.py | 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:
"""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... | [
"Insert",
"a",
"variable",
"of",
"the",
"names",
"of",
"the",
"(",
"sub",
")",
"devices",
"of",
"the",
"logged",
"sequences",
"into",
"the",
"given",
"NetCDF",
"file"
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1168-L1223 | [
"def",
"insert_subdevices",
"(",
"self",
",",
"ncfile",
")",
"->",
"None",
":",
"prefix",
"=",
"self",
".",
"prefix",
"nmb_subdevices",
"=",
"'%s%s'",
"%",
"(",
"prefix",
",",
"dimmapping",
"[",
"'nmb_subdevices'",
"]",
")",
"nmb_characters",
"=",
"'%s%s'",
... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableBase.query_subdevices | 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... | hydpy/core/netcdftools.py | 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]:
"""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... | [
"Query",
"the",
"names",
"of",
"the",
"(",
"sub",
")",
"devices",
"of",
"the",
"logged",
"sequences",
"from",
"the",
"given",
"NetCDF",
"file"
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1225-L1274 | [
"def",
"query_subdevices",
"(",
"self",
",",
"ncfile",
")",
"->",
"List",
"[",
"str",
"]",
":",
"tests",
"=",
"[",
"'%s%s'",
"%",
"(",
"prefix",
",",
"varmapping",
"[",
"'subdevices'",
"]",
")",
"for",
"prefix",
"in",
"(",
"'%s_'",
"%",
"self",
".",
... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableBase.query_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
|Subdevice2Index| object remembers the NetCDF file the
(s... | hydpy/core/netcdftools.py | 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:
"""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
... | [
"Return",
"a",
"|Subdevice2Index|",
"that",
"maps",
"the",
"(",
"sub",
")",
"device",
"names",
"to",
"their",
"position",
"within",
"the",
"given",
"NetCDF",
"file",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1276-L1322 | [
"def",
"query_subdevice2index",
"(",
"self",
",",
"ncfile",
")",
"->",
"Subdevice2Index",
":",
"subdevices",
"=",
"self",
".",
"query_subdevices",
"(",
"ncfile",
")",
"self",
".",
"_test_duplicate_exists",
"(",
"ncfile",
",",
"subdevices",
")",
"subdev2index",
"... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableBase.sort_timeplaceentries | 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)
>>> ... | hydpy/core/netcdftools.py | 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]:
"""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... | [
"Return",
"a",
"|tuple|",
"containing",
"the",
"given",
"timeentry",
"and",
"placeentry",
"sorted",
"in",
"agreement",
"with",
"the",
"currently",
"selected",
"timeaxis",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1335-L1351 | [
"def",
"sort_timeplaceentries",
"(",
"self",
",",
"timeentry",
",",
"placeentry",
")",
"->",
"Tuple",
"[",
"Any",
",",
"Any",
"]",
":",
"if",
"self",
".",
"_timeaxis",
":",
"return",
"placeentry",
",",
"timeentry",
"return",
"timeentry",
",",
"placeentry"
] | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableBase.get_timeplaceslice | 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... | hydpy/core/netcdftools.py | 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 a |tuple| for indexing a complete time series of a certain
location available in |NetCDFVariableBase.array|.
>>> from hydpy.core.netcdftools import NetCDFVariableBase
>>> fro... | [
"Return",
"a",
"|tuple|",
"for",
"indexing",
"a",
"complete",
"time",
"series",
"of",
"a",
"certain",
"location",
"available",
"in",
"|NetCDFVariableBase",
".",
"array|",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1353-L1368 | [
"def",
"get_timeplaceslice",
"(",
"self",
",",
"placeindex",
")",
"->",
"Union",
"[",
"Tuple",
"[",
"slice",
",",
"int",
"]",
",",
"Tuple",
"[",
"int",
",",
"slice",
"]",
"]",
":",
"return",
"self",
".",
"sort_timeplaceentries",
"(",
"slice",
"(",
"Non... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | DeepAndAggMixin.subdevicenames | A |tuple| containing the device names. | hydpy/core/netcdftools.py | def subdevicenames(self) -> Tuple[str, ...]:
"""A |tuple| containing the device names."""
self: NetCDFVariableBase
return tuple(self.sequences.keys()) | def subdevicenames(self) -> Tuple[str, ...]:
"""A |tuple| containing the device names."""
self: NetCDFVariableBase
return tuple(self.sequences.keys()) | [
"A",
"|tuple|",
"containing",
"the",
"device",
"names",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1396-L1399 | [
"def",
"subdevicenames",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"self",
":",
"NetCDFVariableBase",
"return",
"tuple",
"(",
"self",
".",
"sequences",
".",
"keys",
"(",
")",
")"
] | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | DeepAndAggMixin.write | Write the data to the given NetCDF file.
See the general documentation on classes |NetCDFVariableDeep|
and |NetCDFVariableAgg| for some examples. | hydpy/core/netcdftools.py | 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:
"""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... | [
"Write",
"the",
"data",
"to",
"the",
"given",
"NetCDF",
"file",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1401-L1414 | [
"def",
"write",
"(",
"self",
",",
"ncfile",
")",
"->",
"None",
":",
"self",
":",
"NetCDFVariableBase",
"self",
".",
"insert_subdevices",
"(",
"ncfile",
")",
"dimensions",
"=",
"self",
".",
"dimensions",
"array",
"=",
"self",
".",
"array",
"for",
"dimension... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | AggAndFlatMixin.dimensions | 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... | hydpy/core/netcdftools.py | 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, ...]:
"""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:
... | [
"The",
"dimension",
"names",
"of",
"the",
"NetCDF",
"variable",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1421-L1455 | [
"def",
"dimensions",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"self",
":",
"NetCDFVariableBase",
"return",
"self",
".",
"sort_timeplaceentries",
"(",
"dimmapping",
"[",
"'nmb_timepoints'",
"]",
",",
"'%s%s'",
"%",
"(",
"self",
"."... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableDeep.get_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... | hydpy/core/netcdftools.py | 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, ...]:
"""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... | [
"Return",
"a",
"|tuple|",
"of",
"one",
"|int|",
"and",
"some",
"|slice|",
"objects",
"to",
"accesses",
"all",
"values",
"of",
"a",
"certain",
"device",
"within",
"|NetCDFVariableDeep",
".",
"array|",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1584-L1602 | [
"def",
"get_slices",
"(",
"self",
",",
"idx",
",",
"shape",
")",
"->",
"Tuple",
"[",
"IntOrSlice",
",",
"...",
"]",
":",
"slices",
"=",
"list",
"(",
"self",
".",
"get_timeplaceslice",
"(",
"idx",
")",
")",
"for",
"length",
"in",
"shape",
":",
"slices... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableDeep.shape | 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... | hydpy/core/netcdftools.py | 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, ...]:
"""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|:
... | [
"Required",
"shape",
"of",
"|NetCDFVariableDeep",
".",
"array|",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1605-L1649 | [
"def",
"shape",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"...",
"]",
":",
"nmb_place",
"=",
"len",
"(",
"self",
".",
"sequences",
")",
"nmb_time",
"=",
"len",
"(",
"hydpy",
".",
"pub",
".",
"timegrids",
".",
"init",
")",
"nmb_others",
"=",... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableDeep.array | 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... | hydpy/core/netcdftools.py | 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:
"""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... | [
"The",
"series",
"data",
"of",
"all",
"logged",
"|IOSequence|",
"objects",
"contained",
"in",
"one",
"single",
"|numpy",
".",
"ndarray|",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1652-L1705 | [
"def",
"array",
"(",
"self",
")",
"->",
"numpy",
".",
"ndarray",
":",
"array",
"=",
"numpy",
".",
"full",
"(",
"self",
".",
"shape",
",",
"fillvalue",
",",
"dtype",
"=",
"float",
")",
"for",
"idx",
",",
"(",
"descr",
",",
"subarray",
")",
"in",
"... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableDeep.dimensions | 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... | hydpy/core/netcdftools.py | 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, ...]:
"""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:
... | [
"The",
"dimension",
"names",
"of",
"the",
"NetCDF",
"variable",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1708-L1745 | [
"def",
"dimensions",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"nmb_timepoints",
"=",
"dimmapping",
"[",
"'nmb_timepoints'",
"]",
"nmb_subdevices",
"=",
"'%s%s'",
"%",
"(",
"self",
".",
"prefix",
",",
"dimmapping",
"[",
"'nmb_subde... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableDeep.read | 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. | hydpy/core/netcdftools.py | 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:
"""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 = ... | [
"Read",
"the",
"data",
"from",
"the",
"given",
"NetCDF",
"file",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1747-L1762 | [
"def",
"read",
"(",
"self",
",",
"ncfile",
",",
"timegrid_data",
")",
"->",
"None",
":",
"array",
"=",
"query_array",
"(",
"ncfile",
",",
"self",
".",
"name",
")",
"subdev2index",
"=",
"self",
".",
"query_subdevice2index",
"(",
"ncfile",
")",
"for",
"sub... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableAgg.shape | 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... | hydpy/core/netcdftools.py | 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]:
"""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|:
... | [
"Required",
"shape",
"of",
"|NetCDFVariableAgg",
".",
"array|",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1824-L1850 | [
"def",
"shape",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"int",
"]",
":",
"return",
"self",
".",
"sort_timeplaceentries",
"(",
"len",
"(",
"hydpy",
".",
"pub",
".",
"timegrids",
".",
"init",
")",
",",
"len",
"(",
"self",
".",
"sequences",
... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableAgg.array | 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`),
... | hydpy/core/netcdftools.py | 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:
"""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... | [
"The",
"aggregated",
"data",
"of",
"all",
"logged",
"|IOSequence|",
"objects",
"contained",
"in",
"one",
"single",
"|numpy",
".",
"ndarray|",
"object",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1853-L1891 | [
"def",
"array",
"(",
"self",
")",
"->",
"numpy",
".",
"ndarray",
":",
"array",
"=",
"numpy",
".",
"full",
"(",
"self",
".",
"shape",
",",
"fillvalue",
",",
"dtype",
"=",
"float",
")",
"for",
"idx",
",",
"subarray",
"in",
"enumerate",
"(",
"self",
"... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableFlat.shape | 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... | hydpy/core/netcdftools.py | 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]:
"""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... | [
"Required",
"shape",
"of",
"|NetCDFVariableFlat",
".",
"array|",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L1979-L2019 | [
"def",
"shape",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"int",
"]",
":",
"return",
"self",
".",
"sort_timeplaceentries",
"(",
"len",
"(",
"hydpy",
".",
"pub",
".",
"timegrids",
".",
"init",
")",
",",
"sum",
"(",
"len",
"(",
"seq",
")",
... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableFlat.array | 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
... | hydpy/core/netcdftools.py | 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:
"""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... | [
"The",
"series",
"data",
"of",
"all",
"logged",
"|IOSequence|",
"objects",
"contained",
"in",
"one",
"single",
"|numpy",
".",
"ndarray|",
"object",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L2022-L2081 | [
"def",
"array",
"(",
"self",
")",
"->",
"numpy",
".",
"ndarray",
":",
"array",
"=",
"numpy",
".",
"full",
"(",
"self",
".",
"shape",
",",
"fillvalue",
",",
"dtype",
"=",
"float",
")",
"idx0",
"=",
"0",
"idxs",
":",
"List",
"[",
"Any",
"]",
"=",
... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableFlat.subdevicenames | 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... | hydpy/core/netcdftools.py | 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, ...]:
"""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... | [
"A",
"|tuple|",
"containing",
"the",
"(",
"sub",
")",
"device",
"names",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L2084-L2123 | [
"def",
"subdevicenames",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"stats",
":",
"List",
"[",
"str",
"]",
"=",
"collections",
".",
"deque",
"(",
")",
"for",
"devicename",
",",
"seq",
"in",
"self",
".",
"sequences",
".",
"it... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableFlat._product | 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... | hydpy/core/netcdftools.py | 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, ...]]:
"""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... | [
"Should",
"return",
"all",
"subdevice",
"index",
"combinations",
"for",
"sequences",
"with",
"arbitrary",
"dimensions",
":"
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L2126-L2141 | [
"def",
"_product",
"(",
"shape",
")",
"->",
"Iterator",
"[",
"Tuple",
"[",
"int",
",",
"...",
"]",
"]",
":",
"return",
"itertools",
".",
"product",
"(",
"*",
"(",
"range",
"(",
"nmb",
")",
"for",
"nmb",
"in",
"shape",
")",
")"
] | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableFlat.read | 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. | hydpy/core/netcdftools.py | 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:
"""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 = ... | [
"Read",
"the",
"data",
"from",
"the",
"given",
"NetCDF",
"file",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L2143-L2170 | [
"def",
"read",
"(",
"self",
",",
"ncfile",
",",
"timegrid_data",
")",
"->",
"None",
":",
"array",
"=",
"query_array",
"(",
"ncfile",
",",
"self",
".",
"name",
")",
"idxs",
":",
"Tuple",
"[",
"Any",
"]",
"=",
"(",
"slice",
"(",
"None",
")",
",",
"... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NetCDFVariableFlat.write | Write the data to the given NetCDF file.
See the general documentation on class |NetCDFVariableFlat|
for some examples. | hydpy/core/netcdftools.py | 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:
"""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... | [
"Write",
"the",
"data",
"to",
"the",
"given",
"NetCDF",
"file",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L2172-L2180 | [
"def",
"write",
"(",
"self",
",",
"ncfile",
")",
"->",
"None",
":",
"self",
".",
"insert_subdevices",
"(",
"ncfile",
")",
"create_variable",
"(",
"ncfile",
",",
"self",
".",
"name",
",",
"'f8'",
",",
"self",
".",
"dimensions",
")",
"ncfile",
"[",
"self... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | NmbSubsteps.update | 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... | hydpy/models/llake/llake_derived.py | 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):
"""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... | [
"Determine",
"the",
"number",
"of",
"substeps",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/llake/llake_derived.py#L25-L67 | [
"def",
"update",
"(",
"self",
")",
":",
"maxdt",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
".",
"maxdt",
"seconds",
"=",
"self",
".",
"simulationstep",
".",
"seconds",
"self",
".",
"value",
"=",
"numpy",
".",
"ceil",
"(",
"seconds",
"... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | VQ.update | 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... | hydpy/models/llake/llake_derived.py | 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):
"""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... | [
"Calulate",
"the",
"auxilary",
"term",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/llake/llake_derived.py#L74-L95 | [
"def",
"update",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"der",
"=",
"self",
".",
"subpars",
"for",
"(",
"toy",
",",
"qs",
")",
"in",
"con",
".",
"q",
":",
"setattr",
"(",
"self",
",",
"str",
"(",... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | prepare_io_example_1 | 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',
... | hydpy/core/examples.py | 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
"""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... | [
"Prepare",
"an",
"IO",
"example",
"configuration",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/examples.py#L17-L156 | [
"def",
"prepare_io_example_1",
"(",
")",
"->",
"Tuple",
"[",
"devicetools",
".",
"Nodes",
",",
"devicetools",
".",
"Elements",
"]",
":",
"# noinspection PyUnresolvedReferences",
"from",
"hydpy",
"import",
"TestIO",
"TestIO",
".",
"clear",
"(",
")",
"from",
"hydp... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | prepare_full_example_1 | 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... | hydpy/core/examples.py | 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:
"""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('.')))
... | [
"Prepare",
"the",
"complete",
"LahnH",
"project",
"for",
"testing",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/examples.py#L159-L184 | [
"def",
"prepare_full_example_1",
"(",
")",
"->",
"None",
":",
"testtools",
".",
"TestIO",
".",
"clear",
"(",
")",
"shutil",
".",
"copytree",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data",
".",
"__path__",
"[",
"0",
"]",
",",
"'LahnH'",
")",
",",
... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | prepare_full_example_2 | 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... | hydpy/core/examples.py | 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 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 ... | [
"Prepare",
"the",
"complete",
"LahnH",
"project",
"for",
"testing",
"."
] | hydpy-dev/hydpy | python | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/examples.py#L187-L224 | [
"def",
"prepare_full_example_2",
"(",
"lastdate",
"=",
"'1996-01-05'",
")",
"->",
"(",
"hydpytools",
".",
"HydPy",
",",
"hydpy",
".",
"pub",
",",
"testtools",
".",
"TestIO",
")",
":",
"prepare_full_example_1",
"(",
")",
"with",
"testtools",
".",
"TestIO",
"(... | 1bc6a82cf30786521d86b36e27900c6717d3348d |
train | PostalCodeDatabase.get_postalcodes_around_radius | Bounding box calculations updated from pyzipcode | pypostalcode/__init__.py | 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're searching for.")
else:
pc = postalcodes[0]
radius = float(radius)
... | [
"Bounding",
"box",
"calculations",
"updated",
"from",
"pyzipcode"
] | inkjet/pypostalcode | python | https://github.com/inkjet/pypostalcode/blob/077c0085a57c2d24a0bb2596af56d701091fb9f4/pypostalcode/__init__.py#L71-L99 | [
"def",
"get_postalcodes_around_radius",
"(",
"self",
",",
"pc",
",",
"radius",
")",
":",
"postalcodes",
"=",
"self",
".",
"get",
"(",
"pc",
")",
"if",
"postalcodes",
"is",
"None",
":",
"raise",
"PostalCodeNotFoundException",
"(",
"\"Could not find postal code you'... | 077c0085a57c2d24a0bb2596af56d701091fb9f4 |
train | get_all_player_ids | 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 ... | nbashots/api.py | 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"):
"""
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 ... | [
"Returns",
"a",
"pandas",
"DataFrame",
"containing",
"the",
"player",
"IDs",
"used",
"in",
"the",
"stats",
".",
"nba",
".",
"com",
"API",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L251-L320 | [
"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",
"=... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | get_player_id | 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
... | nbashots/api.py | 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):
"""
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... | [
"Returns",
"the",
"player",
"ID",
"(",
"s",
")",
"associated",
"with",
"the",
"player",
"name",
"that",
"is",
"passed",
"in",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L323-L350 | [
"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... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | get_all_team_ids | Returns a pandas DataFrame with all Team IDs | nbashots/api.py | 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():
"""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 | [
"Returns",
"a",
"pandas",
"DataFrame",
"with",
"all",
"Team",
"IDs"
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L353-L358 | [
"def",
"get_all_team_ids",
"(",
")",
":",
"df",
"=",
"get_all_player_ids",
"(",
"\"all_data\"",
")",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"{",
"\"TEAM_NAME\"",
":",
"df",
".",
"TEAM_NAME",
".",
"unique",
"(",
")",
",",
"\"TEAM_ID\"",
":",
"df",
".",
... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | get_team_id | 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... | nbashots/api.py | 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):
""" 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... | [
"Returns",
"the",
"team",
"ID",
"associated",
"with",
"the",
"team",
"name",
"that",
"is",
"passed",
"in",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L361-L383 | [
"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... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | get_player_img | 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... | nbashots/api.py | 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):
"""
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
... | [
"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",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L386-L406 | [
"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",
"("... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | TeamLog.get_game_logs | Returns team game logs as a pandas DataFrame | nbashots/api.py | 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):
"""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)
... | [
"Returns",
"team",
"game",
"logs",
"as",
"a",
"pandas",
"DataFrame"
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L36-L42 | [
"def",
"get_game_logs",
"(",
"self",
")",
":",
"logs",
"=",
"self",
".",
"response",
".",
"json",
"(",
")",
"[",
"'resultSets'",
"]",
"[",
"0",
"]",
"[",
"'rowSet'",
"]",
"headers",
"=",
"self",
".",
"response",
".",
"json",
"(",
")",
"[",
"'result... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | TeamLog.get_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... | nbashots/api.py | 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):
"""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"
... | [
"Returns",
"the",
"Game",
"ID",
"associated",
"with",
"the",
"date",
"that",
"is",
"passed",
"in",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L44-L62 | [
"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"
] | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | TeamLog.update_params | 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... | nbashots/api.py | 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):
"""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
-------
... | [
"Pass",
"in",
"a",
"dictionary",
"to",
"update",
"url",
"parameters",
"for",
"NBA",
"stats",
"API"
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L64-L84 | [
"def",
"update_params",
"(",
"self",
",",
"parameters",
")",
":",
"self",
".",
"url_paramaters",
".",
"update",
"(",
"parameters",
")",
"self",
".",
"response",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"base_url",
",",
"params",
"=",
"self",
".",
... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | Shots.get_shots | Returns the shot chart data as a pandas DataFrame. | nbashots/api.py | 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):
"""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) | [
"Returns",
"the",
"shot",
"chart",
"data",
"as",
"a",
"pandas",
"DataFrame",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/api.py#L218-L222 | [
"def",
"get_shots",
"(",
"self",
")",
":",
"shots",
"=",
"self",
".",
"response",
".",
"json",
"(",
")",
"[",
"'resultSets'",
"]",
"[",
"0",
"]",
"[",
"'rowSet'",
"]",
"headers",
"=",
"self",
".",
"response",
".",
"json",
"(",
")",
"[",
"'resultSet... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | Connection.connect | Connect will attempt to connect to the NATS server. The url can
contain username/password semantics. | pynats/connection.py | 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):
"""
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() | [
"Connect",
"will",
"attempt",
"to",
"connect",
"to",
"the",
"NATS",
"server",
".",
"The",
"url",
"can",
"contain",
"username",
"/",
"password",
"semantics",
"."
] | mcuadros/pynats | python | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L45-L53 | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"_build_socket",
"(",
")",
"self",
".",
"_connect_socket",
"(",
")",
"self",
".",
"_build_file_socket",
"(",
")",
"self",
".",
"_send_connect_msg",
"(",
")"
] | afbf0766c5546f9b8e7b54ddc89abd2602883b6c |
train | Connection.subscribe | 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 | pynats/connection.py | 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=''):
"""
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
... | [
"Subscribe",
"will",
"express",
"interest",
"in",
"the",
"given",
"subject",
".",
"The",
"subject",
"can",
"have",
"wildcards",
"(",
"partial",
":",
"*",
"full",
":",
">",
")",
".",
"Messages",
"will",
"be",
"delivered",
"to",
"the",
"associated",
"callbac... | mcuadros/pynats | python | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L93-L115 | [
"def",
"subscribe",
"(",
"self",
",",
"subject",
",",
"callback",
",",
"queue",
"=",
"''",
")",
":",
"s",
"=",
"Subscription",
"(",
"sid",
"=",
"self",
".",
"_next_sid",
",",
"subject",
"=",
"subject",
",",
"queue",
"=",
"queue",
",",
"callback",
"="... | afbf0766c5546f9b8e7b54ddc89abd2602883b6c |
train | Connection.unsubscribe | 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 | pynats/connection.py | 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):
"""
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... | [
"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"
] | mcuadros/pynats | python | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L117-L132 | [
"def",
"unsubscribe",
"(",
"self",
",",
"subscription",
",",
"max",
"=",
"None",
")",
":",
"if",
"max",
"is",
"None",
":",
"self",
".",
"_send",
"(",
"'UNSUB %d'",
"%",
"subscription",
".",
"sid",
")",
"self",
".",
"_subscriptions",
".",
"pop",
"(",
... | afbf0766c5546f9b8e7b54ddc89abd2602883b6c |
train | Connection.publish | 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 | pynats/connection.py | 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):
"""
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... | [
"Publish",
"publishes",
"the",
"data",
"argument",
"to",
"the",
"given",
"subject",
"."
] | mcuadros/pynats | python | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L134-L152 | [
"def",
"publish",
"(",
"self",
",",
"subject",
",",
"msg",
",",
"reply",
"=",
"None",
")",
":",
"if",
"msg",
"is",
"None",
":",
"msg",
"=",
"''",
"if",
"reply",
"is",
"None",
":",
"command",
"=",
"'PUB %s %d'",
"%",
"(",
"subject",
",",
"len",
"(... | afbf0766c5546f9b8e7b54ddc89abd2602883b6c |
train | Connection.request | 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 | pynats/connection.py | 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):
"""
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... | [
"ublish",
"a",
"message",
"with",
"an",
"implicit",
"inbox",
"listener",
"as",
"the",
"reply",
".",
"Message",
"is",
"optional",
"."
] | mcuadros/pynats | python | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L154-L169 | [
"def",
"request",
"(",
"self",
",",
"subject",
",",
"callback",
",",
"msg",
"=",
"None",
")",
":",
"inbox",
"=",
"self",
".",
"_build_inbox",
"(",
")",
"s",
"=",
"self",
".",
"subscribe",
"(",
"inbox",
",",
"callback",
")",
"self",
".",
"unsubscribe"... | afbf0766c5546f9b8e7b54ddc89abd2602883b6c |
train | Connection.wait | 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 | pynats/connection.py | 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):
"""
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()
... | [
"Publish",
"publishes",
"the",
"data",
"argument",
"to",
"the",
"given",
"subject",
"."
] | mcuadros/pynats | python | https://github.com/mcuadros/pynats/blob/afbf0766c5546f9b8e7b54ddc89abd2602883b6c/pynats/connection.py#L175-L199 | [
"def",
"wait",
"(",
"self",
",",
"duration",
"=",
"None",
",",
"count",
"=",
"0",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"total",
"=",
"0",
"while",
"True",
":",
"type",
",",
"result",
"=",
"self",
".",
"_recv",
"(",
"MSG",
",",... | afbf0766c5546f9b8e7b54ddc89abd2602883b6c |
train | draw_court | 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... | nbashots/charts.py | 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):
"""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) ... | [
"Returns",
"an",
"axes",
"with",
"a",
"basketball",
"court",
"drawn",
"onto",
"to",
"it",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L15-L103 | [
"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... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | shot_chart | 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... | nbashots/charts.py | 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, -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... | [
"Returns",
"an",
"Axes",
"object",
"with",
"player",
"shots",
"plotted",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L106-L219 | [
"def",
"shot_chart",
"(",
"x",
",",
"y",
",",
"kind",
"=",
"\"scatter\"",
",",
"title",
"=",
"\"\"",
",",
"color",
"=",
"\"b\"",
",",
"cmap",
"=",
"None",
",",
"xlim",
"=",
"(",
"-",
"250",
",",
"250",
")",
",",
"ylim",
"=",
"(",
"422.5",
",",
... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | shot_chart_jointgrid | 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
... | nbashots/charts.py | 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),
ylim=(422.5, -47.5), court_color="gray", court_lw=1,
outer_lines=False, flip_court=False,
joint_kde... | [
"Returns",
"a",
"JointGrid",
"object",
"containing",
"the",
"shot",
"chart",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L222-L398 | [
"def",
"shot_chart_jointgrid",
"(",
"x",
",",
"y",
",",
"data",
"=",
"None",
",",
"joint_type",
"=",
"\"scatter\"",
",",
"title",
"=",
"\"\"",
",",
"joint_color",
"=",
"\"b\"",
",",
"cmap",
"=",
"None",
",",
"xlim",
"=",
"(",
"-",
"250",
",",
"250",
... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | shot_chart_jointplot | 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... | nbashots/charts.py | 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), ylim=(422.5, -47.5),
court_color="gray", court_lw=1, outer_lines=False,
flip_court=False, size=(12, 11), space=0,
... | [
"Returns",
"a",
"seaborn",
"JointGrid",
"using",
"sns",
".",
"jointplot"
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L401-L514 | [
"def",
"shot_chart_jointplot",
"(",
"x",
",",
"y",
",",
"data",
"=",
"None",
",",
"kind",
"=",
"\"scatter\"",
",",
"title",
"=",
"\"\"",
",",
"color",
"=",
"\"b\"",
",",
"cmap",
"=",
"None",
",",
"xlim",
"=",
"(",
"-",
"250",
",",
"250",
")",
","... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | heatmap | Returns an AxesImage object that contains a heatmap.
TODO: Redo some code and explain parameters | nbashots/charts.py | 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, -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... | [
"Returns",
"an",
"AxesImage",
"object",
"that",
"contains",
"a",
"heatmap",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L517-L559 | [
"def",
"heatmap",
"(",
"x",
",",
"y",
",",
"z",
",",
"title",
"=",
"\"\"",
",",
"cmap",
"=",
"plt",
".",
"cm",
".",
"YlOrRd",
",",
"bins",
"=",
"20",
",",
"xlim",
"=",
"(",
"-",
"250",
",",
"250",
")",
",",
"ylim",
"=",
"(",
"422.5",
",",
... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | bokeh_draw_court | 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... | nbashots/charts.py | 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):
"""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... | [
"Returns",
"a",
"figure",
"with",
"the",
"basketball",
"court",
"lines",
"drawn",
"onto",
"it"
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L563-L641 | [
"def",
"bokeh_draw_court",
"(",
"figure",
",",
"line_color",
"=",
"'gray'",
",",
"line_width",
"=",
"1",
")",
":",
"# hoop",
"figure",
".",
"circle",
"(",
"x",
"=",
"0",
",",
"y",
"=",
"0",
",",
"radius",
"=",
"7.5",
",",
"fill_alpha",
"=",
"0",
",... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | bokeh_shot_chart | 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... | nbashots/charts.py | 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='gray', court_line_width=1,
hover_tool=False, tooltips=None, **kwargs):
# TODO: Settings for hover tooltip
"""
... | [
"Returns",
"a",
"figure",
"with",
"both",
"FGA",
"and",
"basketball",
"court",
"lines",
"drawn",
"onto",
"it",
"."
] | savvastj/nbashots | python | https://github.com/savvastj/nbashots/blob/76ece28d717f10b25eb0fc681b317df6ef6b5157/nbashots/charts.py#L644-L704 | [
"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",
"=... | 76ece28d717f10b25eb0fc681b317df6ef6b5157 |
train | _update_centers | Update Cluster Centers:
calculate the mean of feature vectors for each cluster.
distance can be a string or callable. | pyclust/_kmedoids.py | 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):
""" 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... | [
"Update",
"Cluster",
"Centers",
":",
"calculate",
"the",
"mean",
"of",
"feature",
"vectors",
"for",
"each",
"cluster",
"."
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmedoids.py#L8-L27 | [
"def",
"_update_centers",
"(",
"X",
",",
"membs",
",",
"n_clusters",
",",
"distance",
")",
":",
"centers",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"(",
"n_clusters",
",",
"X",
".",
"shape",
"[",
"1",
"]",
")",
",",
"dtype",
"=",
"float",
")",
... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _kmedoids_run | Run a single trial of k-medoids clustering
on dataset X, and given number of clusters | pyclust/_kmedoids.py | 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):
""" 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
... | [
"Run",
"a",
"single",
"trial",
"of",
"k",
"-",
"medoids",
"clustering",
"on",
"dataset",
"X",
"and",
"given",
"number",
"of",
"clusters"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmedoids.py#L31-L49 | [
"def",
"_kmedoids_run",
"(",
"X",
",",
"n_clusters",
",",
"distance",
",",
"max_iter",
",",
"tol",
",",
"rng",
")",
":",
"membs",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"int",
")",
"center... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | KMedoids.fit | Apply KMeans Clustering
X: dataset with feature vectors | pyclust/_kmedoids.py | 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):
""" 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) | [
"Apply",
"KMeans",
"Clustering",
"X",
":",
"dataset",
"with",
"feature",
"vectors"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmedoids.py#L129-L134 | [
"def",
"fit",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"centers_",
",",
"self",
".",
"labels_",
",",
"self",
".",
"sse_arr_",
",",
"self",
".",
"n_iter_",
"=",
"_kmedoids",
"(",
"X",
",",
"self",
".",
"n_clusters",
",",
"self",
".",
"distance"... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _kernelized_dist2centers | 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 ... | pyclust/_kernel_kmeans.py | 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):
""" 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... | [
"Computin",
"the",
"distance",
"in",
"transformed",
"feature",
"space",
"to",
"cluster",
"centers",
".",
"K",
"is",
"the",
"kernel",
"gram",
"matrix",
".",
"wmemb",
"contains",
"cluster",
"assignment",
".",
"{",
"0",
"1",
"}"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kernel_kmeans.py#L29-L51 | [
"def",
"_kernelized_dist2centers",
"(",
"K",
",",
"n_clusters",
",",
"wmemb",
",",
"kernel_dist",
")",
":",
"n_samples",
"=",
"K",
".",
"shape",
"[",
"0",
"]",
"for",
"j",
"in",
"range",
"(",
"n_clusters",
")",
":",
"memb_j",
"=",
"np",
".",
"where",
... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _init_mixture_params | Initialize mixture density parameters with
equal priors
random means
identity covariance matrices | pyclust/_gaussian_mixture_model.py | 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):
"""
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... | [
"Initialize",
"mixture",
"density",
"parameters",
"with",
"equal",
"priors",
"random",
"means",
"identity",
"covariance",
"matrices"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_gaussian_mixture_model.py#L8-L35 | [
"def",
"_init_mixture_params",
"(",
"X",
",",
"n_mixtures",
",",
"init_method",
")",
":",
"init_priors",
"=",
"np",
".",
"ones",
"(",
"shape",
"=",
"n_mixtures",
",",
"dtype",
"=",
"float",
")",
"/",
"n_mixtures",
"if",
"init_method",
"==",
"'kmeans'",
":"... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | __log_density_single | 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. | pyclust/_gaussian_mixture_model.py | 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):
""" 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 - ... | [
"This",
"is",
"just",
"a",
"test",
"function",
"to",
"calculate",
"the",
"normal",
"density",
"at",
"x",
"given",
"mean",
"and",
"covariance",
"matrix",
"."
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_gaussian_mixture_model.py#L39-L54 | [
"def",
"__log_density_single",
"(",
"x",
",",
"mean",
",",
"covar",
")",
":",
"n_dim",
"=",
"mean",
".",
"shape",
"[",
"0",
"]",
"dx",
"=",
"x",
"-",
"mean",
"covar_inv",
"=",
"scipy",
".",
"linalg",
".",
"inv",
"(",
"covar",
")",
"covar_det",
"=",... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _log_multivariate_density | 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)) | pyclust/_gaussian_mixture_model.py | 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):
"""
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... | [
"Class",
"conditional",
"density",
":",
"P",
"(",
"x",
"|",
"mu",
"Sigma",
")",
"=",
"1",
"/",
"((",
"2pi",
")",
"^d",
"/",
"2",
"*",
"|Sigma|^1",
"/",
"2",
")",
"*",
"exp",
"(",
"-",
"1",
"/",
"2",
"*",
"(",
"x",
"-",
"mu",
")",
"^T",
"*... | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_gaussian_mixture_model.py#L57-L90 | [
"def",
"_log_multivariate_density",
"(",
"X",
",",
"means",
",",
"covars",
")",
":",
"n_samples",
",",
"n_dim",
"=",
"X",
".",
"shape",
"n_components",
"=",
"means",
".",
"shape",
"[",
"0",
"]",
"assert",
"(",
"means",
".",
"shape",
"[",
"0",
"]",
"=... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _log_likelihood_per_sample | Theta = (theta_1, theta_2, ... theta_M)
Likelihood of mixture parameters given data: L(Theta | X) = product_i P(x_i | Theta)
log likelihood: log L(Theta | X) = sum_i log(P(x_i | Theta))
and note that p(x_i | Theta) = sum_j prior_j * p(x_i | theta_j)
Probability of sample x being generated fro... | pyclust/_gaussian_mixture_model.py | def _log_likelihood_per_sample(X, means, covars):
"""
Theta = (theta_1, theta_2, ... theta_M)
Likelihood of mixture parameters given data: L(Theta | X) = product_i P(x_i | Theta)
log likelihood: log L(Theta | X) = sum_i log(P(x_i | Theta))
and note that p(x_i | Theta) = sum_j prior_j * p(x_... | def _log_likelihood_per_sample(X, means, covars):
"""
Theta = (theta_1, theta_2, ... theta_M)
Likelihood of mixture parameters given data: L(Theta | X) = product_i P(x_i | Theta)
log likelihood: log L(Theta | X) = sum_i log(P(x_i | Theta))
and note that p(x_i | Theta) = sum_j prior_j * p(x_... | [
"Theta",
"=",
"(",
"theta_1",
"theta_2",
"...",
"theta_M",
")",
"Likelihood",
"of",
"mixture",
"parameters",
"given",
"data",
":",
"L",
"(",
"Theta",
"|",
"X",
")",
"=",
"product_i",
"P",
"(",
"x_i",
"|",
"Theta",
")",
"log",
"likelihood",
":",
"log",
... | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_gaussian_mixture_model.py#L95-L120 | [
"def",
"_log_likelihood_per_sample",
"(",
"X",
",",
"means",
",",
"covars",
")",
":",
"logden",
"=",
"_log_multivariate_density",
"(",
"X",
",",
"means",
",",
"covars",
")",
"logden_max",
"=",
"logden",
".",
"max",
"(",
"axis",
"=",
"1",
")",
"log_likeliho... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _validate_params | Validation Check for M.L. paramateres | pyclust/_gaussian_mixture_model.py | def _validate_params(priors, means, covars):
""" Validation Check for M.L. paramateres
"""
for i,(p,m,cv) in enumerate(zip(priors, means, covars)):
if np.any(np.isinf(p)) or np.any(np.isnan(p)):
raise ValueError("Component %d of priors is not valid " % i)
if np.any(np.isinf(m))... | def _validate_params(priors, means, covars):
""" Validation Check for M.L. paramateres
"""
for i,(p,m,cv) in enumerate(zip(priors, means, covars)):
if np.any(np.isinf(p)) or np.any(np.isnan(p)):
raise ValueError("Component %d of priors is not valid " % i)
if np.any(np.isinf(m))... | [
"Validation",
"Check",
"for",
"M",
".",
"L",
".",
"paramateres"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_gaussian_mixture_model.py#L124-L139 | [
"def",
"_validate_params",
"(",
"priors",
",",
"means",
",",
"covars",
")",
":",
"for",
"i",
",",
"(",
"p",
",",
"m",
",",
"cv",
")",
"in",
"enumerate",
"(",
"zip",
"(",
"priors",
",",
"means",
",",
"covars",
")",
")",
":",
"if",
"np",
".",
"an... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _maximization_step | Update class parameters as below:
priors: P(w_i) = sum_x P(w_i | x) ==> Then normalize to get in [0,1]
Class means: center_w_i = sum_x P(w_i|x)*x / sum_i sum_x P(w_i|x) | pyclust/_gaussian_mixture_model.py | def _maximization_step(X, posteriors):
"""
Update class parameters as below:
priors: P(w_i) = sum_x P(w_i | x) ==> Then normalize to get in [0,1]
Class means: center_w_i = sum_x P(w_i|x)*x / sum_i sum_x P(w_i|x)
"""
### Prior probabilities or class weights
sum_post_proba = np.sum... | def _maximization_step(X, posteriors):
"""
Update class parameters as below:
priors: P(w_i) = sum_x P(w_i | x) ==> Then normalize to get in [0,1]
Class means: center_w_i = sum_x P(w_i|x)*x / sum_i sum_x P(w_i|x)
"""
### Prior probabilities or class weights
sum_post_proba = np.sum... | [
"Update",
"class",
"parameters",
"as",
"below",
":",
"priors",
":",
"P",
"(",
"w_i",
")",
"=",
"sum_x",
"P",
"(",
"w_i",
"|",
"x",
")",
"==",
">",
"Then",
"normalize",
"to",
"get",
"in",
"[",
"0",
"1",
"]",
"Class",
"means",
":",
"center_w_i",
"=... | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_gaussian_mixture_model.py#L143-L173 | [
"def",
"_maximization_step",
"(",
"X",
",",
"posteriors",
")",
":",
"### Prior probabilities or class weights",
"sum_post_proba",
"=",
"np",
".",
"sum",
"(",
"posteriors",
",",
"axis",
"=",
"0",
")",
"prior_proba",
"=",
"sum_post_proba",
"/",
"(",
"sum_post_proba"... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | GMM.fit | Fit mixture-density parameters with EM algorithm | pyclust/_gaussian_mixture_model.py | def fit(self, X):
""" Fit mixture-density parameters with EM algorithm
"""
params_dict = _fit_gmm_params(X=X, n_mixtures=self.n_clusters, \
n_init=self.n_trials, init_method=self.init_method, \
n_iter=self.max_iter, tol=self.tol)
self.prior... | def fit(self, X):
""" Fit mixture-density parameters with EM algorithm
"""
params_dict = _fit_gmm_params(X=X, n_mixtures=self.n_clusters, \
n_init=self.n_trials, init_method=self.init_method, \
n_iter=self.max_iter, tol=self.tol)
self.prior... | [
"Fit",
"mixture",
"-",
"density",
"parameters",
"with",
"EM",
"algorithm"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_gaussian_mixture_model.py#L247-L258 | [
"def",
"fit",
"(",
"self",
",",
"X",
")",
":",
"params_dict",
"=",
"_fit_gmm_params",
"(",
"X",
"=",
"X",
",",
"n_mixtures",
"=",
"self",
".",
"n_clusters",
",",
"n_init",
"=",
"self",
".",
"n_trials",
",",
"init_method",
"=",
"self",
".",
"init_method... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _kmeans_init | Initialize k=n_clusters centroids randomly | pyclust/_kmeans.py | def _kmeans_init(X, n_clusters, method='balanced', rng=None):
""" Initialize k=n_clusters centroids randomly
"""
n_samples = X.shape[0]
if rng is None:
cent_idx = np.random.choice(n_samples, replace=False, size=n_clusters)
else:
#print('Generate random centers using RNG')
cen... | def _kmeans_init(X, n_clusters, method='balanced', rng=None):
""" Initialize k=n_clusters centroids randomly
"""
n_samples = X.shape[0]
if rng is None:
cent_idx = np.random.choice(n_samples, replace=False, size=n_clusters)
else:
#print('Generate random centers using RNG')
cen... | [
"Initialize",
"k",
"=",
"n_clusters",
"centroids",
"randomly"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmeans.py#L4-L20 | [
"def",
"_kmeans_init",
"(",
"X",
",",
"n_clusters",
",",
"method",
"=",
"'balanced'",
",",
"rng",
"=",
"None",
")",
":",
"n_samples",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
"if",
"rng",
"is",
"None",
":",
"cent_idx",
"=",
"np",
".",
"random",
".",
... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _assign_clusters | Assignment Step:
assign each point to the closet cluster center | pyclust/_kmeans.py | def _assign_clusters(X, centers):
""" Assignment Step:
assign each point to the closet cluster center
"""
dist2cents = scipy.spatial.distance.cdist(X, centers, metric='seuclidean')
membs = np.argmin(dist2cents, axis=1)
return(membs) | def _assign_clusters(X, centers):
""" Assignment Step:
assign each point to the closet cluster center
"""
dist2cents = scipy.spatial.distance.cdist(X, centers, metric='seuclidean')
membs = np.argmin(dist2cents, axis=1)
return(membs) | [
"Assignment",
"Step",
":",
"assign",
"each",
"point",
"to",
"the",
"closet",
"cluster",
"center"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmeans.py#L23-L30 | [
"def",
"_assign_clusters",
"(",
"X",
",",
"centers",
")",
":",
"dist2cents",
"=",
"scipy",
".",
"spatial",
".",
"distance",
".",
"cdist",
"(",
"X",
",",
"centers",
",",
"metric",
"=",
"'seuclidean'",
")",
"membs",
"=",
"np",
".",
"argmin",
"(",
"dist2c... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _cal_dist2center | Calculate the SSE to the cluster center | pyclust/_kmeans.py | def _cal_dist2center(X, center):
""" Calculate the SSE to the cluster center
"""
dmemb2cen = scipy.spatial.distance.cdist(X, center.reshape(1,X.shape[1]), metric='seuclidean')
return(np.sum(dmemb2cen)) | def _cal_dist2center(X, center):
""" Calculate the SSE to the cluster center
"""
dmemb2cen = scipy.spatial.distance.cdist(X, center.reshape(1,X.shape[1]), metric='seuclidean')
return(np.sum(dmemb2cen)) | [
"Calculate",
"the",
"SSE",
"to",
"the",
"cluster",
"center"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmeans.py#L32-L36 | [
"def",
"_cal_dist2center",
"(",
"X",
",",
"center",
")",
":",
"dmemb2cen",
"=",
"scipy",
".",
"spatial",
".",
"distance",
".",
"cdist",
"(",
"X",
",",
"center",
".",
"reshape",
"(",
"1",
",",
"X",
".",
"shape",
"[",
"1",
"]",
")",
",",
"metric",
... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _update_centers | Update Cluster Centers:
calculate the mean of feature vectors for each cluster | pyclust/_kmeans.py | def _update_centers(X, membs, n_clusters):
""" Update Cluster Centers:
calculate the mean of feature vectors for each cluster
"""
centers = np.empty(shape=(n_clusters, X.shape[1]), dtype=float)
sse = np.empty(shape=n_clusters, dtype=float)
for clust_id in range(n_clusters):
memb_i... | def _update_centers(X, membs, n_clusters):
""" Update Cluster Centers:
calculate the mean of feature vectors for each cluster
"""
centers = np.empty(shape=(n_clusters, X.shape[1]), dtype=float)
sse = np.empty(shape=n_clusters, dtype=float)
for clust_id in range(n_clusters):
memb_i... | [
"Update",
"Cluster",
"Centers",
":",
"calculate",
"the",
"mean",
"of",
"feature",
"vectors",
"for",
"each",
"cluster"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmeans.py#L38-L53 | [
"def",
"_update_centers",
"(",
"X",
",",
"membs",
",",
"n_clusters",
")",
":",
"centers",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"(",
"n_clusters",
",",
"X",
".",
"shape",
"[",
"1",
"]",
")",
",",
"dtype",
"=",
"float",
")",
"sse",
"=",
"np"... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _kmeans_run | Run a single trial of k-means clustering
on dataset X, and given number of clusters | pyclust/_kmeans.py | def _kmeans_run(X, n_clusters, max_iter, tol):
""" Run a single trial of k-means clustering
on dataset X, and given number of clusters
"""
membs = np.empty(shape=X.shape[0], dtype=int)
centers = _kmeans_init(X, n_clusters)
sse_last = 9999.9
n_iter = 0
for it in range(1,max_iter):
... | def _kmeans_run(X, n_clusters, max_iter, tol):
""" Run a single trial of k-means clustering
on dataset X, and given number of clusters
"""
membs = np.empty(shape=X.shape[0], dtype=int)
centers = _kmeans_init(X, n_clusters)
sse_last = 9999.9
n_iter = 0
for it in range(1,max_iter):
... | [
"Run",
"a",
"single",
"trial",
"of",
"k",
"-",
"means",
"clustering",
"on",
"dataset",
"X",
"and",
"given",
"number",
"of",
"clusters"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmeans.py#L57-L75 | [
"def",
"_kmeans_run",
"(",
"X",
",",
"n_clusters",
",",
"max_iter",
",",
"tol",
")",
":",
"membs",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"int",
")",
"centers",
"=",
"_kmeans_init",
"(",
"... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _kmeans | Run multiple trials of k-means clustering,
and outputt he best centers, and cluster labels | pyclust/_kmeans.py | def _kmeans(X, n_clusters, max_iter, n_trials, tol):
""" Run multiple trials of k-means clustering,
and outputt he best centers, and cluster labels
"""
n_samples, n_features = X.shape[0], X.shape[1]
centers_best = np.empty(shape=(n_clusters,n_features), dtype=float)
labels_best = np.empty(... | def _kmeans(X, n_clusters, max_iter, n_trials, tol):
""" Run multiple trials of k-means clustering,
and outputt he best centers, and cluster labels
"""
n_samples, n_features = X.shape[0], X.shape[1]
centers_best = np.empty(shape=(n_clusters,n_features), dtype=float)
labels_best = np.empty(... | [
"Run",
"multiple",
"trials",
"of",
"k",
"-",
"means",
"clustering",
"and",
"outputt",
"he",
"best",
"centers",
"and",
"cluster",
"labels"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmeans.py#L78-L101 | [
"def",
"_kmeans",
"(",
"X",
",",
"n_clusters",
",",
"max_iter",
",",
"n_trials",
",",
"tol",
")",
":",
"n_samples",
",",
"n_features",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
",",
"X",
".",
"shape",
"[",
"1",
"]",
"centers_best",
"=",
"np",
".",
"... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | KMeans.fit | Apply KMeans Clustering
X: dataset with feature vectors | pyclust/_kmeans.py | def fit(self, X):
""" Apply KMeans Clustering
X: dataset with feature vectors
"""
self.centers_, self.labels_, self.sse_arr_, self.n_iter_ = \
_kmeans(X, self.n_clusters, self.max_iter, self.n_trials, self.tol) | def fit(self, X):
""" Apply KMeans Clustering
X: dataset with feature vectors
"""
self.centers_, self.labels_, self.sse_arr_, self.n_iter_ = \
_kmeans(X, self.n_clusters, self.max_iter, self.n_trials, self.tol) | [
"Apply",
"KMeans",
"Clustering",
"X",
":",
"dataset",
"with",
"feature",
"vectors"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_kmeans.py#L137-L142 | [
"def",
"fit",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"centers_",
",",
"self",
".",
"labels_",
",",
"self",
".",
"sse_arr_",
",",
"self",
".",
"n_iter_",
"=",
"_kmeans",
"(",
"X",
",",
"self",
".",
"n_clusters",
",",
"self",
".",
"max_iter",
... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _cut_tree | Cut the tree to get desired number of clusters as n_clusters
2 <= n_desired <= n_clusters | pyclust/_bisect_kmeans.py | def _cut_tree(tree, n_clusters, membs):
""" Cut the tree to get desired number of clusters as n_clusters
2 <= n_desired <= n_clusters
"""
## starting from root,
## a node is added to the cut_set or
## its children are added to node_set
assert(n_clusters >= 2)
assert(n_clusters <... | def _cut_tree(tree, n_clusters, membs):
""" Cut the tree to get desired number of clusters as n_clusters
2 <= n_desired <= n_clusters
"""
## starting from root,
## a node is added to the cut_set or
## its children are added to node_set
assert(n_clusters >= 2)
assert(n_clusters <... | [
"Cut",
"the",
"tree",
"to",
"get",
"desired",
"number",
"of",
"clusters",
"as",
"n_clusters",
"2",
"<",
"=",
"n_desired",
"<",
"=",
"n_clusters"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_bisect_kmeans.py#L27-L70 | [
"def",
"_cut_tree",
"(",
"tree",
",",
"n_clusters",
",",
"membs",
")",
":",
"## starting from root,",
"## a node is added to the cut_set or ",
"## its children are added to node_set",
"assert",
"(",
"n_clusters",
">=",
"2",
")",
"assert",
"(",
"n_clusters",
"<=",
"len",... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _add_tree_node | Add a node to the tree
if parent is not known, the node is a root
The nodes of this tree keep properties of each cluster/subcluster:
size --> cluster size as the number of points in the cluster
center --> mean of the cluster
label --> cluster label
sse ... | pyclust/_bisect_kmeans.py | def _add_tree_node(tree, label, ilev, X=None, size=None, center=None, sse=None, parent=None):
""" Add a node to the tree
if parent is not known, the node is a root
The nodes of this tree keep properties of each cluster/subcluster:
size --> cluster size as the number of points in the ... | def _add_tree_node(tree, label, ilev, X=None, size=None, center=None, sse=None, parent=None):
""" Add a node to the tree
if parent is not known, the node is a root
The nodes of this tree keep properties of each cluster/subcluster:
size --> cluster size as the number of points in the ... | [
"Add",
"a",
"node",
"to",
"the",
"tree",
"if",
"parent",
"is",
"not",
"known",
"the",
"node",
"is",
"a",
"root"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_bisect_kmeans.py#L73-L105 | [
"def",
"_add_tree_node",
"(",
"tree",
",",
"label",
",",
"ilev",
",",
"X",
"=",
"None",
",",
"size",
"=",
"None",
",",
"center",
"=",
"None",
",",
"sse",
"=",
"None",
",",
"parent",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | _bisect_kmeans | Apply Bisecting Kmeans clustering
to reach n_clusters number of clusters | pyclust/_bisect_kmeans.py | def _bisect_kmeans(X, n_clusters, n_trials, max_iter, tol):
""" Apply Bisecting Kmeans clustering
to reach n_clusters number of clusters
"""
membs = np.empty(shape=X.shape[0], dtype=int)
centers = dict() #np.empty(shape=(n_clusters,X.shape[1]), dtype=float)
sse_arr = dict() #-1.0*np.ones(sha... | def _bisect_kmeans(X, n_clusters, n_trials, max_iter, tol):
""" Apply Bisecting Kmeans clustering
to reach n_clusters number of clusters
"""
membs = np.empty(shape=X.shape[0], dtype=int)
centers = dict() #np.empty(shape=(n_clusters,X.shape[1]), dtype=float)
sse_arr = dict() #-1.0*np.ones(sha... | [
"Apply",
"Bisecting",
"Kmeans",
"clustering",
"to",
"reach",
"n_clusters",
"number",
"of",
"clusters"
] | vmirly/pyclust | python | https://github.com/vmirly/pyclust/blob/bdb12be4649e70c6c90da2605bc5f4b314e2d07e/pyclust/_bisect_kmeans.py#L110-L157 | [
"def",
"_bisect_kmeans",
"(",
"X",
",",
"n_clusters",
",",
"n_trials",
",",
"max_iter",
",",
"tol",
")",
":",
"membs",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"int",
")",
"centers",
"=",
"d... | bdb12be4649e70c6c90da2605bc5f4b314e2d07e |
train | Comparison.dic | r""" Returns the corrected Deviance Information Criterion (DIC) for all chains loaded into ChainConsumer.
If a chain does not have a posterior, this method will return `None` for that chain. **Note that
the DIC metric is only valid on posterior surfaces which closely resemble multivariate normals!**
... | chainconsumer/comparisons.py | def dic(self):
r""" Returns the corrected Deviance Information Criterion (DIC) for all chains loaded into ChainConsumer.
If a chain does not have a posterior, this method will return `None` for that chain. **Note that
the DIC metric is only valid on posterior surfaces which closely resemble mul... | def dic(self):
r""" Returns the corrected Deviance Information Criterion (DIC) for all chains loaded into ChainConsumer.
If a chain does not have a posterior, this method will return `None` for that chain. **Note that
the DIC metric is only valid on posterior surfaces which closely resemble mul... | [
"r",
"Returns",
"the",
"corrected",
"Deviance",
"Information",
"Criterion",
"(",
"DIC",
")",
"for",
"all",
"chains",
"loaded",
"into",
"ChainConsumer",
"."
] | Samreay/ChainConsumer | python | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/comparisons.py#L13-L65 | [
"def",
"dic",
"(",
"self",
")",
":",
"dics",
"=",
"[",
"]",
"dics_bool",
"=",
"[",
"]",
"for",
"i",
",",
"chain",
"in",
"enumerate",
"(",
"self",
".",
"parent",
".",
"chains",
")",
":",
"p",
"=",
"chain",
".",
"posterior",
"if",
"p",
"is",
"Non... | 902288e4d85c2677a9051a2172e03128a6169ad7 |
train | Comparison.bic | r""" Returns the corrected Bayesian Information Criterion (BIC) for all chains loaded into ChainConsumer.
If a chain does not have a posterior, number of data points, and number of free parameters
loaded, this method will return `None` for that chain. Formally, the BIC is defined as
.. math::
... | chainconsumer/comparisons.py | def bic(self):
r""" Returns the corrected Bayesian Information Criterion (BIC) for all chains loaded into ChainConsumer.
If a chain does not have a posterior, number of data points, and number of free parameters
loaded, this method will return `None` for that chain. Formally, the BIC is defined... | def bic(self):
r""" Returns the corrected Bayesian Information Criterion (BIC) for all chains loaded into ChainConsumer.
If a chain does not have a posterior, number of data points, and number of free parameters
loaded, this method will return `None` for that chain. Formally, the BIC is defined... | [
"r",
"Returns",
"the",
"corrected",
"Bayesian",
"Information",
"Criterion",
"(",
"BIC",
")",
"for",
"all",
"chains",
"loaded",
"into",
"ChainConsumer",
"."
] | Samreay/ChainConsumer | python | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/comparisons.py#L67-L113 | [
"def",
"bic",
"(",
"self",
")",
":",
"bics",
"=",
"[",
"]",
"bics_bool",
"=",
"[",
"]",
"for",
"i",
",",
"chain",
"in",
"enumerate",
"(",
"self",
".",
"parent",
".",
"chains",
")",
":",
"p",
",",
"n_data",
",",
"n_free",
"=",
"chain",
".",
"pos... | 902288e4d85c2677a9051a2172e03128a6169ad7 |
train | Comparison.aic | r""" Returns the corrected Akaike Information Criterion (AICc) for all chains loaded into ChainConsumer.
If a chain does not have a posterior, number of data points, and number of free parameters
loaded, this method will return `None` for that chain. Formally, the AIC is defined as
.. math::
... | chainconsumer/comparisons.py | def aic(self):
r""" Returns the corrected Akaike Information Criterion (AICc) for all chains loaded into ChainConsumer.
If a chain does not have a posterior, number of data points, and number of free parameters
loaded, this method will return `None` for that chain. Formally, the AIC is defined ... | def aic(self):
r""" Returns the corrected Akaike Information Criterion (AICc) for all chains loaded into ChainConsumer.
If a chain does not have a posterior, number of data points, and number of free parameters
loaded, this method will return `None` for that chain. Formally, the AIC is defined ... | [
"r",
"Returns",
"the",
"corrected",
"Akaike",
"Information",
"Criterion",
"(",
"AICc",
")",
"for",
"all",
"chains",
"loaded",
"into",
"ChainConsumer",
"."
] | Samreay/ChainConsumer | python | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/comparisons.py#L115-L168 | [
"def",
"aic",
"(",
"self",
")",
":",
"aics",
"=",
"[",
"]",
"aics_bool",
"=",
"[",
"]",
"for",
"i",
",",
"chain",
"in",
"enumerate",
"(",
"self",
".",
"parent",
".",
"chains",
")",
":",
"p",
",",
"n_data",
",",
"n_free",
"=",
"chain",
".",
"pos... | 902288e4d85c2677a9051a2172e03128a6169ad7 |
train | Comparison.comparison_table | Return a LaTeX ready table of model comparisons.
Parameters
----------
caption : str, optional
The table caption to insert.
label : str, optional
The table label to insert.
hlines : bool, optional
Whether to insert hlines in the table or not.
... | chainconsumer/comparisons.py | def comparison_table(self, caption=None, label="tab:model_comp", hlines=True,
aic=True, bic=True, dic=True, sort="bic", descending=True): # pragma: no cover
"""
Return a LaTeX ready table of model comparisons.
Parameters
----------
caption : str, option... | def comparison_table(self, caption=None, label="tab:model_comp", hlines=True,
aic=True, bic=True, dic=True, sort="bic", descending=True): # pragma: no cover
"""
Return a LaTeX ready table of model comparisons.
Parameters
----------
caption : str, option... | [
"Return",
"a",
"LaTeX",
"ready",
"table",
"of",
"model",
"comparisons",
"."
] | Samreay/ChainConsumer | python | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/comparisons.py#L170-L270 | [
"def",
"comparison_table",
"(",
"self",
",",
"caption",
"=",
"None",
",",
"label",
"=",
"\"tab:model_comp\"",
",",
"hlines",
"=",
"True",
",",
"aic",
"=",
"True",
",",
"bic",
"=",
"True",
",",
"dic",
"=",
"True",
",",
"sort",
"=",
"\"bic\"",
",",
"de... | 902288e4d85c2677a9051a2172e03128a6169ad7 |
train | MegKDE.evaluate | Estimate un-normalised probability density at target points
Parameters
----------
data : np.ndarray
A `(num_targets, num_dim)` array of points to investigate.
Returns
-------
np.ndarray
A `(num_targets)` length array of estimates... | chainconsumer/kde.py | def evaluate(self, data):
""" Estimate un-normalised probability density at target points
Parameters
----------
data : np.ndarray
A `(num_targets, num_dim)` array of points to investigate.
Returns
-------
np.ndarray
A `(n... | def evaluate(self, data):
""" Estimate un-normalised probability density at target points
Parameters
----------
data : np.ndarray
A `(num_targets, num_dim)` array of points to investigate.
Returns
-------
np.ndarray
A `(n... | [
"Estimate",
"un",
"-",
"normalised",
"probability",
"density",
"at",
"target",
"points",
"Parameters",
"----------",
"data",
":",
"np",
".",
"ndarray",
"A",
"(",
"num_targets",
"num_dim",
")",
"array",
"of",
"points",
"to",
"investigate",
".",
"Returns",
"----... | Samreay/ChainConsumer | python | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/kde.py#L52-L84 | [
"def",
"evaluate",
"(",
"self",
",",
"data",
")",
":",
"if",
"len",
"(",
"data",
".",
"shape",
")",
"==",
"1",
"and",
"self",
".",
"num_dim",
"==",
"1",
":",
"data",
"=",
"np",
".",
"atleast_2d",
"(",
"data",
")",
".",
"T",
"_d",
"=",
"np",
"... | 902288e4d85c2677a9051a2172e03128a6169ad7 |
train | Plotter.plot | Plot the chain!
Parameters
----------
figsize : str|tuple(float)|float, optional
The figure size to generate. Accepts a regular two tuple of size in inches,
or one of several key words. The default value of ``COLUMN`` creates a figure
of appropriate size of i... | chainconsumer/plotter.py | def plot(self, figsize="GROW", parameters=None, chains=None, extents=None, filename=None,
display=False, truth=None, legend=None, blind=None, watermark=None): # pragma: no cover
""" Plot the chain!
Parameters
----------
figsize : str|tuple(float)|float, optional
... | def plot(self, figsize="GROW", parameters=None, chains=None, extents=None, filename=None,
display=False, truth=None, legend=None, blind=None, watermark=None): # pragma: no cover
""" Plot the chain!
Parameters
----------
figsize : str|tuple(float)|float, optional
... | [
"Plot",
"the",
"chain!"
] | Samreay/ChainConsumer | python | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/plotter.py#L20-L283 | [
"def",
"plot",
"(",
"self",
",",
"figsize",
"=",
"\"GROW\"",
",",
"parameters",
"=",
"None",
",",
"chains",
"=",
"None",
",",
"extents",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"display",
"=",
"False",
",",
"truth",
"=",
"None",
",",
"legend"... | 902288e4d85c2677a9051a2172e03128a6169ad7 |
train | Plotter.plot_walks | Plots the chain walk; the parameter values as a function of step index.
This plot is more for a sanity or consistency check than for use with final results.
Plotting this before plotting with :func:`plot` allows you to quickly see if the
chains are well behaved, or if certain parameters are sus... | chainconsumer/plotter.py | def plot_walks(self, parameters=None, truth=None, extents=None, display=False,
filename=None, chains=None, convolve=None, figsize=None,
plot_weights=True, plot_posterior=True, log_weight=None): # pragma: no cover
""" Plots the chain walk; the parameter values as a function... | def plot_walks(self, parameters=None, truth=None, extents=None, display=False,
filename=None, chains=None, convolve=None, figsize=None,
plot_weights=True, plot_posterior=True, log_weight=None): # pragma: no cover
""" Plots the chain walk; the parameter values as a function... | [
"Plots",
"the",
"chain",
"walk",
";",
"the",
"parameter",
"values",
"as",
"a",
"function",
"of",
"step",
"index",
"."
] | Samreay/ChainConsumer | python | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/plotter.py#L319-L426 | [
"def",
"plot_walks",
"(",
"self",
",",
"parameters",
"=",
"None",
",",
"truth",
"=",
"None",
",",
"extents",
"=",
"None",
",",
"display",
"=",
"False",
",",
"filename",
"=",
"None",
",",
"chains",
"=",
"None",
",",
"convolve",
"=",
"None",
",",
"figs... | 902288e4d85c2677a9051a2172e03128a6169ad7 |
train | Plotter.plot_distributions | Plots the 1D parameter distributions for verification purposes.
This plot is more for a sanity or consistency check than for use with final results.
Plotting this before plotting with :func:`plot` allows you to quickly see if the
chains give well behaved distributions, or if certain parameters ... | chainconsumer/plotter.py | def plot_distributions(self, parameters=None, truth=None, extents=None, display=False,
filename=None, chains=None, col_wrap=4, figsize=None, blind=None): # pragma: no cover
""" Plots the 1D parameter distributions for verification purposes.
This plot is more for a sanity or ... | def plot_distributions(self, parameters=None, truth=None, extents=None, display=False,
filename=None, chains=None, col_wrap=4, figsize=None, blind=None): # pragma: no cover
""" Plots the 1D parameter distributions for verification purposes.
This plot is more for a sanity or ... | [
"Plots",
"the",
"1D",
"parameter",
"distributions",
"for",
"verification",
"purposes",
"."
] | Samreay/ChainConsumer | python | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/plotter.py#L428-L536 | [
"def",
"plot_distributions",
"(",
"self",
",",
"parameters",
"=",
"None",
",",
"truth",
"=",
"None",
",",
"extents",
"=",
"None",
",",
"display",
"=",
"False",
",",
"filename",
"=",
"None",
",",
"chains",
"=",
"None",
",",
"col_wrap",
"=",
"4",
",",
... | 902288e4d85c2677a9051a2172e03128a6169ad7 |
train | Plotter.plot_summary | Plots parameter summaries
This plot is more for a sanity or consistency check than for use with final results.
Plotting this before plotting with :func:`plot` allows you to quickly see if the
chains give well behaved distributions, or if certain parameters are suspect
or require a great... | chainconsumer/plotter.py | def plot_summary(self, parameters=None, truth=None, extents=None, display=False,
filename=None, chains=None, figsize=1.0, errorbar=False, include_truth_chain=True,
blind=None, watermark=None, extra_parameter_spacing=0.5,
vertical_spacing_ratio=1.0, show_nam... | def plot_summary(self, parameters=None, truth=None, extents=None, display=False,
filename=None, chains=None, figsize=1.0, errorbar=False, include_truth_chain=True,
blind=None, watermark=None, extra_parameter_spacing=0.5,
vertical_spacing_ratio=1.0, show_nam... | [
"Plots",
"parameter",
"summaries"
] | Samreay/ChainConsumer | python | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/plotter.py#L538-L724 | [
"def",
"plot_summary",
"(",
"self",
",",
"parameters",
"=",
"None",
",",
"truth",
"=",
"None",
",",
"extents",
"=",
"None",
",",
"display",
"=",
"False",
",",
"filename",
"=",
"None",
",",
"chains",
"=",
"None",
",",
"figsize",
"=",
"1.0",
",",
"erro... | 902288e4d85c2677a9051a2172e03128a6169ad7 |
train | Diagnostic.gelman_rubin | r""" Runs the Gelman Rubin diagnostic on the supplied chains.
Parameters
----------
chain : int|str, optional
Which chain to run the diagnostic on. By default, this is `None`,
which will run the diagnostic on all chains. You can also
supply and integer (the c... | chainconsumer/diagnostic.py | def gelman_rubin(self, chain=None, threshold=0.05):
r""" Runs the Gelman Rubin diagnostic on the supplied chains.
Parameters
----------
chain : int|str, optional
Which chain to run the diagnostic on. By default, this is `None`,
which will run the diagnostic on al... | def gelman_rubin(self, chain=None, threshold=0.05):
r""" Runs the Gelman Rubin diagnostic on the supplied chains.
Parameters
----------
chain : int|str, optional
Which chain to run the diagnostic on. By default, this is `None`,
which will run the diagnostic on al... | [
"r",
"Runs",
"the",
"Gelman",
"Rubin",
"diagnostic",
"on",
"the",
"supplied",
"chains",
"."
] | Samreay/ChainConsumer | python | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/diagnostic.py#L11-L76 | [
"def",
"gelman_rubin",
"(",
"self",
",",
"chain",
"=",
"None",
",",
"threshold",
"=",
"0.05",
")",
":",
"if",
"chain",
"is",
"None",
":",
"return",
"np",
".",
"all",
"(",
"[",
"self",
".",
"gelman_rubin",
"(",
"k",
",",
"threshold",
"=",
"threshold",... | 902288e4d85c2677a9051a2172e03128a6169ad7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.