id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
16,400 | janpipek/physt | physt/plotting/matplotlib.py | bar3d | def bar3d(h2: Histogram2D, ax: Axes3D, **kwargs):
"""Plot of 2D histograms as 3D boxes."""
density = kwargs.pop("density", False)
data = get_data(h2, cumulative=False, flatten=True, density=density)
if "cmap" in kwargs:
cmap = _get_cmap(kwargs)
_, cmap_data = _get_cmap_data(data, kwargs... | python | def bar3d(h2: Histogram2D, ax: Axes3D, **kwargs):
"""Plot of 2D histograms as 3D boxes."""
density = kwargs.pop("density", False)
data = get_data(h2, cumulative=False, flatten=True, density=density)
if "cmap" in kwargs:
cmap = _get_cmap(kwargs)
_, cmap_data = _get_cmap_data(data, kwargs... | [
"def",
"bar3d",
"(",
"h2",
":",
"Histogram2D",
",",
"ax",
":",
"Axes3D",
",",
"*",
"*",
"kwargs",
")",
":",
"density",
"=",
"kwargs",
".",
"pop",
"(",
"\"density\"",
",",
"False",
")",
"data",
"=",
"get_data",
"(",
"h2",
",",
"cumulative",
"=",
"Fa... | Plot of 2D histograms as 3D boxes. | [
"Plot",
"of",
"2D",
"histograms",
"as",
"3D",
"boxes",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L393-L411 |
16,401 | janpipek/physt | physt/plotting/matplotlib.py | image | def image(h2: Histogram2D, ax: Axes, *, show_colorbar: bool = True, interpolation: str = "nearest", **kwargs):
"""Plot of 2D histograms based on pixmaps.
Similar to map, but it:
- has fewer options
- is much more effective (enables thousands)
- does not support irregular bins
Parameters
--... | python | def image(h2: Histogram2D, ax: Axes, *, show_colorbar: bool = True, interpolation: str = "nearest", **kwargs):
"""Plot of 2D histograms based on pixmaps.
Similar to map, but it:
- has fewer options
- is much more effective (enables thousands)
- does not support irregular bins
Parameters
--... | [
"def",
"image",
"(",
"h2",
":",
"Histogram2D",
",",
"ax",
":",
"Axes",
",",
"*",
",",
"show_colorbar",
":",
"bool",
"=",
"True",
",",
"interpolation",
":",
"str",
"=",
"\"nearest\"",
",",
"*",
"*",
"kwargs",
")",
":",
"cmap",
"=",
"_get_cmap",
"(",
... | Plot of 2D histograms based on pixmaps.
Similar to map, but it:
- has fewer options
- is much more effective (enables thousands)
- does not support irregular bins
Parameters
----------
interpolation: interpolation parameter passed to imshow, default: "nearest" (creates rectangles) | [
"Plot",
"of",
"2D",
"histograms",
"based",
"on",
"pixmaps",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L415-L450 |
16,402 | janpipek/physt | physt/plotting/matplotlib.py | polar_map | def polar_map(hist: Histogram2D, ax: Axes, *, show_zero: bool = True, show_colorbar: bool = True, **kwargs):
"""Polar map of polar histograms.
Similar to map, but supports less parameters."""
data = get_data(hist, cumulative=False, flatten=True,
density=kwargs.pop("density", False))
... | python | def polar_map(hist: Histogram2D, ax: Axes, *, show_zero: bool = True, show_colorbar: bool = True, **kwargs):
"""Polar map of polar histograms.
Similar to map, but supports less parameters."""
data = get_data(hist, cumulative=False, flatten=True,
density=kwargs.pop("density", False))
... | [
"def",
"polar_map",
"(",
"hist",
":",
"Histogram2D",
",",
"ax",
":",
"Axes",
",",
"*",
",",
"show_zero",
":",
"bool",
"=",
"True",
",",
"show_colorbar",
":",
"bool",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"get_data",
"(",
"his... | Polar map of polar histograms.
Similar to map, but supports less parameters. | [
"Polar",
"map",
"of",
"polar",
"histograms",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L454-L487 |
16,403 | janpipek/physt | physt/plotting/matplotlib.py | globe_map | def globe_map(hist: Union[Histogram2D, DirectionalHistogram], ax: Axes3D, *, show_zero: bool = True, **kwargs):
"""Heat map plotted on the surface of a sphere."""
data = get_data(hist, cumulative=False, flatten=False,
density=kwargs.pop("density", False))
cmap = _get_cmap(kwargs)
no... | python | def globe_map(hist: Union[Histogram2D, DirectionalHistogram], ax: Axes3D, *, show_zero: bool = True, **kwargs):
"""Heat map plotted on the surface of a sphere."""
data = get_data(hist, cumulative=False, flatten=False,
density=kwargs.pop("density", False))
cmap = _get_cmap(kwargs)
no... | [
"def",
"globe_map",
"(",
"hist",
":",
"Union",
"[",
"Histogram2D",
",",
"DirectionalHistogram",
"]",
",",
"ax",
":",
"Axes3D",
",",
"*",
",",
"show_zero",
":",
"bool",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"get_data",
"(",
"his... | Heat map plotted on the surface of a sphere. | [
"Heat",
"map",
"plotted",
"on",
"the",
"surface",
"of",
"a",
"sphere",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L491-L529 |
16,404 | janpipek/physt | physt/plotting/matplotlib.py | pair_bars | def pair_bars(first: Histogram1D, second: Histogram2D, *, orientation: str = "vertical", kind: str = "bar", **kwargs):
"""Draw two different histograms mirrored in one figure.
Parameters
----------
first: Histogram1D
second: Histogram1D
color1:
color2:
orientation: str
Returns
... | python | def pair_bars(first: Histogram1D, second: Histogram2D, *, orientation: str = "vertical", kind: str = "bar", **kwargs):
"""Draw two different histograms mirrored in one figure.
Parameters
----------
first: Histogram1D
second: Histogram1D
color1:
color2:
orientation: str
Returns
... | [
"def",
"pair_bars",
"(",
"first",
":",
"Histogram1D",
",",
"second",
":",
"Histogram2D",
",",
"*",
",",
"orientation",
":",
"str",
"=",
"\"vertical\"",
",",
"kind",
":",
"str",
"=",
"\"bar\"",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: enable vertical as ... | Draw two different histograms mirrored in one figure.
Parameters
----------
first: Histogram1D
second: Histogram1D
color1:
color2:
orientation: str
Returns
-------
plt.Axes | [
"Draw",
"two",
"different",
"histograms",
"mirrored",
"in",
"one",
"figure",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L648-L681 |
16,405 | janpipek/physt | physt/plotting/matplotlib.py | _get_axes | def _get_axes(kwargs: Dict[str, Any], *, use_3d: bool = False, use_polar: bool = False) -> Tuple[Figure, Union[Axes, Axes3D]]:
"""Prepare the axis to draw into.
Parameters
----------
use_3d: If True, an axis with 3D projection is created.
use_polar: If True, the plot will have polar coordinates.
... | python | def _get_axes(kwargs: Dict[str, Any], *, use_3d: bool = False, use_polar: bool = False) -> Tuple[Figure, Union[Axes, Axes3D]]:
"""Prepare the axis to draw into.
Parameters
----------
use_3d: If True, an axis with 3D projection is created.
use_polar: If True, the plot will have polar coordinates.
... | [
"def",
"_get_axes",
"(",
"kwargs",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"*",
",",
"use_3d",
":",
"bool",
"=",
"False",
",",
"use_polar",
":",
"bool",
"=",
"False",
")",
"->",
"Tuple",
"[",
"Figure",
",",
"Union",
"[",
"Axes",
",",
"Axes... | Prepare the axis to draw into.
Parameters
----------
use_3d: If True, an axis with 3D projection is created.
use_polar: If True, the plot will have polar coordinates.
Kwargs
------
ax: Optional[plt.Axes]
An already existing axis to be used.
figsize: Optional[tuple]
Size... | [
"Prepare",
"the",
"axis",
"to",
"draw",
"into",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L684-L716 |
16,406 | janpipek/physt | physt/plotting/matplotlib.py | _get_cmap | def _get_cmap(kwargs: dict) -> colors.Colormap:
"""Get the colour map for plots that support it.
Parameters
----------
cmap : str or colors.Colormap or list of colors
A map or an instance of cmap. This can also be a seaborn palette
(if seaborn is installed).
"""
from matplotlib.... | python | def _get_cmap(kwargs: dict) -> colors.Colormap:
"""Get the colour map for plots that support it.
Parameters
----------
cmap : str or colors.Colormap or list of colors
A map or an instance of cmap. This can also be a seaborn palette
(if seaborn is installed).
"""
from matplotlib.... | [
"def",
"_get_cmap",
"(",
"kwargs",
":",
"dict",
")",
"->",
"colors",
".",
"Colormap",
":",
"from",
"matplotlib",
".",
"colors",
"import",
"ListedColormap",
"cmap",
"=",
"kwargs",
".",
"pop",
"(",
"\"cmap\"",
",",
"default_cmap",
")",
"if",
"isinstance",
"(... | Get the colour map for plots that support it.
Parameters
----------
cmap : str or colors.Colormap or list of colors
A map or an instance of cmap. This can also be a seaborn palette
(if seaborn is installed). | [
"Get",
"the",
"colour",
"map",
"for",
"plots",
"that",
"support",
"it",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L719-L744 |
16,407 | janpipek/physt | physt/plotting/matplotlib.py | _get_cmap_data | def _get_cmap_data(data, kwargs) -> Tuple[colors.Normalize, np.ndarray]:
"""Get normalized values to be used with a colormap.
Parameters
----------
data : array_like
cmap_min : Optional[float] or "min"
By default 0. If "min", minimum value of the data.
cmap_max : Optional[float]
... | python | def _get_cmap_data(data, kwargs) -> Tuple[colors.Normalize, np.ndarray]:
"""Get normalized values to be used with a colormap.
Parameters
----------
data : array_like
cmap_min : Optional[float] or "min"
By default 0. If "min", minimum value of the data.
cmap_max : Optional[float]
... | [
"def",
"_get_cmap_data",
"(",
"data",
",",
"kwargs",
")",
"->",
"Tuple",
"[",
"colors",
".",
"Normalize",
",",
"np",
".",
"ndarray",
"]",
":",
"norm",
"=",
"kwargs",
".",
"pop",
"(",
"\"cmap_normalize\"",
",",
"None",
")",
"if",
"norm",
"==",
"\"log\""... | Get normalized values to be used with a colormap.
Parameters
----------
data : array_like
cmap_min : Optional[float] or "min"
By default 0. If "min", minimum value of the data.
cmap_max : Optional[float]
By default, maximum value of the data
cmap_normalize : str or colors.Normal... | [
"Get",
"normalized",
"values",
"to",
"be",
"used",
"with",
"a",
"colormap",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L747-L775 |
16,408 | janpipek/physt | physt/plotting/matplotlib.py | _get_alpha_data | def _get_alpha_data(data: np.ndarray, kwargs) -> Union[float, np.ndarray]:
"""Get alpha values for all data points.
Parameters
----------
alpha: Callable or float
This can be a fixed value or a function of the data.
"""
alpha = kwargs.pop("alpha", 1)
if hasattr(alpha, "__call__"):
... | python | def _get_alpha_data(data: np.ndarray, kwargs) -> Union[float, np.ndarray]:
"""Get alpha values for all data points.
Parameters
----------
alpha: Callable or float
This can be a fixed value or a function of the data.
"""
alpha = kwargs.pop("alpha", 1)
if hasattr(alpha, "__call__"):
... | [
"def",
"_get_alpha_data",
"(",
"data",
":",
"np",
".",
"ndarray",
",",
"kwargs",
")",
"->",
"Union",
"[",
"float",
",",
"np",
".",
"ndarray",
"]",
":",
"alpha",
"=",
"kwargs",
".",
"pop",
"(",
"\"alpha\"",
",",
"1",
")",
"if",
"hasattr",
"(",
"alph... | Get alpha values for all data points.
Parameters
----------
alpha: Callable or float
This can be a fixed value or a function of the data. | [
"Get",
"alpha",
"values",
"for",
"all",
"data",
"points",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L778-L789 |
16,409 | janpipek/physt | physt/plotting/matplotlib.py | _add_values | def _add_values(ax: Axes, h1: Histogram1D, data, *, value_format=lambda x: x, **kwargs):
"""Show values next to each bin in a 1D plot.
Parameters
----------
ax : plt.Axes
h1 : physt.histogram1d.Histogram1D
data : array_like
The values to be displayed
kwargs : dict
Parameters... | python | def _add_values(ax: Axes, h1: Histogram1D, data, *, value_format=lambda x: x, **kwargs):
"""Show values next to each bin in a 1D plot.
Parameters
----------
ax : plt.Axes
h1 : physt.histogram1d.Histogram1D
data : array_like
The values to be displayed
kwargs : dict
Parameters... | [
"def",
"_add_values",
"(",
"ax",
":",
"Axes",
",",
"h1",
":",
"Histogram1D",
",",
"data",
",",
"*",
",",
"value_format",
"=",
"lambda",
"x",
":",
"x",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"common",
"import",
"get_value_format",
"value_format... | Show values next to each bin in a 1D plot.
Parameters
----------
ax : plt.Axes
h1 : physt.histogram1d.Histogram1D
data : array_like
The values to be displayed
kwargs : dict
Parameters to be passed to matplotlib to override standard text params. | [
"Show",
"values",
"next",
"to",
"each",
"bin",
"in",
"a",
"1D",
"plot",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L810-L828 |
16,410 | janpipek/physt | physt/plotting/matplotlib.py | _add_colorbar | def _add_colorbar(ax: Axes, cmap: colors.Colormap, cmap_data: np.ndarray, norm: colors.Normalize):
"""Show a colorbar right of the plot."""
fig = ax.get_figure()
mappable = cm.ScalarMappable(cmap=cmap, norm=norm)
mappable.set_array(cmap_data) # TODO: Or what???
fig.colorbar(mappable, ax=ax) | python | def _add_colorbar(ax: Axes, cmap: colors.Colormap, cmap_data: np.ndarray, norm: colors.Normalize):
"""Show a colorbar right of the plot."""
fig = ax.get_figure()
mappable = cm.ScalarMappable(cmap=cmap, norm=norm)
mappable.set_array(cmap_data) # TODO: Or what???
fig.colorbar(mappable, ax=ax) | [
"def",
"_add_colorbar",
"(",
"ax",
":",
"Axes",
",",
"cmap",
":",
"colors",
".",
"Colormap",
",",
"cmap_data",
":",
"np",
".",
"ndarray",
",",
"norm",
":",
"colors",
".",
"Normalize",
")",
":",
"fig",
"=",
"ax",
".",
"get_figure",
"(",
")",
"mappable... | Show a colorbar right of the plot. | [
"Show",
"a",
"colorbar",
"right",
"of",
"the",
"plot",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L831-L836 |
16,411 | janpipek/physt | physt/plotting/matplotlib.py | _add_stats_box | def _add_stats_box(h1: Histogram1D, ax: Axes, stats: Union[str, bool] = "all"):
"""Insert a small legend-like box with statistical information.
Parameters
----------
stats : "all" | "total" | True
What info to display
Note
----
Very basic implementation.
"""
# place a text... | python | def _add_stats_box(h1: Histogram1D, ax: Axes, stats: Union[str, bool] = "all"):
"""Insert a small legend-like box with statistical information.
Parameters
----------
stats : "all" | "total" | True
What info to display
Note
----
Very basic implementation.
"""
# place a text... | [
"def",
"_add_stats_box",
"(",
"h1",
":",
"Histogram1D",
",",
"ax",
":",
"Axes",
",",
"stats",
":",
"Union",
"[",
"str",
",",
"bool",
"]",
"=",
"\"all\"",
")",
":",
"# place a text box in upper left in axes coords",
"if",
"stats",
"in",
"[",
"\"all\"",
",",
... | Insert a small legend-like box with statistical information.
Parameters
----------
stats : "all" | "total" | True
What info to display
Note
----
Very basic implementation. | [
"Insert",
"a",
"small",
"legend",
"-",
"like",
"box",
"with",
"statistical",
"information",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L839-L862 |
16,412 | janpipek/physt | physt/examples/__init__.py | normal_h1 | def normal_h1(size: int = 10000, mean: float = 0, sigma: float = 1) -> Histogram1D:
"""A simple 1D histogram with normal distribution.
Parameters
----------
size : Number of points
mean : Mean of the distribution
sigma : Sigma of the distribution
"""
data = np.random.normal(mean, sigma,... | python | def normal_h1(size: int = 10000, mean: float = 0, sigma: float = 1) -> Histogram1D:
"""A simple 1D histogram with normal distribution.
Parameters
----------
size : Number of points
mean : Mean of the distribution
sigma : Sigma of the distribution
"""
data = np.random.normal(mean, sigma,... | [
"def",
"normal_h1",
"(",
"size",
":",
"int",
"=",
"10000",
",",
"mean",
":",
"float",
"=",
"0",
",",
"sigma",
":",
"float",
"=",
"1",
")",
"->",
"Histogram1D",
":",
"data",
"=",
"np",
".",
"random",
".",
"normal",
"(",
"mean",
",",
"sigma",
",",
... | A simple 1D histogram with normal distribution.
Parameters
----------
size : Number of points
mean : Mean of the distribution
sigma : Sigma of the distribution | [
"A",
"simple",
"1D",
"histogram",
"with",
"normal",
"distribution",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/examples/__init__.py#L12-L22 |
16,413 | janpipek/physt | physt/examples/__init__.py | normal_h2 | def normal_h2(size: int = 10000) -> Histogram2D:
"""A simple 2D histogram with normal distribution.
Parameters
----------
size : Number of points
"""
data1 = np.random.normal(0, 1, (size,))
data2 = np.random.normal(0, 1, (size,))
return h2(data1, data2, name="normal", axis_names=tuple("... | python | def normal_h2(size: int = 10000) -> Histogram2D:
"""A simple 2D histogram with normal distribution.
Parameters
----------
size : Number of points
"""
data1 = np.random.normal(0, 1, (size,))
data2 = np.random.normal(0, 1, (size,))
return h2(data1, data2, name="normal", axis_names=tuple("... | [
"def",
"normal_h2",
"(",
"size",
":",
"int",
"=",
"10000",
")",
"->",
"Histogram2D",
":",
"data1",
"=",
"np",
".",
"random",
".",
"normal",
"(",
"0",
",",
"1",
",",
"(",
"size",
",",
")",
")",
"data2",
"=",
"np",
".",
"random",
".",
"normal",
"... | A simple 2D histogram with normal distribution.
Parameters
----------
size : Number of points | [
"A",
"simple",
"2D",
"histogram",
"with",
"normal",
"distribution",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/examples/__init__.py#L25-L34 |
16,414 | janpipek/physt | physt/examples/__init__.py | normal_h3 | def normal_h3(size: int = 10000) -> HistogramND:
"""A simple 3D histogram with normal distribution.
Parameters
----------
size : Number of points
"""
data1 = np.random.normal(0, 1, (size,))
data2 = np.random.normal(0, 1, (size,))
data3 = np.random.normal(0, 1, (size,))
return h3([da... | python | def normal_h3(size: int = 10000) -> HistogramND:
"""A simple 3D histogram with normal distribution.
Parameters
----------
size : Number of points
"""
data1 = np.random.normal(0, 1, (size,))
data2 = np.random.normal(0, 1, (size,))
data3 = np.random.normal(0, 1, (size,))
return h3([da... | [
"def",
"normal_h3",
"(",
"size",
":",
"int",
"=",
"10000",
")",
"->",
"HistogramND",
":",
"data1",
"=",
"np",
".",
"random",
".",
"normal",
"(",
"0",
",",
"1",
",",
"(",
"size",
",",
")",
")",
"data2",
"=",
"np",
".",
"random",
".",
"normal",
"... | A simple 3D histogram with normal distribution.
Parameters
----------
size : Number of points | [
"A",
"simple",
"3D",
"histogram",
"with",
"normal",
"distribution",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/examples/__init__.py#L37-L47 |
16,415 | janpipek/physt | physt/examples/__init__.py | fist | def fist() -> Histogram1D:
"""A simple histogram in the shape of a fist."""
import numpy as np
from ..histogram1d import Histogram1D
widths = [0, 1.2, 0.2, 1, 0.1, 1, 0.1, 0.9, 0.1, 0.8]
edges = np.cumsum(widths)
heights = np.asarray([4, 1, 7.5, 6, 7.6, 6, 7.5, 6, 7.2]) + 5
return Histogram1... | python | def fist() -> Histogram1D:
"""A simple histogram in the shape of a fist."""
import numpy as np
from ..histogram1d import Histogram1D
widths = [0, 1.2, 0.2, 1, 0.1, 1, 0.1, 0.9, 0.1, 0.8]
edges = np.cumsum(widths)
heights = np.asarray([4, 1, 7.5, 6, 7.6, 6, 7.5, 6, 7.2]) + 5
return Histogram1... | [
"def",
"fist",
"(",
")",
"->",
"Histogram1D",
":",
"import",
"numpy",
"as",
"np",
"from",
".",
".",
"histogram1d",
"import",
"Histogram1D",
"widths",
"=",
"[",
"0",
",",
"1.2",
",",
"0.2",
",",
"1",
",",
"0.1",
",",
"1",
",",
"0.1",
",",
"0.9",
"... | A simple histogram in the shape of a fist. | [
"A",
"simple",
"histogram",
"in",
"the",
"shape",
"of",
"a",
"fist",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/examples/__init__.py#L50-L57 |
16,416 | janpipek/physt | physt/io/__init__.py | require_compatible_version | def require_compatible_version(compatible_version, word="File"):
"""Check that compatible version of input data is not too new."""
if isinstance(compatible_version, str):
compatible_version = parse_version(compatible_version)
elif not isinstance(compatible_version, Version):
raise ValueError... | python | def require_compatible_version(compatible_version, word="File"):
"""Check that compatible version of input data is not too new."""
if isinstance(compatible_version, str):
compatible_version = parse_version(compatible_version)
elif not isinstance(compatible_version, Version):
raise ValueError... | [
"def",
"require_compatible_version",
"(",
"compatible_version",
",",
"word",
"=",
"\"File\"",
")",
":",
"if",
"isinstance",
"(",
"compatible_version",
",",
"str",
")",
":",
"compatible_version",
"=",
"parse_version",
"(",
"compatible_version",
")",
"elif",
"not",
... | Check that compatible version of input data is not too new. | [
"Check",
"that",
"compatible",
"version",
"of",
"input",
"data",
"is",
"not",
"too",
"new",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/__init__.py#L52-L63 |
16,417 | janpipek/physt | physt/io/json.py | save_json | def save_json(histogram: Union[HistogramBase, HistogramCollection], path: Optional[str] = None, **kwargs) -> str:
"""Save histogram to JSON format.
Parameters
----------
histogram : Any histogram
path : If set, also writes to the path.
Returns
-------
json : The JSON representation of ... | python | def save_json(histogram: Union[HistogramBase, HistogramCollection], path: Optional[str] = None, **kwargs) -> str:
"""Save histogram to JSON format.
Parameters
----------
histogram : Any histogram
path : If set, also writes to the path.
Returns
-------
json : The JSON representation of ... | [
"def",
"save_json",
"(",
"histogram",
":",
"Union",
"[",
"HistogramBase",
",",
"HistogramCollection",
"]",
",",
"path",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"# TODO: Implement multiple histograms in one... | Save histogram to JSON format.
Parameters
----------
histogram : Any histogram
path : If set, also writes to the path.
Returns
-------
json : The JSON representation of the histogram | [
"Save",
"histogram",
"to",
"JSON",
"format",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/json.py#L13-L40 |
16,418 | janpipek/physt | physt/io/json.py | load_json | def load_json(path: str, encoding: str = "utf-8") -> HistogramBase:
"""Load histogram from a JSON file."""
with open(path, "r", encoding=encoding) as f:
text = f.read()
return parse_json(text) | python | def load_json(path: str, encoding: str = "utf-8") -> HistogramBase:
"""Load histogram from a JSON file."""
with open(path, "r", encoding=encoding) as f:
text = f.read()
return parse_json(text) | [
"def",
"load_json",
"(",
"path",
":",
"str",
",",
"encoding",
":",
"str",
"=",
"\"utf-8\"",
")",
"->",
"HistogramBase",
":",
"with",
"open",
"(",
"path",
",",
"\"r\"",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f",
":",
"text",
"=",
"f",
".",
"r... | Load histogram from a JSON file. | [
"Load",
"histogram",
"from",
"a",
"JSON",
"file",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/json.py#L43-L47 |
16,419 | janpipek/physt | physt/io/json.py | parse_json | def parse_json(text: str, encoding: str = "utf-8") -> HistogramBase:
"""Create histogram from a JSON string."""
data = json.loads(text, encoding=encoding)
return create_from_dict(data, format_name="JSON") | python | def parse_json(text: str, encoding: str = "utf-8") -> HistogramBase:
"""Create histogram from a JSON string."""
data = json.loads(text, encoding=encoding)
return create_from_dict(data, format_name="JSON") | [
"def",
"parse_json",
"(",
"text",
":",
"str",
",",
"encoding",
":",
"str",
"=",
"\"utf-8\"",
")",
"->",
"HistogramBase",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"text",
",",
"encoding",
"=",
"encoding",
")",
"return",
"create_from_dict",
"(",
"data"... | Create histogram from a JSON string. | [
"Create",
"histogram",
"from",
"a",
"JSON",
"string",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/json.py#L50-L53 |
16,420 | janpipek/physt | physt/__init__.py | histogram | def histogram(data, bins=None, *args, **kwargs):
"""Facade function to create 1D histograms.
This proceeds in three steps:
1) Based on magical parameter bins, construct bins for the histogram
2) Calculate frequencies for the bins
3) Construct the histogram object itself
*Guiding principle:* pa... | python | def histogram(data, bins=None, *args, **kwargs):
"""Facade function to create 1D histograms.
This proceeds in three steps:
1) Based on magical parameter bins, construct bins for the histogram
2) Calculate frequencies for the bins
3) Construct the histogram object itself
*Guiding principle:* pa... | [
"def",
"histogram",
"(",
"data",
",",
"bins",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
".",
"histogram1d",
"import",
"Histogram1D",
",",
"calculate_frequencies",
"from",
".",
"binnings",
"im... | Facade function to create 1D histograms.
This proceeds in three steps:
1) Based on magical parameter bins, construct bins for the histogram
2) Calculate frequencies for the bins
3) Construct the histogram object itself
*Guiding principle:* parameters understood by numpy.histogram should be
und... | [
"Facade",
"function",
"to",
"create",
"1D",
"histograms",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/__init__.py#L16-L127 |
16,421 | janpipek/physt | physt/__init__.py | histogram2d | def histogram2d(data1, data2, bins=10, *args, **kwargs):
"""Facade function to create 2D histograms.
For implementation and parameters, see histogramdd.
This function is also aliased as "h2".
Returns
-------
physt.histogram_nd.Histogram2D
See Also
--------
numpy.histogram2d
h... | python | def histogram2d(data1, data2, bins=10, *args, **kwargs):
"""Facade function to create 2D histograms.
For implementation and parameters, see histogramdd.
This function is also aliased as "h2".
Returns
-------
physt.histogram_nd.Histogram2D
See Also
--------
numpy.histogram2d
h... | [
"def",
"histogram2d",
"(",
"data1",
",",
"data2",
",",
"bins",
"=",
"10",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"numpy",
"as",
"np",
"# guess axis names",
"if",
"\"axis_names\"",
"not",
"in",
"kwargs",
":",
"if",
"hasattr",
"("... | Facade function to create 2D histograms.
For implementation and parameters, see histogramdd.
This function is also aliased as "h2".
Returns
-------
physt.histogram_nd.Histogram2D
See Also
--------
numpy.histogram2d
histogramdd | [
"Facade",
"function",
"to",
"create",
"2D",
"histograms",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/__init__.py#L130-L159 |
16,422 | janpipek/physt | physt/__init__.py | histogramdd | def histogramdd(data, bins=10, *args, **kwargs):
"""Facade function to create n-dimensional histograms.
3D variant of this function is also aliased as "h3".
Parameters
----------
data : array_like
Container of all the values
bins: Any
weights: array_like, optional
(as numpy... | python | def histogramdd(data, bins=10, *args, **kwargs):
"""Facade function to create n-dimensional histograms.
3D variant of this function is also aliased as "h3".
Parameters
----------
data : array_like
Container of all the values
bins: Any
weights: array_like, optional
(as numpy... | [
"def",
"histogramdd",
"(",
"data",
",",
"bins",
"=",
"10",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
".",
"import",
"histogram_nd",
"from",
".",
"binnings",
"import",
"calculate_bins_nd",
"adaptive",
"=",... | Facade function to create n-dimensional histograms.
3D variant of this function is also aliased as "h3".
Parameters
----------
data : array_like
Container of all the values
bins: Any
weights: array_like, optional
(as numpy.histogram)
dropna: bool
whether to clear da... | [
"Facade",
"function",
"to",
"create",
"n",
"-",
"dimensional",
"histograms",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/__init__.py#L162-L254 |
16,423 | janpipek/physt | physt/__init__.py | h3 | def h3(data, *args, **kwargs):
"""Facade function to create 3D histograms.
Parameters
----------
data : array_like or list[array_like] or tuple[array_like]
Can be a single array (with three columns) or three different arrays
(for each component)
Returns
-------
physt.histog... | python | def h3(data, *args, **kwargs):
"""Facade function to create 3D histograms.
Parameters
----------
data : array_like or list[array_like] or tuple[array_like]
Can be a single array (with three columns) or three different arrays
(for each component)
Returns
-------
physt.histog... | [
"def",
"h3",
"(",
"data",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"numpy",
"as",
"np",
"if",
"data",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"data",
",",
"(",
"list",
",",
"tuple",
")",
")",
"and",
"not",
"np",
"."... | Facade function to create 3D histograms.
Parameters
----------
data : array_like or list[array_like] or tuple[array_like]
Can be a single array (with three columns) or three different arrays
(for each component)
Returns
-------
physt.histogram_nd.HistogramND | [
"Facade",
"function",
"to",
"create",
"3D",
"histograms",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/__init__.py#L263-L284 |
16,424 | janpipek/physt | physt/__init__.py | collection | def collection(data, bins=10, *args, **kwargs):
"""Create histogram collection with shared binnning."""
from physt.histogram_collection import HistogramCollection
if hasattr(data, "columns"):
data = {column: data[column] for column in data.columns}
return HistogramCollection.multi_h1(data, bins,... | python | def collection(data, bins=10, *args, **kwargs):
"""Create histogram collection with shared binnning."""
from physt.histogram_collection import HistogramCollection
if hasattr(data, "columns"):
data = {column: data[column] for column in data.columns}
return HistogramCollection.multi_h1(data, bins,... | [
"def",
"collection",
"(",
"data",
",",
"bins",
"=",
"10",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"physt",
".",
"histogram_collection",
"import",
"HistogramCollection",
"if",
"hasattr",
"(",
"data",
",",
"\"columns\"",
")",
":",
"dat... | Create histogram collection with shared binnning. | [
"Create",
"histogram",
"collection",
"with",
"shared",
"binnning",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/__init__.py#L287-L292 |
16,425 | janpipek/physt | physt/io/root.py | write_root | def write_root(histogram: HistogramBase, hfile: uproot.write.TFile.TFileUpdate, name: str):
"""Write histogram to an open ROOT file.
Parameters
----------
histogram : Any histogram
hfile : Updateable uproot file object
name : The name of the histogram inside the file
"""
hfile[name] = h... | python | def write_root(histogram: HistogramBase, hfile: uproot.write.TFile.TFileUpdate, name: str):
"""Write histogram to an open ROOT file.
Parameters
----------
histogram : Any histogram
hfile : Updateable uproot file object
name : The name of the histogram inside the file
"""
hfile[name] = h... | [
"def",
"write_root",
"(",
"histogram",
":",
"HistogramBase",
",",
"hfile",
":",
"uproot",
".",
"write",
".",
"TFile",
".",
"TFileUpdate",
",",
"name",
":",
"str",
")",
":",
"hfile",
"[",
"name",
"]",
"=",
"histogram"
] | Write histogram to an open ROOT file.
Parameters
----------
histogram : Any histogram
hfile : Updateable uproot file object
name : The name of the histogram inside the file | [
"Write",
"histogram",
"to",
"an",
"open",
"ROOT",
"file",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/root.py#L16-L25 |
16,426 | janpipek/physt | physt/io/protobuf/__init__.py | write | def write(histogram):
"""Convert a histogram to a protobuf message.
Note: Currently, all binnings are converted to
static form. When you load the histogram again,
you will lose any related behaviour.
Note: A histogram collection is also planned.
Parameters
----------
histogram... | python | def write(histogram):
"""Convert a histogram to a protobuf message.
Note: Currently, all binnings are converted to
static form. When you load the histogram again,
you will lose any related behaviour.
Note: A histogram collection is also planned.
Parameters
----------
histogram... | [
"def",
"write",
"(",
"histogram",
")",
":",
"histogram_dict",
"=",
"histogram",
".",
"to_dict",
"(",
")",
"message",
"=",
"Histogram",
"(",
")",
"for",
"field",
"in",
"SIMPLE_CONVERSION_FIELDS",
":",
"setattr",
"(",
"message",
",",
"field",
",",
"histogram_d... | Convert a histogram to a protobuf message.
Note: Currently, all binnings are converted to
static form. When you load the histogram again,
you will lose any related behaviour.
Note: A histogram collection is also planned.
Parameters
----------
histogram : HistogramBase | list | dic... | [
"Convert",
"a",
"histogram",
"to",
"a",
"protobuf",
"message",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/protobuf/__init__.py#L24-L76 |
16,427 | janpipek/physt | physt/io/protobuf/__init__.py | read | def read(message):
"""Convert a parsed protobuf message into a histogram."""
require_compatible_version(message.physt_compatible)
# Currently the only implementation
a_dict = _dict_from_v0342(message)
return create_from_dict(a_dict, "Message") | python | def read(message):
"""Convert a parsed protobuf message into a histogram."""
require_compatible_version(message.physt_compatible)
# Currently the only implementation
a_dict = _dict_from_v0342(message)
return create_from_dict(a_dict, "Message") | [
"def",
"read",
"(",
"message",
")",
":",
"require_compatible_version",
"(",
"message",
".",
"physt_compatible",
")",
"# Currently the only implementation",
"a_dict",
"=",
"_dict_from_v0342",
"(",
"message",
")",
"return",
"create_from_dict",
"(",
"a_dict",
",",
"\"Mes... | Convert a parsed protobuf message into a histogram. | [
"Convert",
"a",
"parsed",
"protobuf",
"message",
"into",
"a",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/io/protobuf/__init__.py#L79-L85 |
16,428 | janpipek/physt | physt/bin_utils.py | make_bin_array | def make_bin_array(bins) -> np.ndarray:
"""Turn bin data into array understood by HistogramXX classes.
Parameters
----------
bins: array_like
Array of edges or array of edge tuples
Examples
--------
>>> make_bin_array([0, 1, 2])
array([[0, 1],
[1, 2]])
>>> make_b... | python | def make_bin_array(bins) -> np.ndarray:
"""Turn bin data into array understood by HistogramXX classes.
Parameters
----------
bins: array_like
Array of edges or array of edge tuples
Examples
--------
>>> make_bin_array([0, 1, 2])
array([[0, 1],
[1, 2]])
>>> make_b... | [
"def",
"make_bin_array",
"(",
"bins",
")",
"->",
"np",
".",
"ndarray",
":",
"bins",
"=",
"np",
".",
"asarray",
"(",
"bins",
")",
"if",
"bins",
".",
"ndim",
"==",
"1",
":",
"# if bins.shape[0] == 0:",
"# raise RuntimeError(\"Needs at least one bin\")",
"retur... | Turn bin data into array understood by HistogramXX classes.
Parameters
----------
bins: array_like
Array of edges or array of edge tuples
Examples
--------
>>> make_bin_array([0, 1, 2])
array([[0, 1],
[1, 2]])
>>> make_bin_array([[0, 1], [2, 3]])
array([[0, 1],
... | [
"Turn",
"bin",
"data",
"into",
"array",
"understood",
"by",
"HistogramXX",
"classes",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/bin_utils.py#L7-L36 |
16,429 | janpipek/physt | physt/bin_utils.py | to_numpy_bins | def to_numpy_bins(bins) -> np.ndarray:
"""Convert physt bin format to numpy edges.
Parameters
----------
bins: array_like
1-D (n) or 2-D (n, 2) array of edges
Returns
-------
edges: all edges
"""
bins = np.asarray(bins)
if bins.ndim == 1: # Already in the proper for... | python | def to_numpy_bins(bins) -> np.ndarray:
"""Convert physt bin format to numpy edges.
Parameters
----------
bins: array_like
1-D (n) or 2-D (n, 2) array of edges
Returns
-------
edges: all edges
"""
bins = np.asarray(bins)
if bins.ndim == 1: # Already in the proper for... | [
"def",
"to_numpy_bins",
"(",
"bins",
")",
"->",
"np",
".",
"ndarray",
":",
"bins",
"=",
"np",
".",
"asarray",
"(",
"bins",
")",
"if",
"bins",
".",
"ndim",
"==",
"1",
":",
"# Already in the proper format",
"return",
"bins",
"if",
"not",
"is_consecutive",
... | Convert physt bin format to numpy edges.
Parameters
----------
bins: array_like
1-D (n) or 2-D (n, 2) array of edges
Returns
-------
edges: all edges | [
"Convert",
"physt",
"bin",
"format",
"to",
"numpy",
"edges",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/bin_utils.py#L39-L56 |
16,430 | janpipek/physt | physt/bin_utils.py | to_numpy_bins_with_mask | def to_numpy_bins_with_mask(bins) -> Tuple[np.ndarray, np.ndarray]:
"""Numpy binning edges including gaps.
Parameters
----------
bins: array_like
1-D (n) or 2-D (n, 2) array of edges
Returns
-------
edges: np.ndarray
all edges
mask: np.ndarray
List of indices th... | python | def to_numpy_bins_with_mask(bins) -> Tuple[np.ndarray, np.ndarray]:
"""Numpy binning edges including gaps.
Parameters
----------
bins: array_like
1-D (n) or 2-D (n, 2) array of edges
Returns
-------
edges: np.ndarray
all edges
mask: np.ndarray
List of indices th... | [
"def",
"to_numpy_bins_with_mask",
"(",
"bins",
")",
"->",
"Tuple",
"[",
"np",
".",
"ndarray",
",",
"np",
".",
"ndarray",
"]",
":",
"bins",
"=",
"np",
".",
"asarray",
"(",
"bins",
")",
"if",
"bins",
".",
"ndim",
"==",
"1",
":",
"edges",
"=",
"bins",... | Numpy binning edges including gaps.
Parameters
----------
bins: array_like
1-D (n) or 2-D (n, 2) array of edges
Returns
-------
edges: np.ndarray
all edges
mask: np.ndarray
List of indices that correspond to bins that have to be included
Examples
--------
... | [
"Numpy",
"binning",
"edges",
"including",
"gaps",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/bin_utils.py#L59-L108 |
16,431 | janpipek/physt | physt/bin_utils.py | is_rising | def is_rising(bins) -> bool:
"""Check whether the bins are in raising order.
Does not check if the bins are consecutive.
Parameters
----------
bins: array_like
"""
# TODO: Optimize for numpy bins
bins = make_bin_array(bins)
if np.any(bins[:, 0] >= bins[:, 1]):
return False
... | python | def is_rising(bins) -> bool:
"""Check whether the bins are in raising order.
Does not check if the bins are consecutive.
Parameters
----------
bins: array_like
"""
# TODO: Optimize for numpy bins
bins = make_bin_array(bins)
if np.any(bins[:, 0] >= bins[:, 1]):
return False
... | [
"def",
"is_rising",
"(",
"bins",
")",
"->",
"bool",
":",
"# TODO: Optimize for numpy bins",
"bins",
"=",
"make_bin_array",
"(",
"bins",
")",
"if",
"np",
".",
"any",
"(",
"bins",
"[",
":",
",",
"0",
"]",
">=",
"bins",
"[",
":",
",",
"1",
"]",
")",
"... | Check whether the bins are in raising order.
Does not check if the bins are consecutive.
Parameters
----------
bins: array_like | [
"Check",
"whether",
"the",
"bins",
"are",
"in",
"raising",
"order",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/bin_utils.py#L111-L126 |
16,432 | janpipek/physt | physt/plotting/common.py | get_data | def get_data(histogram: HistogramBase, density: bool = False, cumulative: bool = False, flatten: bool = False) -> np.ndarray:
"""Get histogram data based on plotting parameters.
Parameters
----------
density : Whether to divide bin contents by bin size
cumulative : Whether to return cumulative sums... | python | def get_data(histogram: HistogramBase, density: bool = False, cumulative: bool = False, flatten: bool = False) -> np.ndarray:
"""Get histogram data based on plotting parameters.
Parameters
----------
density : Whether to divide bin contents by bin size
cumulative : Whether to return cumulative sums... | [
"def",
"get_data",
"(",
"histogram",
":",
"HistogramBase",
",",
"density",
":",
"bool",
"=",
"False",
",",
"cumulative",
":",
"bool",
"=",
"False",
",",
"flatten",
":",
"bool",
"=",
"False",
")",
"->",
"np",
".",
"ndarray",
":",
"if",
"density",
":",
... | Get histogram data based on plotting parameters.
Parameters
----------
density : Whether to divide bin contents by bin size
cumulative : Whether to return cumulative sums instead of individual
flatten : Whether to flatten multidimensional bins | [
"Get",
"histogram",
"data",
"based",
"on",
"plotting",
"parameters",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/common.py#L15-L37 |
16,433 | janpipek/physt | physt/plotting/common.py | get_err_data | def get_err_data(histogram: HistogramBase, density: bool = False, cumulative: bool = False, flatten: bool = False) -> np.ndarray:
"""Get histogram error data based on plotting parameters.
Parameters
----------
density : Whether to divide bin contents by bin size
cumulative : Whether to return cumul... | python | def get_err_data(histogram: HistogramBase, density: bool = False, cumulative: bool = False, flatten: bool = False) -> np.ndarray:
"""Get histogram error data based on plotting parameters.
Parameters
----------
density : Whether to divide bin contents by bin size
cumulative : Whether to return cumul... | [
"def",
"get_err_data",
"(",
"histogram",
":",
"HistogramBase",
",",
"density",
":",
"bool",
"=",
"False",
",",
"cumulative",
":",
"bool",
"=",
"False",
",",
"flatten",
":",
"bool",
"=",
"False",
")",
"->",
"np",
".",
"ndarray",
":",
"if",
"cumulative",
... | Get histogram error data based on plotting parameters.
Parameters
----------
density : Whether to divide bin contents by bin size
cumulative : Whether to return cumulative sums instead of individual
flatten : Whether to flatten multidimensional bins | [
"Get",
"histogram",
"error",
"data",
"based",
"on",
"plotting",
"parameters",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/common.py#L40-L57 |
16,434 | janpipek/physt | physt/plotting/common.py | get_value_format | def get_value_format(value_format: Union[Callable, str] = str) -> Callable[[float], str]:
"""Create a formatting function from a generic value_format argument.
"""
if value_format is None:
value_format = ""
if isinstance(value_format, str):
format_str = "{0:" + value_format + "}"
... | python | def get_value_format(value_format: Union[Callable, str] = str) -> Callable[[float], str]:
"""Create a formatting function from a generic value_format argument.
"""
if value_format is None:
value_format = ""
if isinstance(value_format, str):
format_str = "{0:" + value_format + "}"
... | [
"def",
"get_value_format",
"(",
"value_format",
":",
"Union",
"[",
"Callable",
",",
"str",
"]",
"=",
"str",
")",
"->",
"Callable",
"[",
"[",
"float",
"]",
",",
"str",
"]",
":",
"if",
"value_format",
"is",
"None",
":",
"value_format",
"=",
"\"\"",
"if",... | Create a formatting function from a generic value_format argument. | [
"Create",
"a",
"formatting",
"function",
"from",
"a",
"generic",
"value_format",
"argument",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/common.py#L60-L70 |
16,435 | janpipek/physt | physt/plotting/common.py | pop_kwargs_with_prefix | def pop_kwargs_with_prefix(prefix: str, kwargs: dict) -> dict:
"""Pop all items from a dictionary that have keys beginning with a prefix.
Parameters
----------
prefix : str
kwargs : dict
Returns
-------
kwargs : dict
Items popped from the original directory, with prefix removed... | python | def pop_kwargs_with_prefix(prefix: str, kwargs: dict) -> dict:
"""Pop all items from a dictionary that have keys beginning with a prefix.
Parameters
----------
prefix : str
kwargs : dict
Returns
-------
kwargs : dict
Items popped from the original directory, with prefix removed... | [
"def",
"pop_kwargs_with_prefix",
"(",
"prefix",
":",
"str",
",",
"kwargs",
":",
"dict",
")",
"->",
"dict",
":",
"keys",
"=",
"[",
"key",
"for",
"key",
"in",
"kwargs",
"if",
"key",
".",
"startswith",
"(",
"prefix",
")",
"]",
"return",
"{",
"key",
"[",... | Pop all items from a dictionary that have keys beginning with a prefix.
Parameters
----------
prefix : str
kwargs : dict
Returns
-------
kwargs : dict
Items popped from the original directory, with prefix removed. | [
"Pop",
"all",
"items",
"from",
"a",
"dictionary",
"that",
"have",
"keys",
"beginning",
"with",
"a",
"prefix",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/common.py#L73-L87 |
16,436 | janpipek/physt | physt/histogram_nd.py | HistogramND.bins | def bins(self) -> List[np.ndarray]:
"""List of bin matrices."""
return [binning.bins for binning in self._binnings] | python | def bins(self) -> List[np.ndarray]:
"""List of bin matrices."""
return [binning.bins for binning in self._binnings] | [
"def",
"bins",
"(",
"self",
")",
"->",
"List",
"[",
"np",
".",
"ndarray",
"]",
":",
"return",
"[",
"binning",
".",
"bins",
"for",
"binning",
"in",
"self",
".",
"_binnings",
"]"
] | List of bin matrices. | [
"List",
"of",
"bin",
"matrices",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_nd.py#L54-L56 |
16,437 | janpipek/physt | physt/histogram_nd.py | HistogramND.select | def select(self, axis: AxisIdentifier, index, force_copy: bool = False) -> HistogramBase:
"""Select in an axis.
Parameters
----------
axis: int or str
Axis, in which we select.
index: int or slice
Index of bin (as in numpy).
force_copy: bool
... | python | def select(self, axis: AxisIdentifier, index, force_copy: bool = False) -> HistogramBase:
"""Select in an axis.
Parameters
----------
axis: int or str
Axis, in which we select.
index: int or slice
Index of bin (as in numpy).
force_copy: bool
... | [
"def",
"select",
"(",
"self",
",",
"axis",
":",
"AxisIdentifier",
",",
"index",
",",
"force_copy",
":",
"bool",
"=",
"False",
")",
"->",
"HistogramBase",
":",
"if",
"index",
"==",
"slice",
"(",
"None",
")",
"and",
"not",
"force_copy",
":",
"return",
"s... | Select in an axis.
Parameters
----------
axis: int or str
Axis, in which we select.
index: int or slice
Index of bin (as in numpy).
force_copy: bool
If True, identity slice force a copy to be made. | [
"Select",
"in",
"an",
"axis",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_nd.py#L71-L104 |
16,438 | janpipek/physt | physt/histogram_nd.py | HistogramND.accumulate | def accumulate(self, axis: AxisIdentifier) -> HistogramBase:
"""Calculate cumulative frequencies along a certain axis.
Returns
-------
new_hist: Histogram of the same type & size
"""
# TODO: Merge with Histogram1D.cumulative_frequencies
# TODO: Deal with errors a... | python | def accumulate(self, axis: AxisIdentifier) -> HistogramBase:
"""Calculate cumulative frequencies along a certain axis.
Returns
-------
new_hist: Histogram of the same type & size
"""
# TODO: Merge with Histogram1D.cumulative_frequencies
# TODO: Deal with errors a... | [
"def",
"accumulate",
"(",
"self",
",",
"axis",
":",
"AxisIdentifier",
")",
"->",
"HistogramBase",
":",
"# TODO: Merge with Histogram1D.cumulative_frequencies",
"# TODO: Deal with errors and totals etc.",
"# TODO: inplace",
"new_one",
"=",
"self",
".",
"copy",
"(",
")",
"a... | Calculate cumulative frequencies along a certain axis.
Returns
-------
new_hist: Histogram of the same type & size | [
"Calculate",
"cumulative",
"frequencies",
"along",
"a",
"certain",
"axis",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_nd.py#L338-L351 |
16,439 | janpipek/physt | physt/histogram_nd.py | Histogram2D.T | def T(self) -> "Histogram2D":
"""Histogram with swapped axes.
Returns
-------
Histogram2D - a copy with swapped axes
"""
a_copy = self.copy()
a_copy._binnings = list(reversed(a_copy._binnings))
a_copy.axis_names = list(reversed(a_copy.axis_names))
... | python | def T(self) -> "Histogram2D":
"""Histogram with swapped axes.
Returns
-------
Histogram2D - a copy with swapped axes
"""
a_copy = self.copy()
a_copy._binnings = list(reversed(a_copy._binnings))
a_copy.axis_names = list(reversed(a_copy.axis_names))
... | [
"def",
"T",
"(",
"self",
")",
"->",
"\"Histogram2D\"",
":",
"a_copy",
"=",
"self",
".",
"copy",
"(",
")",
"a_copy",
".",
"_binnings",
"=",
"list",
"(",
"reversed",
"(",
"a_copy",
".",
"_binnings",
")",
")",
"a_copy",
".",
"axis_names",
"=",
"list",
"... | Histogram with swapped axes.
Returns
-------
Histogram2D - a copy with swapped axes | [
"Histogram",
"with",
"swapped",
"axes",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_nd.py#L414-L426 |
16,440 | janpipek/physt | physt/histogram_nd.py | Histogram2D.partial_normalize | def partial_normalize(self, axis: AxisIdentifier = 0, inplace: bool = False):
"""Normalize in rows or columns.
Parameters
----------
axis: int or str
Along which axis to sum (numpy-sense)
inplace: bool
Update the object itself
Returns
---... | python | def partial_normalize(self, axis: AxisIdentifier = 0, inplace: bool = False):
"""Normalize in rows or columns.
Parameters
----------
axis: int or str
Along which axis to sum (numpy-sense)
inplace: bool
Update the object itself
Returns
---... | [
"def",
"partial_normalize",
"(",
"self",
",",
"axis",
":",
"AxisIdentifier",
"=",
"0",
",",
"inplace",
":",
"bool",
"=",
"False",
")",
":",
"# TODO: Is this applicable for HistogramND?",
"axis",
"=",
"self",
".",
"_get_axis",
"(",
"axis",
")",
"if",
"not",
"... | Normalize in rows or columns.
Parameters
----------
axis: int or str
Along which axis to sum (numpy-sense)
inplace: bool
Update the object itself
Returns
-------
hist : Histogram2D | [
"Normalize",
"in",
"rows",
"or",
"columns",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_nd.py#L428-L457 |
16,441 | janpipek/physt | physt/binnings.py | numpy_binning | def numpy_binning(data, bins=10, range=None, *args, **kwargs) -> NumpyBinning:
"""Construct binning schema compatible with numpy.histogram
Parameters
----------
data: array_like, optional
This is optional if both bins and range are set
bins: int or array_like
range: Optional[tuple]
... | python | def numpy_binning(data, bins=10, range=None, *args, **kwargs) -> NumpyBinning:
"""Construct binning schema compatible with numpy.histogram
Parameters
----------
data: array_like, optional
This is optional if both bins and range are set
bins: int or array_like
range: Optional[tuple]
... | [
"def",
"numpy_binning",
"(",
"data",
",",
"bins",
"=",
"10",
",",
"range",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"NumpyBinning",
":",
"if",
"isinstance",
"(",
"bins",
",",
"int",
")",
":",
"if",
"range",
":",
"bins",
... | Construct binning schema compatible with numpy.histogram
Parameters
----------
data: array_like, optional
This is optional if both bins and range are set
bins: int or array_like
range: Optional[tuple]
(min, max)
includes_right_edge: Optional[bool]
default: True
See ... | [
"Construct",
"binning",
"schema",
"compatible",
"with",
"numpy",
".",
"histogram"
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L596-L625 |
16,442 | janpipek/physt | physt/binnings.py | human_binning | def human_binning(data=None, bin_count: Optional[int] = None, *, range=None, **kwargs) -> FixedWidthBinning:
"""Construct fixed-width ninning schema with bins automatically optimized to human-friendly widths.
Typical widths are: 1.0, 25,0, 0.02, 500, 2.5e-7, ...
Parameters
----------
bin_count: Nu... | python | def human_binning(data=None, bin_count: Optional[int] = None, *, range=None, **kwargs) -> FixedWidthBinning:
"""Construct fixed-width ninning schema with bins automatically optimized to human-friendly widths.
Typical widths are: 1.0, 25,0, 0.02, 500, 2.5e-7, ...
Parameters
----------
bin_count: Nu... | [
"def",
"human_binning",
"(",
"data",
"=",
"None",
",",
"bin_count",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"*",
",",
"range",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"FixedWidthBinning",
":",
"subscales",
"=",
"np",
".",
"array"... | Construct fixed-width ninning schema with bins automatically optimized to human-friendly widths.
Typical widths are: 1.0, 25,0, 0.02, 500, 2.5e-7, ...
Parameters
----------
bin_count: Number of bins
range: Optional[tuple]
(min, max) | [
"Construct",
"fixed",
"-",
"width",
"ninning",
"schema",
"with",
"bins",
"automatically",
"optimized",
"to",
"human",
"-",
"friendly",
"widths",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L628-L653 |
16,443 | janpipek/physt | physt/binnings.py | quantile_binning | def quantile_binning(data=None, bins=10, *, qrange=(0.0, 1.0), **kwargs) -> StaticBinning:
"""Binning schema based on quantile ranges.
This binning finds equally spaced quantiles. This should lead to
all bins having roughly the same frequencies.
Note: weights are not (yet) take into account for calcul... | python | def quantile_binning(data=None, bins=10, *, qrange=(0.0, 1.0), **kwargs) -> StaticBinning:
"""Binning schema based on quantile ranges.
This binning finds equally spaced quantiles. This should lead to
all bins having roughly the same frequencies.
Note: weights are not (yet) take into account for calcul... | [
"def",
"quantile_binning",
"(",
"data",
"=",
"None",
",",
"bins",
"=",
"10",
",",
"*",
",",
"qrange",
"=",
"(",
"0.0",
",",
"1.0",
")",
",",
"*",
"*",
"kwargs",
")",
"->",
"StaticBinning",
":",
"if",
"np",
".",
"isscalar",
"(",
"bins",
")",
":",
... | Binning schema based on quantile ranges.
This binning finds equally spaced quantiles. This should lead to
all bins having roughly the same frequencies.
Note: weights are not (yet) take into account for calculating
quantiles.
Parameters
----------
bins: sequence or Optional[int]
Nu... | [
"Binning",
"schema",
"based",
"on",
"quantile",
"ranges",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L656-L680 |
16,444 | janpipek/physt | physt/binnings.py | static_binning | def static_binning(data=None, bins=None, **kwargs) -> StaticBinning:
"""Construct static binning with whatever bins."""
return StaticBinning(bins=make_bin_array(bins), **kwargs) | python | def static_binning(data=None, bins=None, **kwargs) -> StaticBinning:
"""Construct static binning with whatever bins."""
return StaticBinning(bins=make_bin_array(bins), **kwargs) | [
"def",
"static_binning",
"(",
"data",
"=",
"None",
",",
"bins",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"StaticBinning",
":",
"return",
"StaticBinning",
"(",
"bins",
"=",
"make_bin_array",
"(",
"bins",
")",
",",
"*",
"*",
"kwargs",
")"
] | Construct static binning with whatever bins. | [
"Construct",
"static",
"binning",
"with",
"whatever",
"bins",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L683-L685 |
16,445 | janpipek/physt | physt/binnings.py | integer_binning | def integer_binning(data=None, **kwargs) -> StaticBinning:
"""Construct fixed-width binning schema with bins centered around integers.
Parameters
----------
range: Optional[Tuple[int]]
min (included) and max integer (excluded) bin
bin_width: Optional[int]
group "bin_width" integers ... | python | def integer_binning(data=None, **kwargs) -> StaticBinning:
"""Construct fixed-width binning schema with bins centered around integers.
Parameters
----------
range: Optional[Tuple[int]]
min (included) and max integer (excluded) bin
bin_width: Optional[int]
group "bin_width" integers ... | [
"def",
"integer_binning",
"(",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"StaticBinning",
":",
"if",
"\"range\"",
"in",
"kwargs",
":",
"kwargs",
"[",
"\"range\"",
"]",
"=",
"tuple",
"(",
"r",
"-",
"0.5",
"for",
"r",
"in",
"kwargs",
"["... | Construct fixed-width binning schema with bins centered around integers.
Parameters
----------
range: Optional[Tuple[int]]
min (included) and max integer (excluded) bin
bin_width: Optional[int]
group "bin_width" integers into one bin (not recommended) | [
"Construct",
"fixed",
"-",
"width",
"binning",
"schema",
"with",
"bins",
"centered",
"around",
"integers",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L688-L701 |
16,446 | janpipek/physt | physt/binnings.py | fixed_width_binning | def fixed_width_binning(data=None, bin_width: Union[float, int] = 1, *, range=None, includes_right_edge=False, **kwargs) -> FixedWidthBinning:
"""Construct fixed-width binning schema.
Parameters
----------
bin_width: float
range: Optional[tuple]
(min, max)
align: Optional[float]
... | python | def fixed_width_binning(data=None, bin_width: Union[float, int] = 1, *, range=None, includes_right_edge=False, **kwargs) -> FixedWidthBinning:
"""Construct fixed-width binning schema.
Parameters
----------
bin_width: float
range: Optional[tuple]
(min, max)
align: Optional[float]
... | [
"def",
"fixed_width_binning",
"(",
"data",
"=",
"None",
",",
"bin_width",
":",
"Union",
"[",
"float",
",",
"int",
"]",
"=",
"1",
",",
"*",
",",
"range",
"=",
"None",
",",
"includes_right_edge",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
"->",
"Fixed... | Construct fixed-width binning schema.
Parameters
----------
bin_width: float
range: Optional[tuple]
(min, max)
align: Optional[float]
Must be multiple of bin_width | [
"Construct",
"fixed",
"-",
"width",
"binning",
"schema",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L704-L726 |
16,447 | janpipek/physt | physt/binnings.py | exponential_binning | def exponential_binning(data=None, bin_count: Optional[int] = None, *, range=None, **kwargs) -> ExponentialBinning:
"""Construct exponential binning schema.
Parameters
----------
bin_count: Optional[int]
Number of bins
range: Optional[tuple]
(min, max)
See also
--------
... | python | def exponential_binning(data=None, bin_count: Optional[int] = None, *, range=None, **kwargs) -> ExponentialBinning:
"""Construct exponential binning schema.
Parameters
----------
bin_count: Optional[int]
Number of bins
range: Optional[tuple]
(min, max)
See also
--------
... | [
"def",
"exponential_binning",
"(",
"data",
"=",
"None",
",",
"bin_count",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"*",
",",
"range",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"ExponentialBinning",
":",
"if",
"bin_count",
"is",
"None"... | Construct exponential binning schema.
Parameters
----------
bin_count: Optional[int]
Number of bins
range: Optional[tuple]
(min, max)
See also
--------
numpy.logspace - note that our range semantics is different | [
"Construct",
"exponential",
"binning",
"schema",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L729-L751 |
16,448 | janpipek/physt | physt/binnings.py | calculate_bins | def calculate_bins(array, _=None, *args, **kwargs) -> BinningBase:
"""Find optimal binning from arguments.
Parameters
----------
array: arraylike
Data from which the bins should be decided (sometimes used, sometimes not)
_: int or str or Callable or arraylike or Iterable or BinningBase
... | python | def calculate_bins(array, _=None, *args, **kwargs) -> BinningBase:
"""Find optimal binning from arguments.
Parameters
----------
array: arraylike
Data from which the bins should be decided (sometimes used, sometimes not)
_: int or str or Callable or arraylike or Iterable or BinningBase
... | [
"def",
"calculate_bins",
"(",
"array",
",",
"_",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"BinningBase",
":",
"if",
"array",
"is",
"not",
"None",
":",
"if",
"kwargs",
".",
"pop",
"(",
"\"check_nan\"",
",",
"True",
")",
":"... | Find optimal binning from arguments.
Parameters
----------
array: arraylike
Data from which the bins should be decided (sometimes used, sometimes not)
_: int or str or Callable or arraylike or Iterable or BinningBase
To-be-guessed parameter that specifies what kind of binning should be ... | [
"Find",
"optimal",
"binning",
"from",
"arguments",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L754-L804 |
16,449 | janpipek/physt | physt/binnings.py | ideal_bin_count | def ideal_bin_count(data, method: str = "default") -> int:
"""A theoretically ideal bin count.
Parameters
----------
data: array_likes
Data to work on. Most methods don't use this.
method: str
Name of the method to apply, available values:
- default (~sturges)
- ... | python | def ideal_bin_count(data, method: str = "default") -> int:
"""A theoretically ideal bin count.
Parameters
----------
data: array_likes
Data to work on. Most methods don't use this.
method: str
Name of the method to apply, available values:
- default (~sturges)
- ... | [
"def",
"ideal_bin_count",
"(",
"data",
",",
"method",
":",
"str",
"=",
"\"default\"",
")",
"->",
"int",
":",
"n",
"=",
"data",
".",
"size",
"if",
"n",
"<",
"1",
":",
"return",
"1",
"if",
"method",
"==",
"\"default\"",
":",
"if",
"n",
"<=",
"32",
... | A theoretically ideal bin count.
Parameters
----------
data: array_likes
Data to work on. Most methods don't use this.
method: str
Name of the method to apply, available values:
- default (~sturges)
- sqrt
- sturges
- doane
- rice
... | [
"A",
"theoretically",
"ideal",
"bin",
"count",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L972-L1007 |
16,450 | janpipek/physt | physt/binnings.py | as_binning | def as_binning(obj, copy: bool = False) -> BinningBase:
"""Ensure that an object is a binning
Parameters
---------
obj : BinningBase or array_like
Can be a binning, numpy-like bins or full physt bins
copy : If true, ensure that the returned object is independent
"""
if isinstance(ob... | python | def as_binning(obj, copy: bool = False) -> BinningBase:
"""Ensure that an object is a binning
Parameters
---------
obj : BinningBase or array_like
Can be a binning, numpy-like bins or full physt bins
copy : If true, ensure that the returned object is independent
"""
if isinstance(ob... | [
"def",
"as_binning",
"(",
"obj",
",",
"copy",
":",
"bool",
"=",
"False",
")",
"->",
"BinningBase",
":",
"if",
"isinstance",
"(",
"obj",
",",
"BinningBase",
")",
":",
"if",
"copy",
":",
"return",
"obj",
".",
"copy",
"(",
")",
"else",
":",
"return",
... | Ensure that an object is a binning
Parameters
---------
obj : BinningBase or array_like
Can be a binning, numpy-like bins or full physt bins
copy : If true, ensure that the returned object is independent | [
"Ensure",
"that",
"an",
"object",
"is",
"a",
"binning"
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L1013-L1029 |
16,451 | janpipek/physt | physt/binnings.py | BinningBase.to_dict | def to_dict(self) -> OrderedDict:
"""Dictionary representation of the binning schema.
This serves as template method, please implement _update_dict
"""
result = OrderedDict()
result["adaptive"] = self._adaptive
result["binning_type"] = type(self).__name__
self._u... | python | def to_dict(self) -> OrderedDict:
"""Dictionary representation of the binning schema.
This serves as template method, please implement _update_dict
"""
result = OrderedDict()
result["adaptive"] = self._adaptive
result["binning_type"] = type(self).__name__
self._u... | [
"def",
"to_dict",
"(",
"self",
")",
"->",
"OrderedDict",
":",
"result",
"=",
"OrderedDict",
"(",
")",
"result",
"[",
"\"adaptive\"",
"]",
"=",
"self",
".",
"_adaptive",
"result",
"[",
"\"binning_type\"",
"]",
"=",
"type",
"(",
"self",
")",
".",
"__name__... | Dictionary representation of the binning schema.
This serves as template method, please implement _update_dict | [
"Dictionary",
"representation",
"of",
"the",
"binning",
"schema",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L77-L86 |
16,452 | janpipek/physt | physt/binnings.py | BinningBase.is_regular | def is_regular(self, rtol: float = 1.e-5, atol: float = 1.e-8) -> bool:
"""Whether all bins have the same width.
Parameters
----------
rtol, atol : numpy tolerance parameters
"""
return np.allclose(np.diff(self.bins[1] - self.bins[0]), 0.0, rtol=rtol, atol=atol) | python | def is_regular(self, rtol: float = 1.e-5, atol: float = 1.e-8) -> bool:
"""Whether all bins have the same width.
Parameters
----------
rtol, atol : numpy tolerance parameters
"""
return np.allclose(np.diff(self.bins[1] - self.bins[0]), 0.0, rtol=rtol, atol=atol) | [
"def",
"is_regular",
"(",
"self",
",",
"rtol",
":",
"float",
"=",
"1.e-5",
",",
"atol",
":",
"float",
"=",
"1.e-8",
")",
"->",
"bool",
":",
"return",
"np",
".",
"allclose",
"(",
"np",
".",
"diff",
"(",
"self",
".",
"bins",
"[",
"1",
"]",
"-",
"... | Whether all bins have the same width.
Parameters
----------
rtol, atol : numpy tolerance parameters | [
"Whether",
"all",
"bins",
"have",
"the",
"same",
"width",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L97-L104 |
16,453 | janpipek/physt | physt/binnings.py | BinningBase.is_consecutive | def is_consecutive(self, rtol: float = 1.e-5, atol: float = 1.e-8) -> bool:
"""Whether all bins are in a growing order.
Parameters
----------
rtol, atol : numpy tolerance parameters
"""
if self.inconsecutive_allowed:
if self._consecutive is None:
... | python | def is_consecutive(self, rtol: float = 1.e-5, atol: float = 1.e-8) -> bool:
"""Whether all bins are in a growing order.
Parameters
----------
rtol, atol : numpy tolerance parameters
"""
if self.inconsecutive_allowed:
if self._consecutive is None:
... | [
"def",
"is_consecutive",
"(",
"self",
",",
"rtol",
":",
"float",
"=",
"1.e-5",
",",
"atol",
":",
"float",
"=",
"1.e-8",
")",
"->",
"bool",
":",
"if",
"self",
".",
"inconsecutive_allowed",
":",
"if",
"self",
".",
"_consecutive",
"is",
"None",
":",
"if",... | Whether all bins are in a growing order.
Parameters
----------
rtol, atol : numpy tolerance parameters | [
"Whether",
"all",
"bins",
"are",
"in",
"a",
"growing",
"order",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L106-L120 |
16,454 | janpipek/physt | physt/binnings.py | BinningBase.adapt | def adapt(self, other: 'BinningBase'):
"""Adapt this binning so that it contains all bins of another binning.
Parameters
----------
other: BinningBase
"""
# TODO: in-place arg
if np.array_equal(self.bins, other.bins):
return None, None
elif no... | python | def adapt(self, other: 'BinningBase'):
"""Adapt this binning so that it contains all bins of another binning.
Parameters
----------
other: BinningBase
"""
# TODO: in-place arg
if np.array_equal(self.bins, other.bins):
return None, None
elif no... | [
"def",
"adapt",
"(",
"self",
",",
"other",
":",
"'BinningBase'",
")",
":",
"# TODO: in-place arg",
"if",
"np",
".",
"array_equal",
"(",
"self",
".",
"bins",
",",
"other",
".",
"bins",
")",
":",
"return",
"None",
",",
"None",
"elif",
"not",
"self",
".",... | Adapt this binning so that it contains all bins of another binning.
Parameters
----------
other: BinningBase | [
"Adapt",
"this",
"binning",
"so",
"that",
"it",
"contains",
"all",
"bins",
"of",
"another",
"binning",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L154-L167 |
16,455 | janpipek/physt | physt/binnings.py | BinningBase.numpy_bins | def numpy_bins(self) -> np.ndarray:
"""Bins in the numpy format
This might not be available for inconsecutive binnings.
Returns
-------
edges: np.ndarray
shape=(bin_count+1,)
"""
if self._numpy_bins is None:
self._numpy_bins = to_numpy_bi... | python | def numpy_bins(self) -> np.ndarray:
"""Bins in the numpy format
This might not be available for inconsecutive binnings.
Returns
-------
edges: np.ndarray
shape=(bin_count+1,)
"""
if self._numpy_bins is None:
self._numpy_bins = to_numpy_bi... | [
"def",
"numpy_bins",
"(",
"self",
")",
"->",
"np",
".",
"ndarray",
":",
"if",
"self",
".",
"_numpy_bins",
"is",
"None",
":",
"self",
".",
"_numpy_bins",
"=",
"to_numpy_bins",
"(",
"self",
".",
"bins",
")",
"return",
"self",
".",
"_numpy_bins"
] | Bins in the numpy format
This might not be available for inconsecutive binnings.
Returns
-------
edges: np.ndarray
shape=(bin_count+1,) | [
"Bins",
"in",
"the",
"numpy",
"format"
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L200-L212 |
16,456 | janpipek/physt | physt/binnings.py | BinningBase.numpy_bins_with_mask | def numpy_bins_with_mask(self) -> Tuple[np.ndarray, np.ndarray]:
"""Bins in the numpy format, including the gaps in inconsecutive binnings.
Returns
-------
edges, mask: np.ndarray
See Also
--------
bin_utils.to_numpy_bins_with_mask
"""
bwm = to_n... | python | def numpy_bins_with_mask(self) -> Tuple[np.ndarray, np.ndarray]:
"""Bins in the numpy format, including the gaps in inconsecutive binnings.
Returns
-------
edges, mask: np.ndarray
See Also
--------
bin_utils.to_numpy_bins_with_mask
"""
bwm = to_n... | [
"def",
"numpy_bins_with_mask",
"(",
"self",
")",
"->",
"Tuple",
"[",
"np",
".",
"ndarray",
",",
"np",
".",
"ndarray",
"]",
":",
"bwm",
"=",
"to_numpy_bins_with_mask",
"(",
"self",
".",
"bins",
")",
"if",
"not",
"self",
".",
"includes_right_edge",
":",
"b... | Bins in the numpy format, including the gaps in inconsecutive binnings.
Returns
-------
edges, mask: np.ndarray
See Also
--------
bin_utils.to_numpy_bins_with_mask | [
"Bins",
"in",
"the",
"numpy",
"format",
"including",
"the",
"gaps",
"in",
"inconsecutive",
"binnings",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L215-L229 |
16,457 | janpipek/physt | physt/binnings.py | StaticBinning.as_static | def as_static(self, copy: bool = True) -> 'StaticBinning':
"""Convert binning to a static form.
Returns
-------
StaticBinning
A new static binning with a copy of bins.
Parameters
----------
copy : if True, returns itself (already satisfying condition... | python | def as_static(self, copy: bool = True) -> 'StaticBinning':
"""Convert binning to a static form.
Returns
-------
StaticBinning
A new static binning with a copy of bins.
Parameters
----------
copy : if True, returns itself (already satisfying condition... | [
"def",
"as_static",
"(",
"self",
",",
"copy",
":",
"bool",
"=",
"True",
")",
"->",
"'StaticBinning'",
":",
"if",
"copy",
":",
"return",
"StaticBinning",
"(",
"bins",
"=",
"self",
".",
"bins",
".",
"copy",
"(",
")",
",",
"includes_right_edge",
"=",
"sel... | Convert binning to a static form.
Returns
-------
StaticBinning
A new static binning with a copy of bins.
Parameters
----------
copy : if True, returns itself (already satisfying conditions). | [
"Convert",
"binning",
"to",
"a",
"static",
"form",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L319-L335 |
16,458 | janpipek/physt | physt/compat/dask.py | histogram1d | def histogram1d(data, bins=None, *args, **kwargs):
"""Facade function to create one-dimensional histogram using dask.
Parameters
----------
data: dask.DaskArray or array-like
See also
--------
physt.histogram
"""
import dask
if not hasattr(data, "dask"):
data = dask.arr... | python | def histogram1d(data, bins=None, *args, **kwargs):
"""Facade function to create one-dimensional histogram using dask.
Parameters
----------
data: dask.DaskArray or array-like
See also
--------
physt.histogram
"""
import dask
if not hasattr(data, "dask"):
data = dask.arr... | [
"def",
"histogram1d",
"(",
"data",
",",
"bins",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"dask",
"if",
"not",
"hasattr",
"(",
"data",
",",
"\"dask\"",
")",
":",
"data",
"=",
"dask",
".",
"array",
".",
"from_array"... | Facade function to create one-dimensional histogram using dask.
Parameters
----------
data: dask.DaskArray or array-like
See also
--------
physt.histogram | [
"Facade",
"function",
"to",
"create",
"one",
"-",
"dimensional",
"histogram",
"using",
"dask",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/compat/dask.py#L30-L57 |
16,459 | janpipek/physt | physt/compat/dask.py | histogram2d | def histogram2d(data1, data2, bins=None, *args, **kwargs):
"""Facade function to create 2D histogram using dask."""
# TODO: currently very unoptimized! for non-dasks
import dask
if "axis_names" not in kwargs:
if hasattr(data1, "name") and hasattr(data2, "name"):
kwargs["axis_names"] ... | python | def histogram2d(data1, data2, bins=None, *args, **kwargs):
"""Facade function to create 2D histogram using dask."""
# TODO: currently very unoptimized! for non-dasks
import dask
if "axis_names" not in kwargs:
if hasattr(data1, "name") and hasattr(data2, "name"):
kwargs["axis_names"] ... | [
"def",
"histogram2d",
"(",
"data1",
",",
"data2",
",",
"bins",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: currently very unoptimized! for non-dasks",
"import",
"dask",
"if",
"\"axis_names\"",
"not",
"in",
"kwargs",
":",
"if",
... | Facade function to create 2D histogram using dask. | [
"Facade",
"function",
"to",
"create",
"2D",
"histogram",
"using",
"dask",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/compat/dask.py#L88-L102 |
16,460 | janpipek/physt | physt/util.py | all_subclasses | def all_subclasses(cls: type) -> Tuple[type, ...]:
"""All subclasses of a class.
From: http://stackoverflow.com/a/17246726/2692780
"""
subclasses = []
for subclass in cls.__subclasses__():
subclasses.append(subclass)
subclasses.extend(all_subclasses(subclass))
return tuple(subcl... | python | def all_subclasses(cls: type) -> Tuple[type, ...]:
"""All subclasses of a class.
From: http://stackoverflow.com/a/17246726/2692780
"""
subclasses = []
for subclass in cls.__subclasses__():
subclasses.append(subclass)
subclasses.extend(all_subclasses(subclass))
return tuple(subcl... | [
"def",
"all_subclasses",
"(",
"cls",
":",
"type",
")",
"->",
"Tuple",
"[",
"type",
",",
"...",
"]",
":",
"subclasses",
"=",
"[",
"]",
"for",
"subclass",
"in",
"cls",
".",
"__subclasses__",
"(",
")",
":",
"subclasses",
".",
"append",
"(",
"subclass",
... | All subclasses of a class.
From: http://stackoverflow.com/a/17246726/2692780 | [
"All",
"subclasses",
"of",
"a",
"class",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/util.py#L9-L18 |
16,461 | janpipek/physt | physt/util.py | find_subclass | def find_subclass(base: type, name: str) -> type:
"""Find a named subclass of a base class.
Uses only the class name without namespace.
"""
class_candidates = [klass
for klass in all_subclasses(base)
if klass.__name__ == name
]
... | python | def find_subclass(base: type, name: str) -> type:
"""Find a named subclass of a base class.
Uses only the class name without namespace.
"""
class_candidates = [klass
for klass in all_subclasses(base)
if klass.__name__ == name
]
... | [
"def",
"find_subclass",
"(",
"base",
":",
"type",
",",
"name",
":",
"str",
")",
"->",
"type",
":",
"class_candidates",
"=",
"[",
"klass",
"for",
"klass",
"in",
"all_subclasses",
"(",
"base",
")",
"if",
"klass",
".",
"__name__",
"==",
"name",
"]",
"if",... | Find a named subclass of a base class.
Uses only the class name without namespace. | [
"Find",
"a",
"named",
"subclass",
"of",
"a",
"base",
"class",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/util.py#L21-L34 |
16,462 | janpipek/physt | physt/histogram_collection.py | HistogramCollection.add | def add(self, histogram: Histogram1D):
"""Add a histogram to the collection."""
if self.binning and not self.binning == histogram.binning:
raise ValueError("Cannot add histogram with different binning.")
self.histograms.append(histogram) | python | def add(self, histogram: Histogram1D):
"""Add a histogram to the collection."""
if self.binning and not self.binning == histogram.binning:
raise ValueError("Cannot add histogram with different binning.")
self.histograms.append(histogram) | [
"def",
"add",
"(",
"self",
",",
"histogram",
":",
"Histogram1D",
")",
":",
"if",
"self",
".",
"binning",
"and",
"not",
"self",
".",
"binning",
"==",
"histogram",
".",
"binning",
":",
"raise",
"ValueError",
"(",
"\"Cannot add histogram with different binning.\"",... | Add a histogram to the collection. | [
"Add",
"a",
"histogram",
"to",
"the",
"collection",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_collection.py#L80-L84 |
16,463 | janpipek/physt | physt/histogram_collection.py | HistogramCollection.normalize_bins | def normalize_bins(self, inplace: bool = False) -> "HistogramCollection":
"""Normalize each bin in the collection so that the sum is 1.0 for each bin.
Note: If a bin is zero in all collections, the result will be inf.
"""
col = self if inplace else self.copy()
sums = self.sum().... | python | def normalize_bins(self, inplace: bool = False) -> "HistogramCollection":
"""Normalize each bin in the collection so that the sum is 1.0 for each bin.
Note: If a bin is zero in all collections, the result will be inf.
"""
col = self if inplace else self.copy()
sums = self.sum().... | [
"def",
"normalize_bins",
"(",
"self",
",",
"inplace",
":",
"bool",
"=",
"False",
")",
"->",
"\"HistogramCollection\"",
":",
"col",
"=",
"self",
"if",
"inplace",
"else",
"self",
".",
"copy",
"(",
")",
"sums",
"=",
"self",
".",
"sum",
"(",
")",
".",
"f... | Normalize each bin in the collection so that the sum is 1.0 for each bin.
Note: If a bin is zero in all collections, the result will be inf. | [
"Normalize",
"each",
"bin",
"in",
"the",
"collection",
"so",
"that",
"the",
"sum",
"is",
"1",
".",
"0",
"for",
"each",
"bin",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_collection.py#L113-L124 |
16,464 | janpipek/physt | physt/histogram_collection.py | HistogramCollection.multi_h1 | def multi_h1(cls, a_dict: Dict[str, Any], bins=None, **kwargs) -> "HistogramCollection":
"""Create a collection from multiple datasets."""
from physt.binnings import calculate_bins
mega_values = np.concatenate(list(a_dict.values()))
binning = calculate_bins(mega_values, bins, **kwargs)
... | python | def multi_h1(cls, a_dict: Dict[str, Any], bins=None, **kwargs) -> "HistogramCollection":
"""Create a collection from multiple datasets."""
from physt.binnings import calculate_bins
mega_values = np.concatenate(list(a_dict.values()))
binning = calculate_bins(mega_values, bins, **kwargs)
... | [
"def",
"multi_h1",
"(",
"cls",
",",
"a_dict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"bins",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"\"HistogramCollection\"",
":",
"from",
"physt",
".",
"binnings",
"import",
"calculate_bins",
"mega_valu... | Create a collection from multiple datasets. | [
"Create",
"a",
"collection",
"from",
"multiple",
"datasets",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_collection.py#L142-L154 |
16,465 | janpipek/physt | physt/histogram_collection.py | HistogramCollection.to_json | def to_json(self, path: Optional[str] = None, **kwargs) -> str:
"""Convert to JSON representation.
Parameters
----------
path: Where to write the JSON.
Returns
-------
The JSON representation.
"""
from .io import save_json
return save_jso... | python | def to_json(self, path: Optional[str] = None, **kwargs) -> str:
"""Convert to JSON representation.
Parameters
----------
path: Where to write the JSON.
Returns
-------
The JSON representation.
"""
from .io import save_json
return save_jso... | [
"def",
"to_json",
"(",
"self",
",",
"path",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"from",
".",
"io",
"import",
"save_json",
"return",
"save_json",
"(",
"self",
",",
"path",
",",
"*",
"*",
"... | Convert to JSON representation.
Parameters
----------
path: Where to write the JSON.
Returns
-------
The JSON representation. | [
"Convert",
"to",
"JSON",
"representation",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_collection.py#L171-L183 |
16,466 | janpipek/physt | physt/histogram_base.py | HistogramBase._get_axis | def _get_axis(self, name_or_index: AxisIdentifier) -> int:
"""Get a zero-based index of an axis and check its existence."""
# TODO: Add unit test
if isinstance(name_or_index, int):
if name_or_index < 0 or name_or_index >= self.ndim:
raise ValueError("No such axis, mus... | python | def _get_axis(self, name_or_index: AxisIdentifier) -> int:
"""Get a zero-based index of an axis and check its existence."""
# TODO: Add unit test
if isinstance(name_or_index, int):
if name_or_index < 0 or name_or_index >= self.ndim:
raise ValueError("No such axis, mus... | [
"def",
"_get_axis",
"(",
"self",
",",
"name_or_index",
":",
"AxisIdentifier",
")",
"->",
"int",
":",
"# TODO: Add unit test",
"if",
"isinstance",
"(",
"name_or_index",
",",
"int",
")",
":",
"if",
"name_or_index",
"<",
"0",
"or",
"name_or_index",
">=",
"self",
... | Get a zero-based index of an axis and check its existence. | [
"Get",
"a",
"zero",
"-",
"based",
"index",
"of",
"an",
"axis",
"and",
"check",
"its",
"existence",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L177-L191 |
16,467 | janpipek/physt | physt/histogram_base.py | HistogramBase.shape | def shape(self) -> Tuple[int, ...]:
"""Shape of histogram's data.
Returns
-------
One-element tuple with the number of bins along each axis.
"""
return tuple(bins.bin_count for bins in self._binnings) | python | def shape(self) -> Tuple[int, ...]:
"""Shape of histogram's data.
Returns
-------
One-element tuple with the number of bins along each axis.
"""
return tuple(bins.bin_count for bins in self._binnings) | [
"def",
"shape",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"...",
"]",
":",
"return",
"tuple",
"(",
"bins",
".",
"bin_count",
"for",
"bins",
"in",
"self",
".",
"_binnings",
")"
] | Shape of histogram's data.
Returns
-------
One-element tuple with the number of bins along each axis. | [
"Shape",
"of",
"histogram",
"s",
"data",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L194-L201 |
16,468 | janpipek/physt | physt/histogram_base.py | HistogramBase.set_dtype | def set_dtype(self, value, check: bool = True):
"""Change data type of the bin contents.
Allowed conversions:
- from integral to float types
- between the same category of type (float/integer)
- from float types to integer if weights are trivial
Parameters
-----... | python | def set_dtype(self, value, check: bool = True):
"""Change data type of the bin contents.
Allowed conversions:
- from integral to float types
- between the same category of type (float/integer)
- from float types to integer if weights are trivial
Parameters
-----... | [
"def",
"set_dtype",
"(",
"self",
",",
"value",
",",
"check",
":",
"bool",
"=",
"True",
")",
":",
"# TODO? Deal with unsigned types",
"value",
",",
"type_info",
"=",
"self",
".",
"_eval_dtype",
"(",
"value",
")",
"if",
"value",
"==",
"self",
".",
"_dtype",
... | Change data type of the bin contents.
Allowed conversions:
- from integral to float types
- between the same category of type (float/integer)
- from float types to integer if weights are trivial
Parameters
----------
value: np.dtype or something convertible to i... | [
"Change",
"data",
"type",
"of",
"the",
"bin",
"contents",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L244-L278 |
16,469 | janpipek/physt | physt/histogram_base.py | HistogramBase._coerce_dtype | def _coerce_dtype(self, other_dtype):
"""Possibly change the bin content type to allow correct operations with other operand.
Parameters
----------
other_dtype : np.dtype or type
"""
if self._dtype is None:
new_dtype = np.dtype(other_dtype)
else:
... | python | def _coerce_dtype(self, other_dtype):
"""Possibly change the bin content type to allow correct operations with other operand.
Parameters
----------
other_dtype : np.dtype or type
"""
if self._dtype is None:
new_dtype = np.dtype(other_dtype)
else:
... | [
"def",
"_coerce_dtype",
"(",
"self",
",",
"other_dtype",
")",
":",
"if",
"self",
".",
"_dtype",
"is",
"None",
":",
"new_dtype",
"=",
"np",
".",
"dtype",
"(",
"other_dtype",
")",
"else",
":",
"new_dtype",
"=",
"np",
".",
"find_common_type",
"(",
"[",
"s... | Possibly change the bin content type to allow correct operations with other operand.
Parameters
----------
other_dtype : np.dtype or type | [
"Possibly",
"change",
"the",
"bin",
"content",
"type",
"to",
"allow",
"correct",
"operations",
"with",
"other",
"operand",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L282-L294 |
16,470 | janpipek/physt | physt/histogram_base.py | HistogramBase.normalize | def normalize(self, inplace: bool = False, percent: bool = False) -> "HistogramBase":
"""Normalize the histogram, so that the total weight is equal to 1.
Parameters
----------
inplace: If True, updates itself. If False (default), returns copy
percent: If True, normalizes to perc... | python | def normalize(self, inplace: bool = False, percent: bool = False) -> "HistogramBase":
"""Normalize the histogram, so that the total weight is equal to 1.
Parameters
----------
inplace: If True, updates itself. If False (default), returns copy
percent: If True, normalizes to perc... | [
"def",
"normalize",
"(",
"self",
",",
"inplace",
":",
"bool",
"=",
"False",
",",
"percent",
":",
"bool",
"=",
"False",
")",
"->",
"\"HistogramBase\"",
":",
"if",
"inplace",
":",
"self",
"/=",
"self",
".",
"total",
"*",
"(",
".01",
"if",
"percent",
"e... | Normalize the histogram, so that the total weight is equal to 1.
Parameters
----------
inplace: If True, updates itself. If False (default), returns copy
percent: If True, normalizes to percent instead of 1. Default: False
Returns
-------
HistogramBase : either ... | [
"Normalize",
"the",
"histogram",
"so",
"that",
"the",
"total",
"weight",
"is",
"equal",
"to",
"1",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L314-L335 |
16,471 | janpipek/physt | physt/histogram_base.py | HistogramBase._change_binning | def _change_binning(self, new_binning, bin_map: Iterable[Tuple[int, int]], axis: int = 0):
"""Set new binnning and update the bin contents according to a map.
Fills frequencies and errors with 0.
It's the caller's responsibility to provide correct binning and map.
Parameters
--... | python | def _change_binning(self, new_binning, bin_map: Iterable[Tuple[int, int]], axis: int = 0):
"""Set new binnning and update the bin contents according to a map.
Fills frequencies and errors with 0.
It's the caller's responsibility to provide correct binning and map.
Parameters
--... | [
"def",
"_change_binning",
"(",
"self",
",",
"new_binning",
",",
"bin_map",
":",
"Iterable",
"[",
"Tuple",
"[",
"int",
",",
"int",
"]",
"]",
",",
"axis",
":",
"int",
"=",
"0",
")",
":",
"axis",
"=",
"int",
"(",
"axis",
")",
"if",
"axis",
"<",
"0",... | Set new binnning and update the bin contents according to a map.
Fills frequencies and errors with 0.
It's the caller's responsibility to provide correct binning and map.
Parameters
----------
new_binning: physt.binnings.BinningBase
bin_map: Iterable[tuple]
... | [
"Set",
"new",
"binnning",
"and",
"update",
"the",
"bin",
"contents",
"according",
"to",
"a",
"map",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L386-L404 |
16,472 | janpipek/physt | physt/histogram_base.py | HistogramBase._reshape_data | def _reshape_data(self, new_size, bin_map, axis=0):
"""Reshape data to match new binning schema.
Fills frequencies and errors with 0.
Parameters
----------
new_size: int
bin_map: Iterable[(old, new)] or int or None
If None, we can keep the data unchanged.
... | python | def _reshape_data(self, new_size, bin_map, axis=0):
"""Reshape data to match new binning schema.
Fills frequencies and errors with 0.
Parameters
----------
new_size: int
bin_map: Iterable[(old, new)] or int or None
If None, we can keep the data unchanged.
... | [
"def",
"_reshape_data",
"(",
"self",
",",
"new_size",
",",
"bin_map",
",",
"axis",
"=",
"0",
")",
":",
"if",
"bin_map",
"is",
"None",
":",
"return",
"else",
":",
"new_shape",
"=",
"list",
"(",
"self",
".",
"shape",
")",
"new_shape",
"[",
"axis",
"]",... | Reshape data to match new binning schema.
Fills frequencies and errors with 0.
Parameters
----------
new_size: int
bin_map: Iterable[(old, new)] or int or None
If None, we can keep the data unchanged.
If int, it is offset by which to shift the data (can ... | [
"Reshape",
"data",
"to",
"match",
"new",
"binning",
"schema",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L455-L482 |
16,473 | janpipek/physt | physt/histogram_base.py | HistogramBase._apply_bin_map | def _apply_bin_map(self, old_frequencies, new_frequencies, old_errors2,
new_errors2, bin_map, axis=0):
"""Fill new data arrays using a map.
Parameters
----------
old_frequencies : np.ndarray
Source of frequencies data
new_frequencies : np.ndarr... | python | def _apply_bin_map(self, old_frequencies, new_frequencies, old_errors2,
new_errors2, bin_map, axis=0):
"""Fill new data arrays using a map.
Parameters
----------
old_frequencies : np.ndarray
Source of frequencies data
new_frequencies : np.ndarr... | [
"def",
"_apply_bin_map",
"(",
"self",
",",
"old_frequencies",
",",
"new_frequencies",
",",
"old_errors2",
",",
"new_errors2",
",",
"bin_map",
",",
"axis",
"=",
"0",
")",
":",
"if",
"old_frequencies",
"is",
"not",
"None",
"and",
"old_frequencies",
".",
"shape",... | Fill new data arrays using a map.
Parameters
----------
old_frequencies : np.ndarray
Source of frequencies data
new_frequencies : np.ndarray
Target of frequencies data
old_errors2 : np.ndarray
Source of errors data
new_errors2 : np.nda... | [
"Fill",
"new",
"data",
"arrays",
"using",
"a",
"map",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L484-L520 |
16,474 | janpipek/physt | physt/histogram_base.py | HistogramBase.has_same_bins | def has_same_bins(self, other: "HistogramBase") -> bool:
"""Whether two histograms share the same binning."""
if self.shape != other.shape:
return False
elif self.ndim == 1:
return np.allclose(self.bins, other.bins)
elif self.ndim > 1:
for i in range(s... | python | def has_same_bins(self, other: "HistogramBase") -> bool:
"""Whether two histograms share the same binning."""
if self.shape != other.shape:
return False
elif self.ndim == 1:
return np.allclose(self.bins, other.bins)
elif self.ndim > 1:
for i in range(s... | [
"def",
"has_same_bins",
"(",
"self",
",",
"other",
":",
"\"HistogramBase\"",
")",
"->",
"bool",
":",
"if",
"self",
".",
"shape",
"!=",
"other",
".",
"shape",
":",
"return",
"False",
"elif",
"self",
".",
"ndim",
"==",
"1",
":",
"return",
"np",
".",
"a... | Whether two histograms share the same binning. | [
"Whether",
"two",
"histograms",
"share",
"the",
"same",
"binning",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L522-L532 |
16,475 | janpipek/physt | physt/histogram_base.py | HistogramBase.copy | def copy(self, include_frequencies: bool = True) -> "HistogramBase":
"""Copy the histogram.
Parameters
----------
include_frequencies : If false, all frequencies are set to zero.
"""
if include_frequencies:
frequencies = np.copy(self.frequencies)
... | python | def copy(self, include_frequencies: bool = True) -> "HistogramBase":
"""Copy the histogram.
Parameters
----------
include_frequencies : If false, all frequencies are set to zero.
"""
if include_frequencies:
frequencies = np.copy(self.frequencies)
... | [
"def",
"copy",
"(",
"self",
",",
"include_frequencies",
":",
"bool",
"=",
"True",
")",
"->",
"\"HistogramBase\"",
":",
"if",
"include_frequencies",
":",
"frequencies",
"=",
"np",
".",
"copy",
"(",
"self",
".",
"frequencies",
")",
"missed",
"=",
"self",
"."... | Copy the histogram.
Parameters
----------
include_frequencies : If false, all frequencies are set to zero. | [
"Copy",
"the",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L534-L560 |
16,476 | janpipek/physt | physt/histogram_base.py | HistogramBase.to_dict | def to_dict(self) -> OrderedDict:
"""Dictionary with all data in the histogram.
This is used for export into various formats (e.g. JSON)
If a descendant class needs to update the dictionary in some way
(put some more information), override the _update_dict method.
"""
re... | python | def to_dict(self) -> OrderedDict:
"""Dictionary with all data in the histogram.
This is used for export into various formats (e.g. JSON)
If a descendant class needs to update the dictionary in some way
(put some more information), override the _update_dict method.
"""
re... | [
"def",
"to_dict",
"(",
"self",
")",
"->",
"OrderedDict",
":",
"result",
"=",
"OrderedDict",
"(",
")",
"result",
"[",
"\"histogram_type\"",
"]",
"=",
"type",
"(",
"self",
")",
".",
"__name__",
"result",
"[",
"\"binnings\"",
"]",
"=",
"[",
"binning",
".",
... | Dictionary with all data in the histogram.
This is used for export into various formats (e.g. JSON)
If a descendant class needs to update the dictionary in some way
(put some more information), override the _update_dict method. | [
"Dictionary",
"with",
"all",
"data",
"in",
"the",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L619-L638 |
16,477 | janpipek/physt | physt/histogram_base.py | HistogramBase._merge_meta_data | def _merge_meta_data(cls, first: "HistogramBase", second: "HistogramBase") -> dict:
"""Merge meta data of two histograms leaving only the equal values.
(Used in addition and subtraction)
"""
keys = set(first._meta_data.keys())
keys = keys.union(set(second._meta_data.keys()))
... | python | def _merge_meta_data(cls, first: "HistogramBase", second: "HistogramBase") -> dict:
"""Merge meta data of two histograms leaving only the equal values.
(Used in addition and subtraction)
"""
keys = set(first._meta_data.keys())
keys = keys.union(set(second._meta_data.keys()))
... | [
"def",
"_merge_meta_data",
"(",
"cls",
",",
"first",
":",
"\"HistogramBase\"",
",",
"second",
":",
"\"HistogramBase\"",
")",
"->",
"dict",
":",
"keys",
"=",
"set",
"(",
"first",
".",
"_meta_data",
".",
"keys",
"(",
")",
")",
"keys",
"=",
"keys",
".",
"... | Merge meta data of two histograms leaving only the equal values.
(Used in addition and subtraction) | [
"Merge",
"meta",
"data",
"of",
"two",
"histograms",
"leaving",
"only",
"the",
"equal",
"values",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L816-L825 |
16,478 | janpipek/physt | physt/histogram1d.py | Histogram1D.mean | def mean(self) -> Optional[float]:
"""Statistical mean of all values entered into histogram.
This number is precise, because we keep the necessary data
separate from bin contents.
"""
if self._stats: # TODO: should be true always?
if self.total > 0:
... | python | def mean(self) -> Optional[float]:
"""Statistical mean of all values entered into histogram.
This number is precise, because we keep the necessary data
separate from bin contents.
"""
if self._stats: # TODO: should be true always?
if self.total > 0:
... | [
"def",
"mean",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"if",
"self",
".",
"_stats",
":",
"# TODO: should be true always?",
"if",
"self",
".",
"total",
">",
"0",
":",
"return",
"self",
".",
"_stats",
"[",
"\"sum\"",
"]",
"/",
"self",... | Statistical mean of all values entered into histogram.
This number is precise, because we keep the necessary data
separate from bin contents. | [
"Statistical",
"mean",
"of",
"all",
"values",
"entered",
"into",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram1d.py#L208-L220 |
16,479 | janpipek/physt | physt/histogram1d.py | Histogram1D.std | def std(self) -> Optional[float]: #, ddof=0):
"""Standard deviation of all values entered into histogram.
This number is precise, because we keep the necessary data
separate from bin contents.
Returns
-------
float
"""
# TODO: Add DOF
if self._s... | python | def std(self) -> Optional[float]: #, ddof=0):
"""Standard deviation of all values entered into histogram.
This number is precise, because we keep the necessary data
separate from bin contents.
Returns
-------
float
"""
# TODO: Add DOF
if self._s... | [
"def",
"std",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"#, ddof=0):",
"# TODO: Add DOF",
"if",
"self",
".",
"_stats",
":",
"return",
"np",
".",
"sqrt",
"(",
"self",
".",
"variance",
"(",
")",
")",
"else",
":",
"return",
"None"
] | Standard deviation of all values entered into histogram.
This number is precise, because we keep the necessary data
separate from bin contents.
Returns
-------
float | [
"Standard",
"deviation",
"of",
"all",
"values",
"entered",
"into",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram1d.py#L222-L236 |
16,480 | janpipek/physt | physt/histogram1d.py | Histogram1D.variance | def variance(self) -> Optional[float]: #, ddof: int = 0) -> float:
"""Statistical variance of all values entered into histogram.
This number is precise, because we keep the necessary data
separate from bin contents.
Returns
-------
float
"""
# TODO: Add... | python | def variance(self) -> Optional[float]: #, ddof: int = 0) -> float:
"""Statistical variance of all values entered into histogram.
This number is precise, because we keep the necessary data
separate from bin contents.
Returns
-------
float
"""
# TODO: Add... | [
"def",
"variance",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"#, ddof: int = 0) -> float:",
"# TODO: Add DOF",
"# http://stats.stackexchange.com/questions/6534/how-do-i-calculate-a-weighted-standard-deviation-in-excel",
"if",
"self",
".",
"_stats",
":",
"if",
... | Statistical variance of all values entered into histogram.
This number is precise, because we keep the necessary data
separate from bin contents.
Returns
-------
float | [
"Statistical",
"variance",
"of",
"all",
"values",
"entered",
"into",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram1d.py#L238-L256 |
16,481 | janpipek/physt | physt/histogram1d.py | Histogram1D.find_bin | def find_bin(self, value):
"""Index of bin corresponding to a value.
Parameters
----------
value: float
Value to be searched for.
Returns
-------
int
index of bin to which value belongs
(-1=underflow, N=overflow, None=not foun... | python | def find_bin(self, value):
"""Index of bin corresponding to a value.
Parameters
----------
value: float
Value to be searched for.
Returns
-------
int
index of bin to which value belongs
(-1=underflow, N=overflow, None=not foun... | [
"def",
"find_bin",
"(",
"self",
",",
"value",
")",
":",
"ixbin",
"=",
"np",
".",
"searchsorted",
"(",
"self",
".",
"bin_left_edges",
",",
"value",
",",
"side",
"=",
"\"right\"",
")",
"if",
"ixbin",
"==",
"0",
":",
"return",
"-",
"1",
"elif",
"ixbin",... | Index of bin corresponding to a value.
Parameters
----------
value: float
Value to be searched for.
Returns
-------
int
index of bin to which value belongs
(-1=underflow, N=overflow, None=not found - inconsecutive) | [
"Index",
"of",
"bin",
"corresponding",
"to",
"a",
"value",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram1d.py#L342-L369 |
16,482 | janpipek/physt | physt/histogram1d.py | Histogram1D.fill | def fill(self, value, weight=1):
"""Update histogram with a new value.
Parameters
----------
value: float
Value to be added.
weight: float, optional
Weight assigned to the value.
Returns
-------
int
index of bin which ... | python | def fill(self, value, weight=1):
"""Update histogram with a new value.
Parameters
----------
value: float
Value to be added.
weight: float, optional
Weight assigned to the value.
Returns
-------
int
index of bin which ... | [
"def",
"fill",
"(",
"self",
",",
"value",
",",
"weight",
"=",
"1",
")",
":",
"self",
".",
"_coerce_dtype",
"(",
"type",
"(",
"weight",
")",
")",
"if",
"self",
".",
"_binning",
".",
"is_adaptive",
"(",
")",
":",
"map",
"=",
"self",
".",
"_binning",
... | Update histogram with a new value.
Parameters
----------
value: float
Value to be added.
weight: float, optional
Weight assigned to the value.
Returns
-------
int
index of bin which was incremented (-1=underflow, N=overflow, N... | [
"Update",
"histogram",
"with",
"a",
"new",
"value",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram1d.py#L371-L408 |
16,483 | janpipek/physt | physt/histogram1d.py | Histogram1D.fill_n | def fill_n(self, values, weights=None, dropna: bool = True):
"""Update histograms with a set of values.
Parameters
----------
values: array_like
weights: Optional[array_like]
drop_na: Optional[bool]
If true (default), all nan's are skipped.
"""
... | python | def fill_n(self, values, weights=None, dropna: bool = True):
"""Update histograms with a set of values.
Parameters
----------
values: array_like
weights: Optional[array_like]
drop_na: Optional[bool]
If true (default), all nan's are skipped.
"""
... | [
"def",
"fill_n",
"(",
"self",
",",
"values",
",",
"weights",
"=",
"None",
",",
"dropna",
":",
"bool",
"=",
"True",
")",
":",
"# TODO: Unify with HistogramBase",
"values",
"=",
"np",
".",
"asarray",
"(",
"values",
")",
"if",
"dropna",
":",
"values",
"=",
... | Update histograms with a set of values.
Parameters
----------
values: array_like
weights: Optional[array_like]
drop_na: Optional[bool]
If true (default), all nan's are skipped. | [
"Update",
"histograms",
"with",
"a",
"set",
"of",
"values",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram1d.py#L410-L441 |
16,484 | janpipek/physt | physt/histogram1d.py | Histogram1D.to_xarray | def to_xarray(self) -> "xarray.Dataset":
"""Convert to xarray.Dataset"""
import xarray as xr
data_vars = {
"frequencies": xr.DataArray(self.frequencies, dims="bin"),
"errors2": xr.DataArray(self.errors2, dims="bin"),
"bins": xr.DataArray(self.bins, dims=("bin"... | python | def to_xarray(self) -> "xarray.Dataset":
"""Convert to xarray.Dataset"""
import xarray as xr
data_vars = {
"frequencies": xr.DataArray(self.frequencies, dims="bin"),
"errors2": xr.DataArray(self.errors2, dims="bin"),
"bins": xr.DataArray(self.bins, dims=("bin"... | [
"def",
"to_xarray",
"(",
"self",
")",
"->",
"\"xarray.Dataset\"",
":",
"import",
"xarray",
"as",
"xr",
"data_vars",
"=",
"{",
"\"frequencies\"",
":",
"xr",
".",
"DataArray",
"(",
"self",
".",
"frequencies",
",",
"dims",
"=",
"\"bin\"",
")",
",",
"\"errors2... | Convert to xarray.Dataset | [
"Convert",
"to",
"xarray",
".",
"Dataset"
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram1d.py#L487-L504 |
16,485 | janpipek/physt | physt/histogram1d.py | Histogram1D.from_xarray | def from_xarray(cls, arr: "xarray.Dataset") -> "Histogram1D":
"""Convert form xarray.Dataset
Parameters
----------
arr: The data in xarray representation
"""
kwargs = {'frequencies': arr["frequencies"],
'binning': arr["bins"],
'errors2... | python | def from_xarray(cls, arr: "xarray.Dataset") -> "Histogram1D":
"""Convert form xarray.Dataset
Parameters
----------
arr: The data in xarray representation
"""
kwargs = {'frequencies': arr["frequencies"],
'binning': arr["bins"],
'errors2... | [
"def",
"from_xarray",
"(",
"cls",
",",
"arr",
":",
"\"xarray.Dataset\"",
")",
"->",
"\"Histogram1D\"",
":",
"kwargs",
"=",
"{",
"'frequencies'",
":",
"arr",
"[",
"\"frequencies\"",
"]",
",",
"'binning'",
":",
"arr",
"[",
"\"bins\"",
"]",
",",
"'errors2'",
... | Convert form xarray.Dataset
Parameters
----------
arr: The data in xarray representation | [
"Convert",
"form",
"xarray",
".",
"Dataset"
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram1d.py#L507-L521 |
16,486 | janpipek/physt | physt/plotting/__init__.py | set_default_backend | def set_default_backend(name: str):
"""Choose a default backend."""
global _default_backend
if name == "bokeh":
raise RuntimeError("Support for bokeh has been discontinued. At some point, we may return to support holoviews.")
if not name in backends:
raise RuntimeError("Backend {0} is no... | python | def set_default_backend(name: str):
"""Choose a default backend."""
global _default_backend
if name == "bokeh":
raise RuntimeError("Support for bokeh has been discontinued. At some point, we may return to support holoviews.")
if not name in backends:
raise RuntimeError("Backend {0} is no... | [
"def",
"set_default_backend",
"(",
"name",
":",
"str",
")",
":",
"global",
"_default_backend",
"if",
"name",
"==",
"\"bokeh\"",
":",
"raise",
"RuntimeError",
"(",
"\"Support for bokeh has been discontinued. At some point, we may return to support holoviews.\"",
")",
"if",
"... | Choose a default backend. | [
"Choose",
"a",
"default",
"backend",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/__init__.py#L139-L146 |
16,487 | janpipek/physt | physt/plotting/__init__.py | _get_backend | def _get_backend(name: str = None):
"""Get a plotting backend.
Tries to get it using the name - or the default one.
"""
if not backends:
raise RuntimeError("No plotting backend available. Please, install matplotlib (preferred) or bokeh (limited).")
if not name:
name = _default_backe... | python | def _get_backend(name: str = None):
"""Get a plotting backend.
Tries to get it using the name - or the default one.
"""
if not backends:
raise RuntimeError("No plotting backend available. Please, install matplotlib (preferred) or bokeh (limited).")
if not name:
name = _default_backe... | [
"def",
"_get_backend",
"(",
"name",
":",
"str",
"=",
"None",
")",
":",
"if",
"not",
"backends",
":",
"raise",
"RuntimeError",
"(",
"\"No plotting backend available. Please, install matplotlib (preferred) or bokeh (limited).\"",
")",
"if",
"not",
"name",
":",
"name",
"... | Get a plotting backend.
Tries to get it using the name - or the default one. | [
"Get",
"a",
"plotting",
"backend",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/__init__.py#L149-L163 |
16,488 | janpipek/physt | physt/plotting/__init__.py | plot | def plot(histogram: HistogramBase, kind: Optional[str] = None, backend: Optional[str] = None, **kwargs):
"""Universal plotting function.
All keyword arguments are passed to the plotting methods.
Parameters
----------
kind: Type of the plot (like "scatter", "line", ...), similar to pandas
"""
... | python | def plot(histogram: HistogramBase, kind: Optional[str] = None, backend: Optional[str] = None, **kwargs):
"""Universal plotting function.
All keyword arguments are passed to the plotting methods.
Parameters
----------
kind: Type of the plot (like "scatter", "line", ...), similar to pandas
"""
... | [
"def",
"plot",
"(",
"histogram",
":",
"HistogramBase",
",",
"kind",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"backend",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"backend_name",
",",
"backend",
"=",
... | Universal plotting function.
All keyword arguments are passed to the plotting methods.
Parameters
----------
kind: Type of the plot (like "scatter", "line", ...), similar to pandas | [
"Universal",
"plotting",
"function",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/__init__.py#L166-L187 |
16,489 | janpipek/physt | physt/plotting/vega.py | enable_inline_view | def enable_inline_view(f):
"""Decorator to enable in-line viewing in Python and saving to external file.
It adds several parameters to each decorated plotted function:
Parameters
----------
write_to: str (optional)
Path to write vega JSON/HTML to.
write_format: "auto" | "json" | "html"... | python | def enable_inline_view(f):
"""Decorator to enable in-line viewing in Python and saving to external file.
It adds several parameters to each decorated plotted function:
Parameters
----------
write_to: str (optional)
Path to write vega JSON/HTML to.
write_format: "auto" | "json" | "html"... | [
"def",
"enable_inline_view",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"hist",
",",
"write_to",
"=",
"None",
",",
"write_format",
"=",
"\"auto\"",
",",
"display",
"=",
"\"auto\"",
",",
"indent",
"=",
"2",
",",
"*",
"*",
... | Decorator to enable in-line viewing in Python and saving to external file.
It adds several parameters to each decorated plotted function:
Parameters
----------
write_to: str (optional)
Path to write vega JSON/HTML to.
write_format: "auto" | "json" | "html"
Whether to create a JSON ... | [
"Decorator",
"to",
"enable",
"in",
"-",
"line",
"viewing",
"in",
"Python",
"and",
"saving",
"to",
"external",
"file",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L102-L134 |
16,490 | janpipek/physt | physt/plotting/vega.py | write_vega | def write_vega(vega_data, *, title: Optional[str], write_to: str, write_format: str = "auto", indent: int = 2):
"""Write vega dictionary to an external file.
Parameters
----------
vega_data : Valid vega data as dictionary
write_to: Path to write vega JSON/HTML to.
write_format: "auto" | "json" ... | python | def write_vega(vega_data, *, title: Optional[str], write_to: str, write_format: str = "auto", indent: int = 2):
"""Write vega dictionary to an external file.
Parameters
----------
vega_data : Valid vega data as dictionary
write_to: Path to write vega JSON/HTML to.
write_format: "auto" | "json" ... | [
"def",
"write_vega",
"(",
"vega_data",
",",
"*",
",",
"title",
":",
"Optional",
"[",
"str",
"]",
",",
"write_to",
":",
"str",
",",
"write_format",
":",
"str",
"=",
"\"auto\"",
",",
"indent",
":",
"int",
"=",
"2",
")",
":",
"spec",
"=",
"json",
".",... | Write vega dictionary to an external file.
Parameters
----------
vega_data : Valid vega data as dictionary
write_to: Path to write vega JSON/HTML to.
write_format: "auto" | "json" | "html"
Whether to create a JSON data file or a full-fledged HTML page.
indent: Indentation of JSON | [
"Write",
"vega",
"dictionary",
"to",
"an",
"external",
"file",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L137-L156 |
16,491 | janpipek/physt | physt/plotting/vega.py | display_vega | def display_vega(vega_data: dict, display: bool = True) -> Union['Vega', dict]:
"""Optionally display vega dictionary.
Parameters
----------
vega_data : Valid vega data as dictionary
display: Whether to try in-line display in IPython
"""
if VEGA_IPYTHON_PLUGIN_ENABLED and display:
... | python | def display_vega(vega_data: dict, display: bool = True) -> Union['Vega', dict]:
"""Optionally display vega dictionary.
Parameters
----------
vega_data : Valid vega data as dictionary
display: Whether to try in-line display in IPython
"""
if VEGA_IPYTHON_PLUGIN_ENABLED and display:
... | [
"def",
"display_vega",
"(",
"vega_data",
":",
"dict",
",",
"display",
":",
"bool",
"=",
"True",
")",
"->",
"Union",
"[",
"'Vega'",
",",
"dict",
"]",
":",
"if",
"VEGA_IPYTHON_PLUGIN_ENABLED",
"and",
"display",
":",
"from",
"vega3",
"import",
"Vega",
"return... | Optionally display vega dictionary.
Parameters
----------
vega_data : Valid vega data as dictionary
display: Whether to try in-line display in IPython | [
"Optionally",
"display",
"vega",
"dictionary",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L159-L171 |
16,492 | janpipek/physt | physt/plotting/vega.py | bar | def bar(h1: Histogram1D, **kwargs) -> dict:
"""Bar plot of 1D histogram.
Parameters
----------
lw : float
Width of the line between bars
alpha : float
Opacity of the bars
hover_alpha: float
Opacity of the bars when hover on
"""
# TODO: Enable collections
# TO... | python | def bar(h1: Histogram1D, **kwargs) -> dict:
"""Bar plot of 1D histogram.
Parameters
----------
lw : float
Width of the line between bars
alpha : float
Opacity of the bars
hover_alpha: float
Opacity of the bars when hover on
"""
# TODO: Enable collections
# TO... | [
"def",
"bar",
"(",
"h1",
":",
"Histogram1D",
",",
"*",
"*",
"kwargs",
")",
"->",
"dict",
":",
"# TODO: Enable collections",
"# TODO: Enable legend",
"vega",
"=",
"_create_figure",
"(",
"kwargs",
")",
"_add_title",
"(",
"h1",
",",
"vega",
",",
"kwargs",
")",
... | Bar plot of 1D histogram.
Parameters
----------
lw : float
Width of the line between bars
alpha : float
Opacity of the bars
hover_alpha: float
Opacity of the bars when hover on | [
"Bar",
"plot",
"of",
"1D",
"histogram",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L175-L237 |
16,493 | janpipek/physt | physt/plotting/vega.py | scatter | def scatter(h1: Histogram1D, **kwargs) -> dict:
"""Scatter plot of 1D histogram values.
Points are horizontally placed in bin centers.
Parameters
----------
shape : str
"""
shape = kwargs.pop("shape", DEFAULT_SCATTER_SHAPE)
# size = kwargs.pop("size", DEFAULT_SCATTER_SIZE)
mark_te... | python | def scatter(h1: Histogram1D, **kwargs) -> dict:
"""Scatter plot of 1D histogram values.
Points are horizontally placed in bin centers.
Parameters
----------
shape : str
"""
shape = kwargs.pop("shape", DEFAULT_SCATTER_SHAPE)
# size = kwargs.pop("size", DEFAULT_SCATTER_SIZE)
mark_te... | [
"def",
"scatter",
"(",
"h1",
":",
"Histogram1D",
",",
"*",
"*",
"kwargs",
")",
"->",
"dict",
":",
"shape",
"=",
"kwargs",
".",
"pop",
"(",
"\"shape\"",
",",
"DEFAULT_SCATTER_SHAPE",
")",
"# size = kwargs.pop(\"size\", DEFAULT_SCATTER_SIZE)",
"mark_template",
"=",
... | Scatter plot of 1D histogram values.
Points are horizontally placed in bin centers.
Parameters
----------
shape : str | [
"Scatter",
"plot",
"of",
"1D",
"histogram",
"values",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L244-L270 |
16,494 | janpipek/physt | physt/plotting/vega.py | line | def line(h1: Histogram1D, **kwargs) -> dict:
"""Line plot of 1D histogram values.
Points are horizontally placed in bin centers.
Parameters
----------
h1 : physt.histogram1d.Histogram1D
Dimensionality of histogram for which it is applicable
"""
lw = kwargs.pop("lw", DEFAULT_STROKE... | python | def line(h1: Histogram1D, **kwargs) -> dict:
"""Line plot of 1D histogram values.
Points are horizontally placed in bin centers.
Parameters
----------
h1 : physt.histogram1d.Histogram1D
Dimensionality of histogram for which it is applicable
"""
lw = kwargs.pop("lw", DEFAULT_STROKE... | [
"def",
"line",
"(",
"h1",
":",
"Histogram1D",
",",
"*",
"*",
"kwargs",
")",
"->",
"dict",
":",
"lw",
"=",
"kwargs",
".",
"pop",
"(",
"\"lw\"",
",",
"DEFAULT_STROKE_WIDTH",
")",
"mark_template",
"=",
"[",
"{",
"\"type\"",
":",
"\"line\"",
",",
"\"encode... | Line plot of 1D histogram values.
Points are horizontally placed in bin centers.
Parameters
----------
h1 : physt.histogram1d.Histogram1D
Dimensionality of histogram for which it is applicable | [
"Line",
"plot",
"of",
"1D",
"histogram",
"values",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L276-L302 |
16,495 | janpipek/physt | physt/plotting/vega.py | _create_figure | def _create_figure(kwargs: Mapping[str, Any]) -> dict:
"""Create basic dictionary object with figure properties."""
return {
"$schema": "https://vega.github.io/schema/vega/v3.json",
"width": kwargs.pop("width", DEFAULT_WIDTH),
"height": kwargs.pop("height", DEFAULT_HEIGHT),
"padd... | python | def _create_figure(kwargs: Mapping[str, Any]) -> dict:
"""Create basic dictionary object with figure properties."""
return {
"$schema": "https://vega.github.io/schema/vega/v3.json",
"width": kwargs.pop("width", DEFAULT_WIDTH),
"height": kwargs.pop("height", DEFAULT_HEIGHT),
"padd... | [
"def",
"_create_figure",
"(",
"kwargs",
":",
"Mapping",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"dict",
":",
"return",
"{",
"\"$schema\"",
":",
"\"https://vega.github.io/schema/vega/v3.json\"",
",",
"\"width\"",
":",
"kwargs",
".",
"pop",
"(",
"\"width\"",
","... | Create basic dictionary object with figure properties. | [
"Create",
"basic",
"dictionary",
"object",
"with",
"figure",
"properties",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L551-L558 |
16,496 | janpipek/physt | physt/plotting/vega.py | _create_scales | def _create_scales(hist: HistogramBase, vega: dict, kwargs: dict):
"""Find proper scales for axes."""
if hist.ndim == 1:
bins0 = hist.bins.astype(float)
else:
bins0 = hist.bins[0].astype(float)
xlim = kwargs.pop("xlim", "auto")
ylim = kwargs.pop("ylim", "auto")
if xlim is "auto... | python | def _create_scales(hist: HistogramBase, vega: dict, kwargs: dict):
"""Find proper scales for axes."""
if hist.ndim == 1:
bins0 = hist.bins.astype(float)
else:
bins0 = hist.bins[0].astype(float)
xlim = kwargs.pop("xlim", "auto")
ylim = kwargs.pop("ylim", "auto")
if xlim is "auto... | [
"def",
"_create_scales",
"(",
"hist",
":",
"HistogramBase",
",",
"vega",
":",
"dict",
",",
"kwargs",
":",
"dict",
")",
":",
"if",
"hist",
".",
"ndim",
"==",
"1",
":",
"bins0",
"=",
"hist",
".",
"bins",
".",
"astype",
"(",
"float",
")",
"else",
":",... | Find proper scales for axes. | [
"Find",
"proper",
"scales",
"for",
"axes",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L568-L613 |
16,497 | janpipek/physt | physt/plotting/vega.py | _create_axes | def _create_axes(hist: HistogramBase, vega: dict, kwargs: dict):
"""Create axes in the figure."""
xlabel = kwargs.pop("xlabel", hist.axis_names[0])
ylabel = kwargs.pop("ylabel", hist.axis_names[1] if len(hist.axis_names) >= 2 else None)
vega["axes"] = [
{"orient": "bottom", "scale": "xscale", "t... | python | def _create_axes(hist: HistogramBase, vega: dict, kwargs: dict):
"""Create axes in the figure."""
xlabel = kwargs.pop("xlabel", hist.axis_names[0])
ylabel = kwargs.pop("ylabel", hist.axis_names[1] if len(hist.axis_names) >= 2 else None)
vega["axes"] = [
{"orient": "bottom", "scale": "xscale", "t... | [
"def",
"_create_axes",
"(",
"hist",
":",
"HistogramBase",
",",
"vega",
":",
"dict",
",",
"kwargs",
":",
"dict",
")",
":",
"xlabel",
"=",
"kwargs",
".",
"pop",
"(",
"\"xlabel\"",
",",
"hist",
".",
"axis_names",
"[",
"0",
"]",
")",
"ylabel",
"=",
"kwar... | Create axes in the figure. | [
"Create",
"axes",
"in",
"the",
"figure",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L673-L680 |
16,498 | janpipek/physt | physt/plotting/vega.py | _create_tooltips | def _create_tooltips(hist: Histogram1D, vega: dict, kwargs: dict):
"""In one-dimensional plots, show values above the value on hover."""
if kwargs.pop("tooltips", False):
vega["signals"] = vega.get("signals", [])
vega["signals"].append({
"name": "tooltip",
"value": {},
... | python | def _create_tooltips(hist: Histogram1D, vega: dict, kwargs: dict):
"""In one-dimensional plots, show values above the value on hover."""
if kwargs.pop("tooltips", False):
vega["signals"] = vega.get("signals", [])
vega["signals"].append({
"name": "tooltip",
"value": {},
... | [
"def",
"_create_tooltips",
"(",
"hist",
":",
"Histogram1D",
",",
"vega",
":",
"dict",
",",
"kwargs",
":",
"dict",
")",
":",
"if",
"kwargs",
".",
"pop",
"(",
"\"tooltips\"",
",",
"False",
")",
":",
"vega",
"[",
"\"signals\"",
"]",
"=",
"vega",
".",
"g... | In one-dimensional plots, show values above the value on hover. | [
"In",
"one",
"-",
"dimensional",
"plots",
"show",
"values",
"above",
"the",
"value",
"on",
"hover",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L683-L718 |
16,499 | janpipek/physt | physt/plotting/vega.py | _add_title | def _add_title(hist: HistogramBase, vega: dict, kwargs: dict):
"""Display plot title if available."""
title = kwargs.pop("title", hist.title)
if title:
vega["title"] = {
"text": title
} | python | def _add_title(hist: HistogramBase, vega: dict, kwargs: dict):
"""Display plot title if available."""
title = kwargs.pop("title", hist.title)
if title:
vega["title"] = {
"text": title
} | [
"def",
"_add_title",
"(",
"hist",
":",
"HistogramBase",
",",
"vega",
":",
"dict",
",",
"kwargs",
":",
"dict",
")",
":",
"title",
"=",
"kwargs",
".",
"pop",
"(",
"\"title\"",
",",
"hist",
".",
"title",
")",
"if",
"title",
":",
"vega",
"[",
"\"title\""... | Display plot title if available. | [
"Display",
"plot",
"title",
"if",
"available",
"."
] | 6dd441b073514e7728235f50b2352d56aacf38d4 | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L721-L727 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.