Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
DependencyInfo.get_metadata
(self, dependency)
Obtain repository metadata for a dependency. Args: dependency: string providing dependency identifier. Returns: A dictionary with the repository metadata as defined in bazel/repository_locations.bzl.
Obtain repository metadata for a dependency.
def get_metadata(self, dependency): """Obtain repository metadata for a dependency. Args: dependency: string providing dependency identifier. Returns: A dictionary with the repository metadata as defined in bazel/repository_locations.bzl. """ return REPOSITORY_LOCATIONS_S...
[ "def", "get_metadata", "(", "self", ",", "dependency", ")", ":", "return", "REPOSITORY_LOCATIONS_SPEC", ".", "get", "(", "dependency", ")" ]
[ 88, 4 ]
[ 98, 56 ]
python
en
['en', 'en', 'en']
True
BuildGraph.query_external_deps
(self, *targets)
Query the build graph for transitive external dependencies. Args: targets: Bazel targets. Returns: A set of dependency identifiers that are reachable from targets.
Query the build graph for transitive external dependencies.
def query_external_deps(self, *targets): """Query the build graph for transitive external dependencies. Args: targets: Bazel targets. Returns: A set of dependency identifiers that are reachable from targets. """ deps_query = ' union '.join(f'deps({l})' for l in targets) ...
[ "def", "query_external_deps", "(", "self", ",", "*", "targets", ")", ":", "deps_query", "=", "' union '", ".", "join", "(", "f'deps({l})'", "for", "l", "in", "targets", ")", "try", ":", "deps", "=", "subprocess", ".", "check_output", "(", "[", "'bazel'", ...
[ 115, 4 ]
[ 146, 28 ]
python
en
['en', 'en', 'en']
True
BuildGraph.list_extensions
(self)
List all extensions. Returns: Dictionary items from source/extensions/extensions_build_config.bzl.
List all extensions.
def list_extensions(self): """List all extensions. Returns: Dictionary items from source/extensions/extensions_build_config.bzl. """ return extensions_build_config.EXTENSIONS.items()
[ "def", "list_extensions", "(", "self", ")", ":", "return", "extensions_build_config", ".", "EXTENSIONS", ".", "items", "(", ")" ]
[ 148, 4 ]
[ 154, 57 ]
python
en
['en', 'en', 'en']
True
Validator.validate_build_graph_structure
(self)
Validate basic assumptions about dependency relationship in the build graph. Raises: DependencyError: on a dependency validation error.
Validate basic assumptions about dependency relationship in the build graph.
def validate_build_graph_structure(self): """Validate basic assumptions about dependency relationship in the build graph. Raises: DependencyError: on a dependency validation error. """ print('Validating build dependency structure...') queried_core_ext_deps = self._build_graph.quer...
[ "def", "validate_build_graph_structure", "(", "self", ")", ":", "print", "(", "'Validating build dependency structure...'", ")", "queried_core_ext_deps", "=", "self", ".", "_build_graph", ".", "query_external_deps", "(", "'//source/exe:envoy_main_common_with_core_extensions_lib'"...
[ 166, 4 ]
[ 180, 54 ]
python
en
['en', 'en', 'en']
True
Validator.validate_test_only_deps
(self)
Validate that test-only dependencies aren't included in //source/... Raises: DependencyError: on a dependency validation error.
Validate that test-only dependencies aren't included in //source/...
def validate_test_only_deps(self): """Validate that test-only dependencies aren't included in //source/... Raises: DependencyError: on a dependency validation error. """ print('Validating test-only dependencies...') # Validate that //source doesn't depend on test_only quer...
[ "def", "validate_test_only_deps", "(", "self", ")", ":", "print", "(", "'Validating test-only dependencies...'", ")", "# Validate that //source doesn't depend on test_only", "queried_source_deps", "=", "self", ".", "_build_graph", ".", "query_external_deps", "(", "'//source/......
[ 182, 4 ]
[ 205, 85 ]
python
en
['en', 'en', 'en']
True
Validator.validate_data_plane_core_deps
(self)
Validate dataplane_core dependencies. Check that we at least tag as dataplane_core dependencies that match some well-known targets for the data-plane. Raises: DependencyError: on a dependency validation error.
Validate dataplane_core dependencies.
def validate_data_plane_core_deps(self): """Validate dataplane_core dependencies. Check that we at least tag as dataplane_core dependencies that match some well-known targets for the data-plane. Raises: DependencyError: on a dependency validation error. """ print('Validating data...
[ "def", "validate_data_plane_core_deps", "(", "self", ")", ":", "print", "(", "'Validating data-plane dependencies...'", ")", "# Necessary but not sufficient for dataplane. With some refactoring we could", "# probably have more precise tagging of dataplane/controlplane/other deps in", "# thes...
[ 207, 4 ]
[ 235, 30 ]
python
en
['it', 'nl', 'en']
False
Validator.validate_control_plane_deps
(self)
Validate controlplane dependencies. Check that we at least tag as controlplane dependencies that match some well-known targets for the control-plane. Raises: DependencyError: on a dependency validation error.
Validate controlplane dependencies.
def validate_control_plane_deps(self): """Validate controlplane dependencies. Check that we at least tag as controlplane dependencies that match some well-known targets for the control-plane. Raises: DependencyError: on a dependency validation error. """ print('Validating con...
[ "def", "validate_control_plane_deps", "(", "self", ")", ":", "print", "(", "'Validating control-plane dependencies...'", ")", "# Necessary but not sufficient for controlplane. With some refactoring we could", "# probably have more precise tagging of dataplane/controlplane/other deps in", "# ...
[ 237, 4 ]
[ 262, 59 ]
python
en
['it', 'nl', 'en']
False
Validator.validate_extension_deps
(self, name, target)
Validate that extensions are correctly declared for dataplane_ext and observability_ext. Args: name: extension name. target: extension Bazel target. Raises: DependencyError: on a dependency validation error.
Validate that extensions are correctly declared for dataplane_ext and observability_ext.
def validate_extension_deps(self, name, target): """Validate that extensions are correctly declared for dataplane_ext and observability_ext. Args: name: extension name. target: extension Bazel target. Raises: DependencyError: on a dependency validation error. """ print(f'...
[ "def", "validate_extension_deps", "(", "self", ",", "name", ",", "target", ")", ":", "print", "(", "f'Validating extension {name} dependencies...'", ")", "queried_deps", "=", "self", ".", "_build_graph", ".", "query_external_deps", "(", "target", ")", "marginal_deps",...
[ 264, 4 ]
[ 294, 25 ]
python
en
['en', 'en', 'en']
True
Validator.validate_all
(self)
Collection of all validations. Raises: DependencyError: on a dependency validation error.
Collection of all validations.
def validate_all(self): """Collection of all validations. Raises: DependencyError: on a dependency validation error. """ self.validate_build_graph_structure() self.validate_test_only_deps() self.validate_data_plane_core_deps() self.validate_control_plane_deps() ...
[ "def", "validate_all", "(", "self", ")", ":", "self", ".", "validate_build_graph_structure", "(", ")", "self", ".", "validate_test_only_deps", "(", ")", "self", ".", "validate_data_plane_core_deps", "(", ")", "self", ".", "validate_control_plane_deps", "(", ")", "...
[ 296, 4 ]
[ 309, 58 ]
python
en
['en', 'en', 'en']
True
pure_ds
(x, amplitude=1.0, center=0.0, fwhm=1.0, asym=0.5)
Roughly taken from https://rdrr.io/github/GSperanza/RxpsG/src/R/XPSFitAlgorithms.r
Roughly taken from https://rdrr.io/github/GSperanza/RxpsG/src/R/XPSFitAlgorithms.r
def pure_ds(x, amplitude=1.0, center=0.0, fwhm=1.0, asym=0.5): """Roughly taken from https://rdrr.io/github/GSperanza/RxpsG/src/R/XPSFitAlgorithms.r """ sigma = max(fwhm / 2, tiny) arg = center - x am1 = 1 - asym y = ( amplitude / np.pi * ss.gamma(am1) / (arg**2 + sigma**2) *...
[ "def", "pure_ds", "(", "x", ",", "amplitude", "=", "1.0", ",", "center", "=", "0.0", ",", "fwhm", "=", "1.0", ",", "asym", "=", "0.5", ")", ":", "sigma", "=", "max", "(", "fwhm", "/", "2", ",", "tiny", ")", "arg", "=", "center", "-", "x", "am...
[ 22, 0 ]
[ 34, 12 ]
python
en
['en', 'en', 'en']
True
gaussian
(x, amplitude=1.0, center=0.0, fwhm=1.0)
Standard gaussian with amplitude = area.
Standard gaussian with amplitude = area.
def gaussian(x, amplitude=1.0, center=0.0, fwhm=1.0): """Standard gaussian with amplitude = area.""" sigma = max(tiny, fwhm / (2 * s2ln2)) arg = center - x y = amplitude / (s2pi * sigma) * np.exp(-arg**2 / (2 * sigma**2)) return y
[ "def", "gaussian", "(", "x", ",", "amplitude", "=", "1.0", ",", "center", "=", "0.0", ",", "fwhm", "=", "1.0", ")", ":", "sigma", "=", "max", "(", "tiny", ",", "fwhm", "/", "(", "2", "*", "s2ln2", ")", ")", "arg", "=", "center", "-", "x", "y"...
[ 36, 0 ]
[ 41, 12 ]
python
en
['en', 'ro', 'en']
True
lorentzian
(x, amplitude=1.0, center=0.0, fwhm=1.0)
Standard lorentzian with amplitude = area.
Standard lorentzian with amplitude = area.
def lorentzian(x, amplitude=1.0, center=0.0, fwhm=1.0): """Standard lorentzian with amplitude = area.""" gamma = max(tiny, fwhm / 2) arg = center - x y = amplitude / (gamma * np.pi) * gamma**2 / (arg**2 + gamma**2) return y
[ "def", "lorentzian", "(", "x", ",", "amplitude", "=", "1.0", ",", "center", "=", "0.0", ",", "fwhm", "=", "1.0", ")", ":", "gamma", "=", "max", "(", "tiny", ",", "fwhm", "/", "2", ")", "arg", "=", "center", "-", "x", "y", "=", "amplitude", "/",...
[ 43, 0 ]
[ 48, 12 ]
python
en
['en', 'ro', 'pt']
False
voigt
(x, amplitude=1.0, center=0.0, fwhm=1.0, fwhm_l=None)
Voigt function using Faddeeva function wofz. https://en.wikipedia.org/wiki/Voigt_profile Taken from lmfit module, modified to take fwhms: Gaussian fwhm and Lorentzian fwhm_l
Voigt function using Faddeeva function wofz. https://en.wikipedia.org/wiki/Voigt_profile Taken from lmfit module, modified to take fwhms: Gaussian fwhm and Lorentzian fwhm_l
def voigt(x, amplitude=1.0, center=0.0, fwhm=1.0, fwhm_l=None): """Voigt function using Faddeeva function wofz. https://en.wikipedia.org/wiki/Voigt_profile Taken from lmfit module, modified to take fwhms: Gaussian fwhm and Lorentzian fwhm_l """ if fwhm_l is None: fwhm_l = fwhm sigma ...
[ "def", "voigt", "(", "x", ",", "amplitude", "=", "1.0", ",", "center", "=", "0.0", ",", "fwhm", "=", "1.0", ",", "fwhm_l", "=", "None", ")", ":", "if", "fwhm_l", "is", "None", ":", "fwhm_l", "=", "fwhm", "sigma", "=", "max", "(", "tiny", ",", "...
[ 50, 0 ]
[ 64, 12 ]
python
de
['de', 'so', 'en']
False
voigt_defined_fwhm
(x, amplitude=1.0, center=0.0, fwhm=1.0, fwhm_g=None)
Voigt function using Faddeeva function wofz. https://en.wikipedia.org/wiki/Voigt_profile Taken from lmfit module, modified to take fwhms: Full fwhm and Gaussian fwhm (Lorentzian fwhm is inferred, see bottom of wikipedia link)
Voigt function using Faddeeva function wofz. https://en.wikipedia.org/wiki/Voigt_profile Taken from lmfit module, modified to take fwhms: Full fwhm and Gaussian fwhm (Lorentzian fwhm is inferred, see bottom of wikipedia link)
def voigt_defined_fwhm(x, amplitude=1.0, center=0.0, fwhm=1.0, fwhm_g=None): """Voigt function using Faddeeva function wofz. https://en.wikipedia.org/wiki/Voigt_profile Taken from lmfit module, modified to take fwhms: Full fwhm and Gaussian fwhm (Lorentzian fwhm is inferred, see bottom of wikipedia ...
[ "def", "voigt_defined_fwhm", "(", "x", ",", "amplitude", "=", "1.0", ",", "center", "=", "0.0", ",", "fwhm", "=", "1.0", ",", "fwhm_g", "=", "None", ")", ":", "if", "fwhm_g", "is", "None", ":", "fwhm_g", "=", "fwhm", "/", "1.6376", "sigma", "=", "m...
[ 66, 0 ]
[ 82, 12 ]
python
de
['de', 'so', 'en']
False
gl_sum
(x, amplitude=1.0, center=0.0, fwhm=1.0, fraction=0.5)
Sum of a gaussian and a lorentzian component.
Sum of a gaussian and a lorentzian component.
def gl_sum(x, amplitude=1.0, center=0.0, fwhm=1.0, fraction=0.5): """Sum of a gaussian and a lorentzian component.""" G = gaussian(x, amplitude=amplitude, center=center, fwhm=fwhm) L = lorentzian(x, amplitude=amplitude, center=center, fwhm=fwhm) return (1 - fraction) * G + fraction * L
[ "def", "gl_sum", "(", "x", ",", "amplitude", "=", "1.0", ",", "center", "=", "0.0", ",", "fwhm", "=", "1.0", ",", "fraction", "=", "0.5", ")", ":", "G", "=", "gaussian", "(", "x", ",", "amplitude", "=", "amplitude", ",", "center", "=", "center", ...
[ 84, 0 ]
[ 88, 44 ]
python
en
['en', 'en', 'pt']
True
gl_prod
(x, amplitude=1.0, center=0.0, fwhm=1.0, fraction=0.5)
Product form of a gaussian and a lorentzian component.
Product form of a gaussian and a lorentzian component.
def gl_prod(x, amplitude=1.0, center=0.0, fwhm=1.0, fraction=0.5): """Product form of a gaussian and a lorentzian component.""" # area and fwhm are not determined - don't use! fwhm_g = fwhm / (1 - fraction) fwhm_l = fwhm / fraction sigma = max(tiny, fwhm_g / (2 * s2ln2)) gamma = max(tiny, fwhm_l...
[ "def", "gl_prod", "(", "x", ",", "amplitude", "=", "1.0", ",", "center", "=", "0.0", ",", "fwhm", "=", "1.0", ",", "fraction", "=", "0.5", ")", ":", "# area and fwhm are not determined - don't use!", "fwhm_g", "=", "fwhm", "/", "(", "1", "-", "fraction", ...
[ 90, 0 ]
[ 112, 13 ]
python
en
['en', 'en', 'pt']
True
gelius
(x, amplitude=1.0, center=0.0, fwhm=1.0, a=0.5, b=0.5, fwhm_l=0.5)
See http://www.casaxps.com/help_manual/line_shapes.htm Modified to use Voigt profile instead of GL product
See http://www.casaxps.com/help_manual/line_shapes.htm Modified to use Voigt profile instead of GL product
def gelius(x, amplitude=1.0, center=0.0, fwhm=1.0, a=0.5, b=0.5, fwhm_l=0.5): """See http://www.casaxps.com/help_manual/line_shapes.htm Modified to use Voigt profile instead of GL product""" if fwhm_l is None: fwhm_l = fwhm arg = center - x below_c = (x <= center).astype(int) AW = np.exp...
[ "def", "gelius", "(", "x", ",", "amplitude", "=", "1.0", ",", "center", "=", "0.0", ",", "fwhm", "=", "1.0", ",", "a", "=", "0.5", ",", "b", "=", "0.5", ",", "fwhm_l", "=", "0.5", ")", ":", "if", "fwhm_l", "is", "None", ":", "fwhm_l", "=", "f...
[ 114, 0 ]
[ 126, 12 ]
python
en
['en', 'en', 'hi']
False
asymm_tail
(x, center=0, fwhm=1.0, tail=1.0)
Tail for dampening asymmetric lines below x = center.
Tail for dampening asymmetric lines below x = center.
def asymm_tail(x, center=0, fwhm=1.0, tail=1.0): """Tail for dampening asymmetric lines below x = center.""" arg = (center - x) / fwhm try: zeros = np.zeros(len(x)) except TypeError: zeros = 0 y = np.exp(-np.maximum(arg, zeros) * tail) return y
[ "def", "asymm_tail", "(", "x", ",", "center", "=", "0", ",", "fwhm", "=", "1.0", ",", "tail", "=", "1.0", ")", ":", "arg", "=", "(", "center", "-", "x", ")", "/", "fwhm", "try", ":", "zeros", "=", "np", ".", "zeros", "(", "len", "(", "x", "...
[ 128, 0 ]
[ 136, 12 ]
python
en
['en', 'en', 'en']
True
centered_ds
(x, amplitude=1.0, center=0.0, fwhm=1.0, asym=0.5)
DS lineshape with maximum at center.
DS lineshape with maximum at center.
def centered_ds(x, amplitude=1.0, center=0.0, fwhm=1.0, asym=0.5): """DS lineshape with maximum at center.""" emax = fwhm / (2 * np.tan(np.pi / (2 - asym))) center += emax y = pure_ds(x, amplitude=amplitude, center=center, fwhm=fwhm, asym=asym) return y
[ "def", "centered_ds", "(", "x", ",", "amplitude", "=", "1.0", ",", "center", "=", "0.0", ",", "fwhm", "=", "1.0", ",", "asym", "=", "0.5", ")", ":", "emax", "=", "fwhm", "/", "(", "2", "*", "np", ".", "tan", "(", "np", ".", "pi", "/", "(", ...
[ 138, 0 ]
[ 143, 12 ]
python
en
['en', 'en', 'en']
True
tailed_ds
(x, amplitude=1.0, center=0.0, fwhm=1.0, asym=0.5, tail=1.0)
Centered DS with exponential tail at lower x.
Centered DS with exponential tail at lower x.
def tailed_ds(x, amplitude=1.0, center=0.0, fwhm=1.0, asym=0.5, tail=1.0): """Centered DS with exponential tail at lower x.""" emax = fwhm / (2 * np.tan(np.pi / (2 - asym))) center += emax ds = pure_ds(x, amplitude=amplitude, center=center, fwhm=fwhm, asym=asym) as_tail = asymm_tail(x, center=center...
[ "def", "tailed_ds", "(", "x", ",", "amplitude", "=", "1.0", ",", "center", "=", "0.0", ",", "fwhm", "=", "1.0", ",", "asym", "=", "0.5", ",", "tail", "=", "1.0", ")", ":", "emax", "=", "fwhm", "/", "(", "2", "*", "np", ".", "tan", "(", "np", ...
[ 145, 0 ]
[ 151, 23 ]
python
en
['en', 'en', 'en']
True
pah2fwhm
(_position, angle, height, shape)
Calculates fwhm from position, angle, height depending on shape.
Calculates fwhm from position, angle, height depending on shape.
def pah2fwhm(_position, angle, height, shape): """Calculates fwhm from position, angle, height depending on shape.""" if shape == "PseudoVoigt": return np.tan(angle) * height elif shape == "DoniachSunjic": return np.tan(angle) * height elif shape == "Voigt": return np.tan(angle) ...
[ "def", "pah2fwhm", "(", "_position", ",", "angle", ",", "height", ",", "shape", ")", ":", "if", "shape", "==", "\"PseudoVoigt\"", ":", "return", "np", ".", "tan", "(", "angle", ")", "*", "height", "elif", "shape", "==", "\"DoniachSunjic\"", ":", "return"...
[ 243, 0 ]
[ 251, 29 ]
python
en
['en', 'en', 'en']
True
pah2area
(_position, angle, height, shape)
Calculates area from position, angle, height depending on shape.
Calculates area from position, angle, height depending on shape.
def pah2area(_position, angle, height, shape): """Calculates area from position, angle, height depending on shape.""" if shape == "PseudoVoigt": fwhm = np.tan(angle) * height area = (height * (fwhm * np.sqrt(np.pi / ln2)) / (1 + np.sqrt(1 / (np.pi * ln2)))) return area ...
[ "def", "pah2area", "(", "_position", ",", "angle", ",", "height", ",", "shape", ")", ":", "if", "shape", "==", "\"PseudoVoigt\"", ":", "fwhm", "=", "np", ".", "tan", "(", "angle", ")", "*", "height", "area", "=", "(", "height", "*", "(", "fwhm", "*...
[ 253, 0 ]
[ 268, 29 ]
python
en
['en', 'en', 'en']
True
PeakModel.guess
(self, data, **kwargs)
Guess the pars.
Guess the pars.
def guess(self, data, **kwargs): """Guess the pars.""" x = kwargs.get("x", None) negative = kwargs.get("negative", False) pars = guess_from_peak(self, data, x, negative, ampscale=0.5) return update_param_vals(pars, self.prefix, **kwargs)
[ "def", "guess", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "x", "=", "kwargs", ".", "get", "(", "\"x\"", ",", "None", ")", "negative", "=", "kwargs", ".", "get", "(", "\"negative\"", ",", "False", ")", "pars", "=", "guess_from_pea...
[ 168, 4 ]
[ 173, 61 ]
python
en
['en', 'en', 'en']
True
PeakModel.get_fwhm
(self, params, x=None)
Generic FWHM calculator: Searches from center in both directions for values below maximum / 2
Generic FWHM calculator: Searches from center in both directions for values below maximum / 2
def get_fwhm(self, params, x=None): """Generic FWHM calculator: Searches from center in both directions for values below maximum / 2 """ if x: pass funcargs = self.make_funcargs(params) center = funcargs["center"] fwhm = funcargs["fwhm"] hm = s...
[ "def", "get_fwhm", "(", "self", ",", "params", ",", "x", "=", "None", ")", ":", "if", "x", ":", "pass", "funcargs", "=", "self", ".", "make_funcargs", "(", "params", ")", "center", "=", "funcargs", "[", "\"center\"", "]", "fwhm", "=", "funcargs", "["...
[ 175, 4 ]
[ 196, 28 ]
python
en
['en', 'co', 'en']
True
PeakModel.get_area
(self, params, x=None)
Generic area calculator: Integrates interval (center - self.area_range/2, center + self.area_range/2) with resolution self.area_res.
Generic area calculator: Integrates interval (center - self.area_range/2, center + self.area_range/2) with resolution self.area_res.
def get_area(self, params, x=None): """Generic area calculator: Integrates interval (center - self.area_range/2, center + self.area_range/2) with resolution self.area_res. """ funcargs = self.make_funcargs(params) if x: start = x.min() end = x.max(...
[ "def", "get_area", "(", "self", ",", "params", ",", "x", "=", "None", ")", ":", "funcargs", "=", "self", ".", "make_funcargs", "(", "params", ")", "if", "x", ":", "start", "=", "x", ".", "min", "(", ")", "end", "=", "x", ".", "max", "(", ")", ...
[ 198, 4 ]
[ 217, 27 ]
python
en
['en', 'ro', 'en']
True
Anomalies.__init__
(self, X, t, train_size, anomalies_size)
Contructor method which customized dataset to apply anomalies detection techniques. :param X: Dataset samples :type X: pd.DataFrame :param t: Dataset labels :type t: pd.Series :param train_size: percentage of samples used for training :type train_size: float :par...
Contructor method which customized dataset to apply anomalies detection techniques.
def __init__(self, X, t, train_size, anomalies_size): """Contructor method which customized dataset to apply anomalies detection techniques. :param X: Dataset samples :type X: pd.DataFrame :param t: Dataset labels :type t: pd.Series :param train_size: percentage of sampl...
[ "def", "__init__", "(", "self", ",", "X", ",", "t", ",", "train_size", ",", "anomalies_size", ")", ":", "M", "=", "X", "M", "[", "\"label\"", "]", "=", "t", ".", "values", "M", "=", "M", ".", "sort_values", "(", "by", "=", "[", "\"label\"", "]", ...
[ 16, 4 ]
[ 44, 31 ]
python
en
['en', 'en', 'en']
True
Anomalies.perform_IsolationForest
( self, n_estimators=100, target_names=None, contamination=0, **kwargs )
Isolation Forest algorithm. :param n_estimators: number of estimators used, defaults to 100 :type n_estimators: int, optional :param contamination: percentage os samples included as anomalies in trining set, defaults to 0 :type contamination: int, optional :return: classificatio...
Isolation Forest algorithm.
def perform_IsolationForest( self, n_estimators=100, target_names=None, contamination=0, **kwargs ): """Isolation Forest algorithm. :param n_estimators: number of estimators used, defaults to 100 :type n_estimators: int, optional :param contamination: percentage os samples i...
[ "def", "perform_IsolationForest", "(", "self", ",", "n_estimators", "=", "100", ",", "target_names", "=", "None", ",", "contamination", "=", "0", ",", "*", "*", "kwargs", ")", ":", "model", "=", "IsolationForest", "(", "n_estimators", "=", "n_estimators", ",...
[ 46, 4 ]
[ 65, 9 ]
python
en
['en', 'zu', 'en']
True
Anomalies.perform_LOF
(self, n_neighbors=10, target_names=None, novelty=True)
LOF algorithm. :param n_neighbors: number of data neighbours used, defaults to 10 :type n_neighbors: int, optional :param novelty: param necessary to detect anomalies, defaults to True :type novelty: bool, optional :return: classification report with results :rtype: str ...
LOF algorithm.
def perform_LOF(self, n_neighbors=10, target_names=None, novelty=True): """LOF algorithm. :param n_neighbors: number of data neighbours used, defaults to 10 :type n_neighbors: int, optional :param novelty: param necessary to detect anomalies, defaults to True :type novelty: bool...
[ "def", "perform_LOF", "(", "self", ",", "n_neighbors", "=", "10", ",", "target_names", "=", "None", ",", "novelty", "=", "True", ")", ":", "model", "=", "LocalOutlierFactor", "(", "n_neighbors", "=", "n_neighbors", ",", "novelty", "=", "novelty", ")", "mod...
[ 67, 4 ]
[ 82, 9 ]
python
en
['en', 'ro', 'en']
False
Anomalies.perform_autoencoding
(self)
Create an autoencoder neural network.
Create an autoencoder neural network.
def perform_autoencoding(self): """Create an autoencoder neural network.""" _, variables = self.X_train.shape autoencoder = models.Sequential() autoencoder.add(layers.Dense(1, input_dim=variables, activation="relu")) autoencoder.add(layers.Dense(variables, activation="relu")) ...
[ "def", "perform_autoencoding", "(", "self", ")", ":", "_", ",", "variables", "=", "self", ".", "X_train", ".", "shape", "autoencoder", "=", "models", ".", "Sequential", "(", ")", "autoencoder", ".", "add", "(", "layers", ".", "Dense", "(", "1", ",", "i...
[ 84, 4 ]
[ 92, 38 ]
python
de
['de', 'gd', 'en']
False
Anomalies.train_autoencoding
(self, epochs=200, batch_size=100, **kwargs)
Fits autoencoder neural network. :param epochs: number of times all data is passed to network, defaults to 200 :type epochs: int, optional :param batch_size: number of splits of data in batchs, defaults to 100 :type batch_size: int, optional
Fits autoencoder neural network.
def train_autoencoding(self, epochs=200, batch_size=100, **kwargs): """Fits autoencoder neural network. :param epochs: number of times all data is passed to network, defaults to 200 :type epochs: int, optional :param batch_size: number of splits of data in batchs, defaults to 100 ...
[ "def", "train_autoencoding", "(", "self", ",", "epochs", "=", "200", ",", "batch_size", "=", "100", ",", "*", "*", "kwargs", ")", ":", "self", ".", "history", "=", "self", ".", "autoencoder", ".", "fit", "(", "self", ".", "X_train", ",", "self", ".",...
[ 94, 4 ]
[ 109, 9 ]
python
de
['fr', 'de', 'it']
False
Anomalies.plot_autoencoder_validation
( self, xlabel: str = "Mean Square Error (MSE)", ylabel: str = "Iteration (epoch)", legend: tuple = ("Entrenamiento", "Test"), figsize: tuple = (12, 4), )
Plot autoencoder validation curve. :param xlabel: plot xlabel, defaults to "Mean Square Error (MSE)" :type xlabel: str, optional :param ylabel: plot ylabel, defaults to "Iteration (epoch)" :type ylabel: str, optional :param legend: plot legend, defaults to ("Entrenamiento", "Tes...
Plot autoencoder validation curve.
def plot_autoencoder_validation( self, xlabel: str = "Mean Square Error (MSE)", ylabel: str = "Iteration (epoch)", legend: tuple = ("Entrenamiento", "Test"), figsize: tuple = (12, 4), ): """Plot autoencoder validation curve. :param xlabel: plot xlabel, defaul...
[ "def", "plot_autoencoder_validation", "(", "self", ",", "xlabel", ":", "str", "=", "\"Mean Square Error (MSE)\"", ",", "ylabel", ":", "str", "=", "\"Iteration (epoch)\"", ",", "legend", ":", "tuple", "=", "(", "\"Entrenamiento\"", ",", "\"Test\"", ")", ",", "fig...
[ 111, 4 ]
[ 137, 18 ]
python
it
['nl', 'ky', 'it']
False
Anomalies.plot_autoencoder_threshold
( self, xlabel: str = "Reconstruction error (training)", ylabel: str = "Number of data", legend: tuple = ("Threshold"), figsize: tuple = (12, 4), )
Predicts anomalies by recontructing samples passed to encoder. :param xlabel: xlabel plot, defaults to "Reconstruction error (training)" :type xlabel: str, optional :param ylabel: ylabel plot, defaults to "Number of data" :type ylabel: str, optional :param legend: legend plot, d...
Predicts anomalies by recontructing samples passed to encoder.
def plot_autoencoder_threshold( self, xlabel: str = "Reconstruction error (training)", ylabel: str = "Number of data", legend: tuple = ("Threshold"), figsize: tuple = (12, 4), ): """Predicts anomalies by recontructing samples passed to encoder. :param xlabel:...
[ "def", "plot_autoencoder_threshold", "(", "self", ",", "xlabel", ":", "str", "=", "\"Reconstruction error (training)\"", ",", "ylabel", ":", "str", "=", "\"Number of data\"", ",", "legend", ":", "tuple", "=", "(", "\"Threshold\"", ")", ",", "figsize", ":", "tupl...
[ 139, 4 ]
[ 169, 18 ]
python
en
['en', 'en', 'en']
True
Anomalies.plot_autoencoder_error
( self, xlabel: str = "Data Index", ylabel: str = "Reconstruction Error", legend: tuple = ("Training", "Test", "Threshold"), figsize: tuple = (12, 4), )
Plot autoencoder error. :param xlabel: xlabel plot, defaults to "Data Index" :type xlabel: str, optional :param ylabel: ylabel plot, defaults to "Reconstruction Error" :type ylabel: str, optional :param legend: legend plot, defaults to ("Training", "Test", "Threshold") :...
Plot autoencoder error.
def plot_autoencoder_error( self, xlabel: str = "Data Index", ylabel: str = "Reconstruction Error", legend: tuple = ("Training", "Test", "Threshold"), figsize: tuple = (12, 4), ): """Plot autoencoder error. :param xlabel: xlabel plot, defaults to "Data Index"...
[ "def", "plot_autoencoder_error", "(", "self", ",", "xlabel", ":", "str", "=", "\"Data Index\"", ",", "ylabel", ":", "str", "=", "\"Reconstruction Error\"", ",", "legend", ":", "tuple", "=", "(", "\"Training\"", ",", "\"Test\"", ",", "\"Threshold\"", ")", ",", ...
[ 171, 4 ]
[ 208, 18 ]
python
da
['da', 'la', 'it']
False
Anomalies.get_autoencoder_clreport
(self, target_names=None)
Generate classification report with autoencoders results. :return: classification report with results :rtype: str
Generate classification report with autoencoders results.
def get_autoencoder_clreport(self, target_names=None): """Generate classification report with autoencoders results. :return: classification report with results :rtype: str """ y_test = np.ones((self.t_test.shape)) threshold = np.max(self.mse_train) y_test[self.ms...
[ "def", "get_autoencoder_clreport", "(", "self", ",", "target_names", "=", "None", ")", ":", "y_test", "=", "np", ".", "ones", "(", "(", "self", ".", "t_test", ".", "shape", ")", ")", "threshold", "=", "np", ".", "max", "(", "self", ".", "mse_train", ...
[ 210, 4 ]
[ 222, 9 ]
python
en
['en', 'en', 'en']
True
validate_rages
(ranges)
Validates if weight ranges are feasible :param ranges: dict { "assignment_name": [minimum_percentage, maximum_percentage] } :return: True if its feasible else False
Validates if weight ranges are feasible
def validate_rages(ranges): """ Validates if weight ranges are feasible :param ranges: dict { "assignment_name": [minimum_percentage, maximum_percentage] } :return: True if its feasible else False """ min_possible = 0 max_possible = 0 for assignment, range_item in rang...
[ "def", "validate_rages", "(", "ranges", ")", ":", "min_possible", "=", "0", "max_possible", "=", "0", "for", "assignment", ",", "range_item", "in", "ranges", ".", "items", "(", ")", ":", "if", "range_item", "[", "1", "]", "<", "range_item", "[", "0", "...
[ 3, 0 ]
[ 23, 46 ]
python
en
['en', 'error', 'th']
False
validate_grades_and_ranges
(grades, ranges)
This function validates grades and ranges to check if they are feasible and the assignments are identical in grades and ranges :param grades: dict { "assignment_name": [grade1, grade2, ...] } :param ranges: dict { "assignment_name": [minimum_percentage, maximum_percentage] ...
This function validates grades and ranges to check if they are feasible and the assignments are identical in grades and ranges
def validate_grades_and_ranges(grades, ranges): """ This function validates grades and ranges to check if they are feasible and the assignments are identical in grades and ranges :param grades: dict { "assignment_name": [grade1, grade2, ...] } :param ranges: dict { "assi...
[ "def", "validate_grades_and_ranges", "(", "grades", ",", "ranges", ")", ":", "if", "not", "validate_rages", "(", "ranges", ")", ":", "return", "False", "for", "assignment", ",", "range_item", "in", "ranges", ".", "items", "(", ")", ":", "if", "assignment", ...
[ 26, 0 ]
[ 48, 15 ]
python
en
['en', 'error', 'th']
False
calculate_weights
(grades, ranges)
This function calculates best possible choice of weights for a specific students' grades :param grades: dict { "assignment_name": [grade1, grade2, ...] } :param ranges: dict { "assignment_name": [minimum_percentage, maximum_percentage] } :return: dict { "ass...
This function calculates best possible choice of weights for a specific students' grades
def calculate_weights(grades, ranges): """ This function calculates best possible choice of weights for a specific students' grades :param grades: dict { "assignment_name": [grade1, grade2, ...] } :param ranges: dict { "assignment_name": [minimum_percentage, maximum_percenta...
[ "def", "calculate_weights", "(", "grades", ",", "ranges", ")", ":", "if", "not", "validate_grades_and_ranges", "(", "grades", ",", "ranges", ")", ":", "raise", "RangeValidationException", "(", ")", "compact_grades", "=", "{", "assignment", ":", "sum", "(", "gr...
[ 51, 0 ]
[ 96, 17 ]
python
en
['en', 'error', 'th']
False
_ptp
(x)
Peak-to-peak value of x. This implementation avoids the problem of signed integer arrays having a peak-to-peak value that cannot be represented with the array's data type. This function returns an unsigned value for signed integer arrays.
Peak-to-peak value of x.
def _ptp(x): """Peak-to-peak value of x. This implementation avoids the problem of signed integer arrays having a peak-to-peak value that cannot be represented with the array's data type. This function returns an unsigned value for signed integer arrays. """ return _unsigned_subtract(x.max(), x...
[ "def", "_ptp", "(", "x", ")", ":", "return", "_unsigned_subtract", "(", "x", ".", "max", "(", ")", ",", "x", ".", "min", "(", ")", ")" ]
[ 24, 0 ]
[ 31, 47 ]
python
en
['en', 'la', 'en']
True
_hist_bin_sqrt
(x, range)
Square root histogram bin estimator. Bin width is inversely proportional to the data size. Used by many programs for its simplicity. Parameters ---------- x : array_like Input data that is to be histogrammed, trimmed to range. May not be empty. Returns ------- h :...
Square root histogram bin estimator.
def _hist_bin_sqrt(x, range): """ Square root histogram bin estimator. Bin width is inversely proportional to the data size. Used by many programs for its simplicity. Parameters ---------- x : array_like Input data that is to be histogrammed, trimmed to range. May not be em...
[ "def", "_hist_bin_sqrt", "(", "x", ",", "range", ")", ":", "del", "range", "# unused", "return", "_ptp", "(", "x", ")", "/", "np", ".", "sqrt", "(", "x", ".", "size", ")" ]
[ 34, 0 ]
[ 52, 36 ]
python
en
['en', 'error', 'th']
False
_hist_bin_sturges
(x, range)
Sturges histogram bin estimator. A very simplistic estimator based on the assumption of normality of the data. This estimator has poor performance for non-normal data, which becomes especially obvious for large data sets. The estimate depends only on size of the data. Parameters ---------...
Sturges histogram bin estimator.
def _hist_bin_sturges(x, range): """ Sturges histogram bin estimator. A very simplistic estimator based on the assumption of normality of the data. This estimator has poor performance for non-normal data, which becomes especially obvious for large data sets. The estimate depends only on size of...
[ "def", "_hist_bin_sturges", "(", "x", ",", "range", ")", ":", "del", "range", "# unused", "return", "_ptp", "(", "x", ")", "/", "(", "np", ".", "log2", "(", "x", ".", "size", ")", "+", "1.0", ")" ]
[ 55, 0 ]
[ 75, 44 ]
python
en
['en', 'error', 'th']
False
_hist_bin_rice
(x, range)
Rice histogram bin estimator. Another simple estimator with no normality assumption. It has better performance for large data than Sturges, but tends to overestimate the number of bins. The number of bins is proportional to the cube root of data size (asymptotically optimal). The estimate depends ...
Rice histogram bin estimator.
def _hist_bin_rice(x, range): """ Rice histogram bin estimator. Another simple estimator with no normality assumption. It has better performance for large data than Sturges, but tends to overestimate the number of bins. The number of bins is proportional to the cube root of data size (asymptoti...
[ "def", "_hist_bin_rice", "(", "x", ",", "range", ")", ":", "del", "range", "# unused", "return", "_ptp", "(", "x", ")", "/", "(", "2.0", "*", "x", ".", "size", "**", "(", "1.0", "/", "3", ")", ")" ]
[ 78, 0 ]
[ 99, 48 ]
python
en
['en', 'error', 'th']
False
_hist_bin_scott
(x, range)
Scott histogram bin estimator. The binwidth is proportional to the standard deviation of the data and inversely proportional to the cube root of data size (asymptotically optimal). Parameters ---------- x : array_like Input data that is to be histogrammed, trimmed to range. May no...
Scott histogram bin estimator.
def _hist_bin_scott(x, range): """ Scott histogram bin estimator. The binwidth is proportional to the standard deviation of the data and inversely proportional to the cube root of data size (asymptotically optimal). Parameters ---------- x : array_like Input data that is to be ...
[ "def", "_hist_bin_scott", "(", "x", ",", "range", ")", ":", "del", "range", "# unused", "return", "(", "24.0", "*", "np", ".", "pi", "**", "0.5", "/", "x", ".", "size", ")", "**", "(", "1.0", "/", "3.0", ")", "*", "np", ".", "std", "(", "x", ...
[ 102, 0 ]
[ 121, 64 ]
python
en
['en', 'error', 'th']
False
_hist_bin_stone
(x, range)
Histogram bin estimator based on minimizing the estimated integrated squared error (ISE). The number of bins is chosen by minimizing the estimated ISE against the unknown true distribution. The ISE is estimated using cross-validation and can be regarded as a generalization of Scott's rule. https://en....
Histogram bin estimator based on minimizing the estimated integrated squared error (ISE).
def _hist_bin_stone(x, range): """ Histogram bin estimator based on minimizing the estimated integrated squared error (ISE). The number of bins is chosen by minimizing the estimated ISE against the unknown true distribution. The ISE is estimated using cross-validation and can be regarded as a generaliz...
[ "def", "_hist_bin_stone", "(", "x", ",", "range", ")", ":", "n", "=", "x", ".", "size", "ptp_x", "=", "_ptp", "(", "x", ")", "if", "n", "<=", "1", "or", "ptp_x", "==", "0", ":", "return", "0", "def", "jhat", "(", "nbins", ")", ":", "hh", "=",...
[ 124, 0 ]
[ 163, 24 ]
python
en
['en', 'error', 'th']
False
_hist_bin_doane
(x, range)
Doane's histogram bin estimator. Improved version of Sturges' formula which works better for non-normal data. See stats.stackexchange.com/questions/55134/doanes-formula-for-histogram-binning Parameters ---------- x : array_like Input data that is to be histogrammed, trimmed to ran...
Doane's histogram bin estimator.
def _hist_bin_doane(x, range): """ Doane's histogram bin estimator. Improved version of Sturges' formula which works better for non-normal data. See stats.stackexchange.com/questions/55134/doanes-formula-for-histogram-binning Parameters ---------- x : array_like Input data that...
[ "def", "_hist_bin_doane", "(", "x", ",", "range", ")", ":", "del", "range", "# unused", "if", "x", ".", "size", ">", "2", ":", "sg1", "=", "np", ".", "sqrt", "(", "6.0", "*", "(", "x", ".", "size", "-", "2", ")", "/", "(", "(", "x", ".", "s...
[ 166, 0 ]
[ 198, 14 ]
python
en
['en', 'error', 'th']
False
_hist_bin_fd
(x, range)
The Freedman-Diaconis histogram bin estimator. The Freedman-Diaconis rule uses interquartile range (IQR) to estimate binwidth. It is considered a variation of the Scott rule with more robustness as the IQR is less affected by outliers than the standard deviation. However, the IQR depends on fewer ...
The Freedman-Diaconis histogram bin estimator.
def _hist_bin_fd(x, range): """ The Freedman-Diaconis histogram bin estimator. The Freedman-Diaconis rule uses interquartile range (IQR) to estimate binwidth. It is considered a variation of the Scott rule with more robustness as the IQR is less affected by outliers than the standard deviation....
[ "def", "_hist_bin_fd", "(", "x", ",", "range", ")", ":", "del", "range", "# unused", "iqr", "=", "np", ".", "subtract", "(", "*", "np", ".", "percentile", "(", "x", ",", "[", "75", ",", "25", "]", ")", ")", "return", "2.0", "*", "iqr", "*", "x"...
[ 201, 0 ]
[ 228, 45 ]
python
en
['en', 'error', 'th']
False
_hist_bin_auto
(x, range)
Histogram bin estimator that uses the minimum width of the Freedman-Diaconis and Sturges estimators if the FD bandwidth is non zero and the Sturges estimator if the FD bandwidth is 0. The FD estimator is usually the most robust method, but its width estimate tends to be too large for small `x` and...
Histogram bin estimator that uses the minimum width of the Freedman-Diaconis and Sturges estimators if the FD bandwidth is non zero and the Sturges estimator if the FD bandwidth is 0.
def _hist_bin_auto(x, range): """ Histogram bin estimator that uses the minimum width of the Freedman-Diaconis and Sturges estimators if the FD bandwidth is non zero and the Sturges estimator if the FD bandwidth is 0. The FD estimator is usually the most robust method, but its width estimate te...
[ "def", "_hist_bin_auto", "(", "x", ",", "range", ")", ":", "fd_bw", "=", "_hist_bin_fd", "(", "x", ",", "range", ")", "sturges_bw", "=", "_hist_bin_sturges", "(", "x", ",", "range", ")", "del", "range", "# unused", "if", "fd_bw", ":", "return", "min", ...
[ 231, 0 ]
[ 272, 25 ]
python
en
['en', 'error', 'th']
False
_ravel_and_check_weights
(a, weights)
Check a and weights have matching shapes, and ravel both
Check a and weights have matching shapes, and ravel both
def _ravel_and_check_weights(a, weights): """ Check a and weights have matching shapes, and ravel both """ a = np.asarray(a) # Ensure that the array is a "subtractable" dtype if a.dtype == np.bool_: warnings.warn("Converting input from {} to {} for compatibility." .format(...
[ "def", "_ravel_and_check_weights", "(", "a", ",", "weights", ")", ":", "a", "=", "np", ".", "asarray", "(", "a", ")", "# Ensure that the array is a \"subtractable\" dtype", "if", "a", ".", "dtype", "==", "np", ".", "bool_", ":", "warnings", ".", "warn", "(",...
[ 285, 0 ]
[ 303, 21 ]
python
en
['en', 'en', 'en']
True
_get_outer_edges
(a, range)
Determine the outer bin edges to use, from either the data or the range argument
Determine the outer bin edges to use, from either the data or the range argument
def _get_outer_edges(a, range): """ Determine the outer bin edges to use, from either the data or the range argument """ if range is not None: first_edge, last_edge = range if first_edge > last_edge: raise ValueError( 'max must be larger than min in range ...
[ "def", "_get_outer_edges", "(", "a", ",", "range", ")", ":", "if", "range", "is", "not", "None", ":", "first_edge", ",", "last_edge", "=", "range", "if", "first_edge", ">", "last_edge", ":", "raise", "ValueError", "(", "'max must be larger than min in range para...
[ 306, 0 ]
[ 333, 32 ]
python
en
['en', 'error', 'th']
False
_unsigned_subtract
(a, b)
Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram
Subtract two values where a >= b, and produce an unsigned result
def _unsigned_subtract(a, b): """ Subtract two values where a >= b, and produce an unsigned result This is needed when finding the difference between the upper and lower bound of an int16 histogram """ # coerce to a single type signed_to_unsigned = { np.byte: np.ubyte, np.sh...
[ "def", "_unsigned_subtract", "(", "a", ",", "b", ")", ":", "# coerce to a single type", "signed_to_unsigned", "=", "{", "np", ".", "byte", ":", "np", ".", "ubyte", ",", "np", ".", "short", ":", "np", ".", "ushort", ",", "np", ".", "intc", ":", "np", ...
[ 336, 0 ]
[ 359, 60 ]
python
en
['en', 'error', 'th']
False
_get_bin_edges
(a, bins, range, weights)
Computes the bins used internally by `histogram`. Parameters ========== a : ndarray Ravelled data array bins, range Forwarded arguments from `histogram`. weights : ndarray, optional Ravelled weights array, or None Returns ======= bin_edges : ndarray ...
Computes the bins used internally by `histogram`.
def _get_bin_edges(a, bins, range, weights): """ Computes the bins used internally by `histogram`. Parameters ========== a : ndarray Ravelled data array bins, range Forwarded arguments from `histogram`. weights : ndarray, optional Ravelled weights array, or None ...
[ "def", "_get_bin_edges", "(", "a", ",", "bins", ",", "range", ",", "weights", ")", ":", "# parse the overloaded bins argument", "n_equal_bins", "=", "None", "bin_edges", "=", "None", "if", "isinstance", "(", "bins", ",", "basestring", ")", ":", "bin_name", "="...
[ 362, 0 ]
[ 453, 30 ]
python
en
['en', 'error', 'th']
False
_search_sorted_inclusive
(a, v)
Like `searchsorted`, but where the last item in `v` is placed on the right. In the context of a histogram, this makes the last bin edge inclusive
Like `searchsorted`, but where the last item in `v` is placed on the right.
def _search_sorted_inclusive(a, v): """ Like `searchsorted`, but where the last item in `v` is placed on the right. In the context of a histogram, this makes the last bin edge inclusive """ return np.concatenate(( a.searchsorted(v[:-1], 'left'), a.searchsorted(v[-1:], 'right') )...
[ "def", "_search_sorted_inclusive", "(", "a", ",", "v", ")", ":", "return", "np", ".", "concatenate", "(", "(", "a", ".", "searchsorted", "(", "v", "[", ":", "-", "1", "]", ",", "'left'", ")", ",", "a", ".", "searchsorted", "(", "v", "[", "-", "1"...
[ 456, 0 ]
[ 465, 6 ]
python
en
['en', 'error', 'th']
False
histogram_bin_edges
(a, bins=10, range=None, weights=None)
r""" Function to calculate only the edges of the bins used by the `histogram` function. Parameters ---------- a : array_like Input data. The histogram is computed over the flattened array. bins : int or sequence of scalars or str, optional If `bins` is an int, it defines the num...
r""" Function to calculate only the edges of the bins used by the `histogram` function.
def histogram_bin_edges(a, bins=10, range=None, weights=None): r""" Function to calculate only the edges of the bins used by the `histogram` function. Parameters ---------- a : array_like Input data. The histogram is computed over the flattened array. bins : int or sequence of scala...
[ "def", "histogram_bin_edges", "(", "a", ",", "bins", "=", "10", ",", "range", "=", "None", ",", "weights", "=", "None", ")", ":", "a", ",", "weights", "=", "_ravel_and_check_weights", "(", "a", ",", "weights", ")", "bin_edges", ",", "_", "=", "_get_bin...
[ 473, 0 ]
[ 671, 20 ]
python
cy
['en', 'cy', 'hi']
False
histogram
(a, bins=10, range=None, normed=None, weights=None, density=None)
r""" Compute the histogram of a set of data. Parameters ---------- a : array_like Input data. The histogram is computed over the flattened array. bins : int or sequence of scalars or str, optional If `bins` is an int, it defines the number of equal-width bins in the given ra...
r""" Compute the histogram of a set of data.
def histogram(a, bins=10, range=None, normed=None, weights=None, density=None): r""" Compute the histogram of a set of data. Parameters ---------- a : array_like Input data. The histogram is computed over the flattened array. bins : int or sequence of scalars or str, optio...
[ "def", "histogram", "(", "a", ",", "bins", "=", "10", ",", "range", "=", "None", ",", "normed", "=", "None", ",", "weights", "=", "None", ",", "density", "=", "None", ")", ":", "a", ",", "weights", "=", "_ravel_and_check_weights", "(", "a", ",", "w...
[ 680, 0 ]
[ 930, 27 ]
python
cy
['en', 'cy', 'hi']
False
histogramdd
(sample, bins=10, range=None, normed=None, weights=None, density=None)
Compute the multidimensional histogram of some data. Parameters ---------- sample : (N, D) array, or (D, N) array_like The data to be histogrammed. Note the unusual interpretation of sample when an array_like: * When an array, each row is a coordinate in a D-dimensional space...
Compute the multidimensional histogram of some data.
def histogramdd(sample, bins=10, range=None, normed=None, weights=None, density=None): """ Compute the multidimensional histogram of some data. Parameters ---------- sample : (N, D) array, or (D, N) array_like The data to be histogrammed. Note the unusual interpreta...
[ "def", "histogramdd", "(", "sample", ",", "bins", "=", "10", ",", "range", "=", "None", ",", "normed", "=", "None", ",", "weights", "=", "None", ",", "density", "=", "None", ")", ":", "try", ":", "# Sample is an ND-array.", "N", ",", "D", "=", "sampl...
[ 945, 0 ]
[ 1122, 22 ]
python
en
['en', 'error', 'th']
False
test_resume_training_on_cpu
(tmpdir)
Checks if training can be resumed from a saved checkpoint on CPU
Checks if training can be resumed from a saved checkpoint on CPU
def test_resume_training_on_cpu(tmpdir): """ Checks if training can be resumed from a saved checkpoint on CPU""" # Train a model on TPU model = BoringModel() trainer = Trainer( checkpoint_callback=True, max_epochs=1, tpu_cores=8, ) trainer.fit(model) model_path = tra...
[ "def", "test_resume_training_on_cpu", "(", "tmpdir", ")", ":", "# Train a model on TPU", "model", "=", "BoringModel", "(", ")", "trainer", "=", "Trainer", "(", "checkpoint_callback", "=", "True", ",", "max_epochs", "=", "1", ",", "tpu_cores", "=", "8", ",", ")...
[ 43, 0 ]
[ 69, 90 ]
python
en
['en', 'en', 'en']
True
test_if_test_works_after_train
(tmpdir)
Ensure that .test() works after .fit()
Ensure that .test() works after .fit()
def test_if_test_works_after_train(tmpdir): """ Ensure that .test() works after .fit() """ # Train a model on TPU model = BoringModel() trainer = Trainer(max_epochs=1, tpu_cores=8, default_root_dir=tmpdir, fast_dev_run=True) trainer.fit(model) assert len(trainer.test(model)) == 1
[ "def", "test_if_test_works_after_train", "(", "tmpdir", ")", ":", "# Train a model on TPU", "model", "=", "BoringModel", "(", ")", "trainer", "=", "Trainer", "(", "max_epochs", "=", "1", ",", "tpu_cores", "=", "8", ",", "default_root_dir", "=", "tmpdir", ",", ...
[ 74, 0 ]
[ 81, 40 ]
python
en
['en', 'en', 'en']
True
test_weight_tying_warning
(tmpdir, capsys=None)
Ensure a warning is thrown if model parameter lengths do not match post moving to device.
Ensure a warning is thrown if model parameter lengths do not match post moving to device.
def test_weight_tying_warning(tmpdir, capsys=None): """ Ensure a warning is thrown if model parameter lengths do not match post moving to device. """ model = WeightSharingModule() trainer = Trainer(checkpoint_callback=True, max_epochs=1, tpu_cores=1) with pytest.warns(UserWarning, match=r'...
[ "def", "test_weight_tying_warning", "(", "tmpdir", ",", "capsys", "=", "None", ")", ":", "model", "=", "WeightSharingModule", "(", ")", "trainer", "=", "Trainer", "(", "checkpoint_callback", "=", "True", ",", "max_epochs", "=", "1", ",", "tpu_cores", "=", "1...
[ 86, 0 ]
[ 97, 21 ]
python
en
['en', 'error', 'th']
False
test_if_weights_tied
(tmpdir, capsys=None)
Test if weights are properly tied on `on_post_move_to_device`. Ensure no warning for parameter mismatch is thrown.
Test if weights are properly tied on `on_post_move_to_device`. Ensure no warning for parameter mismatch is thrown.
def test_if_weights_tied(tmpdir, capsys=None): """ Test if weights are properly tied on `on_post_move_to_device`. Ensure no warning for parameter mismatch is thrown. """ class Model(WeightSharingModule): def on_post_move_to_device(self): self.layer_3.weight = self.layer_1.weigh...
[ "def", "test_if_weights_tied", "(", "tmpdir", ",", "capsys", "=", "None", ")", ":", "class", "Model", "(", "WeightSharingModule", ")", ":", "def", "on_post_move_to_device", "(", "self", ")", ":", "self", ".", "layer_3", ".", "weight", "=", "self", ".", "la...
[ 102, 0 ]
[ 121, 40 ]
python
en
['en', 'error', 'th']
False
ix_
(*args)
Construct an open mesh from multiple sequences. This function takes N 1-D sequences and returns N outputs with N dimensions each, such that the shape is 1 in all but one dimension and the dimension with the non-unit shape value cycles through all N dimensions. Using `ix_` one can quickly cons...
Construct an open mesh from multiple sequences.
def ix_(*args): """ Construct an open mesh from multiple sequences. This function takes N 1-D sequences and returns N outputs with N dimensions each, such that the shape is 1 in all but one dimension and the dimension with the non-unit shape value cycles through all N dimensions. Using `ix...
[ "def", "ix_", "(", "*", "args", ")", ":", "out", "=", "[", "]", "nd", "=", "len", "(", "args", ")", "for", "k", ",", "new", "in", "enumerate", "(", "args", ")", ":", "if", "not", "isinstance", "(", "new", ",", "_nx", ".", "ndarray", ")", ":",...
[ 36, 0 ]
[ 107, 21 ]
python
en
['en', 'error', 'th']
False
fill_diagonal
(a, val, wrap=False)
Fill the main diagonal of the given array of any dimensionality. For an array `a` with ``a.ndim >= 2``, the diagonal is the list of locations with indices ``a[i, ..., i]`` all identical. This function modifies the input array in-place, it does not return a value. Parameters ---------- a : arra...
Fill the main diagonal of the given array of any dimensionality.
def fill_diagonal(a, val, wrap=False): """Fill the main diagonal of the given array of any dimensionality. For an array `a` with ``a.ndim >= 2``, the diagonal is the list of locations with indices ``a[i, ..., i]`` all identical. This function modifies the input array in-place, it does not return a valu...
[ "def", "fill_diagonal", "(", "a", ",", "val", ",", "wrap", "=", "False", ")", ":", "if", "a", ".", "ndim", "<", "2", ":", "raise", "ValueError", "(", "\"array must be at least 2-d\"", ")", "end", "=", "None", "if", "a", ".", "ndim", "==", "2", ":", ...
[ 751, 0 ]
[ 879, 27 ]
python
en
['en', 'en', 'en']
True
diag_indices
(n, ndim=2)
Return the indices to access the main diagonal of an array. This returns a tuple of indices that can be used to access the main diagonal of an array `a` with ``a.ndim >= 2`` dimensions and shape (n, n, ..., n). For ``a.ndim = 2`` this is the usual diagonal, for ``a.ndim > 2`` this is the set of in...
Return the indices to access the main diagonal of an array.
def diag_indices(n, ndim=2): """ Return the indices to access the main diagonal of an array. This returns a tuple of indices that can be used to access the main diagonal of an array `a` with ``a.ndim >= 2`` dimensions and shape (n, n, ..., n). For ``a.ndim = 2`` this is the usual diagonal, for ...
[ "def", "diag_indices", "(", "n", ",", "ndim", "=", "2", ")", ":", "idx", "=", "arange", "(", "n", ")", "return", "(", "idx", ",", ")", "*", "ndim" ]
[ 883, 0 ]
[ 948, 24 ]
python
en
['en', 'error', 'th']
False
diag_indices_from
(arr)
Return the indices to access the main diagonal of an n-dimensional array. See `diag_indices` for full details. Parameters ---------- arr : array, at least 2-D See Also -------- diag_indices Notes ----- .. versionadded:: 1.4.0
Return the indices to access the main diagonal of an n-dimensional array.
def diag_indices_from(arr): """ Return the indices to access the main diagonal of an n-dimensional array. See `diag_indices` for full details. Parameters ---------- arr : array, at least 2-D See Also -------- diag_indices Notes ----- .. versionadded:: 1.4.0 """ ...
[ "def", "diag_indices_from", "(", "arr", ")", ":", "if", "not", "arr", ".", "ndim", ">=", "2", ":", "raise", "ValueError", "(", "\"input array must be at least 2-d\"", ")", "# For more than d=2, the strided formula is only valid for arrays with", "# all dimensions equal, so we...
[ 956, 0 ]
[ 983, 47 ]
python
en
['en', 'error', 'th']
False
loop_pos.first_group
(self, getter=None)
Returns true if this item is the start of a new group, where groups mean that some attribute has changed. The getter can be None (the item itself changes), an attribute name like ``'.attr'``, a function, or a dict key or list index.
Returns true if this item is the start of a new group, where groups mean that some attribute has changed. The getter can be None (the item itself changes), an attribute name like ``'.attr'``, a function, or a dict key or list index.
def first_group(self, getter=None): """ Returns true if this item is the start of a new group, where groups mean that some attribute has changed. The getter can be None (the item itself changes), an attribute name like ``'.attr'``, a function, or a dict key or list index. ...
[ "def", "first_group", "(", "self", ",", "getter", "=", "None", ")", ":", "if", "self", ".", "first", ":", "return", "True", "return", "self", ".", "_compare_group", "(", "self", ".", "item", ",", "self", ".", "previous", ",", "getter", ")" ]
[ 127, 4 ]
[ 136, 68 ]
python
en
['en', 'error', 'th']
False
loop_pos.last_group
(self, getter=None)
Returns true if this item is the end of a new group, where groups mean that some attribute has changed. The getter can be None (the item itself changes), an attribute name like ``'.attr'``, a function, or a dict key or list index.
Returns true if this item is the end of a new group, where groups mean that some attribute has changed. The getter can be None (the item itself changes), an attribute name like ``'.attr'``, a function, or a dict key or list index.
def last_group(self, getter=None): """ Returns true if this item is the end of a new group, where groups mean that some attribute has changed. The getter can be None (the item itself changes), an attribute name like ``'.attr'``, a function, or a dict key or list index. "...
[ "def", "last_group", "(", "self", ",", "getter", "=", "None", ")", ":", "if", "self", ".", "last", ":", "return", "True", "return", "self", ".", "_compare_group", "(", "self", ".", "item", ",", "self", ".", "__next__", ",", "getter", ")" ]
[ 138, 4 ]
[ 147, 68 ]
python
en
['en', 'error', 'th']
False
TensorBoardLogger.root_dir
(self)
Parent directory for all tensorboard checkpoint subdirectories. If the experiment name parameter is ``None`` or the empty string, no experiment subdirectory is used and the checkpoint will be saved in "save_dir/version_dir"
Parent directory for all tensorboard checkpoint subdirectories. If the experiment name parameter is ``None`` or the empty string, no experiment subdirectory is used and the checkpoint will be saved in "save_dir/version_dir"
def root_dir(self) -> str: """ Parent directory for all tensorboard checkpoint subdirectories. If the experiment name parameter is ``None`` or the empty string, no experiment subdirectory is used and the checkpoint will be saved in "save_dir/version_dir" """ if self.name ...
[ "def", "root_dir", "(", "self", ")", "->", "str", ":", "if", "self", ".", "name", "is", "None", "or", "len", "(", "self", ".", "name", ")", "==", "0", ":", "return", "self", ".", "save_dir", "else", ":", "return", "os", ".", "path", ".", "join", ...
[ 96, 4 ]
[ 105, 57 ]
python
en
['en', 'error', 'th']
False
TensorBoardLogger.log_dir
(self)
The directory for this run's tensorboard checkpoint. By default, it is named ``'version_${self.version}'`` but it can be overridden by passing a string value for the constructor's version parameter instead of ``None`` or an int.
The directory for this run's tensorboard checkpoint. By default, it is named ``'version_${self.version}'`` but it can be overridden by passing a string value for the constructor's version parameter instead of ``None`` or an int.
def log_dir(self) -> str: """ The directory for this run's tensorboard checkpoint. By default, it is named ``'version_${self.version}'`` but it can be overridden by passing a string value for the constructor's version parameter instead of ``None`` or an int. """ # create ...
[ "def", "log_dir", "(", "self", ")", "->", "str", ":", "# create a pseudo standard path ala test-tube", "version", "=", "self", ".", "version", "if", "isinstance", "(", "self", ".", "version", ",", "str", ")", "else", "f\"version_{self.version}\"", "log_dir", "=", ...
[ 108, 4 ]
[ 117, 22 ]
python
en
['en', 'error', 'th']
False
TensorBoardLogger.experiment
(self)
r""" Actual tensorboard object. To use TensorBoard features in your :class:`~pytorch_lightning.core.lightning.LightningModule` do the following. Example:: self.logger.experiment.some_tensorboard_function()
r""" Actual tensorboard object. To use TensorBoard features in your :class:`~pytorch_lightning.core.lightning.LightningModule` do the following.
def experiment(self) -> SummaryWriter: r""" Actual tensorboard object. To use TensorBoard features in your :class:`~pytorch_lightning.core.lightning.LightningModule` do the following. Example:: self.logger.experiment.some_tensorboard_function() """ if self....
[ "def", "experiment", "(", "self", ")", "->", "SummaryWriter", ":", "if", "self", ".", "_experiment", "is", "not", "None", ":", "return", "self", ".", "_experiment", "assert", "rank_zero_only", ".", "rank", "==", "0", ",", "'tried to init log dirs in non global_r...
[ 125, 4 ]
[ 142, 31 ]
python
cy
['en', 'cy', 'hi']
False
TensorBoardLogger.log_hyperparams
( self, params: Union[Dict[str, Any], Namespace], metrics: Optional[Dict[str, Any]] = None, )
Record hyperparameters. TensorBoard logs with and without saved hyperparameters are incompatible, the hyperparameters are then not displayed in the TensorBoard. Please delete or move the previously saved logs to display the new ones with hyperparameters. Args: params: a dic...
Record hyperparameters. TensorBoard logs with and without saved hyperparameters are incompatible, the hyperparameters are then not displayed in the TensorBoard. Please delete or move the previously saved logs to display the new ones with hyperparameters.
def log_hyperparams( self, params: Union[Dict[str, Any], Namespace], metrics: Optional[Dict[str, Any]] = None, ) -> None: """ Record hyperparameters. TensorBoard logs with and without saved hyperparameters are incompatible, the hyperparameters are then not displayed i...
[ "def", "log_hyperparams", "(", "self", ",", "params", ":", "Union", "[", "Dict", "[", "str", ",", "Any", "]", ",", "Namespace", "]", ",", "metrics", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ",", ")", "->", "Non...
[ 145, 4 ]
[ 184, 35 ]
python
en
['en', 'error', 'th']
False
verify_matching_signatures
(implementation, dispatcher)
Verify that a dispatcher function has the right signature.
Verify that a dispatcher function has the right signature.
def verify_matching_signatures(implementation, dispatcher): """Verify that a dispatcher function has the right signature.""" implementation_spec = ArgSpec(*getargspec(implementation)) dispatcher_spec = ArgSpec(*getargspec(dispatcher)) if (implementation_spec.args != dispatcher_spec.args or ...
[ "def", "verify_matching_signatures", "(", "implementation", ",", "dispatcher", ")", ":", "implementation_spec", "=", "ArgSpec", "(", "*", "getargspec", "(", "implementation", ")", ")", "dispatcher_spec", "=", "ArgSpec", "(", "*", "getargspec", "(", "dispatcher", "...
[ 71, 0 ]
[ 90, 57 ]
python
en
['en', 'en', 'en']
True
set_module
(module)
Decorator for overriding __module__ on a function or class. Example usage:: @set_module('numpy') def example(): pass assert example.__module__ == 'numpy'
Decorator for overriding __module__ on a function or class.
def set_module(module): """Decorator for overriding __module__ on a function or class. Example usage:: @set_module('numpy') def example(): pass assert example.__module__ == 'numpy' """ def decorator(func): if module is not None: func.__module__ ...
[ "def", "set_module", "(", "module", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "module", "is", "not", "None", ":", "func", ".", "__module__", "=", "module", "return", "func", "return", "decorator" ]
[ 93, 0 ]
[ 108, 20 ]
python
en
['en', 'en', 'en']
True
array_function_dispatch
(dispatcher, module=None, verify=True, docs_from_dispatcher=False)
Decorator for adding dispatch with the __array_function__ protocol. See NEP-18 for example usage. Parameters ---------- dispatcher : callable Function that when called like ``dispatcher(*args, **kwargs)`` with arguments from the NumPy function call returns an iterable of array-...
Decorator for adding dispatch with the __array_function__ protocol.
def array_function_dispatch(dispatcher, module=None, verify=True, docs_from_dispatcher=False): """Decorator for adding dispatch with the __array_function__ protocol. See NEP-18 for example usage. Parameters ---------- dispatcher : callable Function that when cal...
[ "def", "array_function_dispatch", "(", "dispatcher", ",", "module", "=", "None", ",", "verify", "=", "True", ",", "docs_from_dispatcher", "=", "False", ")", ":", "if", "not", "ARRAY_FUNCTION_ENABLED", ":", "def", "decorator", "(", "implementation", ")", ":", "...
[ 111, 0 ]
[ 192, 20 ]
python
en
['en', 'en', 'en']
True
array_function_from_dispatcher
( implementation, module=None, verify=True, docs_from_dispatcher=True)
Like array_function_dispatcher, but with function arguments flipped.
Like array_function_dispatcher, but with function arguments flipped.
def array_function_from_dispatcher( implementation, module=None, verify=True, docs_from_dispatcher=True): """Like array_function_dispatcher, but with function arguments flipped.""" def decorator(dispatcher): return array_function_dispatch( dispatcher, module, verify=verify, ...
[ "def", "array_function_from_dispatcher", "(", "implementation", ",", "module", "=", "None", ",", "verify", "=", "True", ",", "docs_from_dispatcher", "=", "True", ")", ":", "def", "decorator", "(", "dispatcher", ")", ":", "return", "array_function_dispatch", "(", ...
[ 195, 0 ]
[ 203, 20 ]
python
en
['en', 'en', 'en']
True
test_state_dict
(tmpdir)
test that metric states can be removed and added to state dict
test that metric states can be removed and added to state dict
def test_state_dict(tmpdir): """ test that metric states can be removed and added to state dict """ metric = Dummy() assert metric.state_dict() == OrderedDict() metric.persistent(True) assert metric.state_dict() == OrderedDict(x=0) metric.persistent(False) assert metric.state_dict() == Order...
[ "def", "test_state_dict", "(", "tmpdir", ")", ":", "metric", "=", "Dummy", "(", ")", "assert", "metric", ".", "state_dict", "(", ")", "==", "OrderedDict", "(", ")", "metric", ".", "persistent", "(", "True", ")", "assert", "metric", ".", "state_dict", "("...
[ 239, 0 ]
[ 246, 47 ]
python
en
['en', 'en', 'en']
True
test_child_metric_state_dict
()
test that child metric states will be added to parent state dict
test that child metric states will be added to parent state dict
def test_child_metric_state_dict(): """ test that child metric states will be added to parent state dict """ class TestModule(nn.Module): def __init__(self): super().__init__() self.metric = Dummy() self.metric.add_state('a', torch.tensor(0), persistent=True) ...
[ "def", "test_child_metric_state_dict", "(", ")", ":", "class", "TestModule", "(", "nn", ".", "Module", ")", ":", "def", "__init__", "(", "self", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "metric", "=", "Dummy", "(", ")", "s...
[ 249, 0 ]
[ 267, 53 ]
python
en
['en', 'en', 'en']
True
test_metric_collection_wrong_input
(tmpdir)
Check that errors are raised on wrong input
Check that errors are raised on wrong input
def test_metric_collection_wrong_input(tmpdir): """ Check that errors are raised on wrong input """ m1 = DummyMetric1() # Not all input are metrics (list) with pytest.raises(ValueError): _ = MetricCollection([m1, 5]) # Not all input are metrics (dict) with pytest.raises(ValueError): ...
[ "def", "test_metric_collection_wrong_input", "(", "tmpdir", ")", ":", "m1", "=", "DummyMetric1", "(", ")", "# Not all input are metrics (list)", "with", "pytest", ".", "raises", "(", "ValueError", ")", ":", "_", "=", "MetricCollection", "(", "[", "m1", ",", "5",...
[ 346, 0 ]
[ 364, 32 ]
python
en
['en', 'en', 'en']
True
test_metric_collection_args_kwargs
(tmpdir)
Check that args and kwargs gets passed correctly in metric collection, Checks both update and forward method
Check that args and kwargs gets passed correctly in metric collection, Checks both update and forward method
def test_metric_collection_args_kwargs(tmpdir): """ Check that args and kwargs gets passed correctly in metric collection, Checks both update and forward method """ m1 = DummyMetric1() m2 = DummyMetric2() metric_collection = MetricCollection([m1, m2]) # args gets passed to all metrics ...
[ "def", "test_metric_collection_args_kwargs", "(", "tmpdir", ")", ":", "m1", "=", "DummyMetric1", "(", ")", "m2", "=", "DummyMetric2", "(", ")", "metric_collection", "=", "MetricCollection", "(", "[", "m1", ",", "m2", "]", ")", "# args gets passed to all metrics", ...
[ 367, 0 ]
[ 393, 53 ]
python
en
['en', 'en', 'en']
True
find_Triplets_with_zero_sum
(arr, num)
find triplets in a given array whose sum is zero Parameteres : arr : input array num = size of input array Output : if triplets found return their values else return "No Triplet Found"
find triplets in a given array whose sum is zero Parameteres : arr : input array num = size of input array Output : if triplets found return their values else return "No Triplet Found"
def find_Triplets_with_zero_sum(arr, num): ''' find triplets in a given array whose sum is zero Parameteres : arr : input array num = size of input array Output : if triplets found return their values else return "No Triplet Found" ...
[ "def", "find_Triplets_with_zero_sum", "(", "arr", ",", "num", ")", ":", "# bool variable to check if triplet found or not ", "found", "=", "False", "# sort array elements ", "arr", ".", "sort", "(", ")", "# Run a loop until l is less than r, if the sum of array[l], array[r] is eq...
[ 7, 0 ]
[ 56, 34 ]
python
en
['en', 'en', 'en']
True
BottomUpBaseDataset.__len__
(self)
Get dataset length.
Get dataset length.
def __len__(self): """Get dataset length.""" return len(self.img_ids)
[ "def", "__len__", "(", "self", ")", ":", "return", "len", "(", "self", ".", "img_ids", ")" ]
[ 58, 4 ]
[ 60, 32 ]
python
en
['fr', 'su', 'en']
False
BottomUpBaseDataset._get_single
(self, idx)
Get anno for a single image.
Get anno for a single image.
def _get_single(self, idx): """Get anno for a single image.""" raise NotImplementedError
[ "def", "_get_single", "(", "self", ",", "idx", ")", ":", "raise", "NotImplementedError" ]
[ 62, 4 ]
[ 64, 33 ]
python
en
['en', 'en', 'en']
True
BottomUpBaseDataset.prepare_train_img
(self, idx)
Prepare image for training given the index.
Prepare image for training given the index.
def prepare_train_img(self, idx): """Prepare image for training given the index.""" results = copy.deepcopy(self._get_single(idx)) results['ann_info'] = self.ann_info return self.pipeline(results)
[ "def", "prepare_train_img", "(", "self", ",", "idx", ")", ":", "results", "=", "copy", ".", "deepcopy", "(", "self", ".", "_get_single", "(", "idx", ")", ")", "results", "[", "'ann_info'", "]", "=", "self", ".", "ann_info", "return", "self", ".", "pipe...
[ 66, 4 ]
[ 70, 37 ]
python
en
['en', 'en', 'en']
True
BottomUpBaseDataset.prepare_test_img
(self, idx)
Prepare image for testing given the index.
Prepare image for testing given the index.
def prepare_test_img(self, idx): """Prepare image for testing given the index.""" results = copy.deepcopy(self._get_single(idx)) results['ann_info'] = self.ann_info return self.pipeline(results)
[ "def", "prepare_test_img", "(", "self", ",", "idx", ")", ":", "results", "=", "copy", ".", "deepcopy", "(", "self", ".", "_get_single", "(", "idx", ")", ")", "results", "[", "'ann_info'", "]", "=", "self", ".", "ann_info", "return", "self", ".", "pipel...
[ 72, 4 ]
[ 76, 37 ]
python
en
['en', 'en', 'en']
True
BottomUpBaseDataset.__getitem__
(self, idx)
Get the sample for either training or testing given index.
Get the sample for either training or testing given index.
def __getitem__(self, idx): """Get the sample for either training or testing given index.""" if self.test_mode: return self.prepare_test_img(idx) return self.prepare_train_img(idx)
[ "def", "__getitem__", "(", "self", ",", "idx", ")", ":", "if", "self", ".", "test_mode", ":", "return", "self", ".", "prepare_test_img", "(", "idx", ")", "return", "self", ".", "prepare_train_img", "(", "idx", ")" ]
[ 78, 4 ]
[ 83, 42 ]
python
en
['en', 'en', 'en']
True
Tuner.scale_batch_size
( self, model, mode: str = 'power', steps_per_trial: int = 3, init_val: int = 2, max_trials: int = 25, batch_arg_name: str = 'batch_size', **fit_kwargs )
r""" Will iteratively try to find the largest batch size for a given model that does not give an out of memory (OOM) error. Args: model: Model to fit. mode: string setting the search mode. Either `power` or `binsearch`. If mode is `power` we keep multipl...
r""" Will iteratively try to find the largest batch size for a given model that does not give an out of memory (OOM) error.
def scale_batch_size( self, model, mode: str = 'power', steps_per_trial: int = 3, init_val: int = 2, max_trials: int = 25, batch_arg_name: str = 'batch_size', **fit_kwargs ): r""" Will iteratively try to find the largest batch size for ...
[ "def", "scale_batch_size", "(", "self", ",", "model", ",", "mode", ":", "str", "=", "'power'", ",", "steps_per_trial", ":", "int", "=", "3", ",", "init_val", ":", "int", "=", "2", ",", "max_trials", ":", "int", "=", "25", ",", "batch_arg_name", ":", ...
[ 57, 4 ]
[ 112, 9 ]
python
cy
['en', 'cy', 'hi']
False
MatrixTestCase.testDet
(self)
Test det function
Test det function
def testDet(self): "Test det function" print(self.typeStr, "... ", end=' ', file=sys.stderr) det = Matrix.__dict__[self.typeStr + "Det"] matrix = [[8, 7], [6, 9]] self.assertEqual(det(matrix), 30)
[ "def", "testDet", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "det", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\"Det\"",...
[ 27, 4 ]
[ 32, 41 ]
python
da
['da', 'no', 'en']
False
MatrixTestCase.testDetBadList
(self)
Test det function with bad list
Test det function with bad list
def testDetBadList(self): "Test det function with bad list" print(self.typeStr, "... ", end=' ', file=sys.stderr) det = Matrix.__dict__[self.typeStr + "Det"] matrix = [[8, 7], ["e", "pi"]] self.assertRaises(BadListError, det, matrix)
[ "def", "testDetBadList", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "det", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\"...
[ 35, 4 ]
[ 40, 52 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testDetWrongDim
(self)
Test det function with wrong dimensions
Test det function with wrong dimensions
def testDetWrongDim(self): "Test det function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) det = Matrix.__dict__[self.typeStr + "Det"] matrix = [8, 7] self.assertRaises(TypeError, det, matrix)
[ "def", "testDetWrongDim", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "det", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\...
[ 43, 4 ]
[ 48, 49 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testDetWrongSize
(self)
Test det function with wrong size
Test det function with wrong size
def testDetWrongSize(self): "Test det function with wrong size" print(self.typeStr, "... ", end=' ', file=sys.stderr) det = Matrix.__dict__[self.typeStr + "Det"] matrix = [[8, 7, 6], [5, 4, 3], [2, 1, 0]] self.assertRaises(TypeError, det, matrix)
[ "def", "testDetWrongSize", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "det", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "...
[ 51, 4 ]
[ 56, 49 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testDetNonContainer
(self)
Test det function with non-container
Test det function with non-container
def testDetNonContainer(self): "Test det function with non-container" print(self.typeStr, "... ", end=' ', file=sys.stderr) det = Matrix.__dict__[self.typeStr + "Det"] self.assertRaises(TypeError, det, None)
[ "def", "testDetNonContainer", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "det", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", ...
[ 59, 4 ]
[ 63, 47 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testMax
(self)
Test max function
Test max function
def testMax(self): "Test max function" print(self.typeStr, "... ", end=' ', file=sys.stderr) max = Matrix.__dict__[self.typeStr + "Max"] matrix = [[6, 5, 4], [3, 2, 1]] self.assertEqual(max(matrix), 6)
[ "def", "testMax", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "max", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\"Max\"",...
[ 66, 4 ]
[ 71, 40 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testMaxBadList
(self)
Test max function with bad list
Test max function with bad list
def testMaxBadList(self): "Test max function with bad list" print(self.typeStr, "... ", end=' ', file=sys.stderr) max = Matrix.__dict__[self.typeStr + "Max"] matrix = [[6, "five", 4], ["three", 2, "one"]] self.assertRaises(BadListError, max, matrix)
[ "def", "testMaxBadList", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "max", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\"...
[ 74, 4 ]
[ 79, 52 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testMaxNonContainer
(self)
Test max function with non-container
Test max function with non-container
def testMaxNonContainer(self): "Test max function with non-container" print(self.typeStr, "... ", end=' ', file=sys.stderr) max = Matrix.__dict__[self.typeStr + "Max"] self.assertRaises(TypeError, max, None)
[ "def", "testMaxNonContainer", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "max", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", ...
[ 82, 4 ]
[ 86, 47 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testMaxWrongDim
(self)
Test max function with wrong dimensions
Test max function with wrong dimensions
def testMaxWrongDim(self): "Test max function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) max = Matrix.__dict__[self.typeStr + "Max"] self.assertRaises(TypeError, max, [0, 1, 2, 3])
[ "def", "testMaxWrongDim", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "max", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\...
[ 89, 4 ]
[ 93, 55 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testMin
(self)
Test min function
Test min function
def testMin(self): "Test min function" print(self.typeStr, "... ", end=' ', file=sys.stderr) min = Matrix.__dict__[self.typeStr + "Min"] matrix = [[9, 8], [7, 6], [5, 4]] self.assertEqual(min(matrix), 4)
[ "def", "testMin", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "min", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\"Min\"",...
[ 96, 4 ]
[ 101, 40 ]
python
en
['de', 'en', 'en']
True
MatrixTestCase.testMinBadList
(self)
Test min function with bad list
Test min function with bad list
def testMinBadList(self): "Test min function with bad list" print(self.typeStr, "... ", end=' ', file=sys.stderr) min = Matrix.__dict__[self.typeStr + "Min"] matrix = [["nine", "eight"], ["seven", "six"]] self.assertRaises(BadListError, min, matrix)
[ "def", "testMinBadList", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "min", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\"...
[ 104, 4 ]
[ 109, 52 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testMinWrongDim
(self)
Test min function with wrong dimensions
Test min function with wrong dimensions
def testMinWrongDim(self): "Test min function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) min = Matrix.__dict__[self.typeStr + "Min"] self.assertRaises(TypeError, min, [1, 3, 5, 7, 9])
[ "def", "testMinWrongDim", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "min", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\...
[ 112, 4 ]
[ 116, 58 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testMinNonContainer
(self)
Test min function with non-container
Test min function with non-container
def testMinNonContainer(self): "Test min function with non-container" print(self.typeStr, "... ", end=' ', file=sys.stderr) min = Matrix.__dict__[self.typeStr + "Min"] self.assertRaises(TypeError, min, False)
[ "def", "testMinNonContainer", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "min", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", ...
[ 119, 4 ]
[ 123, 48 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testScale
(self)
Test scale function
Test scale function
def testScale(self): "Test scale function" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Matrix.__dict__[self.typeStr + "Scale"] matrix = np.array([[1, 2, 3], [2, 1, 2], [3, 2, 1]], self.typeCode) scale(matrix, 4) self.assertEqual((matrix == [[4, 8, 12], [...
[ "def", "testScale", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "scale", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\"Sca...
[ 126, 4 ]
[ 132, 85 ]
python
en
['it', 'en', 'en']
True
MatrixTestCase.testScaleWrongDim
(self)
Test scale function with wrong dimensions
Test scale function with wrong dimensions
def testScaleWrongDim(self): "Test scale function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Matrix.__dict__[self.typeStr + "Scale"] matrix = np.array([1, 2, 2, 1], self.typeCode) self.assertRaises(TypeError, scale, matrix)
[ "def", "testScaleWrongDim", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "scale", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+", ...
[ 135, 4 ]
[ 140, 51 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testScaleWrongSize
(self)
Test scale function with wrong size
Test scale function with wrong size
def testScaleWrongSize(self): "Test scale function with wrong size" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Matrix.__dict__[self.typeStr + "Scale"] matrix = np.array([[1, 2], [2, 1]], self.typeCode) self.assertRaises(TypeError, scale, matrix)
[ "def", "testScaleWrongSize", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "scale", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+",...
[ 143, 4 ]
[ 148, 51 ]
python
en
['en', 'en', 'en']
True
MatrixTestCase.testScaleWrongType
(self)
Test scale function with wrong type
Test scale function with wrong type
def testScaleWrongType(self): "Test scale function with wrong type" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Matrix.__dict__[self.typeStr + "Scale"] matrix = np.array([[1, 2, 3], [2, 1, 2], [3, 2, 1]], 'c') self.assertRaises(TypeError, scale, matrix)
[ "def", "testScaleWrongType", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "scale", "=", "Matrix", ".", "__dict__", "[", "self", ".", "typeStr", "+",...
[ 151, 4 ]
[ 156, 51 ]
python
en
['en', 'en', 'en']
True