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
partition
stringclasses
1 value
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
janpipek/physt
physt/special.py
_prepare_data
def _prepare_data(data, transformed, klass, *args, **kwargs): """Transform data for binning. Returns ------- np.ndarray """ # TODO: Maybe include in the class itself? data = np.asarray(data) if not transformed: data = klass.transform(data) dropna = kwargs.get("dropna", Fals...
python
def _prepare_data(data, transformed, klass, *args, **kwargs): """Transform data for binning. Returns ------- np.ndarray """ # TODO: Maybe include in the class itself? data = np.asarray(data) if not transformed: data = klass.transform(data) dropna = kwargs.get("dropna", Fals...
[ "def", "_prepare_data", "(", "data", ",", "transformed", ",", "klass", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# TODO: Maybe include in the class itself?", "data", "=", "np", ".", "asarray", "(", "data", ")", "if", "not", "transformed", ":", ...
Transform data for binning. Returns ------- np.ndarray
[ "Transform", "data", "for", "binning", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/special.py#L331-L345
train
janpipek/physt
physt/special.py
polar_histogram
def polar_histogram(xdata, ydata, radial_bins="numpy", phi_bins=16, transformed=False, *args, **kwargs): """Facade construction function for the PolarHistogram. Parameters ---------- transformed : bool phi_range : Optional[tuple] range """ dropna = kwargs.pop("dropna...
python
def polar_histogram(xdata, ydata, radial_bins="numpy", phi_bins=16, transformed=False, *args, **kwargs): """Facade construction function for the PolarHistogram. Parameters ---------- transformed : bool phi_range : Optional[tuple] range """ dropna = kwargs.pop("dropna...
[ "def", "polar_histogram", "(", "xdata", ",", "ydata", ",", "radial_bins", "=", "\"numpy\"", ",", "phi_bins", "=", "16", ",", "transformed", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "dropna", "=", "kwargs", ".", "pop", "(", "...
Facade construction function for the PolarHistogram. Parameters ---------- transformed : bool phi_range : Optional[tuple] range
[ "Facade", "construction", "function", "for", "the", "PolarHistogram", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/special.py#L348-L377
train
janpipek/physt
physt/special.py
spherical_histogram
def spherical_histogram(data=None, radial_bins="numpy", theta_bins=16, phi_bins=16, transformed=False, *args, **kwargs): """Facade construction function for the SphericalHistogram. """ dropna = kwargs.pop("dropna", True) data = _prepare_data(data, transformed=transformed, klass=SphericalHistogram, dro...
python
def spherical_histogram(data=None, radial_bins="numpy", theta_bins=16, phi_bins=16, transformed=False, *args, **kwargs): """Facade construction function for the SphericalHistogram. """ dropna = kwargs.pop("dropna", True) data = _prepare_data(data, transformed=transformed, klass=SphericalHistogram, dro...
[ "def", "spherical_histogram", "(", "data", "=", "None", ",", "radial_bins", "=", "\"numpy\"", ",", "theta_bins", "=", "16", ",", "phi_bins", "=", "16", ",", "transformed", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "dropna", "="...
Facade construction function for the SphericalHistogram.
[ "Facade", "construction", "function", "for", "the", "SphericalHistogram", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/special.py#L380-L412
train
janpipek/physt
physt/special.py
cylindrical_histogram
def cylindrical_histogram(data=None, rho_bins="numpy", phi_bins=16, z_bins="numpy", transformed=False, *args, **kwargs): """Facade construction function for the CylindricalHistogram. """ dropna = kwargs.pop("dropna", True) data = _prepare_data(data, transformed=transformed, klass=CylindricalHistogram,...
python
def cylindrical_histogram(data=None, rho_bins="numpy", phi_bins=16, z_bins="numpy", transformed=False, *args, **kwargs): """Facade construction function for the CylindricalHistogram. """ dropna = kwargs.pop("dropna", True) data = _prepare_data(data, transformed=transformed, klass=CylindricalHistogram,...
[ "def", "cylindrical_histogram", "(", "data", "=", "None", ",", "rho_bins", "=", "\"numpy\"", ",", "phi_bins", "=", "16", ",", "z_bins", "=", "\"numpy\"", ",", "transformed", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "dropna", "...
Facade construction function for the CylindricalHistogram.
[ "Facade", "construction", "function", "for", "the", "CylindricalHistogram", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/special.py#L415-L439
train
janpipek/physt
physt/special.py
TransformedHistogramMixin.projection
def projection(self, *axes, **kwargs): """Projection to lower-dimensional histogram. The inheriting class should implement the _projection_class_map class attribute to suggest class for the projection. If the arguments don't match any of the map keys, HistogramND is used. ...
python
def projection(self, *axes, **kwargs): """Projection to lower-dimensional histogram. The inheriting class should implement the _projection_class_map class attribute to suggest class for the projection. If the arguments don't match any of the map keys, HistogramND is used. ...
[ "def", "projection", "(", "self", ",", "*", "axes", ",", "*", "*", "kwargs", ")", ":", "axes", ",", "_", "=", "self", ".", "_get_projection_axes", "(", "*", "axes", ")", "axes", "=", "tuple", "(", "sorted", "(", "axes", ")", ")", "if", "axes", "i...
Projection to lower-dimensional histogram. The inheriting class should implement the _projection_class_map class attribute to suggest class for the projection. If the arguments don't match any of the map keys, HistogramND is used.
[ "Projection", "to", "lower", "-", "dimensional", "histogram", ".", "The", "inheriting", "class", "should", "implement", "the", "_projection_class_map", "class", "attribute", "to", "suggest", "class", "for", "the", "projection", ".", "If", "the", "arguments", "don"...
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/special.py#L86-L99
train
janpipek/physt
physt/plotting/plotly.py
enable_collection
def enable_collection(f): """Call the wrapped function with a HistogramCollection as argument.""" @wraps(f) def new_f(h: AbstractHistogram1D, **kwargs): from physt.histogram_collection import HistogramCollection if isinstance(h, HistogramCollection): return f(h, **kwargs) ...
python
def enable_collection(f): """Call the wrapped function with a HistogramCollection as argument.""" @wraps(f) def new_f(h: AbstractHistogram1D, **kwargs): from physt.histogram_collection import HistogramCollection if isinstance(h, HistogramCollection): return f(h, **kwargs) ...
[ "def", "enable_collection", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "new_f", "(", "h", ":", "AbstractHistogram1D", ",", "*", "*", "kwargs", ")", ":", "from", "physt", ".", "histogram_collection", "import", "HistogramCollection", "if", "isin...
Call the wrapped function with a HistogramCollection as argument.
[ "Call", "the", "wrapped", "function", "with", "a", "HistogramCollection", "as", "argument", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/plotly.py#L80-L89
train
janpipek/physt
physt/plotting/plotly.py
bar
def bar(h: Histogram2D, *, barmode: str = DEFAULT_BARMODE, alpha: float = DEFAULT_ALPHA, **kwargs): """Bar plot. Parameters ---------- alpha: Opacity (0.0 - 1.0) barmode : "overlay" | "group" | "stack" """ get_data_kwargs = pop_many(kwargs, "density", "cumulative", "...
python
def bar(h: Histogram2D, *, barmode: str = DEFAULT_BARMODE, alpha: float = DEFAULT_ALPHA, **kwargs): """Bar plot. Parameters ---------- alpha: Opacity (0.0 - 1.0) barmode : "overlay" | "group" | "stack" """ get_data_kwargs = pop_many(kwargs, "density", "cumulative", "...
[ "def", "bar", "(", "h", ":", "Histogram2D", ",", "*", ",", "barmode", ":", "str", "=", "DEFAULT_BARMODE", ",", "alpha", ":", "float", "=", "DEFAULT_ALPHA", ",", "*", "*", "kwargs", ")", ":", "get_data_kwargs", "=", "pop_many", "(", "kwargs", ",", "\"de...
Bar plot. Parameters ---------- alpha: Opacity (0.0 - 1.0) barmode : "overlay" | "group" | "stack"
[ "Bar", "plot", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/plotly.py#L143-L169
train
janpipek/physt
physt/plotting/folium.py
_bins_to_json
def _bins_to_json(h2): """Create GeoJSON representation of histogram bins Parameters ---------- h2: physt.histogram_nd.Histogram2D A histogram of coordinates (in degrees) Returns ------- geo_json : dict """ south = h2.get_bin_left_edges(0) north = h2.get_bin_right_edges...
python
def _bins_to_json(h2): """Create GeoJSON representation of histogram bins Parameters ---------- h2: physt.histogram_nd.Histogram2D A histogram of coordinates (in degrees) Returns ------- geo_json : dict """ south = h2.get_bin_left_edges(0) north = h2.get_bin_right_edges...
[ "def", "_bins_to_json", "(", "h2", ")", ":", "south", "=", "h2", ".", "get_bin_left_edges", "(", "0", ")", "north", "=", "h2", ".", "get_bin_right_edges", "(", "0", ")", "west", "=", "h2", ".", "get_bin_left_edges", "(", "1", ")", "east", "=", "h2", ...
Create GeoJSON representation of histogram bins Parameters ---------- h2: physt.histogram_nd.Histogram2D A histogram of coordinates (in degrees) Returns ------- geo_json : dict
[ "Create", "GeoJSON", "representation", "of", "histogram", "bins" ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/folium.py#L16-L54
train
janpipek/physt
physt/plotting/folium.py
geo_map
def geo_map(h2, map=None, tiles='stamenterrain', cmap="wk", alpha=0.5, lw=1, fit_bounds=None, layer_name=None): """Show rectangular grid over a map. Parameters ---------- h2: physt.histogram_nd.Histogram2D A histogram of coordinates (in degrees: latitude, longitude) map : folium.folium.Map ...
python
def geo_map(h2, map=None, tiles='stamenterrain', cmap="wk", alpha=0.5, lw=1, fit_bounds=None, layer_name=None): """Show rectangular grid over a map. Parameters ---------- h2: physt.histogram_nd.Histogram2D A histogram of coordinates (in degrees: latitude, longitude) map : folium.folium.Map ...
[ "def", "geo_map", "(", "h2", ",", "map", "=", "None", ",", "tiles", "=", "'stamenterrain'", ",", "cmap", "=", "\"wk\"", ",", "alpha", "=", "0.5", ",", "lw", "=", "1", ",", "fit_bounds", "=", "None", ",", "layer_name", "=", "None", ")", ":", "if", ...
Show rectangular grid over a map. Parameters ---------- h2: physt.histogram_nd.Histogram2D A histogram of coordinates (in degrees: latitude, longitude) map : folium.folium.Map Returns ------- map : folium.folium.Map
[ "Show", "rectangular", "grid", "over", "a", "map", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/folium.py#L57-L110
train
janpipek/physt
physt/compat/geant4.py
load_csv
def load_csv(path): """Loads a histogram as output from Geant4 analysis tools in CSV format. Parameters ---------- path: str Path to the CSV file Returns ------- physt.histogram1d.Histogram1D or physt.histogram_nd.Histogram2D """ meta = [] data = [] with codecs.open...
python
def load_csv(path): """Loads a histogram as output from Geant4 analysis tools in CSV format. Parameters ---------- path: str Path to the CSV file Returns ------- physt.histogram1d.Histogram1D or physt.histogram_nd.Histogram2D """ meta = [] data = [] with codecs.open...
[ "def", "load_csv", "(", "path", ")", ":", "meta", "=", "[", "]", "data", "=", "[", "]", "with", "codecs", ".", "open", "(", "path", ",", "encoding", "=", "\"ASCII\"", ")", "as", "in_file", ":", "for", "line", "in", "in_file", ":", "if", "line", "...
Loads a histogram as output from Geant4 analysis tools in CSV format. Parameters ---------- path: str Path to the CSV file Returns ------- physt.histogram1d.Histogram1D or physt.histogram_nd.Histogram2D
[ "Loads", "a", "histogram", "as", "output", "from", "Geant4", "analysis", "tools", "in", "CSV", "format", "." ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/compat/geant4.py#L11-L40
train
janpipek/physt
physt/compat/geant4.py
_get
def _get(pseudodict, key, single=True): """Helper method for getting values from "multi-dict"s""" matches = [item[1] for item in pseudodict if item[0] == key] if single: return matches[0] else: return matches
python
def _get(pseudodict, key, single=True): """Helper method for getting values from "multi-dict"s""" matches = [item[1] for item in pseudodict if item[0] == key] if single: return matches[0] else: return matches
[ "def", "_get", "(", "pseudodict", ",", "key", ",", "single", "=", "True", ")", ":", "matches", "=", "[", "item", "[", "1", "]", "for", "item", "in", "pseudodict", "if", "item", "[", "0", "]", "==", "key", "]", "if", "single", ":", "return", "matc...
Helper method for getting values from "multi-dict"s
[ "Helper", "method", "for", "getting", "values", "from", "multi", "-", "dict", "s" ]
6dd441b073514e7728235f50b2352d56aacf38d4
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/compat/geant4.py#L43-L49
train
openid/python-openid
openid/yadis/xrires.py
ProxyResolver.queryURL
def queryURL(self, xri, service_type=None): """Build a URL to query the proxy resolver. @param xri: An XRI to resolve. @type xri: unicode @param service_type: The service type to resolve, if you desire service endpoint selection. A service type is a URI. @type serv...
python
def queryURL(self, xri, service_type=None): """Build a URL to query the proxy resolver. @param xri: An XRI to resolve. @type xri: unicode @param service_type: The service type to resolve, if you desire service endpoint selection. A service type is a URI. @type serv...
[ "def", "queryURL", "(", "self", ",", "xri", ",", "service_type", "=", "None", ")", ":", "# Trim off the xri:// prefix. The proxy resolver didn't accept it", "# when this code was written, but that may (or may not) change for", "# XRI Resolution 2.0 Working Draft 11.", "qxri", "=", ...
Build a URL to query the proxy resolver. @param xri: An XRI to resolve. @type xri: unicode @param service_type: The service type to resolve, if you desire service endpoint selection. A service type is a URI. @type service_type: str @returns: a URL @returnt...
[ "Build", "a", "URL", "to", "query", "the", "proxy", "resolver", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/xrires.py#L20-L51
train
openid/python-openid
openid/yadis/xrires.py
ProxyResolver.query
def query(self, xri, service_types): """Resolve some services for an XRI. Note: I don't implement any service endpoint selection beyond what the resolver I'm querying does, so the Services I return may well include Services that were not of the types you asked for. May raise fe...
python
def query(self, xri, service_types): """Resolve some services for an XRI. Note: I don't implement any service endpoint selection beyond what the resolver I'm querying does, so the Services I return may well include Services that were not of the types you asked for. May raise fe...
[ "def", "query", "(", "self", ",", "xri", ",", "service_types", ")", ":", "# FIXME: No test coverage!", "services", "=", "[", "]", "# Make a seperate request to the proxy resolver for each service", "# type, as, if it is following Refs, it could return a different", "# XRDS for each...
Resolve some services for an XRI. Note: I don't implement any service endpoint selection beyond what the resolver I'm querying does, so the Services I return may well include Services that were not of the types you asked for. May raise fetchers.HTTPFetchingError or L{etxrd.XRDSError} i...
[ "Resolve", "some", "services", "for", "an", "XRI", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/xrires.py#L54-L97
train
openid/python-openid
openid/yadis/accept.py
generateAcceptHeader
def generateAcceptHeader(*elements): """Generate an accept header value [str or (str, float)] -> str """ parts = [] for element in elements: if type(element) is str: qs = "1.0" mtype = element else: mtype, q = element q = float(q) ...
python
def generateAcceptHeader(*elements): """Generate an accept header value [str or (str, float)] -> str """ parts = [] for element in elements: if type(element) is str: qs = "1.0" mtype = element else: mtype, q = element q = float(q) ...
[ "def", "generateAcceptHeader", "(", "*", "elements", ")", ":", "parts", "=", "[", "]", "for", "element", "in", "elements", ":", "if", "type", "(", "element", ")", "is", "str", ":", "qs", "=", "\"1.0\"", "mtype", "=", "element", "else", ":", "mtype", ...
Generate an accept header value [str or (str, float)] -> str
[ "Generate", "an", "accept", "header", "value" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/accept.py#L5-L33
train
openid/python-openid
openid/yadis/accept.py
parseAcceptHeader
def parseAcceptHeader(value): """Parse an accept header, ignoring any accept-extensions returns a list of tuples containing main MIME type, MIME subtype, and quality markdown. str -> [(str, str, float)] """ chunks = [chunk.strip() for chunk in value.split(',')] accept = [] for chunk in...
python
def parseAcceptHeader(value): """Parse an accept header, ignoring any accept-extensions returns a list of tuples containing main MIME type, MIME subtype, and quality markdown. str -> [(str, str, float)] """ chunks = [chunk.strip() for chunk in value.split(',')] accept = [] for chunk in...
[ "def", "parseAcceptHeader", "(", "value", ")", ":", "chunks", "=", "[", "chunk", ".", "strip", "(", ")", "for", "chunk", "in", "value", ".", "split", "(", "','", ")", "]", "accept", "=", "[", "]", "for", "chunk", "in", "chunks", ":", "parts", "=", ...
Parse an accept header, ignoring any accept-extensions returns a list of tuples containing main MIME type, MIME subtype, and quality markdown. str -> [(str, str, float)]
[ "Parse", "an", "accept", "header", "ignoring", "any", "accept", "-", "extensions" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/accept.py#L35-L72
train
openid/python-openid
openid/yadis/accept.py
getAcceptable
def getAcceptable(accept_header, have_types): """Parse the accept header and return a list of available types in preferred order. If a type is unacceptable, it will not be in the resulting list. This is a convenience wrapper around matchTypes and parseAcceptHeader. (str, [str]) -> [str] ""...
python
def getAcceptable(accept_header, have_types): """Parse the accept header and return a list of available types in preferred order. If a type is unacceptable, it will not be in the resulting list. This is a convenience wrapper around matchTypes and parseAcceptHeader. (str, [str]) -> [str] ""...
[ "def", "getAcceptable", "(", "accept_header", ",", "have_types", ")", ":", "accepted", "=", "parseAcceptHeader", "(", "accept_header", ")", "preferred", "=", "matchTypes", "(", "accepted", ",", "have_types", ")", "return", "[", "mtype", "for", "(", "mtype", ",...
Parse the accept header and return a list of available types in preferred order. If a type is unacceptable, it will not be in the resulting list. This is a convenience wrapper around matchTypes and parseAcceptHeader. (str, [str]) -> [str]
[ "Parse", "the", "accept", "header", "and", "return", "a", "list", "of", "available", "types", "in", "preferred", "order", ".", "If", "a", "type", "is", "unacceptable", "it", "will", "not", "be", "in", "the", "resulting", "list", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/accept.py#L121-L133
train
openid/python-openid
openid/message.py
Message.fromPostArgs
def fromPostArgs(cls, args): """Construct a Message containing a set of POST arguments. """ self = cls() # Partition into "openid." args and bare args openid_args = {} for key, value in args.items(): if isinstance(value, list): raise TypeErro...
python
def fromPostArgs(cls, args): """Construct a Message containing a set of POST arguments. """ self = cls() # Partition into "openid." args and bare args openid_args = {} for key, value in args.items(): if isinstance(value, list): raise TypeErro...
[ "def", "fromPostArgs", "(", "cls", ",", "args", ")", ":", "self", "=", "cls", "(", ")", "# Partition into \"openid.\" args and bare args", "openid_args", "=", "{", "}", "for", "key", ",", "value", "in", "args", ".", "items", "(", ")", ":", "if", "isinstanc...
Construct a Message containing a set of POST arguments.
[ "Construct", "a", "Message", "containing", "a", "set", "of", "POST", "arguments", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/message.py#L143-L169
train
openid/python-openid
openid/message.py
Message.getKey
def getKey(self, namespace, ns_key): """Get the key for a particular namespaced argument""" namespace = self._fixNS(namespace) if namespace == BARE_NS: return ns_key ns_alias = self.namespaces.getAlias(namespace) # No alias is defined, so no key can exist if...
python
def getKey(self, namespace, ns_key): """Get the key for a particular namespaced argument""" namespace = self._fixNS(namespace) if namespace == BARE_NS: return ns_key ns_alias = self.namespaces.getAlias(namespace) # No alias is defined, so no key can exist if...
[ "def", "getKey", "(", "self", ",", "namespace", ",", "ns_key", ")", ":", "namespace", "=", "self", ".", "_fixNS", "(", "namespace", ")", "if", "namespace", "==", "BARE_NS", ":", "return", "ns_key", "ns_alias", "=", "self", ".", "namespaces", ".", "getAli...
Get the key for a particular namespaced argument
[ "Get", "the", "key", "for", "a", "particular", "namespaced", "argument" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/message.py#L402-L419
train
openid/python-openid
openid/message.py
Message.getArg
def getArg(self, namespace, key, default=None): """Get a value for a namespaced key. @param namespace: The namespace in the message for this key @type namespace: str @param key: The key to get within this namespace @type key: str @param default: The value to use if thi...
python
def getArg(self, namespace, key, default=None): """Get a value for a namespaced key. @param namespace: The namespace in the message for this key @type namespace: str @param key: The key to get within this namespace @type key: str @param default: The value to use if thi...
[ "def", "getArg", "(", "self", ",", "namespace", ",", "key", ",", "default", "=", "None", ")", ":", "namespace", "=", "self", ".", "_fixNS", "(", "namespace", ")", "args_key", "=", "(", "namespace", ",", "key", ")", "try", ":", "return", "self", ".", ...
Get a value for a namespaced key. @param namespace: The namespace in the message for this key @type namespace: str @param key: The key to get within this namespace @type key: str @param default: The value to use if this key is absent from this message. Using the sp...
[ "Get", "a", "value", "for", "a", "namespaced", "key", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/message.py#L421-L448
train
openid/python-openid
openid/message.py
NamespaceMap.add
def add(self, namespace_uri): """Add this namespace URI to the mapping, without caring what alias it ends up with""" # See if this namespace is already mapped to an alias alias = self.namespace_to_alias.get(namespace_uri) if alias is not None: return alias # ...
python
def add(self, namespace_uri): """Add this namespace URI to the mapping, without caring what alias it ends up with""" # See if this namespace is already mapped to an alias alias = self.namespace_to_alias.get(namespace_uri) if alias is not None: return alias # ...
[ "def", "add", "(", "self", ",", "namespace_uri", ")", ":", "# See if this namespace is already mapped to an alias", "alias", "=", "self", ".", "namespace_to_alias", ".", "get", "(", "namespace_uri", ")", "if", "alias", "is", "not", "None", ":", "return", "alias", ...
Add this namespace URI to the mapping, without caring what alias it ends up with
[ "Add", "this", "namespace", "URI", "to", "the", "mapping", "without", "caring", "what", "alias", "it", "ends", "up", "with" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/message.py#L604-L623
train
openid/python-openid
openid/yadis/parsehtml.py
findHTMLMeta
def findHTMLMeta(stream): """Look for a meta http-equiv tag with the YADIS header name. @param stream: Source of the html text @type stream: Object that implements a read() method that works like file.read @return: The URI from which to fetch the XRDS document @rtype: str @raises Meta...
python
def findHTMLMeta(stream): """Look for a meta http-equiv tag with the YADIS header name. @param stream: Source of the html text @type stream: Object that implements a read() method that works like file.read @return: The URI from which to fetch the XRDS document @rtype: str @raises Meta...
[ "def", "findHTMLMeta", "(", "stream", ")", ":", "parser", "=", "YadisHTMLParser", "(", ")", "chunks", "=", "[", "]", "while", "1", ":", "chunk", "=", "stream", ".", "read", "(", "CHUNK_SIZE", ")", "if", "not", "chunk", ":", "# End of file", "break", "c...
Look for a meta http-equiv tag with the YADIS header name. @param stream: Source of the html text @type stream: Object that implements a read() method that works like file.read @return: The URI from which to fetch the XRDS document @rtype: str @raises MetaNotFound: raised with the content...
[ "Look", "for", "a", "meta", "http", "-", "equiv", "tag", "with", "the", "YADIS", "header", "name", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/parsehtml.py#L158-L197
train
openid/python-openid
openid/extensions/ax.py
toTypeURIs
def toTypeURIs(namespace_map, alias_list_s): """Given a namespace mapping and a string containing a comma-separated list of namespace aliases, return a list of type URIs that correspond to those aliases. @param namespace_map: The mapping from namespace URI to alias @type namespace_map: openid.messa...
python
def toTypeURIs(namespace_map, alias_list_s): """Given a namespace mapping and a string containing a comma-separated list of namespace aliases, return a list of type URIs that correspond to those aliases. @param namespace_map: The mapping from namespace URI to alias @type namespace_map: openid.messa...
[ "def", "toTypeURIs", "(", "namespace_map", ",", "alias_list_s", ")", ":", "uris", "=", "[", "]", "if", "alias_list_s", ":", "for", "alias", "in", "alias_list_s", ".", "split", "(", "','", ")", ":", "type_uri", "=", "namespace_map", ".", "getNamespaceURI", ...
Given a namespace mapping and a string containing a comma-separated list of namespace aliases, return a list of type URIs that correspond to those aliases. @param namespace_map: The mapping from namespace URI to alias @type namespace_map: openid.message.NamespaceMap @param alias_list_s: The string...
[ "Given", "a", "namespace", "mapping", "and", "a", "string", "containing", "a", "comma", "-", "separated", "list", "of", "namespace", "aliases", "return", "a", "list", "of", "type", "URIs", "that", "correspond", "to", "those", "aliases", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/ax.py#L149-L179
train
openid/python-openid
openid/extensions/ax.py
FetchRequest.add
def add(self, attribute): """Add an attribute to this attribute exchange request. @param attribute: The attribute that is being requested @type attribute: C{L{AttrInfo}} @returns: None @raise KeyError: when the requested attribute is already present in this fetch r...
python
def add(self, attribute): """Add an attribute to this attribute exchange request. @param attribute: The attribute that is being requested @type attribute: C{L{AttrInfo}} @returns: None @raise KeyError: when the requested attribute is already present in this fetch r...
[ "def", "add", "(", "self", ",", "attribute", ")", ":", "if", "attribute", ".", "type_uri", "in", "self", ".", "requested_attributes", ":", "raise", "KeyError", "(", "'The attribute %r has already been requested'", "%", "(", "attribute", ".", "type_uri", ",", ")"...
Add an attribute to this attribute exchange request. @param attribute: The attribute that is being requested @type attribute: C{L{AttrInfo}} @returns: None @raise KeyError: when the requested attribute is already present in this fetch request.
[ "Add", "an", "attribute", "to", "this", "attribute", "exchange", "request", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/ax.py#L202-L217
train
openid/python-openid
openid/extensions/ax.py
AXKeyValueMessage.addValue
def addValue(self, type_uri, value): """Add a single value for the given attribute type to the message. If there are already values specified for this type, this value will be sent in addition to the values already specified. @param type_uri: The URI for the attribute @...
python
def addValue(self, type_uri, value): """Add a single value for the given attribute type to the message. If there are already values specified for this type, this value will be sent in addition to the values already specified. @param type_uri: The URI for the attribute @...
[ "def", "addValue", "(", "self", ",", "type_uri", ",", "value", ")", ":", "try", ":", "values", "=", "self", ".", "data", "[", "type_uri", "]", "except", "KeyError", ":", "values", "=", "self", ".", "data", "[", "type_uri", "]", "=", "[", "]", "valu...
Add a single value for the given attribute type to the message. If there are already values specified for this type, this value will be sent in addition to the values already specified. @param type_uri: The URI for the attribute @param value: The value to add to the response to...
[ "Add", "a", "single", "value", "for", "the", "given", "attribute", "type", "to", "the", "message", ".", "If", "there", "are", "already", "values", "specified", "for", "this", "type", "this", "value", "will", "be", "sent", "in", "addition", "to", "the", "...
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/ax.py#L425-L444
train
openid/python-openid
openid/extensions/ax.py
AXKeyValueMessage.getSingle
def getSingle(self, type_uri, default=None): """Get a single value for an attribute. If no value was sent for this attribute, use the supplied default. If there is more than one value for this attribute, this method will fail. @type type_uri: str @param type_uri: The URI for the...
python
def getSingle(self, type_uri, default=None): """Get a single value for an attribute. If no value was sent for this attribute, use the supplied default. If there is more than one value for this attribute, this method will fail. @type type_uri: str @param type_uri: The URI for the...
[ "def", "getSingle", "(", "self", ",", "type_uri", ",", "default", "=", "None", ")", ":", "values", "=", "self", ".", "data", ".", "get", "(", "type_uri", ")", "if", "not", "values", ":", "return", "default", "elif", "len", "(", "values", ")", "==", ...
Get a single value for an attribute. If no value was sent for this attribute, use the supplied default. If there is more than one value for this attribute, this method will fail. @type type_uri: str @param type_uri: The URI for the attribute @param default: The value to return ...
[ "Get", "a", "single", "value", "for", "an", "attribute", ".", "If", "no", "value", "was", "sent", "for", "this", "attribute", "use", "the", "supplied", "default", ".", "If", "there", "is", "more", "than", "one", "value", "for", "this", "attribute", "this...
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/ax.py#L529-L555
train
openid/python-openid
openid/extensions/ax.py
FetchResponse.getExtensionArgs
def getExtensionArgs(self): """Serialize this object into arguments in the attribute exchange namespace @returns: The dictionary of unqualified attribute exchange arguments that represent this fetch_response. @rtype: {unicode;unicode} """ aliases = Namespace...
python
def getExtensionArgs(self): """Serialize this object into arguments in the attribute exchange namespace @returns: The dictionary of unqualified attribute exchange arguments that represent this fetch_response. @rtype: {unicode;unicode} """ aliases = Namespace...
[ "def", "getExtensionArgs", "(", "self", ")", ":", "aliases", "=", "NamespaceMap", "(", ")", "zero_value_types", "=", "[", "]", "if", "self", ".", "request", "is", "not", "None", ":", "# Validate the data in the context of the request (the", "# same attributes should b...
Serialize this object into arguments in the attribute exchange namespace @returns: The dictionary of unqualified attribute exchange arguments that represent this fetch_response. @rtype: {unicode;unicode}
[ "Serialize", "this", "object", "into", "arguments", "in", "the", "attribute", "exchange", "namespace" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/ax.py#L616-L682
train
openid/python-openid
openid/extensions/ax.py
FetchResponse.fromSuccessResponse
def fromSuccessResponse(cls, success_response, signed=True): """Construct a FetchResponse object from an OpenID library SuccessResponse object. @param success_response: A successful id_res response object @type success_response: openid.consumer.consumer.SuccessResponse @param s...
python
def fromSuccessResponse(cls, success_response, signed=True): """Construct a FetchResponse object from an OpenID library SuccessResponse object. @param success_response: A successful id_res response object @type success_response: openid.consumer.consumer.SuccessResponse @param s...
[ "def", "fromSuccessResponse", "(", "cls", ",", "success_response", ",", "signed", "=", "True", ")", ":", "self", "=", "cls", "(", ")", "ax_args", "=", "success_response", ".", "extensionResponse", "(", "self", ".", "ns_uri", ",", "signed", ")", "try", ":",...
Construct a FetchResponse object from an OpenID library SuccessResponse object. @param success_response: A successful id_res response object @type success_response: openid.consumer.consumer.SuccessResponse @param signed: Whether non-signed args should be processsed. If True...
[ "Construct", "a", "FetchResponse", "object", "from", "an", "OpenID", "library", "SuccessResponse", "object", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/ax.py#L689-L715
train
openid/python-openid
openid/extensions/sreg.py
SRegRequest.parseExtensionArgs
def parseExtensionArgs(self, args, strict=False): """Parse the unqualified simple registration request parameters and add them to this object. This method is essentially the inverse of C{L{getExtensionArgs}}. This method restores the serialized simple registration request fields...
python
def parseExtensionArgs(self, args, strict=False): """Parse the unqualified simple registration request parameters and add them to this object. This method is essentially the inverse of C{L{getExtensionArgs}}. This method restores the serialized simple registration request fields...
[ "def", "parseExtensionArgs", "(", "self", ",", "args", ",", "strict", "=", "False", ")", ":", "for", "list_name", "in", "[", "'required'", ",", "'optional'", "]", ":", "required", "=", "(", "list_name", "==", "'required'", ")", "items", "=", "args", ".",...
Parse the unqualified simple registration request parameters and add them to this object. This method is essentially the inverse of C{L{getExtensionArgs}}. This method restores the serialized simple registration request fields. If you are extracting arguments from a standard Op...
[ "Parse", "the", "unqualified", "simple", "registration", "request", "parameters", "and", "add", "them", "to", "this", "object", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/sreg.py#L232-L271
train
openid/python-openid
openid/extensions/sreg.py
SRegRequest.requestField
def requestField(self, field_name, required=False, strict=False): """Request the specified field from the OpenID user @param field_name: the unqualified simple registration field name @type field_name: str @param required: whether the given field should be presented to the ...
python
def requestField(self, field_name, required=False, strict=False): """Request the specified field from the OpenID user @param field_name: the unqualified simple registration field name @type field_name: str @param required: whether the given field should be presented to the ...
[ "def", "requestField", "(", "self", ",", "field_name", ",", "required", "=", "False", ",", "strict", "=", "False", ")", ":", "checkFieldName", "(", "field_name", ")", "if", "strict", ":", "if", "field_name", "in", "self", ".", "required", "or", "field_name...
Request the specified field from the OpenID user @param field_name: the unqualified simple registration field name @type field_name: str @param required: whether the given field should be presented to the user as being a required to successfully complete the request ...
[ "Request", "the", "specified", "field", "from", "the", "OpenID", "user" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/sreg.py#L293-L328
train
openid/python-openid
openid/extensions/sreg.py
SRegRequest.requestFields
def requestFields(self, field_names, required=False, strict=False): """Add the given list of fields to the request @param field_names: The simple registration data fields to request @type field_names: [str] @param required: Whether these values should be presented to the us...
python
def requestFields(self, field_names, required=False, strict=False): """Add the given list of fields to the request @param field_names: The simple registration data fields to request @type field_names: [str] @param required: Whether these values should be presented to the us...
[ "def", "requestFields", "(", "self", ",", "field_names", ",", "required", "=", "False", ",", "strict", "=", "False", ")", ":", "if", "isinstance", "(", "field_names", ",", "basestring", ")", ":", "raise", "TypeError", "(", "'Fields should be passed as a list of ...
Add the given list of fields to the request @param field_names: The simple registration data fields to request @type field_names: [str] @param required: Whether these values should be presented to the user as required @param strict: whether to raise an exception when a fie...
[ "Add", "the", "given", "list", "of", "fields", "to", "the", "request" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/sreg.py#L330-L351
train
openid/python-openid
openid/extensions/sreg.py
SRegRequest.getExtensionArgs
def getExtensionArgs(self): """Get a dictionary of unqualified simple registration arguments representing this request. This method is essentially the inverse of C{L{parseExtensionArgs}}. This method serializes the simple registration request fields. @rtype: {str:str} ...
python
def getExtensionArgs(self): """Get a dictionary of unqualified simple registration arguments representing this request. This method is essentially the inverse of C{L{parseExtensionArgs}}. This method serializes the simple registration request fields. @rtype: {str:str} ...
[ "def", "getExtensionArgs", "(", "self", ")", ":", "args", "=", "{", "}", "if", "self", ".", "required", ":", "args", "[", "'required'", "]", "=", "','", ".", "join", "(", "self", ".", "required", ")", "if", "self", ".", "optional", ":", "args", "["...
Get a dictionary of unqualified simple registration arguments representing this request. This method is essentially the inverse of C{L{parseExtensionArgs}}. This method serializes the simple registration request fields. @rtype: {str:str}
[ "Get", "a", "dictionary", "of", "unqualified", "simple", "registration", "arguments", "representing", "this", "request", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/sreg.py#L353-L374
train
openid/python-openid
openid/extensions/sreg.py
SRegResponse.get
def get(self, field_name, default=None): """Like dict.get, except that it checks that the field name is defined by the simple registration specification""" checkFieldName(field_name) return self.data.get(field_name, default)
python
def get(self, field_name, default=None): """Like dict.get, except that it checks that the field name is defined by the simple registration specification""" checkFieldName(field_name) return self.data.get(field_name, default)
[ "def", "get", "(", "self", ",", "field_name", ",", "default", "=", "None", ")", ":", "checkFieldName", "(", "field_name", ")", "return", "self", ".", "data", ".", "get", "(", "field_name", ",", "default", ")" ]
Like dict.get, except that it checks that the field name is defined by the simple registration specification
[ "Like", "dict", ".", "get", "except", "that", "it", "checks", "that", "the", "field", "name", "is", "defined", "by", "the", "simple", "registration", "specification" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/sreg.py#L483-L487
train
openid/python-openid
openid/server/trustroot.py
returnToMatches
def returnToMatches(allowed_return_to_urls, return_to): """Is the return_to URL under one of the supplied allowed return_to URLs? @since: 2.1.0 """ for allowed_return_to in allowed_return_to_urls: # A return_to pattern works the same as a realm, except that # it's not allowed to us...
python
def returnToMatches(allowed_return_to_urls, return_to): """Is the return_to URL under one of the supplied allowed return_to URLs? @since: 2.1.0 """ for allowed_return_to in allowed_return_to_urls: # A return_to pattern works the same as a realm, except that # it's not allowed to us...
[ "def", "returnToMatches", "(", "allowed_return_to_urls", ",", "return_to", ")", ":", "for", "allowed_return_to", "in", "allowed_return_to_urls", ":", "# A return_to pattern works the same as a realm, except that", "# it's not allowed to use a wildcard. We'll model this by", "# parsing ...
Is the return_to URL under one of the supplied allowed return_to URLs? @since: 2.1.0
[ "Is", "the", "return_to", "URL", "under", "one", "of", "the", "supplied", "allowed", "return_to", "URLs?" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/server/trustroot.py#L381-L407
train
openid/python-openid
openid/server/trustroot.py
getAllowedReturnURLs
def getAllowedReturnURLs(relying_party_url): """Given a relying party discovery URL return a list of return_to URLs. @since: 2.1.0 """ (rp_url_after_redirects, return_to_urls) = services.getServiceEndpoints( relying_party_url, _extractReturnURL) if rp_url_after_redirects != relying_party_u...
python
def getAllowedReturnURLs(relying_party_url): """Given a relying party discovery URL return a list of return_to URLs. @since: 2.1.0 """ (rp_url_after_redirects, return_to_urls) = services.getServiceEndpoints( relying_party_url, _extractReturnURL) if rp_url_after_redirects != relying_party_u...
[ "def", "getAllowedReturnURLs", "(", "relying_party_url", ")", ":", "(", "rp_url_after_redirects", ",", "return_to_urls", ")", "=", "services", ".", "getServiceEndpoints", "(", "relying_party_url", ",", "_extractReturnURL", ")", "if", "rp_url_after_redirects", "!=", "rel...
Given a relying party discovery URL return a list of return_to URLs. @since: 2.1.0
[ "Given", "a", "relying", "party", "discovery", "URL", "return", "a", "list", "of", "return_to", "URLs", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/server/trustroot.py#L409-L422
train
openid/python-openid
openid/server/trustroot.py
verifyReturnTo
def verifyReturnTo(realm_str, return_to, _vrfy=getAllowedReturnURLs): """Verify that a return_to URL is valid for the given realm. This function builds a discovery URL, performs Yadis discovery on it, makes sure that the URL does not redirect, parses out the return_to URLs, and finally checks to see if...
python
def verifyReturnTo(realm_str, return_to, _vrfy=getAllowedReturnURLs): """Verify that a return_to URL is valid for the given realm. This function builds a discovery URL, performs Yadis discovery on it, makes sure that the URL does not redirect, parses out the return_to URLs, and finally checks to see if...
[ "def", "verifyReturnTo", "(", "realm_str", ",", "return_to", ",", "_vrfy", "=", "getAllowedReturnURLs", ")", ":", "realm", "=", "TrustRoot", ".", "parse", "(", "realm_str", ")", "if", "realm", "is", "None", ":", "# The realm does not parse as a URL pattern", "retu...
Verify that a return_to URL is valid for the given realm. This function builds a discovery URL, performs Yadis discovery on it, makes sure that the URL does not redirect, parses out the return_to URLs, and finally checks to see if the current return_to URL matches the return_to. @raises DiscoveryF...
[ "Verify", "that", "a", "return_to", "URL", "is", "valid", "for", "the", "given", "realm", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/server/trustroot.py#L425-L454
train
openid/python-openid
openid/server/trustroot.py
TrustRoot.validateURL
def validateURL(self, url): """ Validates a URL against this trust root. @param url: The URL to check @type url: C{str} @return: Whether the given URL is within this trust root. @rtype: C{bool} """ url_parts = _parseURL(url) if url_parts is ...
python
def validateURL(self, url): """ Validates a URL against this trust root. @param url: The URL to check @type url: C{str} @return: Whether the given URL is within this trust root. @rtype: C{bool} """ url_parts = _parseURL(url) if url_parts is ...
[ "def", "validateURL", "(", "self", ",", "url", ")", ":", "url_parts", "=", "_parseURL", "(", "url", ")", "if", "url_parts", "is", "None", ":", "return", "False", "proto", ",", "host", ",", "port", ",", "path", "=", "url_parts", "if", "proto", "!=", "...
Validates a URL against this trust root. @param url: The URL to check @type url: C{str} @return: Whether the given URL is within this trust root. @rtype: C{bool}
[ "Validates", "a", "URL", "against", "this", "trust", "root", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/server/trustroot.py#L190-L247
train
openid/python-openid
openid/server/trustroot.py
TrustRoot.checkSanity
def checkSanity(cls, trust_root_string): """str -> bool is this a sane trust root? """ trust_root = cls.parse(trust_root_string) if trust_root is None: return False else: return trust_root.isSane()
python
def checkSanity(cls, trust_root_string): """str -> bool is this a sane trust root? """ trust_root = cls.parse(trust_root_string) if trust_root is None: return False else: return trust_root.isSane()
[ "def", "checkSanity", "(", "cls", ",", "trust_root_string", ")", ":", "trust_root", "=", "cls", ".", "parse", "(", "trust_root_string", ")", "if", "trust_root", "is", "None", ":", "return", "False", "else", ":", "return", "trust_root", ".", "isSane", "(", ...
str -> bool is this a sane trust root?
[ "str", "-", ">", "bool" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/server/trustroot.py#L303-L312
train
openid/python-openid
openid/server/trustroot.py
TrustRoot.checkURL
def checkURL(cls, trust_root, url): """quick func for validating a url against a trust root. See the TrustRoot class if you need more control.""" tr = cls.parse(trust_root) return tr is not None and tr.validateURL(url)
python
def checkURL(cls, trust_root, url): """quick func for validating a url against a trust root. See the TrustRoot class if you need more control.""" tr = cls.parse(trust_root) return tr is not None and tr.validateURL(url)
[ "def", "checkURL", "(", "cls", ",", "trust_root", ",", "url", ")", ":", "tr", "=", "cls", ".", "parse", "(", "trust_root", ")", "return", "tr", "is", "not", "None", "and", "tr", ".", "validateURL", "(", "url", ")" ]
quick func for validating a url against a trust root. See the TrustRoot class if you need more control.
[ "quick", "func", "for", "validating", "a", "url", "against", "a", "trust", "root", ".", "See", "the", "TrustRoot", "class", "if", "you", "need", "more", "control", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/server/trustroot.py#L316-L320
train
openid/python-openid
openid/server/trustroot.py
TrustRoot.buildDiscoveryURL
def buildDiscoveryURL(self): """Return a discovery URL for this realm. This function does not check to make sure that the realm is valid. Its behaviour on invalid inputs is undefined. @rtype: str @returns: The URL upon which relying party discovery should be run in...
python
def buildDiscoveryURL(self): """Return a discovery URL for this realm. This function does not check to make sure that the realm is valid. Its behaviour on invalid inputs is undefined. @rtype: str @returns: The URL upon which relying party discovery should be run in...
[ "def", "buildDiscoveryURL", "(", "self", ")", ":", "if", "self", ".", "wildcard", ":", "# Use \"www.\" in place of the star", "assert", "self", ".", "host", ".", "startswith", "(", "'.'", ")", ",", "self", ".", "host", "www_domain", "=", "'www'", "+", "self"...
Return a discovery URL for this realm. This function does not check to make sure that the realm is valid. Its behaviour on invalid inputs is undefined. @rtype: str @returns: The URL upon which relying party discovery should be run in order to verify the return_to URL ...
[ "Return", "a", "discovery", "URL", "for", "this", "realm", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/server/trustroot.py#L324-L343
train
openid/python-openid
openid/yadis/manager.py
YadisServiceManager.next
def next(self): """Return the next service self.current() will continue to return that service until the next call to this method.""" try: self._current = self.services.pop(0) except IndexError: raise StopIteration else: return self._c...
python
def next(self): """Return the next service self.current() will continue to return that service until the next call to this method.""" try: self._current = self.services.pop(0) except IndexError: raise StopIteration else: return self._c...
[ "def", "next", "(", "self", ")", ":", "try", ":", "self", ".", "_current", "=", "self", ".", "services", ".", "pop", "(", "0", ")", "except", "IndexError", ":", "raise", "StopIteration", "else", ":", "return", "self", ".", "_current" ]
Return the next service self.current() will continue to return that service until the next call to this method.
[ "Return", "the", "next", "service" ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/manager.py#L27-L37
train
openid/python-openid
openid/yadis/manager.py
Discovery.getNextService
def getNextService(self, discover): """Return the next authentication service for the pair of user_input and session. This function handles fallback. @param discover: a callable that takes a URL and returns a list of services @type discover: str -> [service] @re...
python
def getNextService(self, discover): """Return the next authentication service for the pair of user_input and session. This function handles fallback. @param discover: a callable that takes a URL and returns a list of services @type discover: str -> [service] @re...
[ "def", "getNextService", "(", "self", ",", "discover", ")", ":", "manager", "=", "self", ".", "getManager", "(", ")", "if", "manager", "is", "not", "None", "and", "not", "manager", ":", "self", ".", "destroyManager", "(", ")", "if", "not", "manager", "...
Return the next authentication service for the pair of user_input and session. This function handles fallback. @param discover: a callable that takes a URL and returns a list of services @type discover: str -> [service] @return: the next available service
[ "Return", "the", "next", "authentication", "service", "for", "the", "pair", "of", "user_input", "and", "session", ".", "This", "function", "handles", "fallback", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/manager.py#L87-L114
train
openid/python-openid
openid/yadis/manager.py
Discovery.cleanup
def cleanup(self, force=False): """Clean up Yadis-related services in the session and return the most-recently-attempted service from the manager, if one exists. @param force: True if the manager should be deleted regardless of whether it's a manager for self.url. @retu...
python
def cleanup(self, force=False): """Clean up Yadis-related services in the session and return the most-recently-attempted service from the manager, if one exists. @param force: True if the manager should be deleted regardless of whether it's a manager for self.url. @retu...
[ "def", "cleanup", "(", "self", ",", "force", "=", "False", ")", ":", "manager", "=", "self", ".", "getManager", "(", "force", "=", "force", ")", "if", "manager", "is", "not", "None", ":", "service", "=", "manager", ".", "current", "(", ")", "self", ...
Clean up Yadis-related services in the session and return the most-recently-attempted service from the manager, if one exists. @param force: True if the manager should be deleted regardless of whether it's a manager for self.url. @return: current service endpoint object or None...
[ "Clean", "up", "Yadis", "-", "related", "services", "in", "the", "session", "and", "return", "the", "most", "-", "recently", "-", "attempted", "service", "from", "the", "manager", "if", "one", "exists", "." ]
f7e13536f0d1828d3cef5ae7a7b55cabadff37fc
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/manager.py#L116-L134
train