repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
JelleAalbers/multihist | multihist.py | Hist1d.std | def std(self, bessel_correction=True):
"""Estimates std of underlying data, assuming each datapoint was exactly in the center of its bin."""
if bessel_correction:
n = self.n
bc = n / (n - 1)
else:
bc = 1
return np.sqrt(np.average((self.bin_centers - se... | python | def std(self, bessel_correction=True):
"""Estimates std of underlying data, assuming each datapoint was exactly in the center of its bin."""
if bessel_correction:
n = self.n
bc = n / (n - 1)
else:
bc = 1
return np.sqrt(np.average((self.bin_centers - se... | [
"def",
"std",
"(",
"self",
",",
"bessel_correction",
"=",
"True",
")",
":",
"if",
"bessel_correction",
":",
"n",
"=",
"self",
".",
"n",
"bc",
"=",
"n",
"/",
"(",
"n",
"-",
"1",
")",
"else",
":",
"bc",
"=",
"1",
"return",
"np",
".",
"sqrt",
"(",... | Estimates std of underlying data, assuming each datapoint was exactly in the center of its bin. | [
"Estimates",
"std",
"of",
"underlying",
"data",
"assuming",
"each",
"datapoint",
"was",
"exactly",
"in",
"the",
"center",
"of",
"its",
"bin",
"."
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L205-L212 | train | Estimates std of underlying data assuming each datapoint was exactly in the center of its bin. |
JelleAalbers/multihist | multihist.py | Hist1d.plot | def plot(self, normed=False, scale_errors_by=1.0, scale_histogram_by=1.0, plt=plt, errors=False, **kwargs):
"""Plots the histogram with Poisson (sqrt(n)) error bars
- scale_errors_by multiplies the error bars by its argument
- scale_histogram_by multiplies the histogram AND the error bars by... | python | def plot(self, normed=False, scale_errors_by=1.0, scale_histogram_by=1.0, plt=plt, errors=False, **kwargs):
"""Plots the histogram with Poisson (sqrt(n)) error bars
- scale_errors_by multiplies the error bars by its argument
- scale_histogram_by multiplies the histogram AND the error bars by... | [
"def",
"plot",
"(",
"self",
",",
"normed",
"=",
"False",
",",
"scale_errors_by",
"=",
"1.0",
",",
"scale_histogram_by",
"=",
"1.0",
",",
"plt",
"=",
"plt",
",",
"errors",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"CAN_PLOT",
":",
... | Plots the histogram with Poisson (sqrt(n)) error bars
- scale_errors_by multiplies the error bars by its argument
- scale_histogram_by multiplies the histogram AND the error bars by its argument
- plt thing to call .errorbar on (pylab, figure, axes, whatever the matplotlib guys come up wit... | [
"Plots",
"the",
"histogram",
"with",
"Poisson",
"(",
"sqrt",
"(",
"n",
"))",
"error",
"bars",
"-",
"scale_errors_by",
"multiplies",
"the",
"error",
"bars",
"by",
"its",
"argument",
"-",
"scale_histogram_by",
"multiplies",
"the",
"histogram",
"AND",
"the",
"err... | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L214-L236 | train | Plots the histogram with Poisson error bars. |
JelleAalbers/multihist | multihist.py | Hist1d.percentile | def percentile(self, percentile):
"""Return bin center nearest to percentile"""
return self.bin_centers[np.argmin(np.abs(self.cumulative_density * 100 - percentile))] | python | def percentile(self, percentile):
"""Return bin center nearest to percentile"""
return self.bin_centers[np.argmin(np.abs(self.cumulative_density * 100 - percentile))] | [
"def",
"percentile",
"(",
"self",
",",
"percentile",
")",
":",
"return",
"self",
".",
"bin_centers",
"[",
"np",
".",
"argmin",
"(",
"np",
".",
"abs",
"(",
"self",
".",
"cumulative_density",
"*",
"100",
"-",
"percentile",
")",
")",
"]"
] | Return bin center nearest to percentile | [
"Return",
"bin",
"center",
"nearest",
"to",
"percentile"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L238-L240 | train | Return bin center nearest to a given percentile |
JelleAalbers/multihist | multihist.py | Hist1d.lookup | def lookup(self, coordinates):
"""Lookup values at coordinates.
coordinates: arraylike of coordinates.
Clips if out of range!! TODO: option to throw exception instead.
TODO: Needs tests!!
"""
# Convert coordinates to indices
index_array = np.clip(np.searchsorted(... | python | def lookup(self, coordinates):
"""Lookup values at coordinates.
coordinates: arraylike of coordinates.
Clips if out of range!! TODO: option to throw exception instead.
TODO: Needs tests!!
"""
# Convert coordinates to indices
index_array = np.clip(np.searchsorted(... | [
"def",
"lookup",
"(",
"self",
",",
"coordinates",
")",
":",
"# Convert coordinates to indices",
"index_array",
"=",
"np",
".",
"clip",
"(",
"np",
".",
"searchsorted",
"(",
"self",
".",
"bin_edges",
",",
"coordinates",
")",
"-",
"1",
",",
"0",
",",
"len",
... | Lookup values at coordinates.
coordinates: arraylike of coordinates.
Clips if out of range!! TODO: option to throw exception instead.
TODO: Needs tests!! | [
"Lookup",
"values",
"at",
"coordinates",
".",
"coordinates",
":",
"arraylike",
"of",
"coordinates",
"."
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L242-L255 | train | Lookup values at coordinates. |
JelleAalbers/multihist | multihist.py | Histdd.from_histogram | def from_histogram(cls, histogram, bin_edges, axis_names=None):
"""Make a HistdD from numpy histogram + bin edges
:param histogram: Initial histogram
:param bin_edges: x bin edges of histogram, y bin edges, ...
:return: Histnd instance
"""
bin_edges = np.array(bin_edges)
... | python | def from_histogram(cls, histogram, bin_edges, axis_names=None):
"""Make a HistdD from numpy histogram + bin edges
:param histogram: Initial histogram
:param bin_edges: x bin edges of histogram, y bin edges, ...
:return: Histnd instance
"""
bin_edges = np.array(bin_edges)
... | [
"def",
"from_histogram",
"(",
"cls",
",",
"histogram",
",",
"bin_edges",
",",
"axis_names",
"=",
"None",
")",
":",
"bin_edges",
"=",
"np",
".",
"array",
"(",
"bin_edges",
")",
"self",
"=",
"cls",
"(",
"bins",
"=",
"bin_edges",
",",
"axis_names",
"=",
"... | Make a HistdD from numpy histogram + bin edges
:param histogram: Initial histogram
:param bin_edges: x bin edges of histogram, y bin edges, ...
:return: Histnd instance | [
"Make",
"a",
"HistdD",
"from",
"numpy",
"histogram",
"+",
"bin",
"edges",
":",
"param",
"histogram",
":",
"Initial",
"histogram",
":",
"param",
"bin_edges",
":",
"x",
"bin",
"edges",
"of",
"histogram",
"y",
"bin",
"edges",
"...",
":",
"return",
":",
"His... | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L264-L273 | train | Make a HistdD from numpy histogram + bin edges |
JelleAalbers/multihist | multihist.py | Histdd._data_to_hist | def _data_to_hist(self, data, **kwargs):
"""Return bin_edges, histogram array"""
if hasattr(self, 'bin_edges'):
kwargs.setdefault('bins', self.bin_edges)
if len(data) == 1 and isinstance(data[0], COLUMNAR_DATA_SOURCES):
data = data[0]
if self.axis_names is N... | python | def _data_to_hist(self, data, **kwargs):
"""Return bin_edges, histogram array"""
if hasattr(self, 'bin_edges'):
kwargs.setdefault('bins', self.bin_edges)
if len(data) == 1 and isinstance(data[0], COLUMNAR_DATA_SOURCES):
data = data[0]
if self.axis_names is N... | [
"def",
"_data_to_hist",
"(",
"self",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'bin_edges'",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'bins'",
",",
"self",
".",
"bin_edges",
")",
"if",
"len",
"(",
"data",... | Return bin_edges, histogram array | [
"Return",
"bin_edges",
"histogram",
"array"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L302-L345 | train | Convert data to histogram array |
JelleAalbers/multihist | multihist.py | Histdd.axis_names_without | def axis_names_without(self, axis):
"""Return axis names without axis, or None if axis_names is None"""
if self.axis_names is None:
return None
return itemgetter(*self.other_axes(axis))(self.axis_names) | python | def axis_names_without(self, axis):
"""Return axis names without axis, or None if axis_names is None"""
if self.axis_names is None:
return None
return itemgetter(*self.other_axes(axis))(self.axis_names) | [
"def",
"axis_names_without",
"(",
"self",
",",
"axis",
")",
":",
"if",
"self",
".",
"axis_names",
"is",
"None",
":",
"return",
"None",
"return",
"itemgetter",
"(",
"*",
"self",
".",
"other_axes",
"(",
"axis",
")",
")",
"(",
"self",
".",
"axis_names",
"... | Return axis names without axis, or None if axis_names is None | [
"Return",
"axis",
"names",
"without",
"axis",
"or",
"None",
"if",
"axis_names",
"is",
"None"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L369-L373 | train | Return axis names without axis |
JelleAalbers/multihist | multihist.py | Histdd.bin_centers | def bin_centers(self, axis=None):
"""Return bin centers along an axis, or if axis=None, list of bin_centers along each axis"""
if axis is None:
return np.array([self.bin_centers(axis=i) for i in range(self.dimensions)])
axis = self.get_axis_number(axis)
return 0.5 * (self.bin... | python | def bin_centers(self, axis=None):
"""Return bin centers along an axis, or if axis=None, list of bin_centers along each axis"""
if axis is None:
return np.array([self.bin_centers(axis=i) for i in range(self.dimensions)])
axis = self.get_axis_number(axis)
return 0.5 * (self.bin... | [
"def",
"bin_centers",
"(",
"self",
",",
"axis",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"return",
"np",
".",
"array",
"(",
"[",
"self",
".",
"bin_centers",
"(",
"axis",
"=",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
... | Return bin centers along an axis, or if axis=None, list of bin_centers along each axis | [
"Return",
"bin",
"centers",
"along",
"an",
"axis",
"or",
"if",
"axis",
"=",
"None",
"list",
"of",
"bin_centers",
"along",
"each",
"axis"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L378-L383 | train | Return the bin centers along an axis or list of bin_centers along each axis |
JelleAalbers/multihist | multihist.py | Histdd.get_axis_bin_index | def get_axis_bin_index(self, value, axis):
"""Returns index along axis of bin in histogram which contains value
Inclusive on both endpoints
"""
axis = self.get_axis_number(axis)
bin_edges = self.bin_edges[axis]
# The right bin edge of np.histogram is inclusive:
if... | python | def get_axis_bin_index(self, value, axis):
"""Returns index along axis of bin in histogram which contains value
Inclusive on both endpoints
"""
axis = self.get_axis_number(axis)
bin_edges = self.bin_edges[axis]
# The right bin edge of np.histogram is inclusive:
if... | [
"def",
"get_axis_bin_index",
"(",
"self",
",",
"value",
",",
"axis",
")",
":",
"axis",
"=",
"self",
".",
"get_axis_number",
"(",
"axis",
")",
"bin_edges",
"=",
"self",
".",
"bin_edges",
"[",
"axis",
"]",
"# The right bin edge of np.histogram is inclusive:",
"if"... | Returns index along axis of bin in histogram which contains value
Inclusive on both endpoints | [
"Returns",
"index",
"along",
"axis",
"of",
"bin",
"in",
"histogram",
"which",
"contains",
"value",
"Inclusive",
"on",
"both",
"endpoints"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L385-L400 | train | Returns the index along axis of bin in histogram which contains value Inclusive on both endpoints
|
JelleAalbers/multihist | multihist.py | Histdd.get_bin_indices | def get_bin_indices(self, values):
"""Returns index tuple in histogram of bin which contains value"""
return tuple([self.get_axis_bin_index(values[ax_i], ax_i)
for ax_i in range(self.dimensions)]) | python | def get_bin_indices(self, values):
"""Returns index tuple in histogram of bin which contains value"""
return tuple([self.get_axis_bin_index(values[ax_i], ax_i)
for ax_i in range(self.dimensions)]) | [
"def",
"get_bin_indices",
"(",
"self",
",",
"values",
")",
":",
"return",
"tuple",
"(",
"[",
"self",
".",
"get_axis_bin_index",
"(",
"values",
"[",
"ax_i",
"]",
",",
"ax_i",
")",
"for",
"ax_i",
"in",
"range",
"(",
"self",
".",
"dimensions",
")",
"]",
... | Returns index tuple in histogram of bin which contains value | [
"Returns",
"index",
"tuple",
"in",
"histogram",
"of",
"bin",
"which",
"contains",
"value"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L402-L405 | train | Returns index tuple in histogram of bin which contains value |
JelleAalbers/multihist | multihist.py | Histdd.all_axis_bin_centers | def all_axis_bin_centers(self, axis):
"""Return ndarray of same shape as histogram containing bin center value along axis at each point"""
# Arcane hack that seems to work, at least in 3d... hope
axis = self.get_axis_number(axis)
return np.meshgrid(*self.bin_centers(), indexing='ij')[axi... | python | def all_axis_bin_centers(self, axis):
"""Return ndarray of same shape as histogram containing bin center value along axis at each point"""
# Arcane hack that seems to work, at least in 3d... hope
axis = self.get_axis_number(axis)
return np.meshgrid(*self.bin_centers(), indexing='ij')[axi... | [
"def",
"all_axis_bin_centers",
"(",
"self",
",",
"axis",
")",
":",
"# Arcane hack that seems to work, at least in 3d... hope",
"axis",
"=",
"self",
".",
"get_axis_number",
"(",
"axis",
")",
"return",
"np",
".",
"meshgrid",
"(",
"*",
"self",
".",
"bin_centers",
"("... | Return ndarray of same shape as histogram containing bin center value along axis at each point | [
"Return",
"ndarray",
"of",
"same",
"shape",
"as",
"histogram",
"containing",
"bin",
"center",
"value",
"along",
"axis",
"at",
"each",
"point"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L407-L411 | train | Return ndarray of same shape as histogram containing bin center value along axis at each point |
JelleAalbers/multihist | multihist.py | Histdd.sum | def sum(self, axis):
"""Sums all data along axis, returns d-1 dimensional histogram"""
axis = self.get_axis_number(axis)
if self.dimensions == 2:
new_hist = Hist1d
else:
new_hist = Histdd
return new_hist.from_histogram(np.sum(self.histogram, axis=axis),
... | python | def sum(self, axis):
"""Sums all data along axis, returns d-1 dimensional histogram"""
axis = self.get_axis_number(axis)
if self.dimensions == 2:
new_hist = Hist1d
else:
new_hist = Histdd
return new_hist.from_histogram(np.sum(self.histogram, axis=axis),
... | [
"def",
"sum",
"(",
"self",
",",
"axis",
")",
":",
"axis",
"=",
"self",
".",
"get_axis_number",
"(",
"axis",
")",
"if",
"self",
".",
"dimensions",
"==",
"2",
":",
"new_hist",
"=",
"Hist1d",
"else",
":",
"new_hist",
"=",
"Histdd",
"return",
"new_hist",
... | Sums all data along axis, returns d-1 dimensional histogram | [
"Sums",
"all",
"data",
"along",
"axis",
"returns",
"d",
"-",
"1",
"dimensional",
"histogram"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L416-L425 | train | Sums all data along axis returns d - 1 dimensional histogram |
JelleAalbers/multihist | multihist.py | Histdd.slice | def slice(self, start, stop=None, axis=0):
"""Restrict histogram to bins whose data values (not bin numbers) along axis are between start and stop
(both inclusive). Returns d dimensional histogram."""
if stop is None:
# Make a 1=bin slice
stop = start
axis = self.... | python | def slice(self, start, stop=None, axis=0):
"""Restrict histogram to bins whose data values (not bin numbers) along axis are between start and stop
(both inclusive). Returns d dimensional histogram."""
if stop is None:
# Make a 1=bin slice
stop = start
axis = self.... | [
"def",
"slice",
"(",
"self",
",",
"start",
",",
"stop",
"=",
"None",
",",
"axis",
"=",
"0",
")",
":",
"if",
"stop",
"is",
"None",
":",
"# Make a 1=bin slice",
"stop",
"=",
"start",
"axis",
"=",
"self",
".",
"get_axis_number",
"(",
"axis",
")",
"start... | Restrict histogram to bins whose data values (not bin numbers) along axis are between start and stop
(both inclusive). Returns d dimensional histogram. | [
"Restrict",
"histogram",
"to",
"bins",
"whose",
"data",
"values",
"(",
"not",
"bin",
"numbers",
")",
"along",
"axis",
"are",
"between",
"start",
"and",
"stop",
"(",
"both",
"inclusive",
")",
".",
"Returns",
"d",
"dimensional",
"histogram",
"."
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L427-L440 | train | Restrict histogram to bins whose data values are between start and stop. Returns d dimensional histogram. |
JelleAalbers/multihist | multihist.py | Histdd.slicesum | def slicesum(self, start, stop=None, axis=0):
"""Slices the histogram along axis, then sums over that slice, returning a d-1 dimensional histogram"""
return self.slice(start, stop, axis).sum(axis) | python | def slicesum(self, start, stop=None, axis=0):
"""Slices the histogram along axis, then sums over that slice, returning a d-1 dimensional histogram"""
return self.slice(start, stop, axis).sum(axis) | [
"def",
"slicesum",
"(",
"self",
",",
"start",
",",
"stop",
"=",
"None",
",",
"axis",
"=",
"0",
")",
":",
"return",
"self",
".",
"slice",
"(",
"start",
",",
"stop",
",",
"axis",
")",
".",
"sum",
"(",
"axis",
")"
] | Slices the histogram along axis, then sums over that slice, returning a d-1 dimensional histogram | [
"Slices",
"the",
"histogram",
"along",
"axis",
"then",
"sums",
"over",
"that",
"slice",
"returning",
"a",
"d",
"-",
"1",
"dimensional",
"histogram"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L442-L444 | train | Slices the histogram along axis then sums over that slice returning a d - 1 dimensional histogram |
JelleAalbers/multihist | multihist.py | Histdd.projection | def projection(self, axis):
"""Sums all data along all other axes, then return Hist1D"""
axis = self.get_axis_number(axis)
projected_hist = np.sum(self.histogram, axis=self.other_axes(axis))
return Hist1d.from_histogram(projected_hist, bin_edges=self.bin_edges[axis]) | python | def projection(self, axis):
"""Sums all data along all other axes, then return Hist1D"""
axis = self.get_axis_number(axis)
projected_hist = np.sum(self.histogram, axis=self.other_axes(axis))
return Hist1d.from_histogram(projected_hist, bin_edges=self.bin_edges[axis]) | [
"def",
"projection",
"(",
"self",
",",
"axis",
")",
":",
"axis",
"=",
"self",
".",
"get_axis_number",
"(",
"axis",
")",
"projected_hist",
"=",
"np",
".",
"sum",
"(",
"self",
".",
"histogram",
",",
"axis",
"=",
"self",
".",
"other_axes",
"(",
"axis",
... | Sums all data along all other axes, then return Hist1D | [
"Sums",
"all",
"data",
"along",
"all",
"other",
"axes",
"then",
"return",
"Hist1D"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L446-L450 | train | Sums all data along all other axes then return Hist1D |
JelleAalbers/multihist | multihist.py | Histdd.cumulate | def cumulate(self, axis):
"""Returns new histogram with all data cumulated along axis."""
axis = self.get_axis_number(axis)
return Histdd.from_histogram(np.cumsum(self.histogram, axis=axis),
bin_edges=self.bin_edges,
axis_... | python | def cumulate(self, axis):
"""Returns new histogram with all data cumulated along axis."""
axis = self.get_axis_number(axis)
return Histdd.from_histogram(np.cumsum(self.histogram, axis=axis),
bin_edges=self.bin_edges,
axis_... | [
"def",
"cumulate",
"(",
"self",
",",
"axis",
")",
":",
"axis",
"=",
"self",
".",
"get_axis_number",
"(",
"axis",
")",
"return",
"Histdd",
".",
"from_histogram",
"(",
"np",
".",
"cumsum",
"(",
"self",
".",
"histogram",
",",
"axis",
"=",
"axis",
")",
"... | Returns new histogram with all data cumulated along axis. | [
"Returns",
"new",
"histogram",
"with",
"all",
"data",
"cumulated",
"along",
"axis",
"."
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L456-L461 | train | Returns new histogram with all data cumulated along axis. |
JelleAalbers/multihist | multihist.py | Histdd.normalize | def normalize(self, axis):
"""Returns new histogram where all values along axis (in one bin of the other axes) sum to 1"""
axis = self.get_axis_number(axis)
sum_along_axis = np.sum(self.histogram, axis=axis)
# Don't do anything for subspaces without any entries -- this avoids nans everyw... | python | def normalize(self, axis):
"""Returns new histogram where all values along axis (in one bin of the other axes) sum to 1"""
axis = self.get_axis_number(axis)
sum_along_axis = np.sum(self.histogram, axis=axis)
# Don't do anything for subspaces without any entries -- this avoids nans everyw... | [
"def",
"normalize",
"(",
"self",
",",
"axis",
")",
":",
"axis",
"=",
"self",
".",
"get_axis_number",
"(",
"axis",
")",
"sum_along_axis",
"=",
"np",
".",
"sum",
"(",
"self",
".",
"histogram",
",",
"axis",
"=",
"axis",
")",
"# Don't do anything for subspaces... | Returns new histogram where all values along axis (in one bin of the other axes) sum to 1 | [
"Returns",
"new",
"histogram",
"where",
"all",
"values",
"along",
"axis",
"(",
"in",
"one",
"bin",
"of",
"the",
"other",
"axes",
")",
"sum",
"to",
"1"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L467-L476 | train | Returns new histogram where all values along axis sum to 1 |
JelleAalbers/multihist | multihist.py | Histdd.central_likelihood | def central_likelihood(self, axis):
"""Returns new histogram with all values replaced by their central likelihoods along axis."""
result = self.cumulative_density(axis)
result.histogram = 1 - 2 * np.abs(result.histogram - 0.5)
return result | python | def central_likelihood(self, axis):
"""Returns new histogram with all values replaced by their central likelihoods along axis."""
result = self.cumulative_density(axis)
result.histogram = 1 - 2 * np.abs(result.histogram - 0.5)
return result | [
"def",
"central_likelihood",
"(",
"self",
",",
"axis",
")",
":",
"result",
"=",
"self",
".",
"cumulative_density",
"(",
"axis",
")",
"result",
".",
"histogram",
"=",
"1",
"-",
"2",
"*",
"np",
".",
"abs",
"(",
"result",
".",
"histogram",
"-",
"0.5",
"... | Returns new histogram with all values replaced by their central likelihoods along axis. | [
"Returns",
"new",
"histogram",
"with",
"all",
"values",
"replaced",
"by",
"their",
"central",
"likelihoods",
"along",
"axis",
"."
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L482-L486 | train | Returns a new histogram with all values replaced by their central likelihoods along axis. |
JelleAalbers/multihist | multihist.py | Histdd.percentile | def percentile(self, percentile, axis, inclusive=True):
"""Returns d-1 dimensional histogram containing percentile of values along axis
if inclusive=True, will report bin center of first bin for which percentile% of data lies in or below the bin
=False, ... data lies strictly below t... | python | def percentile(self, percentile, axis, inclusive=True):
"""Returns d-1 dimensional histogram containing percentile of values along axis
if inclusive=True, will report bin center of first bin for which percentile% of data lies in or below the bin
=False, ... data lies strictly below t... | [
"def",
"percentile",
"(",
"self",
",",
"percentile",
",",
"axis",
",",
"inclusive",
"=",
"True",
")",
":",
"axis",
"=",
"self",
".",
"get_axis_number",
"(",
"axis",
")",
"# Shape of histogram",
"s",
"=",
"self",
".",
"histogram",
".",
"shape",
"# Shape of ... | Returns d-1 dimensional histogram containing percentile of values along axis
if inclusive=True, will report bin center of first bin for which percentile% of data lies in or below the bin
=False, ... data lies strictly below the bin
10% percentile is calculated as: value at least 10% ... | [
"Returns",
"d",
"-",
"1",
"dimensional",
"histogram",
"containing",
"percentile",
"of",
"values",
"along",
"axis",
"if",
"inclusive",
"=",
"True",
"will",
"report",
"bin",
"center",
"of",
"first",
"bin",
"for",
"which",
"percentile%",
"of",
"data",
"lies",
"... | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L492-L543 | train | Returns d - 1 dimensional histogram containing percentile of values along the specified axis |
JelleAalbers/multihist | multihist.py | Histdd.average | def average(self, axis):
"""Returns d-1 dimensional histogram of (estimated) mean value of axis
NB this is very different from averaging over the axis!!!
"""
axis = self.get_axis_number(axis)
avg_hist = np.ma.average(self.all_axis_bin_centers(axis),
... | python | def average(self, axis):
"""Returns d-1 dimensional histogram of (estimated) mean value of axis
NB this is very different from averaging over the axis!!!
"""
axis = self.get_axis_number(axis)
avg_hist = np.ma.average(self.all_axis_bin_centers(axis),
... | [
"def",
"average",
"(",
"self",
",",
"axis",
")",
":",
"axis",
"=",
"self",
".",
"get_axis_number",
"(",
"axis",
")",
"avg_hist",
"=",
"np",
".",
"ma",
".",
"average",
"(",
"self",
".",
"all_axis_bin_centers",
"(",
"axis",
")",
",",
"weights",
"=",
"s... | Returns d-1 dimensional histogram of (estimated) mean value of axis
NB this is very different from averaging over the axis!!! | [
"Returns",
"d",
"-",
"1",
"dimensional",
"histogram",
"of",
"(",
"estimated",
")",
"mean",
"value",
"of",
"axis",
"NB",
"this",
"is",
"very",
"different",
"from",
"averaging",
"over",
"the",
"axis!!!"
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L545-L558 | train | Returns d - 1 dimensional histogram of the average value of axis
|
JelleAalbers/multihist | multihist.py | Histdd.std | def std(self, axis):
"""Returns d-1 dimensional histogram of (estimated) std value along axis
NB this is very different from just std of the histogram values (which describe bin counts)
"""
def weighted_std(values, weights, axis):
# Stolen from http://stackoverflow.com/questi... | python | def std(self, axis):
"""Returns d-1 dimensional histogram of (estimated) std value along axis
NB this is very different from just std of the histogram values (which describe bin counts)
"""
def weighted_std(values, weights, axis):
# Stolen from http://stackoverflow.com/questi... | [
"def",
"std",
"(",
"self",
",",
"axis",
")",
":",
"def",
"weighted_std",
"(",
"values",
",",
"weights",
",",
"axis",
")",
":",
"# Stolen from http://stackoverflow.com/questions/2413522",
"average",
"=",
"np",
".",
"average",
"(",
"values",
",",
"weights",
"=",... | Returns d-1 dimensional histogram of (estimated) std value along axis
NB this is very different from just std of the histogram values (which describe bin counts) | [
"Returns",
"d",
"-",
"1",
"dimensional",
"histogram",
"of",
"(",
"estimated",
")",
"std",
"value",
"along",
"axis",
"NB",
"this",
"is",
"very",
"different",
"from",
"just",
"std",
"of",
"the",
"histogram",
"values",
"(",
"which",
"describe",
"bin",
"counts... | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L560-L580 | train | Returns d - 1 dimensional histogram of the standard deviation along axis |
JelleAalbers/multihist | multihist.py | Histdd.rebin | def rebin(self, *factors, **kwargs):
"""Return a new histogram that is 'rebinned' (zoomed) by factors (tuple of floats) along each dimensions
factors: tuple with zoom factors along each axis. e.g. 2 = double number of bins, 0.5 = halve them.
order: Order for spline interpolation in scipy.ndi... | python | def rebin(self, *factors, **kwargs):
"""Return a new histogram that is 'rebinned' (zoomed) by factors (tuple of floats) along each dimensions
factors: tuple with zoom factors along each axis. e.g. 2 = double number of bins, 0.5 = halve them.
order: Order for spline interpolation in scipy.ndi... | [
"def",
"rebin",
"(",
"self",
",",
"*",
"factors",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"HAVE_SCIPY",
":",
"raise",
"NotImplementedError",
"(",
"\"Rebinning requires scipy.ndimage\"",
")",
"if",
"any",
"(",
"[",
"x",
"!=",
"'order'",
"for",
"x",
... | Return a new histogram that is 'rebinned' (zoomed) by factors (tuple of floats) along each dimensions
factors: tuple with zoom factors along each axis. e.g. 2 = double number of bins, 0.5 = halve them.
order: Order for spline interpolation in scipy.ndimage.zoom. Defaults to linear interpolation (or... | [
"Return",
"a",
"new",
"histogram",
"that",
"is",
"rebinned",
"(",
"zoomed",
")",
"by",
"factors",
"(",
"tuple",
"of",
"floats",
")",
"along",
"each",
"dimensions",
"factors",
":",
"tuple",
"with",
"zoom",
"factors",
"along",
"each",
"axis",
".",
"e",
"."... | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L589-L630 | train | Return a new histogram that is rebinned by factors along each axis. |
JelleAalbers/multihist | multihist.py | Histdd.get_random | def get_random(self, size=10):
"""Returns (size, n_dim) array of random variates from the histogram.
Inside the bins, a uniform distribution is assumed
Note this assumes the histogram is an 'events per bin', not a pdf.
TODO: test more.
"""
# Sample random bin centers
... | python | def get_random(self, size=10):
"""Returns (size, n_dim) array of random variates from the histogram.
Inside the bins, a uniform distribution is assumed
Note this assumes the histogram is an 'events per bin', not a pdf.
TODO: test more.
"""
# Sample random bin centers
... | [
"def",
"get_random",
"(",
"self",
",",
"size",
"=",
"10",
")",
":",
"# Sample random bin centers",
"bin_centers_ravel",
"=",
"np",
".",
"array",
"(",
"np",
".",
"meshgrid",
"(",
"*",
"self",
".",
"bin_centers",
"(",
")",
",",
"indexing",
"=",
"'ij'",
")"... | Returns (size, n_dim) array of random variates from the histogram.
Inside the bins, a uniform distribution is assumed
Note this assumes the histogram is an 'events per bin', not a pdf.
TODO: test more. | [
"Returns",
"(",
"size",
"n_dim",
")",
"array",
"of",
"random",
"variates",
"from",
"the",
"histogram",
".",
"Inside",
"the",
"bins",
"a",
"uniform",
"distribution",
"is",
"assumed",
"Note",
"this",
"assumes",
"the",
"histogram",
"is",
"an",
"events",
"per",
... | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L632-L656 | train | Returns a random array of random variates from the histogram. |
JelleAalbers/multihist | multihist.py | Histdd.lookup | def lookup(self, *coordinate_arrays):
"""Lookup values at specific points.
coordinate_arrays: numpy arrays of coordinates, one for each dimension
e.g. lookup(np.array([0, 2]), np.array([1, 3])) looks up (x=0, y=1) and (x=2, y3).
Clips if out of range!! TODO: option to throw exception in... | python | def lookup(self, *coordinate_arrays):
"""Lookup values at specific points.
coordinate_arrays: numpy arrays of coordinates, one for each dimension
e.g. lookup(np.array([0, 2]), np.array([1, 3])) looks up (x=0, y=1) and (x=2, y3).
Clips if out of range!! TODO: option to throw exception in... | [
"def",
"lookup",
"(",
"self",
",",
"*",
"coordinate_arrays",
")",
":",
"assert",
"len",
"(",
"coordinate_arrays",
")",
"==",
"self",
".",
"dimensions",
"# Convert each coordinate array to an index array",
"index_arrays",
"=",
"[",
"np",
".",
"clip",
"(",
"np",
"... | Lookup values at specific points.
coordinate_arrays: numpy arrays of coordinates, one for each dimension
e.g. lookup(np.array([0, 2]), np.array([1, 3])) looks up (x=0, y=1) and (x=2, y3).
Clips if out of range!! TODO: option to throw exception instead.
TODO: Needs tests!!
TODO: ... | [
"Lookup",
"values",
"at",
"specific",
"points",
".",
"coordinate_arrays",
":",
"numpy",
"arrays",
"of",
"coordinates",
"one",
"for",
"each",
"dimension",
"e",
".",
"g",
".",
"lookup",
"(",
"np",
".",
"array",
"(",
"[",
"0",
"2",
"]",
")",
"np",
".",
... | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L658-L675 | train | Lookup values at specific points in the histogram. |
JelleAalbers/multihist | multihist.py | Histdd.lookup_hist | def lookup_hist(self, mh):
"""Return histogram within binning of Histdd mh, with values looked up in this histogram.
This is not rebinning: no interpolation /renormalization is performed.
It's just a lookup.
"""
result = mh.similar_blank_histogram()
points = np.stack([mh... | python | def lookup_hist(self, mh):
"""Return histogram within binning of Histdd mh, with values looked up in this histogram.
This is not rebinning: no interpolation /renormalization is performed.
It's just a lookup.
"""
result = mh.similar_blank_histogram()
points = np.stack([mh... | [
"def",
"lookup_hist",
"(",
"self",
",",
"mh",
")",
":",
"result",
"=",
"mh",
".",
"similar_blank_histogram",
"(",
")",
"points",
"=",
"np",
".",
"stack",
"(",
"[",
"mh",
".",
"all_axis_bin_centers",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"mh"... | Return histogram within binning of Histdd mh, with values looked up in this histogram.
This is not rebinning: no interpolation /renormalization is performed.
It's just a lookup. | [
"Return",
"histogram",
"within",
"binning",
"of",
"Histdd",
"mh",
"with",
"values",
"looked",
"up",
"in",
"this",
"histogram",
"."
] | 072288277f807e7e388fdf424c3921c80576f3ab | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L685-L696 | train | Return a similar histogram with values looked up in this histogram. |
acutesoftware/AIKIF | scripts/examples/doc_roadmap.py | create_roadmap_doc | def create_roadmap_doc(dat, opFile):
"""
takes a dictionary read from a yaml file and converts
it to the roadmap documentation
"""
op = format_title('Roadmap for AIKIF')
for h1 in dat['projects']:
op += format_h1(h1)
if dat[h1] is None:
op += '(No details)\n'
... | python | def create_roadmap_doc(dat, opFile):
"""
takes a dictionary read from a yaml file and converts
it to the roadmap documentation
"""
op = format_title('Roadmap for AIKIF')
for h1 in dat['projects']:
op += format_h1(h1)
if dat[h1] is None:
op += '(No details)\n'
... | [
"def",
"create_roadmap_doc",
"(",
"dat",
",",
"opFile",
")",
":",
"op",
"=",
"format_title",
"(",
"'Roadmap for AIKIF'",
")",
"for",
"h1",
"in",
"dat",
"[",
"'projects'",
"]",
":",
"op",
"+=",
"format_h1",
"(",
"h1",
")",
"if",
"dat",
"[",
"h1",
"]",
... | takes a dictionary read from a yaml file and converts
it to the roadmap documentation | [
"takes",
"a",
"dictionary",
"read",
"from",
"a",
"yaml",
"file",
"and",
"converts",
"it",
"to",
"the",
"roadmap",
"documentation"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/doc_roadmap.py#L20-L41 | train | Creates a roadmap documentation file from a dictionary read from a yaml file and converts it to the roadmap documentation |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.reset | def reset(self):
"""
Reset the game so the grid is zeros (or default items)
"""
self.grid = [[0 for dummy_l in range(self.grid_width)] for dummy_l in range(self.grid_height)] | python | def reset(self):
"""
Reset the game so the grid is zeros (or default items)
"""
self.grid = [[0 for dummy_l in range(self.grid_width)] for dummy_l in range(self.grid_height)] | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"grid",
"=",
"[",
"[",
"0",
"for",
"dummy_l",
"in",
"range",
"(",
"self",
".",
"grid_width",
")",
"]",
"for",
"dummy_l",
"in",
"range",
"(",
"self",
".",
"grid_height",
")",
"]"
] | Reset the game so the grid is zeros (or default items) | [
"Reset",
"the",
"game",
"so",
"the",
"grid",
"is",
"zeros",
"(",
"or",
"default",
"items",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L28-L32 | train | Reset the game so the grid is zeros or default items |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.clear | def clear(self):
"""
Clears grid to be EMPTY
"""
self.grid = [[EMPTY for dummy_col in range(self.grid_width)] for dummy_row in range(self.grid_height)] | python | def clear(self):
"""
Clears grid to be EMPTY
"""
self.grid = [[EMPTY for dummy_col in range(self.grid_width)] for dummy_row in range(self.grid_height)] | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"grid",
"=",
"[",
"[",
"EMPTY",
"for",
"dummy_col",
"in",
"range",
"(",
"self",
".",
"grid_width",
")",
"]",
"for",
"dummy_row",
"in",
"range",
"(",
"self",
".",
"grid_height",
")",
"]"
] | Clears grid to be EMPTY | [
"Clears",
"grid",
"to",
"be",
"EMPTY"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L34-L38 | train | Clears the grid to be EMPTY
|
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.save | def save(self, fname):
""" saves a grid to file as ASCII text """
try:
with open(fname, "w") as f:
f.write(str(self))
except Exception as ex:
print('ERROR = cant save grid results to ' + fname + str(ex)) | python | def save(self, fname):
""" saves a grid to file as ASCII text """
try:
with open(fname, "w") as f:
f.write(str(self))
except Exception as ex:
print('ERROR = cant save grid results to ' + fname + str(ex)) | [
"def",
"save",
"(",
"self",
",",
"fname",
")",
":",
"try",
":",
"with",
"open",
"(",
"fname",
",",
"\"w\"",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"str",
"(",
"self",
")",
")",
"except",
"Exception",
"as",
"ex",
":",
"print",
"(",
"'ERROR... | saves a grid to file as ASCII text | [
"saves",
"a",
"grid",
"to",
"file",
"as",
"ASCII",
"text"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L52-L58 | train | save a grid to file as ASCII text |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.load | def load(self, fname):
""" loads a ASCII text file grid to self """
# get height and width of grid from file
self.grid_width = 4
self.grid_height = 4
# re-read the file and load it
self.grid = [[0 for dummy_l in range(self.grid_width)] for dummy_l in ra... | python | def load(self, fname):
""" loads a ASCII text file grid to self """
# get height and width of grid from file
self.grid_width = 4
self.grid_height = 4
# re-read the file and load it
self.grid = [[0 for dummy_l in range(self.grid_width)] for dummy_l in ra... | [
"def",
"load",
"(",
"self",
",",
"fname",
")",
":",
"# get height and width of grid from file",
"self",
".",
"grid_width",
"=",
"4",
"self",
".",
"grid_height",
"=",
"4",
"# re-read the file and load it",
"self",
".",
"grid",
"=",
"[",
"[",
"0",
"for",
"dummy_... | loads a ASCII text file grid to self | [
"loads",
"a",
"ASCII",
"text",
"file",
"grid",
"to",
"self"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L62-L76 | train | loads a ASCII text file grid to self |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.extract_col | def extract_col(self, col):
"""
get column number 'col'
"""
new_col = [row[col] for row in self.grid]
return new_col | python | def extract_col(self, col):
"""
get column number 'col'
"""
new_col = [row[col] for row in self.grid]
return new_col | [
"def",
"extract_col",
"(",
"self",
",",
"col",
")",
":",
"new_col",
"=",
"[",
"row",
"[",
"col",
"]",
"for",
"row",
"in",
"self",
".",
"grid",
"]",
"return",
"new_col"
] | get column number 'col' | [
"get",
"column",
"number",
"col"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L103-L108 | train | extract column number col |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.extract_row | def extract_row(self, row):
"""
get row number 'row'
"""
new_row = []
for col in range(self.get_grid_width()):
new_row.append(self.get_tile(row, col))
return new_row | python | def extract_row(self, row):
"""
get row number 'row'
"""
new_row = []
for col in range(self.get_grid_width()):
new_row.append(self.get_tile(row, col))
return new_row | [
"def",
"extract_row",
"(",
"self",
",",
"row",
")",
":",
"new_row",
"=",
"[",
"]",
"for",
"col",
"in",
"range",
"(",
"self",
".",
"get_grid_width",
"(",
")",
")",
":",
"new_row",
".",
"append",
"(",
"self",
".",
"get_tile",
"(",
"row",
",",
"col",
... | get row number 'row' | [
"get",
"row",
"number",
"row"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L110-L117 | train | extract row number row |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.replace_row | def replace_row(self, line, ndx):
"""
replace a grids row at index 'ndx' with 'line'
"""
for col in range(len(line)):
self.set_tile(ndx, col, line[col]) | python | def replace_row(self, line, ndx):
"""
replace a grids row at index 'ndx' with 'line'
"""
for col in range(len(line)):
self.set_tile(ndx, col, line[col]) | [
"def",
"replace_row",
"(",
"self",
",",
"line",
",",
"ndx",
")",
":",
"for",
"col",
"in",
"range",
"(",
"len",
"(",
"line",
")",
")",
":",
"self",
".",
"set_tile",
"(",
"ndx",
",",
"col",
",",
"line",
"[",
"col",
"]",
")"
] | replace a grids row at index 'ndx' with 'line' | [
"replace",
"a",
"grids",
"row",
"at",
"index",
"ndx",
"with",
"line"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L119-L124 | train | replace a grids row at index ndx with line |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.replace_col | def replace_col(self, line, ndx):
"""
replace a grids column at index 'ndx' with 'line'
"""
for row in range(len(line)):
self.set_tile(row, ndx, line[row]) | python | def replace_col(self, line, ndx):
"""
replace a grids column at index 'ndx' with 'line'
"""
for row in range(len(line)):
self.set_tile(row, ndx, line[row]) | [
"def",
"replace_col",
"(",
"self",
",",
"line",
",",
"ndx",
")",
":",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"line",
")",
")",
":",
"self",
".",
"set_tile",
"(",
"row",
",",
"ndx",
",",
"line",
"[",
"row",
"]",
")"
] | replace a grids column at index 'ndx' with 'line' | [
"replace",
"a",
"grids",
"column",
"at",
"index",
"ndx",
"with",
"line"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L126-L131 | train | replace a grid column at index ndx with line |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.new_tile | def new_tile(self, num=1):
"""
Create a new tile in a randomly selected empty
square. The tile should be 2 90% of the time and
4 10% of the time.
"""
for _ in range(num):
if random.random() > .5:
new_tile = self.pieces[0]
... | python | def new_tile(self, num=1):
"""
Create a new tile in a randomly selected empty
square. The tile should be 2 90% of the time and
4 10% of the time.
"""
for _ in range(num):
if random.random() > .5:
new_tile = self.pieces[0]
... | [
"def",
"new_tile",
"(",
"self",
",",
"num",
"=",
"1",
")",
":",
"for",
"_",
"in",
"range",
"(",
"num",
")",
":",
"if",
"random",
".",
"random",
"(",
")",
">",
".5",
":",
"new_tile",
"=",
"self",
".",
"pieces",
"[",
"0",
"]",
"else",
":",
"new... | Create a new tile in a randomly selected empty
square. The tile should be 2 90% of the time and
4 10% of the time. | [
"Create",
"a",
"new",
"tile",
"in",
"a",
"randomly",
"selected",
"empty",
"square",
".",
"The",
"tile",
"should",
"be",
"2",
"90%",
"of",
"the",
"time",
"and",
"4",
"10%",
"of",
"the",
"time",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L140-L161 | train | Create a new empty area tile in a randomly selected empty area. |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.count_blank_positions | def count_blank_positions(self):
"""
return a count of blank cells
"""
blanks = 0
for row_ndx in range(self.grid_height - 0):
for col_ndx in range(self.grid_width - 0):
if self.get_tile(row_ndx, col_ndx) == EMPTY:
blanks += 1
... | python | def count_blank_positions(self):
"""
return a count of blank cells
"""
blanks = 0
for row_ndx in range(self.grid_height - 0):
for col_ndx in range(self.grid_width - 0):
if self.get_tile(row_ndx, col_ndx) == EMPTY:
blanks += 1
... | [
"def",
"count_blank_positions",
"(",
"self",
")",
":",
"blanks",
"=",
"0",
"for",
"row_ndx",
"in",
"range",
"(",
"self",
".",
"grid_height",
"-",
"0",
")",
":",
"for",
"col_ndx",
"in",
"range",
"(",
"self",
".",
"grid_width",
"-",
"0",
")",
":",
"if"... | return a count of blank cells | [
"return",
"a",
"count",
"of",
"blank",
"cells"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L164-L173 | train | return a count of blank cells |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.count_filled_positions | def count_filled_positions(self):
"""
return a count of blank cells
"""
filled = 0
for row_ndx in range(self.grid_height - 0):
for col_ndx in range(self.grid_width - 0):
if self.get_tile(row_ndx, col_ndx) != EMPTY:
filled += 1
... | python | def count_filled_positions(self):
"""
return a count of blank cells
"""
filled = 0
for row_ndx in range(self.grid_height - 0):
for col_ndx in range(self.grid_width - 0):
if self.get_tile(row_ndx, col_ndx) != EMPTY:
filled += 1
... | [
"def",
"count_filled_positions",
"(",
"self",
")",
":",
"filled",
"=",
"0",
"for",
"row_ndx",
"in",
"range",
"(",
"self",
".",
"grid_height",
"-",
"0",
")",
":",
"for",
"col_ndx",
"in",
"range",
"(",
"self",
".",
"grid_width",
"-",
"0",
")",
":",
"if... | return a count of blank cells | [
"return",
"a",
"count",
"of",
"blank",
"cells"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L175-L184 | train | return a count of blank cells |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.set_tile | def set_tile(self, row, col, value):
"""
Set the tile at position row, col to have the given value.
"""
#print('set_tile: y=', row, 'x=', col)
if col < 0:
print("ERROR - x less than zero", col)
col = 0
#return
if col > s... | python | def set_tile(self, row, col, value):
"""
Set the tile at position row, col to have the given value.
"""
#print('set_tile: y=', row, 'x=', col)
if col < 0:
print("ERROR - x less than zero", col)
col = 0
#return
if col > s... | [
"def",
"set_tile",
"(",
"self",
",",
"row",
",",
"col",
",",
"value",
")",
":",
"#print('set_tile: y=', row, 'x=', col)",
"if",
"col",
"<",
"0",
":",
"print",
"(",
"\"ERROR - x less than zero\"",
",",
"col",
")",
"col",
"=",
"0",
"#return",
"if",
"col",
">... | Set the tile at position row, col to have the given value. | [
"Set",
"the",
"tile",
"at",
"position",
"row",
"col",
"to",
"have",
"the",
"given",
"value",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L196-L220 | train | Set the value of the tile at position row col. |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.four_neighbors | def four_neighbors(self, row, col):
"""
Returns horiz/vert neighbors of cell (row, col)
"""
ans = []
if row > 0:
ans.append((row - 1, col))
if row < self.grid_height - 1:
ans.append((row + 1, col))
if col > 0:
ans.append((row, c... | python | def four_neighbors(self, row, col):
"""
Returns horiz/vert neighbors of cell (row, col)
"""
ans = []
if row > 0:
ans.append((row - 1, col))
if row < self.grid_height - 1:
ans.append((row + 1, col))
if col > 0:
ans.append((row, c... | [
"def",
"four_neighbors",
"(",
"self",
",",
"row",
",",
"col",
")",
":",
"ans",
"=",
"[",
"]",
"if",
"row",
">",
"0",
":",
"ans",
".",
"append",
"(",
"(",
"row",
"-",
"1",
",",
"col",
")",
")",
"if",
"row",
"<",
"self",
".",
"grid_height",
"-"... | Returns horiz/vert neighbors of cell (row, col) | [
"Returns",
"horiz",
"/",
"vert",
"neighbors",
"of",
"cell",
"(",
"row",
"col",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L243-L256 | train | Returns a list of four neighbors of a cell. |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.eight_neighbors | def eight_neighbors(self, row, col):
"""
Returns horiz/vert neighbors of cell (row, col) as well as
diagonal neighbors
"""
ans = []
if row > 0:
ans.append((row - 1, col))
if row < self.grid_height - 1:
ans.append((row + 1, col))
if ... | python | def eight_neighbors(self, row, col):
"""
Returns horiz/vert neighbors of cell (row, col) as well as
diagonal neighbors
"""
ans = []
if row > 0:
ans.append((row - 1, col))
if row < self.grid_height - 1:
ans.append((row + 1, col))
if ... | [
"def",
"eight_neighbors",
"(",
"self",
",",
"row",
",",
"col",
")",
":",
"ans",
"=",
"[",
"]",
"if",
"row",
">",
"0",
":",
"ans",
".",
"append",
"(",
"(",
"row",
"-",
"1",
",",
"col",
")",
")",
"if",
"row",
"<",
"self",
".",
"grid_height",
"-... | Returns horiz/vert neighbors of cell (row, col) as well as
diagonal neighbors | [
"Returns",
"horiz",
"/",
"vert",
"neighbors",
"of",
"cell",
"(",
"row",
"col",
")",
"as",
"well",
"as",
"diagonal",
"neighbors"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L258-L280 | train | Returns a list of eight neighbors of a cell. |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.replace_grid | def replace_grid(self, updated_grid):
"""
replace all cells in current grid with updated grid
"""
for col in range(self.get_grid_width()):
for row in range(self.get_grid_height()):
if updated_grid[row][col] == EMPTY:
self.set_empty(row, col... | python | def replace_grid(self, updated_grid):
"""
replace all cells in current grid with updated grid
"""
for col in range(self.get_grid_width()):
for row in range(self.get_grid_height()):
if updated_grid[row][col] == EMPTY:
self.set_empty(row, col... | [
"def",
"replace_grid",
"(",
"self",
",",
"updated_grid",
")",
":",
"for",
"col",
"in",
"range",
"(",
"self",
".",
"get_grid_width",
"(",
")",
")",
":",
"for",
"row",
"in",
"range",
"(",
"self",
".",
"get_grid_height",
"(",
")",
")",
":",
"if",
"updat... | replace all cells in current grid with updated grid | [
"replace",
"all",
"cells",
"in",
"current",
"grid",
"with",
"updated",
"grid"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L289-L298 | train | replace all cells in current grid with updated grid |
acutesoftware/AIKIF | aikif/toolbox/cls_grid.py | Grid.find_safe_starting_point | def find_safe_starting_point(self):
"""
finds a place on the grid which is clear on all sides
to avoid starting in the middle of a blockage
"""
y = random.randint(2,self.grid_height-4)
x = random.randint(2,self.grid_width-4)
return y, x | python | def find_safe_starting_point(self):
"""
finds a place on the grid which is clear on all sides
to avoid starting in the middle of a blockage
"""
y = random.randint(2,self.grid_height-4)
x = random.randint(2,self.grid_width-4)
return y, x | [
"def",
"find_safe_starting_point",
"(",
"self",
")",
":",
"y",
"=",
"random",
".",
"randint",
"(",
"2",
",",
"self",
".",
"grid_height",
"-",
"4",
")",
"x",
"=",
"random",
".",
"randint",
"(",
"2",
",",
"self",
".",
"grid_width",
"-",
"4",
")",
"re... | finds a place on the grid which is clear on all sides
to avoid starting in the middle of a blockage | [
"finds",
"a",
"place",
"on",
"the",
"grid",
"which",
"is",
"clear",
"on",
"all",
"sides",
"to",
"avoid",
"starting",
"in",
"the",
"middle",
"of",
"a",
"blockage"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L300-L307 | train | finds a place on the grid which is clear on all sides
to avoid starting in the middle of a blockage |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | screenshot | def screenshot(fname):
"""
takes a screenshot of the users desktop (Currently Win only)
"""
try:
im = ImageGrab.grab()
im.save(fname)
except Exception as ex:
print('image_tools.screenshot:cant create screenshot ' + str(ex)) | python | def screenshot(fname):
"""
takes a screenshot of the users desktop (Currently Win only)
"""
try:
im = ImageGrab.grab()
im.save(fname)
except Exception as ex:
print('image_tools.screenshot:cant create screenshot ' + str(ex)) | [
"def",
"screenshot",
"(",
"fname",
")",
":",
"try",
":",
"im",
"=",
"ImageGrab",
".",
"grab",
"(",
")",
"im",
".",
"save",
"(",
"fname",
")",
"except",
"Exception",
"as",
"ex",
":",
"print",
"(",
"'image_tools.screenshot:cant create screenshot '",
"+",
"st... | takes a screenshot of the users desktop (Currently Win only) | [
"takes",
"a",
"screenshot",
"of",
"the",
"users",
"desktop",
"(",
"Currently",
"Win",
"only",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L19-L27 | train | Takes a screenshot of the users desktop |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | resize | def resize(fname, basewidth, opFilename):
""" resize an image to basewidth """
if basewidth == 0:
basewidth = 300
img = Image.open(fname)
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
i... | python | def resize(fname, basewidth, opFilename):
""" resize an image to basewidth """
if basewidth == 0:
basewidth = 300
img = Image.open(fname)
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
i... | [
"def",
"resize",
"(",
"fname",
",",
"basewidth",
",",
"opFilename",
")",
":",
"if",
"basewidth",
"==",
"0",
":",
"basewidth",
"=",
"300",
"img",
"=",
"Image",
".",
"open",
"(",
"fname",
")",
"wpercent",
"=",
"(",
"basewidth",
"/",
"float",
"(",
"img"... | resize an image to basewidth | [
"resize",
"an",
"image",
"to",
"basewidth"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L103-L111 | train | resize an image to basewidth |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | print_stats | def print_stats(img):
""" prints stats, remember that img should already have been loaded """
stat = ImageStat.Stat(img)
print("extrema : ", stat.extrema)
print("count : ", stat.count)
print("sum : ", stat.sum)
print("sum2 : ", stat.sum2)
print("mean : ", stat.mean... | python | def print_stats(img):
""" prints stats, remember that img should already have been loaded """
stat = ImageStat.Stat(img)
print("extrema : ", stat.extrema)
print("count : ", stat.count)
print("sum : ", stat.sum)
print("sum2 : ", stat.sum2)
print("mean : ", stat.mean... | [
"def",
"print_stats",
"(",
"img",
")",
":",
"stat",
"=",
"ImageStat",
".",
"Stat",
"(",
"img",
")",
"print",
"(",
"\"extrema : \"",
",",
"stat",
".",
"extrema",
")",
"print",
"(",
"\"count : \"",
",",
"stat",
".",
"count",
")",
"print",
"(",
"\... | prints stats, remember that img should already have been loaded | [
"prints",
"stats",
"remember",
"that",
"img",
"should",
"already",
"have",
"been",
"loaded"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L114-L125 | train | prints stats for the given image |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | print_all_metadata | def print_all_metadata(fname):
""" high level that prints all as long list """
print("Filename :", fname )
print("Basename :", os.path.basename(fname))
print("Path :", os.path.dirname(fname))
print("Size :", os.path.getsize(fname))
img = Image.open(fname)
# get the image's wi... | python | def print_all_metadata(fname):
""" high level that prints all as long list """
print("Filename :", fname )
print("Basename :", os.path.basename(fname))
print("Path :", os.path.dirname(fname))
print("Size :", os.path.getsize(fname))
img = Image.open(fname)
# get the image's wi... | [
"def",
"print_all_metadata",
"(",
"fname",
")",
":",
"print",
"(",
"\"Filename :\"",
",",
"fname",
")",
"print",
"(",
"\"Basename :\"",
",",
"os",
".",
"path",
".",
"basename",
"(",
"fname",
")",
")",
"print",
"(",
"\"Path :\"",
",",
"os",
".",
... | high level that prints all as long list | [
"high",
"level",
"that",
"prints",
"all",
"as",
"long",
"list"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L152-L173 | train | high level that prints all metadata as long list |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | get_metadata_as_dict | def get_metadata_as_dict(fname):
""" Gets all metadata and puts into dictionary """
imgdict = {}
try:
imgdict['filename'] = fname
imgdict['size'] = str(os.path.getsize(fname))
imgdict['basename'] = os.path.basename(fname)
imgdict['path'] = os.path.dirname(fname)
img ... | python | def get_metadata_as_dict(fname):
""" Gets all metadata and puts into dictionary """
imgdict = {}
try:
imgdict['filename'] = fname
imgdict['size'] = str(os.path.getsize(fname))
imgdict['basename'] = os.path.basename(fname)
imgdict['path'] = os.path.dirname(fname)
img ... | [
"def",
"get_metadata_as_dict",
"(",
"fname",
")",
":",
"imgdict",
"=",
"{",
"}",
"try",
":",
"imgdict",
"[",
"'filename'",
"]",
"=",
"fname",
"imgdict",
"[",
"'size'",
"]",
"=",
"str",
"(",
"os",
".",
"path",
".",
"getsize",
"(",
"fname",
")",
")",
... | Gets all metadata and puts into dictionary | [
"Gets",
"all",
"metadata",
"and",
"puts",
"into",
"dictionary"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L198-L235 | train | Gets all metadata and puts into dictionary |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | get_metadata_as_csv | def get_metadata_as_csv(fname):
""" Gets all metadata and puts into CSV format """
q = chr(34)
d = ","
res = q + fname + q + d
res = res + q + os.path.basename(fname) + q + d
res = res + q + os.path.dirname(fname) + q + d
try:
res = res + q + str(os.path.getsize(fname)) + q + d
... | python | def get_metadata_as_csv(fname):
""" Gets all metadata and puts into CSV format """
q = chr(34)
d = ","
res = q + fname + q + d
res = res + q + os.path.basename(fname) + q + d
res = res + q + os.path.dirname(fname) + q + d
try:
res = res + q + str(os.path.getsize(fname)) + q + d
... | [
"def",
"get_metadata_as_csv",
"(",
"fname",
")",
":",
"q",
"=",
"chr",
"(",
"34",
")",
"d",
"=",
"\",\"",
"res",
"=",
"q",
"+",
"fname",
"+",
"q",
"+",
"d",
"res",
"=",
"res",
"+",
"q",
"+",
"os",
".",
"path",
".",
"basename",
"(",
"fname",
"... | Gets all metadata and puts into CSV format | [
"Gets",
"all",
"metadata",
"and",
"puts",
"into",
"CSV",
"format"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L237-L271 | train | Gets all metadata and puts them into a CSV file |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | add_text_to_image | def add_text_to_image(fname, txt, opFilename):
""" convert an image by adding text """
ft = ImageFont.load("T://user//dev//src//python//_AS_LIB//timR24.pil")
#wh = ft.getsize(txt)
print("Adding text ", txt, " to ", fname, " pixels wide to file " , opFilename)
im = Image.open(fname)
draw = ImageD... | python | def add_text_to_image(fname, txt, opFilename):
""" convert an image by adding text """
ft = ImageFont.load("T://user//dev//src//python//_AS_LIB//timR24.pil")
#wh = ft.getsize(txt)
print("Adding text ", txt, " to ", fname, " pixels wide to file " , opFilename)
im = Image.open(fname)
draw = ImageD... | [
"def",
"add_text_to_image",
"(",
"fname",
",",
"txt",
",",
"opFilename",
")",
":",
"ft",
"=",
"ImageFont",
".",
"load",
"(",
"\"T://user//dev//src//python//_AS_LIB//timR24.pil\"",
")",
"#wh = ft.getsize(txt)",
"print",
"(",
"\"Adding text \"",
",",
"txt",
",",
"\" t... | convert an image by adding text | [
"convert",
"an",
"image",
"by",
"adding",
"text"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L304-L313 | train | convert an image by adding text to fname |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | add_crosshair_to_image | def add_crosshair_to_image(fname, opFilename):
""" convert an image by adding a cross hair """
im = Image.open(fname)
draw = ImageDraw.Draw(im)
draw.line((0, 0) + im.size, fill=(255, 255, 255))
draw.line((0, im.size[1], im.size[0], 0), fill=(255, 255, 255))
del draw
im.save(opFilename) | python | def add_crosshair_to_image(fname, opFilename):
""" convert an image by adding a cross hair """
im = Image.open(fname)
draw = ImageDraw.Draw(im)
draw.line((0, 0) + im.size, fill=(255, 255, 255))
draw.line((0, im.size[1], im.size[0], 0), fill=(255, 255, 255))
del draw
im.save(opFilename) | [
"def",
"add_crosshair_to_image",
"(",
"fname",
",",
"opFilename",
")",
":",
"im",
"=",
"Image",
".",
"open",
"(",
"fname",
")",
"draw",
"=",
"ImageDraw",
".",
"Draw",
"(",
"im",
")",
"draw",
".",
"line",
"(",
"(",
"0",
",",
"0",
")",
"+",
"im",
"... | convert an image by adding a cross hair | [
"convert",
"an",
"image",
"by",
"adding",
"a",
"cross",
"hair"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L315-L322 | train | convert an image by adding a cross hair |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | filter_contour | def filter_contour(imageFile, opFile):
""" convert an image by applying a contour """
im = Image.open(imageFile)
im1 = im.filter(ImageFilter.CONTOUR)
im1.save(opFile) | python | def filter_contour(imageFile, opFile):
""" convert an image by applying a contour """
im = Image.open(imageFile)
im1 = im.filter(ImageFilter.CONTOUR)
im1.save(opFile) | [
"def",
"filter_contour",
"(",
"imageFile",
",",
"opFile",
")",
":",
"im",
"=",
"Image",
".",
"open",
"(",
"imageFile",
")",
"im1",
"=",
"im",
".",
"filter",
"(",
"ImageFilter",
".",
"CONTOUR",
")",
"im1",
".",
"save",
"(",
"opFile",
")"
] | convert an image by applying a contour | [
"convert",
"an",
"image",
"by",
"applying",
"a",
"contour"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L324-L328 | train | convert an image by applying a contour |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | check_image_duplicates | def check_image_duplicates(file_list):
""" Checking Images for duplicates (despite resizing, colours, etc) """
master_hash = ''
ham_dist = 0
results = []
print("Checking Images for duplicates (despite resizing, colours, etc) " )
for ndx, fname in enumerate(file_list):
#img = Image.open(f... | python | def check_image_duplicates(file_list):
""" Checking Images for duplicates (despite resizing, colours, etc) """
master_hash = ''
ham_dist = 0
results = []
print("Checking Images for duplicates (despite resizing, colours, etc) " )
for ndx, fname in enumerate(file_list):
#img = Image.open(f... | [
"def",
"check_image_duplicates",
"(",
"file_list",
")",
":",
"master_hash",
"=",
"''",
"ham_dist",
"=",
"0",
"results",
"=",
"[",
"]",
"print",
"(",
"\"Checking Images for duplicates (despite resizing, colours, etc) \"",
")",
"for",
"ndx",
",",
"fname",
"in",
"enume... | Checking Images for duplicates (despite resizing, colours, etc) | [
"Checking",
"Images",
"for",
"duplicates",
"(",
"despite",
"resizing",
"colours",
"etc",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L343-L362 | train | Check if images are duplicated |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | hamming_distance | def hamming_distance(s1, s2):
"""
Return the Hamming distance between equal-length sequences
(http://en.wikipedia.org/wiki/Hamming_distance )
"""
if len(s1) != len(s2):
raise ValueError("Undefined for sequences of unequal length")
return sum(ch1 != ch2 for ch1, ch2 in zip(s1, s2)) | python | def hamming_distance(s1, s2):
"""
Return the Hamming distance between equal-length sequences
(http://en.wikipedia.org/wiki/Hamming_distance )
"""
if len(s1) != len(s2):
raise ValueError("Undefined for sequences of unequal length")
return sum(ch1 != ch2 for ch1, ch2 in zip(s1, s2)) | [
"def",
"hamming_distance",
"(",
"s1",
",",
"s2",
")",
":",
"if",
"len",
"(",
"s1",
")",
"!=",
"len",
"(",
"s2",
")",
":",
"raise",
"ValueError",
"(",
"\"Undefined for sequences of unequal length\"",
")",
"return",
"sum",
"(",
"ch1",
"!=",
"ch2",
"for",
"... | Return the Hamming distance between equal-length sequences
(http://en.wikipedia.org/wiki/Hamming_distance ) | [
"Return",
"the",
"Hamming",
"distance",
"between",
"equal",
"-",
"length",
"sequences",
"(",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Hamming_distance",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L364-L371 | train | Returns the Hamming distance between two equal - length sequences. |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | get_img_hash | def get_img_hash(image, hash_size = 8):
""" Grayscale and shrink the image in one step """
image = image.resize((hash_size + 1, hash_size), Image.ANTIALIAS, )
pixels = list(image.getdata())
#print('get_img_hash: pixels=', pixels)
# Compare adjacent pixels.
difference = []
for row in range... | python | def get_img_hash(image, hash_size = 8):
""" Grayscale and shrink the image in one step """
image = image.resize((hash_size + 1, hash_size), Image.ANTIALIAS, )
pixels = list(image.getdata())
#print('get_img_hash: pixels=', pixels)
# Compare adjacent pixels.
difference = []
for row in range... | [
"def",
"get_img_hash",
"(",
"image",
",",
"hash_size",
"=",
"8",
")",
":",
"image",
"=",
"image",
".",
"resize",
"(",
"(",
"hash_size",
"+",
"1",
",",
"hash_size",
")",
",",
"Image",
".",
"ANTIALIAS",
",",
")",
"pixels",
"=",
"list",
"(",
"image",
... | Grayscale and shrink the image in one step | [
"Grayscale",
"and",
"shrink",
"the",
"image",
"in",
"one",
"step"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L374-L400 | train | Returns the image hash in one step. |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | load_image | def load_image(fname):
""" read an image from file - PIL doesnt close nicely """
with open(fname, "rb") as f:
i = Image.open(fname)
#i.load()
return i | python | def load_image(fname):
""" read an image from file - PIL doesnt close nicely """
with open(fname, "rb") as f:
i = Image.open(fname)
#i.load()
return i | [
"def",
"load_image",
"(",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"\"rb\"",
")",
"as",
"f",
":",
"i",
"=",
"Image",
".",
"open",
"(",
"fname",
")",
"#i.load()",
"return",
"i"
] | read an image from file - PIL doesnt close nicely | [
"read",
"an",
"image",
"from",
"file",
"-",
"PIL",
"doesnt",
"close",
"nicely"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L402-L407 | train | read an image from file - PIL doesnt close nicely |
acutesoftware/AIKIF | aikif/toolbox/image_tools.py | dump_img | def dump_img(fname):
""" output the image as text """
img = Image.open(fname)
width, _ = img.size
txt = ''
pixels = list(img.getdata())
for col in range(width):
txt += str(pixels[col:col+width])
return txt | python | def dump_img(fname):
""" output the image as text """
img = Image.open(fname)
width, _ = img.size
txt = ''
pixels = list(img.getdata())
for col in range(width):
txt += str(pixels[col:col+width])
return txt | [
"def",
"dump_img",
"(",
"fname",
")",
":",
"img",
"=",
"Image",
".",
"open",
"(",
"fname",
")",
"width",
",",
"_",
"=",
"img",
".",
"size",
"txt",
"=",
"''",
"pixels",
"=",
"list",
"(",
"img",
".",
"getdata",
"(",
")",
")",
"for",
"col",
"in",
... | output the image as text | [
"output",
"the",
"image",
"as",
"text"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L409-L417 | train | dump the image as text |
mpg-age-bioinformatics/AGEpy | AGEpy/plots.py | CellPlot | def CellPlot(df, output_file=None, gene_expression="log2FC", figure_title="CellPlot", pvalCol="elimFisher", lowerLimit=None, upperLimit=None, colorBarType='Spectral'):
"""
Python implementation of the CellPlot from the CellPlot package for R.
-inf or inf enrichments will come out as min found float or max f... | python | def CellPlot(df, output_file=None, gene_expression="log2FC", figure_title="CellPlot", pvalCol="elimFisher", lowerLimit=None, upperLimit=None, colorBarType='Spectral'):
"""
Python implementation of the CellPlot from the CellPlot package for R.
-inf or inf enrichments will come out as min found float or max f... | [
"def",
"CellPlot",
"(",
"df",
",",
"output_file",
"=",
"None",
",",
"gene_expression",
"=",
"\"log2FC\"",
",",
"figure_title",
"=",
"\"CellPlot\"",
",",
"pvalCol",
"=",
"\"elimFisher\"",
",",
"lowerLimit",
"=",
"None",
",",
"upperLimit",
"=",
"None",
",",
"c... | Python implementation of the CellPlot from the CellPlot package for R.
-inf or inf enrichments will come out as min found float or max found float, respectively.
:param df: pandas dataframe with the following columns - 'Enrichment', 'Term', and 'log2fc'.
For log2fc each cell must contain a comma... | [
"Python",
"implementation",
"of",
"the",
"CellPlot",
"from",
"the",
"CellPlot",
"package",
"for",
"R",
".",
"-",
"inf",
"or",
"inf",
"enrichments",
"will",
"come",
"out",
"as",
"min",
"found",
"float",
"or",
"max",
"found",
"float",
"respectively",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/plots.py#L9-L179 | train | This function is a convenience function that returns a matplotlib figure that can be used to plot a cell with the given enrichment term. |
mpg-age-bioinformatics/AGEpy | AGEpy/plots.py | SymPlot | def SymPlot(df,output_file=None,figure_title="SymPlot",pvalCol="elimFisher"):
"""
Python implementation of the SymPlot from the CellPlot package for R.
-inf or inf enrichments will come out as min found float or max found float, respectively.
:param df: pandas dataframe with the following columns - 'En... | python | def SymPlot(df,output_file=None,figure_title="SymPlot",pvalCol="elimFisher"):
"""
Python implementation of the SymPlot from the CellPlot package for R.
-inf or inf enrichments will come out as min found float or max found float, respectively.
:param df: pandas dataframe with the following columns - 'En... | [
"def",
"SymPlot",
"(",
"df",
",",
"output_file",
"=",
"None",
",",
"figure_title",
"=",
"\"SymPlot\"",
",",
"pvalCol",
"=",
"\"elimFisher\"",
")",
":",
"df",
"[",
"'Annotated'",
"]",
"=",
"df",
"[",
"'Annotated'",
"]",
".",
"astype",
"(",
"float",
")",
... | Python implementation of the SymPlot from the CellPlot package for R.
-inf or inf enrichments will come out as min found float or max found float, respectively.
:param df: pandas dataframe with the following columns - 'Enrichment', 'Significant', 'Annotated', 'Term', and 'log2fc'.
'Annotated'i s... | [
"Python",
"implementation",
"of",
"the",
"SymPlot",
"from",
"the",
"CellPlot",
"package",
"for",
"R",
".",
"-",
"inf",
"or",
"inf",
"enrichments",
"will",
"come",
"out",
"as",
"min",
"found",
"float",
"or",
"max",
"found",
"float",
"respectively",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/plots.py#L181-L339 | train | This function returns a matplotlib figure that can be used to plot a single cell in a DAVID. |
mpg-age-bioinformatics/AGEpy | AGEpy/plots.py | NormInt | def NormInt(df,sampleA,sampleB):
"""
Normalizes intensities of a gene in two samples
:param df: dataframe output of GetData()
:param sampleA: column header of sample A
:param sampleB: column header of sample B
:returns: normalized intensities
"""
c1=df[sampleA]
c2=df[sampleB]
... | python | def NormInt(df,sampleA,sampleB):
"""
Normalizes intensities of a gene in two samples
:param df: dataframe output of GetData()
:param sampleA: column header of sample A
:param sampleB: column header of sample B
:returns: normalized intensities
"""
c1=df[sampleA]
c2=df[sampleB]
... | [
"def",
"NormInt",
"(",
"df",
",",
"sampleA",
",",
"sampleB",
")",
":",
"c1",
"=",
"df",
"[",
"sampleA",
"]",
"c2",
"=",
"df",
"[",
"sampleB",
"]",
"return",
"np",
".",
"log10",
"(",
"np",
".",
"sqrt",
"(",
"c1",
"*",
"c2",
")",
")"
] | Normalizes intensities of a gene in two samples
:param df: dataframe output of GetData()
:param sampleA: column header of sample A
:param sampleB: column header of sample B
:returns: normalized intensities | [
"Normalizes",
"intensities",
"of",
"a",
"gene",
"in",
"two",
"samples"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/plots.py#L341-L354 | train | This function normalizes intensities of a gene in two samples |
mpg-age-bioinformatics/AGEpy | AGEpy/plots.py | MA | def MA(df,title,figName,c, daType="counts",nbins=10,perc=.5,deg=3,eq=True,splines=True,spec=None,Targets=None,ylim=None,sizeRed=8):
"""
Plots an MA like plot GetData() outputs.
:param df: dataframe output of GetData()
:param title: plot title, 'Genes' or 'Transcripts'
:param figName: /path/to/saved... | python | def MA(df,title,figName,c, daType="counts",nbins=10,perc=.5,deg=3,eq=True,splines=True,spec=None,Targets=None,ylim=None,sizeRed=8):
"""
Plots an MA like plot GetData() outputs.
:param df: dataframe output of GetData()
:param title: plot title, 'Genes' or 'Transcripts'
:param figName: /path/to/saved... | [
"def",
"MA",
"(",
"df",
",",
"title",
",",
"figName",
",",
"c",
",",
"daType",
"=",
"\"counts\"",
",",
"nbins",
"=",
"10",
",",
"perc",
"=",
".5",
",",
"deg",
"=",
"3",
",",
"eq",
"=",
"True",
",",
"splines",
"=",
"True",
",",
"spec",
"=",
"N... | Plots an MA like plot GetData() outputs.
:param df: dataframe output of GetData()
:param title: plot title, 'Genes' or 'Transcripts'
:param figName: /path/to/saved/figure/prefix
:param c: pair of samples to be plotted in list format
:param daType: data type, ie. 'counts' or 'FPKM'
:param nbins:... | [
"Plots",
"an",
"MA",
"like",
"plot",
"GetData",
"()",
"outputs",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/plots.py#L356-L505 | train | Plots a MA plot of the data set. |
Nachtfeuer/pipeline | examples/python/primes/demo/primes.py | is_prime | def is_prime(number):
"""
Testing given number to be a prime.
>>> [n for n in range(100+1) if is_prime(n)]
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
"""
if number < 2:
return False
if number % 2 == 0:
return number == 2
... | python | def is_prime(number):
"""
Testing given number to be a prime.
>>> [n for n in range(100+1) if is_prime(n)]
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
"""
if number < 2:
return False
if number % 2 == 0:
return number == 2
... | [
"def",
"is_prime",
"(",
"number",
")",
":",
"if",
"number",
"<",
"2",
":",
"return",
"False",
"if",
"number",
"%",
"2",
"==",
"0",
":",
"return",
"number",
"==",
"2",
"limit",
"=",
"int",
"(",
"math",
".",
"sqrt",
"(",
"number",
")",
")",
"for",
... | Testing given number to be a prime.
>>> [n for n in range(100+1) if is_prime(n)]
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] | [
"Testing",
"given",
"number",
"to",
"be",
"a",
"prime",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/examples/python/primes/demo/primes.py#L32-L49 | train | Test given number to be a prime. |
OpenHydrology/floodestimation | floodestimation/analysis.py | valid_flows_array | def valid_flows_array(catchment):
"""
Return array of valid flows (i.e. excluding rejected years etc)
:param catchment: gauged catchment with amax_records set
:type catchment: :class:`floodestimation.entities.Catchment`
:return: 1D array of flow values
:rtype: :class:`numpy.ndarray`
"""
... | python | def valid_flows_array(catchment):
"""
Return array of valid flows (i.e. excluding rejected years etc)
:param catchment: gauged catchment with amax_records set
:type catchment: :class:`floodestimation.entities.Catchment`
:return: 1D array of flow values
:rtype: :class:`numpy.ndarray`
"""
... | [
"def",
"valid_flows_array",
"(",
"catchment",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"record",
".",
"flow",
"for",
"record",
"in",
"catchment",
".",
"amax_records",
"if",
"record",
".",
"flag",
"==",
"0",
"]",
")"
] | Return array of valid flows (i.e. excluding rejected years etc)
:param catchment: gauged catchment with amax_records set
:type catchment: :class:`floodestimation.entities.Catchment`
:return: 1D array of flow values
:rtype: :class:`numpy.ndarray` | [
"Return",
"array",
"of",
"valid",
"flows",
"(",
"i",
".",
"e",
".",
"excluding",
"rejected",
"years",
"etc",
")"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L31-L40 | train | Returns array of valid flows in a gauged catchment with amax_records set. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis.qmed | def qmed(self, method='best', **method_options):
"""
Return QMED estimate using best available methodology depending on what catchment attributes are available.
The preferred/best order of methods is defined by :attr:`qmed_methods`. Alternatively, a method can be supplied
e.g. `method='... | python | def qmed(self, method='best', **method_options):
"""
Return QMED estimate using best available methodology depending on what catchment attributes are available.
The preferred/best order of methods is defined by :attr:`qmed_methods`. Alternatively, a method can be supplied
e.g. `method='... | [
"def",
"qmed",
"(",
"self",
",",
"method",
"=",
"'best'",
",",
"*",
"*",
"method_options",
")",
":",
"if",
"method",
"==",
"'best'",
":",
"# Rules for gauged catchments",
"if",
"self",
".",
"catchment",
".",
"pot_dataset",
":",
"if",
"self",
".",
"catchmen... | Return QMED estimate using best available methodology depending on what catchment attributes are available.
The preferred/best order of methods is defined by :attr:`qmed_methods`. Alternatively, a method can be supplied
e.g. `method='descriptors_1999'` to force the use of a particular method.
... | [
"Return",
"QMED",
"estimate",
"using",
"best",
"available",
"methodology",
"depending",
"on",
"what",
"catchment",
"attributes",
"are",
"available",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L94-L167 | train | Return QMED estimate of the most suitable catchment for a particular class. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis.qmed_all_methods | def qmed_all_methods(self):
"""
Returns a dict of QMED methods using all available methods.
Available methods are defined in :attr:`qmed_methods`. The returned dict keys contain the method name, e.g.
`amax_record` with value representing the corresponding QMED estimate in m³/s.
... | python | def qmed_all_methods(self):
"""
Returns a dict of QMED methods using all available methods.
Available methods are defined in :attr:`qmed_methods`. The returned dict keys contain the method name, e.g.
`amax_record` with value representing the corresponding QMED estimate in m³/s.
... | [
"def",
"qmed_all_methods",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"for",
"method",
"in",
"self",
".",
"methods",
":",
"try",
":",
"result",
"[",
"method",
"]",
"=",
"getattr",
"(",
"self",
",",
"'_qmed_from_'",
"+",
"method",
")",
"(",
")",
... | Returns a dict of QMED methods using all available methods.
Available methods are defined in :attr:`qmed_methods`. The returned dict keys contain the method name, e.g.
`amax_record` with value representing the corresponding QMED estimate in m³/s.
:return: dict of QMED estimates
:rtype:... | [
"Returns",
"a",
"dict",
"of",
"QMED",
"methods",
"using",
"all",
"available",
"methods",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L169-L185 | train | Returns a dictionary of QMED methods using all available methods. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._qmed_from_amax_records | def _qmed_from_amax_records(self):
"""
Return QMED estimate based on annual maximum flow records.
:return: QMED in m³/s
:rtype: float
"""
valid_flows = valid_flows_array(self.catchment)
n = len(valid_flows)
if n < 2:
raise InsufficientDataErro... | python | def _qmed_from_amax_records(self):
"""
Return QMED estimate based on annual maximum flow records.
:return: QMED in m³/s
:rtype: float
"""
valid_flows = valid_flows_array(self.catchment)
n = len(valid_flows)
if n < 2:
raise InsufficientDataErro... | [
"def",
"_qmed_from_amax_records",
"(",
"self",
")",
":",
"valid_flows",
"=",
"valid_flows_array",
"(",
"self",
".",
"catchment",
")",
"n",
"=",
"len",
"(",
"valid_flows",
")",
"if",
"n",
"<",
"2",
":",
"raise",
"InsufficientDataError",
"(",
"\"Insufficient ann... | Return QMED estimate based on annual maximum flow records.
:return: QMED in m³/s
:rtype: float | [
"Return",
"QMED",
"estimate",
"based",
"on",
"annual",
"maximum",
"flow",
"records",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L187-L199 | train | Return QMED estimate based on annual maximum flow records. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._qmed_from_pot_records | def _qmed_from_pot_records(self):
"""
Return QMED estimate based on peaks-over-threshold (POT) records.
Methodology source: FEH, Vol. 3, pp. 77-78
:return: QMED in m³/s
:rtype: float
"""
pot_dataset = self.catchment.pot_dataset
if not pot_dataset:
... | python | def _qmed_from_pot_records(self):
"""
Return QMED estimate based on peaks-over-threshold (POT) records.
Methodology source: FEH, Vol. 3, pp. 77-78
:return: QMED in m³/s
:rtype: float
"""
pot_dataset = self.catchment.pot_dataset
if not pot_dataset:
... | [
"def",
"_qmed_from_pot_records",
"(",
"self",
")",
":",
"pot_dataset",
"=",
"self",
".",
"catchment",
".",
"pot_dataset",
"if",
"not",
"pot_dataset",
":",
"raise",
"InsufficientDataError",
"(",
"\"POT dataset must be set for catchment {} to estimate QMED from POT data.\"",
... | Return QMED estimate based on peaks-over-threshold (POT) records.
Methodology source: FEH, Vol. 3, pp. 77-78
:return: QMED in m³/s
:rtype: float | [
"Return",
"QMED",
"estimate",
"based",
"on",
"peaks",
"-",
"over",
"-",
"threshold",
"(",
"POT",
")",
"records",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L201-L227 | train | Return QMED estimate based on peaks - over - threshold ( POT records. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._pot_month_counts | def _pot_month_counts(self, pot_dataset):
"""
Return a list of 12 sets. Each sets contains the years included in the POT record period.
:param pot_dataset: POT dataset (records and meta data)
:type pot_dataset: :class:`floodestimation.entities.PotDataset`
"""
periods = p... | python | def _pot_month_counts(self, pot_dataset):
"""
Return a list of 12 sets. Each sets contains the years included in the POT record period.
:param pot_dataset: POT dataset (records and meta data)
:type pot_dataset: :class:`floodestimation.entities.PotDataset`
"""
periods = p... | [
"def",
"_pot_month_counts",
"(",
"self",
",",
"pot_dataset",
")",
":",
"periods",
"=",
"pot_dataset",
".",
"continuous_periods",
"(",
")",
"result",
"=",
"[",
"set",
"(",
")",
"for",
"x",
"in",
"range",
"(",
"12",
")",
"]",
"for",
"period",
"in",
"peri... | Return a list of 12 sets. Each sets contains the years included in the POT record period.
:param pot_dataset: POT dataset (records and meta data)
:type pot_dataset: :class:`floodestimation.entities.PotDataset` | [
"Return",
"a",
"list",
"of",
"12",
"sets",
".",
"Each",
"sets",
"contains",
"the",
"years",
"included",
"in",
"the",
"POT",
"record",
"period",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L229-L252 | train | Return a list of 12 sets where each set contains the years included in the POT record period. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._complete_pot_years | def _complete_pot_years(self, pot_dataset):
"""
Return a tuple of a list of :class:`PotRecord`s filtering out part-complete years; and the number of complete
years.
This method creates complete years by ensuring there is an equal number of each month in the entire record,
taking... | python | def _complete_pot_years(self, pot_dataset):
"""
Return a tuple of a list of :class:`PotRecord`s filtering out part-complete years; and the number of complete
years.
This method creates complete years by ensuring there is an equal number of each month in the entire record,
taking... | [
"def",
"_complete_pot_years",
"(",
"self",
",",
"pot_dataset",
")",
":",
"# Create a list of 12 sets, one for each month. Each set represents the years for which the POT record includes",
"# a particular month.",
"month_counts",
"=",
"self",
".",
"_pot_month_counts",
"(",
"pot_datase... | Return a tuple of a list of :class:`PotRecord`s filtering out part-complete years; and the number of complete
years.
This method creates complete years by ensuring there is an equal number of each month in the entire record,
taking into account data gaps. A month is considered to be covered by ... | [
"Return",
"a",
"tuple",
"of",
"a",
"list",
"of",
":",
"class",
":",
"PotRecord",
"s",
"filtering",
"out",
"part",
"-",
"complete",
"years",
";",
"and",
"the",
"number",
"of",
"complete",
"years",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L254-L280 | train | Returns a tuple of a list of a list of POTRecords filtering out part - complete years ; and the number of complete years. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._residual_soil | def _residual_soil(self):
"""
Methodology source: FEH, Vol. 3, p. 14
"""
return self.catchment.descriptors.bfihost \
+ 1.3 * (0.01 * self.catchment.descriptors.sprhost) \
- 0.987 | python | def _residual_soil(self):
"""
Methodology source: FEH, Vol. 3, p. 14
"""
return self.catchment.descriptors.bfihost \
+ 1.3 * (0.01 * self.catchment.descriptors.sprhost) \
- 0.987 | [
"def",
"_residual_soil",
"(",
"self",
")",
":",
"return",
"self",
".",
"catchment",
".",
"descriptors",
".",
"bfihost",
"+",
"1.3",
"*",
"(",
"0.01",
"*",
"self",
".",
"catchment",
".",
"descriptors",
".",
"sprhost",
")",
"-",
"0.987"
] | Methodology source: FEH, Vol. 3, p. 14 | [
"Methodology",
"source",
":",
"FEH",
"Vol",
".",
"3",
"p",
".",
"14"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L288-L294 | train | Residual soil. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._qmed_from_area | def _qmed_from_area(self):
"""
Return QMED estimate based on catchment area.
TODO: add source of method
:return: QMED in m³/s
:rtype: float
"""
try:
return 1.172 * self.catchment.descriptors.dtm_area ** self._area_exponent() # Area in km²
ex... | python | def _qmed_from_area(self):
"""
Return QMED estimate based on catchment area.
TODO: add source of method
:return: QMED in m³/s
:rtype: float
"""
try:
return 1.172 * self.catchment.descriptors.dtm_area ** self._area_exponent() # Area in km²
ex... | [
"def",
"_qmed_from_area",
"(",
"self",
")",
":",
"try",
":",
"return",
"1.172",
"*",
"self",
".",
"catchment",
".",
"descriptors",
".",
"dtm_area",
"**",
"self",
".",
"_area_exponent",
"(",
")",
"# Area in km²",
"except",
"(",
"TypeError",
",",
"KeyError",
... | Return QMED estimate based on catchment area.
TODO: add source of method
:return: QMED in m³/s
:rtype: float | [
"Return",
"QMED",
"estimate",
"based",
"on",
"catchment",
"area",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L310-L322 | train | Return QMED estimate based on catchment area. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._qmed_from_descriptors_1999 | def _qmed_from_descriptors_1999(self, as_rural=False):
"""
Return QMED estimation based on FEH catchment descriptors, 1999 methodology.
Methodology source: FEH, Vol. 3, p. 14
:param as_rural: assume catchment is fully rural. Default: false.
:type as_rural: bool
:return:... | python | def _qmed_from_descriptors_1999(self, as_rural=False):
"""
Return QMED estimation based on FEH catchment descriptors, 1999 methodology.
Methodology source: FEH, Vol. 3, p. 14
:param as_rural: assume catchment is fully rural. Default: false.
:type as_rural: bool
:return:... | [
"def",
"_qmed_from_descriptors_1999",
"(",
"self",
",",
"as_rural",
"=",
"False",
")",
":",
"try",
":",
"qmed_rural",
"=",
"1.172",
"*",
"self",
".",
"catchment",
".",
"descriptors",
".",
"dtm_area",
"**",
"self",
".",
"_area_exponent",
"(",
")",
"*",
"(",... | Return QMED estimation based on FEH catchment descriptors, 1999 methodology.
Methodology source: FEH, Vol. 3, p. 14
:param as_rural: assume catchment is fully rural. Default: false.
:type as_rural: bool
:return: QMED in m³/s
:rtype: float | [
"Return",
"QMED",
"estimation",
"based",
"on",
"FEH",
"catchment",
"descriptors",
"1999",
"methodology",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L324-L346 | train | Return QMED estimation based on FEH catchment descriptors 1999 methodology. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._qmed_from_descriptors_2008 | def _qmed_from_descriptors_2008(self, as_rural=False, donor_catchments=None):
"""
Return QMED estimation based on FEH catchment descriptors, 2008 methodology.
Methodology source: Science Report SC050050, p. 36
:param as_rural: assume catchment is fully rural. Default: false.
:t... | python | def _qmed_from_descriptors_2008(self, as_rural=False, donor_catchments=None):
"""
Return QMED estimation based on FEH catchment descriptors, 2008 methodology.
Methodology source: Science Report SC050050, p. 36
:param as_rural: assume catchment is fully rural. Default: false.
:t... | [
"def",
"_qmed_from_descriptors_2008",
"(",
"self",
",",
"as_rural",
"=",
"False",
",",
"donor_catchments",
"=",
"None",
")",
":",
"try",
":",
"# Basis rural QMED from descriptors",
"lnqmed_rural",
"=",
"2.1170",
"+",
"0.8510",
"*",
"log",
"(",
"self",
".",
"catc... | Return QMED estimation based on FEH catchment descriptors, 2008 methodology.
Methodology source: Science Report SC050050, p. 36
:param as_rural: assume catchment is fully rural. Default: false.
:type as rural: bool
:param donor_catchments: override donor catchment to improve QMED catch... | [
"Return",
"QMED",
"estimation",
"based",
"on",
"FEH",
"catchment",
"descriptors",
"2008",
"methodology",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L359-L416 | train | Return QMED estimation based on FEH catchment descriptors 2008 methodology. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._pruaf | def _pruaf(self):
"""
Return percentage runoff urban adjustment factor.
Methodology source: eqn. 6, Kjeldsen 2010
"""
return 1 + 0.47 * self.catchment.descriptors.urbext(self.year) \
* self.catchment.descriptors.bfihost / (1 - self.catchment.descriptors.bfihos... | python | def _pruaf(self):
"""
Return percentage runoff urban adjustment factor.
Methodology source: eqn. 6, Kjeldsen 2010
"""
return 1 + 0.47 * self.catchment.descriptors.urbext(self.year) \
* self.catchment.descriptors.bfihost / (1 - self.catchment.descriptors.bfihos... | [
"def",
"_pruaf",
"(",
"self",
")",
":",
"return",
"1",
"+",
"0.47",
"*",
"self",
".",
"catchment",
".",
"descriptors",
".",
"urbext",
"(",
"self",
".",
"year",
")",
"*",
"self",
".",
"catchment",
".",
"descriptors",
".",
"bfihost",
"/",
"(",
"1",
"... | Return percentage runoff urban adjustment factor.
Methodology source: eqn. 6, Kjeldsen 2010 | [
"Return",
"percentage",
"runoff",
"urban",
"adjustment",
"factor",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L418-L425 | train | Return percentage runoff urban adjustment factor. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis.urban_adj_factor | def urban_adj_factor(self):
"""
Return urban adjustment factor (UAF) used to adjust QMED and growth curves.
Methodology source: eqn. 8, Kjeldsen 2010
:return: urban adjustment factor
:rtype: float
"""
urbext = self.catchment.descriptors.urbext(self.year)
... | python | def urban_adj_factor(self):
"""
Return urban adjustment factor (UAF) used to adjust QMED and growth curves.
Methodology source: eqn. 8, Kjeldsen 2010
:return: urban adjustment factor
:rtype: float
"""
urbext = self.catchment.descriptors.urbext(self.year)
... | [
"def",
"urban_adj_factor",
"(",
"self",
")",
":",
"urbext",
"=",
"self",
".",
"catchment",
".",
"descriptors",
".",
"urbext",
"(",
"self",
".",
"year",
")",
"result",
"=",
"self",
".",
"_pruaf",
"(",
")",
"**",
"2.16",
"*",
"(",
"1",
"+",
"urbext",
... | Return urban adjustment factor (UAF) used to adjust QMED and growth curves.
Methodology source: eqn. 8, Kjeldsen 2010
:return: urban adjustment factor
:rtype: float | [
"Return",
"urban",
"adjustment",
"factor",
"(",
"UAF",
")",
"used",
"to",
"adjust",
"QMED",
"and",
"growth",
"curves",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L427-L440 | train | Return the urban adjustment factor used to adjust QMED and growth curves. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._dist_corr | def _dist_corr(dist, phi1, phi2, phi3):
"""
Generic distance-decaying correlation function
:param dist: Distance between catchment centrolds in km
:type dist: float
:param phi1: Decay function parameters 1
:type phi1: float
:param phi2: Decay function parameters ... | python | def _dist_corr(dist, phi1, phi2, phi3):
"""
Generic distance-decaying correlation function
:param dist: Distance between catchment centrolds in km
:type dist: float
:param phi1: Decay function parameters 1
:type phi1: float
:param phi2: Decay function parameters ... | [
"def",
"_dist_corr",
"(",
"dist",
",",
"phi1",
",",
"phi2",
",",
"phi3",
")",
":",
"return",
"phi1",
"*",
"exp",
"(",
"-",
"phi2",
"*",
"dist",
")",
"+",
"(",
"1",
"-",
"phi1",
")",
"*",
"exp",
"(",
"-",
"phi3",
"*",
"dist",
")"
] | Generic distance-decaying correlation function
:param dist: Distance between catchment centrolds in km
:type dist: float
:param phi1: Decay function parameters 1
:type phi1: float
:param phi2: Decay function parameters 2
:type phi2: float
:param phi3: Decay funct... | [
"Generic",
"distance",
"-",
"decaying",
"correlation",
"function"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L443-L458 | train | Generic distance - decaying correlation function |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._model_error_corr | def _model_error_corr(self, catchment1, catchment2):
"""
Return model error correlation between subject catchment and other catchment.
Methodology source: Kjeldsen & Jones, 2009, table 3
:param catchment1: catchment to calculate error correlation with
:type catchment1: :class:`... | python | def _model_error_corr(self, catchment1, catchment2):
"""
Return model error correlation between subject catchment and other catchment.
Methodology source: Kjeldsen & Jones, 2009, table 3
:param catchment1: catchment to calculate error correlation with
:type catchment1: :class:`... | [
"def",
"_model_error_corr",
"(",
"self",
",",
"catchment1",
",",
"catchment2",
")",
":",
"dist",
"=",
"catchment1",
".",
"distance_to",
"(",
"catchment2",
")",
"return",
"self",
".",
"_dist_corr",
"(",
"dist",
",",
"0.3998",
",",
"0.0283",
",",
"0.9494",
"... | Return model error correlation between subject catchment and other catchment.
Methodology source: Kjeldsen & Jones, 2009, table 3
:param catchment1: catchment to calculate error correlation with
:type catchment1: :class:`Catchment`
:param catchment2: catchment to calculate error correl... | [
"Return",
"model",
"error",
"correlation",
"between",
"subject",
"catchment",
"and",
"other",
"catchment",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L460-L474 | train | Calculate model error correlation between subject catchment and other catchment. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._lnqmed_corr | def _lnqmed_corr(self, catchment1, catchment2):
"""
Return model error correlation between subject catchment and other catchment.
Methodology source: Kjeldsen & Jones, 2009, fig 3
:param catchment1: catchment to calculate correlation with
:type catchment1: :class:`Catchment`
... | python | def _lnqmed_corr(self, catchment1, catchment2):
"""
Return model error correlation between subject catchment and other catchment.
Methodology source: Kjeldsen & Jones, 2009, fig 3
:param catchment1: catchment to calculate correlation with
:type catchment1: :class:`Catchment`
... | [
"def",
"_lnqmed_corr",
"(",
"self",
",",
"catchment1",
",",
"catchment2",
")",
":",
"dist",
"=",
"catchment1",
".",
"distance_to",
"(",
"catchment2",
")",
"return",
"self",
".",
"_dist_corr",
"(",
"dist",
",",
"0.2791",
",",
"0.0039",
",",
"0.0632",
")"
] | Return model error correlation between subject catchment and other catchment.
Methodology source: Kjeldsen & Jones, 2009, fig 3
:param catchment1: catchment to calculate correlation with
:type catchment1: :class:`Catchment`
:param catchment2: catchment to calculate correlation with
... | [
"Return",
"model",
"error",
"correlation",
"between",
"subject",
"catchment",
"and",
"other",
"catchment",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L476-L490 | train | Calculate the lnqmed correlation between subject catchment and other catchment. |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._vec_b | def _vec_b(self, donor_catchments):
"""
Return vector ``b`` of model error covariances to estimate weights
Methodology source: Kjeldsen, Jones and Morris, 2009, eqs 3 and 10
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
... | python | def _vec_b(self, donor_catchments):
"""
Return vector ``b`` of model error covariances to estimate weights
Methodology source: Kjeldsen, Jones and Morris, 2009, eqs 3 and 10
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
... | [
"def",
"_vec_b",
"(",
"self",
",",
"donor_catchments",
")",
":",
"p",
"=",
"len",
"(",
"donor_catchments",
")",
"b",
"=",
"0.1175",
"*",
"np",
".",
"ones",
"(",
"p",
")",
"for",
"i",
"in",
"range",
"(",
"p",
")",
":",
"b",
"[",
"i",
"]",
"*=",
... | Return vector ``b`` of model error covariances to estimate weights
Methodology source: Kjeldsen, Jones and Morris, 2009, eqs 3 and 10
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
:return: Model error covariance vector
:... | [
"Return",
"vector",
"b",
"of",
"model",
"error",
"covariances",
"to",
"estimate",
"weights"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L492-L507 | train | Return vector b of model error covariance to estimate weights |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._beta | def _beta(catchment):
"""
Return beta, the GLO scale parameter divided by loc parameter estimated using simple regression model
Methodology source: Kjeldsen & Jones, 2009, table 2
:param catchment: Catchment to estimate beta for
:type catchment: :class:`Catchment`
:retu... | python | def _beta(catchment):
"""
Return beta, the GLO scale parameter divided by loc parameter estimated using simple regression model
Methodology source: Kjeldsen & Jones, 2009, table 2
:param catchment: Catchment to estimate beta for
:type catchment: :class:`Catchment`
:retu... | [
"def",
"_beta",
"(",
"catchment",
")",
":",
"lnbeta",
"=",
"-",
"1.1221",
"-",
"0.0816",
"*",
"log",
"(",
"catchment",
".",
"descriptors",
".",
"dtm_area",
")",
"-",
"0.4580",
"*",
"log",
"(",
"catchment",
".",
"descriptors",
".",
"saar",
"/",
"1000",
... | Return beta, the GLO scale parameter divided by loc parameter estimated using simple regression model
Methodology source: Kjeldsen & Jones, 2009, table 2
:param catchment: Catchment to estimate beta for
:type catchment: :class:`Catchment`
:return: beta
:rtype: float | [
"Return",
"beta",
"the",
"GLO",
"scale",
"parameter",
"divided",
"by",
"loc",
"parameter",
"estimated",
"using",
"simple",
"regression",
"model"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L510-L525 | train | Return beta estimate of the GLO scale parameter divided by loc parameter estimated using simple regression model |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._matrix_sigma_eta | def _matrix_sigma_eta(self, donor_catchments):
"""
Return model error coveriance matrix Sigma eta
Methodology source: Kjelsen, Jones & Morris 2014, eqs 2 and 3
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
:retur... | python | def _matrix_sigma_eta(self, donor_catchments):
"""
Return model error coveriance matrix Sigma eta
Methodology source: Kjelsen, Jones & Morris 2014, eqs 2 and 3
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
:retur... | [
"def",
"_matrix_sigma_eta",
"(",
"self",
",",
"donor_catchments",
")",
":",
"p",
"=",
"len",
"(",
"donor_catchments",
")",
"sigma",
"=",
"0.1175",
"*",
"np",
".",
"ones",
"(",
"(",
"p",
",",
"p",
")",
")",
"for",
"i",
"in",
"range",
"(",
"p",
")",
... | Return model error coveriance matrix Sigma eta
Methodology source: Kjelsen, Jones & Morris 2014, eqs 2 and 3
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
:return: 2-Dimensional, symmetric covariance matrix
:rtype: :clas... | [
"Return",
"model",
"error",
"coveriance",
"matrix",
"Sigma",
"eta"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L527-L544 | train | Compute model error coveriance matrix Sigma eta |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._matrix_sigma_eps | def _matrix_sigma_eps(self, donor_catchments):
"""
Return sampling error coveriance matrix Sigma eta
Methodology source: Kjeldsen & Jones 2009, eq 9
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
:return: 2-Dimens... | python | def _matrix_sigma_eps(self, donor_catchments):
"""
Return sampling error coveriance matrix Sigma eta
Methodology source: Kjeldsen & Jones 2009, eq 9
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
:return: 2-Dimens... | [
"def",
"_matrix_sigma_eps",
"(",
"self",
",",
"donor_catchments",
")",
":",
"p",
"=",
"len",
"(",
"donor_catchments",
")",
"sigma",
"=",
"np",
".",
"empty",
"(",
"(",
"p",
",",
"p",
")",
")",
"for",
"i",
"in",
"range",
"(",
"p",
")",
":",
"beta_i",... | Return sampling error coveriance matrix Sigma eta
Methodology source: Kjeldsen & Jones 2009, eq 9
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
:return: 2-Dimensional, symmetric covariance matrix
:rtype: :class:`numpy.nd... | [
"Return",
"sampling",
"error",
"coveriance",
"matrix",
"Sigma",
"eta"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L546-L569 | train | Return sampling error coveriance matrix Sigma |
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._vec_alpha | def _vec_alpha(self, donor_catchments):
"""
Return vector alpha which is the weights for donor model errors
Methodology source: Kjeldsen, Jones & Morris 2014, eq 10
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
:... | python | def _vec_alpha(self, donor_catchments):
"""
Return vector alpha which is the weights for donor model errors
Methodology source: Kjeldsen, Jones & Morris 2014, eq 10
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
:... | [
"def",
"_vec_alpha",
"(",
"self",
",",
"donor_catchments",
")",
":",
"return",
"np",
".",
"dot",
"(",
"linalg",
".",
"inv",
"(",
"self",
".",
"_matrix_omega",
"(",
"donor_catchments",
")",
")",
",",
"self",
".",
"_vec_b",
"(",
"donor_catchments",
")",
")... | Return vector alpha which is the weights for donor model errors
Methodology source: Kjeldsen, Jones & Morris 2014, eq 10
:param donor_catchments: Catchments to use as donors
:type donor_catchments: list of :class:`Catchment`
:return: Vector of donor weights
:rtype: :class:`nump... | [
"Return",
"vector",
"alpha",
"which",
"is",
"the",
"weights",
"for",
"donor",
"model",
"errors"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L574-L585 | train | Return vector alpha which is the weights for donor model errors
|
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._lnqmed_residual | def _lnqmed_residual(catchment):
"""
Return ln(QMED) model error at a gauged catchment
:param catchment: Gauged catchment
:type catchment: :class:`Catchment`
:return: Model error
:rtype: float
"""
analysis = QmedAnalysis(catchment, year=2000) # Probably ... | python | def _lnqmed_residual(catchment):
"""
Return ln(QMED) model error at a gauged catchment
:param catchment: Gauged catchment
:type catchment: :class:`Catchment`
:return: Model error
:rtype: float
"""
analysis = QmedAnalysis(catchment, year=2000) # Probably ... | [
"def",
"_lnqmed_residual",
"(",
"catchment",
")",
":",
"analysis",
"=",
"QmedAnalysis",
"(",
"catchment",
",",
"year",
"=",
"2000",
")",
"# Probably should set the year to the midpoint of amax rec.",
"logmedian_amax",
"=",
"log",
"(",
"analysis",
".",
"qmed",
"(",
"... | Return ln(QMED) model error at a gauged catchment
:param catchment: Gauged catchment
:type catchment: :class:`Catchment`
:return: Model error
:rtype: float | [
"Return",
"ln",
"(",
"QMED",
")",
"model",
"error",
"at",
"a",
"gauged",
"catchment"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L588-L600 | train | Return ln ( QMED ) model error at a gauged catchment
|
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis._vec_lnqmed_residuals | def _vec_lnqmed_residuals(self, catchments):
"""
Return ln(QMED) model errors for a list of catchments
:param catchments: List of gauged catchments
:type catchments: list of :class:`Catchment`
:return: Model errors
:rtype: list of float
"""
result = np.em... | python | def _vec_lnqmed_residuals(self, catchments):
"""
Return ln(QMED) model errors for a list of catchments
:param catchments: List of gauged catchments
:type catchments: list of :class:`Catchment`
:return: Model errors
:rtype: list of float
"""
result = np.em... | [
"def",
"_vec_lnqmed_residuals",
"(",
"self",
",",
"catchments",
")",
":",
"result",
"=",
"np",
".",
"empty",
"(",
"len",
"(",
"catchments",
")",
")",
"for",
"index",
",",
"donor",
"in",
"enumerate",
"(",
"catchments",
")",
":",
"result",
"[",
"index",
... | Return ln(QMED) model errors for a list of catchments
:param catchments: List of gauged catchments
:type catchments: list of :class:`Catchment`
:return: Model errors
:rtype: list of float | [
"Return",
"ln",
"(",
"QMED",
")",
"model",
"errors",
"for",
"a",
"list",
"of",
"catchments"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L602-L614 | train | Return ln QMED model errors for a list of catchments
|
OpenHydrology/floodestimation | floodestimation/analysis.py | QmedAnalysis.find_donor_catchments | def find_donor_catchments(self, limit=6, dist_limit=500):
"""
Return a suitable donor catchment to improve a QMED estimate based on catchment descriptors alone.
:param limit: maximum number of catchments to return. Default: 6. Set to `None` to return all available
catchmen... | python | def find_donor_catchments(self, limit=6, dist_limit=500):
"""
Return a suitable donor catchment to improve a QMED estimate based on catchment descriptors alone.
:param limit: maximum number of catchments to return. Default: 6. Set to `None` to return all available
catchmen... | [
"def",
"find_donor_catchments",
"(",
"self",
",",
"limit",
"=",
"6",
",",
"dist_limit",
"=",
"500",
")",
":",
"if",
"self",
".",
"gauged_catchments",
":",
"return",
"self",
".",
"gauged_catchments",
".",
"nearest_qmed_catchments",
"(",
"self",
".",
"catchment"... | Return a suitable donor catchment to improve a QMED estimate based on catchment descriptors alone.
:param limit: maximum number of catchments to return. Default: 6. Set to `None` to return all available
catchments.
:type limit: int
:param dist_limit: maximum distance in km... | [
"Return",
"a",
"suitable",
"donor",
"catchment",
"to",
"improve",
"a",
"QMED",
"estimate",
"based",
"on",
"catchment",
"descriptors",
"alone",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L616-L632 | train | Return a list of nearby catchments for a given subject and donor catchment. |
OpenHydrology/floodestimation | floodestimation/analysis.py | GrowthCurveAnalysis.growth_curve | def growth_curve(self, method='best', **method_options):
"""
Return QMED estimate using best available methodology depending on what catchment attributes are available.
====================== ====================== ==================================================================
`meth... | python | def growth_curve(self, method='best', **method_options):
"""
Return QMED estimate using best available methodology depending on what catchment attributes are available.
====================== ====================== ==================================================================
`meth... | [
"def",
"growth_curve",
"(",
"self",
",",
"method",
"=",
"'best'",
",",
"*",
"*",
"method_options",
")",
":",
"if",
"method",
"==",
"'best'",
":",
"if",
"self",
".",
"catchment",
".",
"amax_records",
":",
"# Gauged catchment, use enhanced single site",
"self",
... | Return QMED estimate using best available methodology depending on what catchment attributes are available.
====================== ====================== ==================================================================
`method` `method_options` notes
======================... | [
"Return",
"QMED",
"estimate",
"using",
"best",
"available",
"methodology",
"depending",
"on",
"what",
"catchment",
"attributes",
"are",
"available",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L661-L698 | train | Estimate the growth curve for a given methodology. |
OpenHydrology/floodestimation | floodestimation/analysis.py | GrowthCurveAnalysis._var_and_skew | def _var_and_skew(self, catchments, as_rural=False):
"""
Calculate L-CV and L-SKEW from a single catchment or a pooled group of catchments.
Methodology source: Science Report SC050050, para. 6.4.1-6.4.2
"""
if not hasattr(catchments, '__getitem__'): # In case of a single catchm... | python | def _var_and_skew(self, catchments, as_rural=False):
"""
Calculate L-CV and L-SKEW from a single catchment or a pooled group of catchments.
Methodology source: Science Report SC050050, para. 6.4.1-6.4.2
"""
if not hasattr(catchments, '__getitem__'): # In case of a single catchm... | [
"def",
"_var_and_skew",
"(",
"self",
",",
"catchments",
",",
"as_rural",
"=",
"False",
")",
":",
"if",
"not",
"hasattr",
"(",
"catchments",
",",
"'__getitem__'",
")",
":",
"# In case of a single catchment",
"l_cv",
",",
"l_skew",
"=",
"self",
".",
"_l_cv_and_s... | Calculate L-CV and L-SKEW from a single catchment or a pooled group of catchments.
Methodology source: Science Report SC050050, para. 6.4.1-6.4.2 | [
"Calculate",
"L",
"-",
"CV",
"and",
"L",
"-",
"SKEW",
"from",
"a",
"single",
"catchment",
"or",
"a",
"pooled",
"group",
"of",
"catchments",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L713-L770 | train | Calculate the variable and skew of a single catchment. |
OpenHydrology/floodestimation | floodestimation/analysis.py | GrowthCurveAnalysis._l_cv_and_skew | def _l_cv_and_skew(self, catchment):
"""
Calculate L-CV and L-SKEW for a gauged catchment. Uses `lmoments3` library.
Methodology source: Science Report SC050050, para. 6.7.5
"""
z = self._dimensionless_flows(catchment)
l1, l2, t3 = lm.lmom_ratios(z, nmom=3)
retur... | python | def _l_cv_and_skew(self, catchment):
"""
Calculate L-CV and L-SKEW for a gauged catchment. Uses `lmoments3` library.
Methodology source: Science Report SC050050, para. 6.7.5
"""
z = self._dimensionless_flows(catchment)
l1, l2, t3 = lm.lmom_ratios(z, nmom=3)
retur... | [
"def",
"_l_cv_and_skew",
"(",
"self",
",",
"catchment",
")",
":",
"z",
"=",
"self",
".",
"_dimensionless_flows",
"(",
"catchment",
")",
"l1",
",",
"l2",
",",
"t3",
"=",
"lm",
".",
"lmom_ratios",
"(",
"z",
",",
"nmom",
"=",
"3",
")",
"return",
"l2",
... | Calculate L-CV and L-SKEW for a gauged catchment. Uses `lmoments3` library.
Methodology source: Science Report SC050050, para. 6.7.5 | [
"Calculate",
"L",
"-",
"CV",
"and",
"L",
"-",
"SKEW",
"for",
"a",
"gauged",
"catchment",
".",
"Uses",
"lmoments3",
"library",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L772-L780 | train | Calculate L - CV and L - SKEW for a gauged catchment. Uses lmoments3 library. |
OpenHydrology/floodestimation | floodestimation/analysis.py | GrowthCurveAnalysis._l_cv_weight | def _l_cv_weight(self, donor_catchment):
"""
Return L-CV weighting for a donor catchment.
Methodology source: Science Report SC050050, eqn. 6.18 and 6.22a
"""
try:
dist = donor_catchment.similarity_dist
except AttributeError:
dist = self._similari... | python | def _l_cv_weight(self, donor_catchment):
"""
Return L-CV weighting for a donor catchment.
Methodology source: Science Report SC050050, eqn. 6.18 and 6.22a
"""
try:
dist = donor_catchment.similarity_dist
except AttributeError:
dist = self._similari... | [
"def",
"_l_cv_weight",
"(",
"self",
",",
"donor_catchment",
")",
":",
"try",
":",
"dist",
"=",
"donor_catchment",
".",
"similarity_dist",
"except",
"AttributeError",
":",
"dist",
"=",
"self",
".",
"_similarity_distance",
"(",
"self",
".",
"catchment",
",",
"do... | Return L-CV weighting for a donor catchment.
Methodology source: Science Report SC050050, eqn. 6.18 and 6.22a | [
"Return",
"L",
"-",
"CV",
"weighting",
"for",
"a",
"donor",
"catchment",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L782-L794 | train | Return the L - CV weighting for a donor catchment. |
OpenHydrology/floodestimation | floodestimation/analysis.py | GrowthCurveAnalysis._l_cv_weight_factor | def _l_cv_weight_factor(self):
"""
Return multiplier for L-CV weightings in case of enhanced single site analysis.
Methodology source: Science Report SC050050, eqn. 6.15a and 6.15b
"""
b = 0.0047 * sqrt(0) + 0.0023 / 2
c = 0.02609 / (self.catchment.record_length - 1)
... | python | def _l_cv_weight_factor(self):
"""
Return multiplier for L-CV weightings in case of enhanced single site analysis.
Methodology source: Science Report SC050050, eqn. 6.15a and 6.15b
"""
b = 0.0047 * sqrt(0) + 0.0023 / 2
c = 0.02609 / (self.catchment.record_length - 1)
... | [
"def",
"_l_cv_weight_factor",
"(",
"self",
")",
":",
"b",
"=",
"0.0047",
"*",
"sqrt",
"(",
"0",
")",
"+",
"0.0023",
"/",
"2",
"c",
"=",
"0.02609",
"/",
"(",
"self",
".",
"catchment",
".",
"record_length",
"-",
"1",
")",
"return",
"c",
"/",
"(",
"... | Return multiplier for L-CV weightings in case of enhanced single site analysis.
Methodology source: Science Report SC050050, eqn. 6.15a and 6.15b | [
"Return",
"multiplier",
"for",
"L",
"-",
"CV",
"weightings",
"in",
"case",
"of",
"enhanced",
"single",
"site",
"analysis",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L796-L804 | train | Return multiplier for L - CV weightings in case of enhanced single site analysis. |
OpenHydrology/floodestimation | floodestimation/analysis.py | GrowthCurveAnalysis._l_skew_weight | def _l_skew_weight(self, donor_catchment):
"""
Return L-SKEW weighting for donor catchment.
Methodology source: Science Report SC050050, eqn. 6.19 and 6.22b
"""
try:
dist = donor_catchment.similarity_dist
except AttributeError:
dist = self._simila... | python | def _l_skew_weight(self, donor_catchment):
"""
Return L-SKEW weighting for donor catchment.
Methodology source: Science Report SC050050, eqn. 6.19 and 6.22b
"""
try:
dist = donor_catchment.similarity_dist
except AttributeError:
dist = self._simila... | [
"def",
"_l_skew_weight",
"(",
"self",
",",
"donor_catchment",
")",
":",
"try",
":",
"dist",
"=",
"donor_catchment",
".",
"similarity_dist",
"except",
"AttributeError",
":",
"dist",
"=",
"self",
".",
"_similarity_distance",
"(",
"self",
".",
"catchment",
",",
"... | Return L-SKEW weighting for donor catchment.
Methodology source: Science Report SC050050, eqn. 6.19 and 6.22b | [
"Return",
"L",
"-",
"SKEW",
"weighting",
"for",
"donor",
"catchment",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L806-L818 | train | Return the L - SKEW weighting for a given donor catchment. |
OpenHydrology/floodestimation | floodestimation/analysis.py | GrowthCurveAnalysis._growth_curve_single_site | def _growth_curve_single_site(self, distr='glo'):
"""
Return flood growth curve function based on `amax_records` from the subject catchment only.
:return: Inverse cumulative distribution function with one parameter `aep` (annual exceedance probability)
:type: :class:`.GrowthCurve`
... | python | def _growth_curve_single_site(self, distr='glo'):
"""
Return flood growth curve function based on `amax_records` from the subject catchment only.
:return: Inverse cumulative distribution function with one parameter `aep` (annual exceedance probability)
:type: :class:`.GrowthCurve`
... | [
"def",
"_growth_curve_single_site",
"(",
"self",
",",
"distr",
"=",
"'glo'",
")",
":",
"if",
"self",
".",
"catchment",
".",
"amax_records",
":",
"self",
".",
"donor_catchments",
"=",
"[",
"]",
"return",
"GrowthCurve",
"(",
"distr",
",",
"*",
"self",
".",
... | Return flood growth curve function based on `amax_records` from the subject catchment only.
:return: Inverse cumulative distribution function with one parameter `aep` (annual exceedance probability)
:type: :class:`.GrowthCurve` | [
"Return",
"flood",
"growth",
"curve",
"function",
"based",
"on",
"amax_records",
"from",
"the",
"subject",
"catchment",
"only",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L820-L831 | train | Returns the flood growth curve function based on amax_records from the subject catchment only. |
OpenHydrology/floodestimation | floodestimation/analysis.py | GrowthCurveAnalysis._growth_curve_pooling_group | def _growth_curve_pooling_group(self, distr='glo', as_rural=False):
"""
Return flood growth curve function based on `amax_records` from a pooling group.
:return: Inverse cumulative distribution function with one parameter `aep` (annual exceedance probability)
:type: :class:`.GrowthCurve... | python | def _growth_curve_pooling_group(self, distr='glo', as_rural=False):
"""
Return flood growth curve function based on `amax_records` from a pooling group.
:return: Inverse cumulative distribution function with one parameter `aep` (annual exceedance probability)
:type: :class:`.GrowthCurve... | [
"def",
"_growth_curve_pooling_group",
"(",
"self",
",",
"distr",
"=",
"'glo'",
",",
"as_rural",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"donor_catchments",
":",
"self",
".",
"find_donor_catchments",
"(",
")",
"gc",
"=",
"GrowthCurve",
"(",
"distr",... | Return flood growth curve function based on `amax_records` from a pooling group.
:return: Inverse cumulative distribution function with one parameter `aep` (annual exceedance probability)
:type: :class:`.GrowthCurve`
:param as_rural: assume catchment is fully rural. Default: false.
:typ... | [
"Return",
"flood",
"growth",
"curve",
"function",
"based",
"on",
"amax_records",
"from",
"a",
"pooling",
"group",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L833-L849 | train | Return flood growth curve function based on amax_records. |
OpenHydrology/floodestimation | floodestimation/analysis.py | GrowthCurveAnalysis.find_donor_catchments | def find_donor_catchments(self, include_subject_catchment='auto'):
"""
Find list of suitable donor cachments, ranked by hydrological similarity distance measure. This method is
implicitly called when calling the :meth:`.growth_curve` method unless the attribute :attr:`.donor_catchments`
... | python | def find_donor_catchments(self, include_subject_catchment='auto'):
"""
Find list of suitable donor cachments, ranked by hydrological similarity distance measure. This method is
implicitly called when calling the :meth:`.growth_curve` method unless the attribute :attr:`.donor_catchments`
... | [
"def",
"find_donor_catchments",
"(",
"self",
",",
"include_subject_catchment",
"=",
"'auto'",
")",
":",
"# Only if we have access to db with gauged catchment data",
"if",
"self",
".",
"gauged_cachments",
":",
"self",
".",
"donor_catchments",
"=",
"self",
".",
"gauged_cach... | Find list of suitable donor cachments, ranked by hydrological similarity distance measure. This method is
implicitly called when calling the :meth:`.growth_curve` method unless the attribute :attr:`.donor_catchments`
is set manually.
The results are stored in :attr:`.donor_catchments`. The (lis... | [
"Find",
"list",
"of",
"suitable",
"donor",
"cachments",
"ranked",
"by",
"hydrological",
"similarity",
"distance",
"measure",
".",
"This",
"method",
"is",
"implicitly",
"called",
"when",
"calling",
"the",
":",
"meth",
":",
".",
"growth_curve",
"method",
"unless",... | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L897-L920 | train | This method finds the list of suitable donor cachments ranked by hydrological similarity distance measure. |
OpenHydrology/floodestimation | floodestimation/analysis.py | GrowthCurve._solve_location_param | def _solve_location_param(self):
"""
We're lazy here and simply iterate to find the location parameter such that growth_curve(0.5)=1.
"""
params = copy.copy(self.params)
del params['loc']
f = lambda location: self.distr_f.ppf(0.5, loc=location, **params) - 1
retu... | python | def _solve_location_param(self):
"""
We're lazy here and simply iterate to find the location parameter such that growth_curve(0.5)=1.
"""
params = copy.copy(self.params)
del params['loc']
f = lambda location: self.distr_f.ppf(0.5, loc=location, **params) - 1
retu... | [
"def",
"_solve_location_param",
"(",
"self",
")",
":",
"params",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"params",
")",
"del",
"params",
"[",
"'loc'",
"]",
"f",
"=",
"lambda",
"location",
":",
"self",
".",
"distr_f",
".",
"ppf",
"(",
"0.5",
",",
... | We're lazy here and simply iterate to find the location parameter such that growth_curve(0.5)=1. | [
"We",
"re",
"lazy",
"here",
"and",
"simply",
"iterate",
"to",
"find",
"the",
"location",
"parameter",
"such",
"that",
"growth_curve",
"(",
"0",
".",
"5",
")",
"=",
"1",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/analysis.py#L973-L981 | train | Find the location parameter such that growth_curve = 1. |
Nachtfeuer/pipeline | spline/tools/version.py | VersionsCheck.process | def process(self, document):
"""Logging versions of required tools."""
content = json.dumps(document)
versions = {}
versions.update({'Spline': Version(VERSION)})
versions.update(self.get_version("Bash", self.BASH_VERSION))
if content.find('"docker(container)":') >= 0 or... | python | def process(self, document):
"""Logging versions of required tools."""
content = json.dumps(document)
versions = {}
versions.update({'Spline': Version(VERSION)})
versions.update(self.get_version("Bash", self.BASH_VERSION))
if content.find('"docker(container)":') >= 0 or... | [
"def",
"process",
"(",
"self",
",",
"document",
")",
":",
"content",
"=",
"json",
".",
"dumps",
"(",
"document",
")",
"versions",
"=",
"{",
"}",
"versions",
".",
"update",
"(",
"{",
"'Spline'",
":",
"Version",
"(",
"VERSION",
")",
"}",
")",
"versions... | Logging versions of required tools. | [
"Logging",
"versions",
"of",
"required",
"tools",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/version.py#L70-L85 | train | Processes the log document. |
Nachtfeuer/pipeline | spline/tools/version.py | VersionsCheck.get_version | def get_version(tool_name, tool_command):
"""
Get name and version of a tool defined by given command.
Args:
tool_name (str): name of the tool.
tool_command (str): Bash one line command to get the version of the tool.
Returns:
dict: tool name and ver... | python | def get_version(tool_name, tool_command):
"""
Get name and version of a tool defined by given command.
Args:
tool_name (str): name of the tool.
tool_command (str): Bash one line command to get the version of the tool.
Returns:
dict: tool name and ver... | [
"def",
"get_version",
"(",
"tool_name",
",",
"tool_command",
")",
":",
"result",
"=",
"{",
"}",
"for",
"line",
"in",
"Bash",
"(",
"ShellConfig",
"(",
"script",
"=",
"tool_command",
",",
"internal",
"=",
"True",
")",
")",
".",
"process",
"(",
")",
":",
... | Get name and version of a tool defined by given command.
Args:
tool_name (str): name of the tool.
tool_command (str): Bash one line command to get the version of the tool.
Returns:
dict: tool name and version or empty when no line has been found | [
"Get",
"name",
"and",
"version",
"of",
"a",
"tool",
"defined",
"by",
"given",
"command",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/version.py#L88-L108 | train | Get name and version of a specific tool. |
Nachtfeuer/pipeline | spline/tools/version.py | VersionsReport.process | def process(self, versions):
"""Logging version sorted ascending by tool name."""
for tool_name in sorted(versions.keys()):
version = versions[tool_name]
self._log("Using tool '%s', %s" % (tool_name, version)) | python | def process(self, versions):
"""Logging version sorted ascending by tool name."""
for tool_name in sorted(versions.keys()):
version = versions[tool_name]
self._log("Using tool '%s', %s" % (tool_name, version)) | [
"def",
"process",
"(",
"self",
",",
"versions",
")",
":",
"for",
"tool_name",
"in",
"sorted",
"(",
"versions",
".",
"keys",
"(",
")",
")",
":",
"version",
"=",
"versions",
"[",
"tool_name",
"]",
"self",
".",
"_log",
"(",
"\"Using tool '%s', %s\"",
"%",
... | Logging version sorted ascending by tool name. | [
"Logging",
"version",
"sorted",
"ascending",
"by",
"tool",
"name",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/version.py#L117-L121 | train | Log version sorted by tool name. |
nocarryr/python-dispatch | pydispatch/dispatch.py | Dispatcher.register_event | def register_event(self, *names):
"""Registers new events after instance creation
Args:
*names (str): Name or names of the events to register
"""
for name in names:
if name in self.__events:
continue
self.__events[name] = Event(name) | python | def register_event(self, *names):
"""Registers new events after instance creation
Args:
*names (str): Name or names of the events to register
"""
for name in names:
if name in self.__events:
continue
self.__events[name] = Event(name) | [
"def",
"register_event",
"(",
"self",
",",
"*",
"names",
")",
":",
"for",
"name",
"in",
"names",
":",
"if",
"name",
"in",
"self",
".",
"__events",
":",
"continue",
"self",
".",
"__events",
"[",
"name",
"]",
"=",
"Event",
"(",
"name",
")"
] | Registers new events after instance creation
Args:
*names (str): Name or names of the events to register | [
"Registers",
"new",
"events",
"after",
"instance",
"creation"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/dispatch.py#L125-L134 | train | Registers new events after instance creation. |
nocarryr/python-dispatch | pydispatch/dispatch.py | Dispatcher.bind | def bind(self, **kwargs):
"""Subscribes to events or to :class:`~pydispatch.properties.Property` updates
Keyword arguments are used with the Event or Property names as keys
and the callbacks as values::
class Foo(Dispatcher):
name = Property()
foo = Foo... | python | def bind(self, **kwargs):
"""Subscribes to events or to :class:`~pydispatch.properties.Property` updates
Keyword arguments are used with the Event or Property names as keys
and the callbacks as values::
class Foo(Dispatcher):
name = Property()
foo = Foo... | [
"def",
"bind",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"aio_loop",
"=",
"kwargs",
".",
"pop",
"(",
"'__aio_loop__'",
",",
"None",
")",
"props",
"=",
"self",
".",
"__property_events",
"events",
"=",
"self",
".",
"__events",
"for",
"name",
",",
... | Subscribes to events or to :class:`~pydispatch.properties.Property` updates
Keyword arguments are used with the Event or Property names as keys
and the callbacks as values::
class Foo(Dispatcher):
name = Property()
foo = Foo()
foo.bind(name=my_list... | [
"Subscribes",
"to",
"events",
"or",
"to",
":",
"class",
":",
"~pydispatch",
".",
"properties",
".",
"Property",
"updates"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/dispatch.py#L135-L198 | train | Subscribes to events or to properties or to updates the internal state of the object. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.