hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
⌀
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
0a9fca65f2e8773643ce81cde182085ec4d28c90
faisalnawazmir/Copulas
copulas/univariate/kde.py
[ "MIT" ]
Python
probability_density
<not_specific>
def probability_density(self, X): """Evaluate the estimated pdf on a point. Args: X(float): a datapoint. Returns: (float): value of estimated pdf. """ self.check_fit() if type(X) not in (int, float): raise ValueError('x must be int...
Evaluate the estimated pdf on a point. Args: X(float): a datapoint. Returns: (float): value of estimated pdf.
Evaluate the estimated pdf on a point.
[ "Evaluate", "the", "estimated", "pdf", "on", "a", "point", "." ]
def probability_density(self, X): self.check_fit() if type(X) not in (int, float): raise ValueError('x must be int or float') return self.model.evaluate(X)[0]
[ "def", "probability_density", "(", "self", ",", "X", ")", ":", "self", ".", "check_fit", "(", ")", "if", "type", "(", "X", ")", "not", "in", "(", "int", ",", "float", ")", ":", "raise", "ValueError", "(", "'x must be int or float'", ")", "return", "sel...
Evaluate the estimated pdf on a point.
[ "Evaluate", "the", "estimated", "pdf", "on", "a", "point", "." ]
[ "\"\"\"Evaluate the estimated pdf on a point.\n\n Args:\n X(float): a datapoint.\n\n Returns:\n (float): value of estimated pdf.\n\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "X", "type": null } ]
{ "returns": [ { "docstring": "value of estimated pdf.", "docstring_tokens": [ "value", "of", "estimated", "pdf", "." ], "type": "(float)" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring...
0a9fca65f2e8773643ce81cde182085ec4d28c90
faisalnawazmir/Copulas
copulas/univariate/kde.py
[ "MIT" ]
Python
cumulative_distribution
<not_specific>
def cumulative_distribution(self, X, U=0): """Computes the integral of a 1-D pdf between two bounds Args: X(float): a datapoint. U(float): cdf value in [0,1], only used in get_ppf Returns: float: estimated cumulative distribution. """ self.ch...
Computes the integral of a 1-D pdf between two bounds Args: X(float): a datapoint. U(float): cdf value in [0,1], only used in get_ppf Returns: float: estimated cumulative distribution.
Computes the integral of a 1-D pdf between two bounds
[ "Computes", "the", "integral", "of", "a", "1", "-", "D", "pdf", "between", "two", "bounds" ]
def cumulative_distribution(self, X, U=0): self.check_fit() low_bounds = self.model.dataset.mean() - (5 * self.model.dataset.std()) return self.model.integrate_box_1d(low_bounds, X) - U
[ "def", "cumulative_distribution", "(", "self", ",", "X", ",", "U", "=", "0", ")", ":", "self", ".", "check_fit", "(", ")", "low_bounds", "=", "self", ".", "model", ".", "dataset", ".", "mean", "(", ")", "-", "(", "5", "*", "self", ".", "model", "...
Computes the integral of a 1-D pdf between two bounds
[ "Computes", "the", "integral", "of", "a", "1", "-", "D", "pdf", "between", "two", "bounds" ]
[ "\"\"\"Computes the integral of a 1-D pdf between two bounds\n\n Args:\n X(float): a datapoint.\n U(float): cdf value in [0,1], only used in get_ppf\n\n Returns:\n float: estimated cumulative distribution.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "X", "type": null }, { "param": "U", "type": null } ]
{ "returns": [ { "docstring": "estimated cumulative distribution.", "docstring_tokens": [ "estimated", "cumulative", "distribution", "." ], "type": "float" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "...
0a9fca65f2e8773643ce81cde182085ec4d28c90
faisalnawazmir/Copulas
copulas/univariate/kde.py
[ "MIT" ]
Python
percent_point
<not_specific>
def percent_point(self, U): """Given a cdf value, returns a value in original space. Args: U: `int` or `float` cdf value in [0,1] Returns: float: value in original space """ self.check_fit() if not 0 < U < 1: raise ValueError('cdf va...
Given a cdf value, returns a value in original space. Args: U: `int` or `float` cdf value in [0,1] Returns: float: value in original space
Given a cdf value, returns a value in original space.
[ "Given", "a", "cdf", "value", "returns", "a", "value", "in", "original", "space", "." ]
def percent_point(self, U): self.check_fit() if not 0 < U < 1: raise ValueError('cdf value must be in [0,1]') return scipy.optimize.brentq(self.cumulative_distribution, -1000.0, 1000.0, args=(U))
[ "def", "percent_point", "(", "self", ",", "U", ")", ":", "self", ".", "check_fit", "(", ")", "if", "not", "0", "<", "U", "<", "1", ":", "raise", "ValueError", "(", "'cdf value must be in [0,1]'", ")", "return", "scipy", ".", "optimize", ".", "brentq", ...
Given a cdf value, returns a value in original space.
[ "Given", "a", "cdf", "value", "returns", "a", "value", "in", "original", "space", "." ]
[ "\"\"\"Given a cdf value, returns a value in original space.\n\n Args:\n U: `int` or `float` cdf value in [0,1]\n\n Returns:\n float: value in original space\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "U", "type": null } ]
{ "returns": [ { "docstring": "value in original space", "docstring_tokens": [ "value", "in", "original", "space" ], "type": "float" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, ...
0a9fca65f2e8773643ce81cde182085ec4d28c90
faisalnawazmir/Copulas
copulas/univariate/kde.py
[ "MIT" ]
Python
sample
<not_specific>
def sample(self, num_samples=1): """Samples new data point based on model. Args: num_samples(int): number of points to be sampled Returns: samples: a list of datapoints sampled from the model """ self.check_fit() return self.model.resample(num_s...
Samples new data point based on model. Args: num_samples(int): number of points to be sampled Returns: samples: a list of datapoints sampled from the model
Samples new data point based on model.
[ "Samples", "new", "data", "point", "based", "on", "model", "." ]
def sample(self, num_samples=1): self.check_fit() return self.model.resample(num_samples)
[ "def", "sample", "(", "self", ",", "num_samples", "=", "1", ")", ":", "self", ".", "check_fit", "(", ")", "return", "self", ".", "model", ".", "resample", "(", "num_samples", ")" ]
Samples new data point based on model.
[ "Samples", "new", "data", "point", "based", "on", "model", "." ]
[ "\"\"\"Samples new data point based on model.\n\n Args:\n num_samples(int): number of points to be sampled\n\n Returns:\n samples: a list of datapoints sampled from the model\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "num_samples", "type": null } ]
{ "returns": [ { "docstring": "a list of datapoints sampled from the model", "docstring_tokens": [ "a", "list", "of", "datapoints", "sampled", "from", "the", "model" ], "type": "samples" } ], "raises": [], "params": ...
0a9fca65f2e8773643ce81cde182085ec4d28c90
faisalnawazmir/Copulas
copulas/univariate/kde.py
[ "MIT" ]
Python
from_dict
<not_specific>
def from_dict(cls, copula_dict): """Set attributes with provided values.""" instance = cls() instance.fitted = copula_dict['fitted'] instance.constant_value = copula_dict['constant_value'] if instance.fitted and not instance.constant_value: instance.model = scipy.st...
Set attributes with provided values.
Set attributes with provided values.
[ "Set", "attributes", "with", "provided", "values", "." ]
def from_dict(cls, copula_dict): instance = cls() instance.fitted = copula_dict['fitted'] instance.constant_value = copula_dict['constant_value'] if instance.fitted and not instance.constant_value: instance.model = scipy.stats.gaussian_kde([-1, 0, 0]) for key in [...
[ "def", "from_dict", "(", "cls", ",", "copula_dict", ")", ":", "instance", "=", "cls", "(", ")", "instance", ".", "fitted", "=", "copula_dict", "[", "'fitted'", "]", "instance", ".", "constant_value", "=", "copula_dict", "[", "'constant_value'", "]", "if", ...
Set attributes with provided values.
[ "Set", "attributes", "with", "provided", "values", "." ]
[ "\"\"\"Set attributes with provided values.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "copula_dict", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "copula_dict", "type": null, "docstring": null, "docstring_toke...
cbe02158236ec8c2eafe103bb34638766b381a0f
faisalnawazmir/Copulas
copulas/univariate/gaussian_kde.py
[ "MIT" ]
Python
cumulative_distribution
<not_specific>
def cumulative_distribution(self, X): """Computes the integral of a 1-D pdf between two bounds Args: X(numpy.array): Shaped (1, n), containing the datapoints. Returns: numpy.array: estimated cumulative distribution. """ self.check_fit() low_boun...
Computes the integral of a 1-D pdf between two bounds Args: X(numpy.array): Shaped (1, n), containing the datapoints. Returns: numpy.array: estimated cumulative distribution.
Computes the integral of a 1-D pdf between two bounds
[ "Computes", "the", "integral", "of", "a", "1", "-", "D", "pdf", "between", "two", "bounds" ]
def cumulative_distribution(self, X): self.check_fit() low_bounds = self.model.dataset.mean() - (5 * self.model.dataset.std()) result = [] for value in X: result.append(self.model.integrate_box_1d(low_bounds, value)) return np.array(result)
[ "def", "cumulative_distribution", "(", "self", ",", "X", ")", ":", "self", ".", "check_fit", "(", ")", "low_bounds", "=", "self", ".", "model", ".", "dataset", ".", "mean", "(", ")", "-", "(", "5", "*", "self", ".", "model", ".", "dataset", ".", "s...
Computes the integral of a 1-D pdf between two bounds
[ "Computes", "the", "integral", "of", "a", "1", "-", "D", "pdf", "between", "two", "bounds" ]
[ "\"\"\"Computes the integral of a 1-D pdf between two bounds\n\n Args:\n X(numpy.array): Shaped (1, n), containing the datapoints.\n\n Returns:\n numpy.array: estimated cumulative distribution.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "X", "type": null } ]
{ "returns": [ { "docstring": "estimated cumulative distribution.", "docstring_tokens": [ "estimated", "cumulative", "distribution", "." ], "type": "numpy.array" } ], "raises": [], "params": [ { "identifier": "self", "type": null, ...
cbe02158236ec8c2eafe103bb34638766b381a0f
faisalnawazmir/Copulas
copulas/univariate/gaussian_kde.py
[ "MIT" ]
Python
percent_point
<not_specific>
def percent_point(self, U): """Given a cdf value, returns a value in original space. Args: U(numpy.array): cdf values in [0,1] Returns: numpy.array: value in original space """ self.check_fit() return scipy.optimize.brentq(self._brentq_cdf(U), -...
Given a cdf value, returns a value in original space. Args: U(numpy.array): cdf values in [0,1] Returns: numpy.array: value in original space
Given a cdf value, returns a value in original space.
[ "Given", "a", "cdf", "value", "returns", "a", "value", "in", "original", "space", "." ]
def percent_point(self, U): self.check_fit() return scipy.optimize.brentq(self._brentq_cdf(U), -1000.0, 1000.0)
[ "def", "percent_point", "(", "self", ",", "U", ")", ":", "self", ".", "check_fit", "(", ")", "return", "scipy", ".", "optimize", ".", "brentq", "(", "self", ".", "_brentq_cdf", "(", "U", ")", ",", "-", "1000.0", ",", "1000.0", ")" ]
Given a cdf value, returns a value in original space.
[ "Given", "a", "cdf", "value", "returns", "a", "value", "in", "original", "space", "." ]
[ "\"\"\"Given a cdf value, returns a value in original space.\n\n Args:\n U(numpy.array): cdf values in [0,1]\n\n Returns:\n numpy.array: value in original space\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "U", "type": null } ]
{ "returns": [ { "docstring": "value in original space", "docstring_tokens": [ "value", "in", "original", "space" ], "type": "numpy.array" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null,...
936d5b026dfa1dfc0c304b2622fd53ffe262439f
faisalnawazmir/Copulas
copulas/univariate/base.py
[ "MIT" ]
Python
to_dict
<not_specific>
def to_dict(self): """Returns parameters to replicate the distribution.""" result = { 'type': get_qualified_name(self), 'fitted': self.fitted, 'constant_value': self.constant_value } if not self.fitted: return result result.update...
Returns parameters to replicate the distribution.
Returns parameters to replicate the distribution.
[ "Returns", "parameters", "to", "replicate", "the", "distribution", "." ]
def to_dict(self): result = { 'type': get_qualified_name(self), 'fitted': self.fitted, 'constant_value': self.constant_value } if not self.fitted: return result result.update(self._fit_params()) return result
[ "def", "to_dict", "(", "self", ")", ":", "result", "=", "{", "'type'", ":", "get_qualified_name", "(", "self", ")", ",", "'fitted'", ":", "self", ".", "fitted", ",", "'constant_value'", ":", "self", ".", "constant_value", "}", "if", "not", "self", ".", ...
Returns parameters to replicate the distribution.
[ "Returns", "parameters", "to", "replicate", "the", "distribution", "." ]
[ "\"\"\"Returns parameters to replicate the distribution.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
936d5b026dfa1dfc0c304b2622fd53ffe262439f
faisalnawazmir/Copulas
copulas/univariate/base.py
[ "MIT" ]
Python
_get_constant_value
<not_specific>
def _get_constant_value(X): """Checks if a Series or array contains only one unique value. Args: X(pandas.Series or numpy.ndarray): Array to check for constantness Returns: (float or None): Return the constant value if there is one, else return None. """ ...
Checks if a Series or array contains only one unique value. Args: X(pandas.Series or numpy.ndarray): Array to check for constantness Returns: (float or None): Return the constant value if there is one, else return None.
Checks if a Series or array contains only one unique value.
[ "Checks", "if", "a", "Series", "or", "array", "contains", "only", "one", "unique", "value", "." ]
def _get_constant_value(X): uniques = np.unique(X) if len(uniques) == 1: return uniques[0]
[ "def", "_get_constant_value", "(", "X", ")", ":", "uniques", "=", "np", ".", "unique", "(", "X", ")", "if", "len", "(", "uniques", ")", "==", "1", ":", "return", "uniques", "[", "0", "]" ]
Checks if a Series or array contains only one unique value.
[ "Checks", "if", "a", "Series", "or", "array", "contains", "only", "one", "unique", "value", "." ]
[ "\"\"\"Checks if a Series or array contains only one unique value.\n\n Args:\n X(pandas.Series or numpy.ndarray): Array to check for constantness\n\n Returns:\n (float or None): Return the constant value if there is one, else return None.\n \"\"\"" ]
[ { "param": "X", "type": null } ]
{ "returns": [ { "docstring": "(float or None): Return the constant value if there is one, else return None.", "docstring_tokens": [ "(", "float", "or", "None", ")", ":", "Return", "the", "constant", "value", "if",...
936d5b026dfa1dfc0c304b2622fd53ffe262439f
faisalnawazmir/Copulas
copulas/univariate/base.py
[ "MIT" ]
Python
_constant_sample
<not_specific>
def _constant_sample(self, num_samples): """Sample values for a constant distribution. Args: num_samples(int): Number of rows to sample Returns: numpy.ndarray: Sampled values. Array of shape (num_samples,). """ return np.full(num_samples, self.constant_v...
Sample values for a constant distribution. Args: num_samples(int): Number of rows to sample Returns: numpy.ndarray: Sampled values. Array of shape (num_samples,).
Sample values for a constant distribution.
[ "Sample", "values", "for", "a", "constant", "distribution", "." ]
def _constant_sample(self, num_samples): return np.full(num_samples, self.constant_value)
[ "def", "_constant_sample", "(", "self", ",", "num_samples", ")", ":", "return", "np", ".", "full", "(", "num_samples", ",", "self", ".", "constant_value", ")" ]
Sample values for a constant distribution.
[ "Sample", "values", "for", "a", "constant", "distribution", "." ]
[ "\"\"\"Sample values for a constant distribution.\n\n Args:\n num_samples(int): Number of rows to sample\n\n Returns:\n numpy.ndarray: Sampled values. Array of shape (num_samples,).\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "num_samples", "type": null } ]
{ "returns": [ { "docstring": "Sampled values. Array of shape (num_samples,).", "docstring_tokens": [ "Sampled", "values", ".", "Array", "of", "shape", "(", "num_samples", ")", "." ], "type": "numpy.ndarray" ...
936d5b026dfa1dfc0c304b2622fd53ffe262439f
faisalnawazmir/Copulas
copulas/univariate/base.py
[ "MIT" ]
Python
_constant_cumulative_distribution
<not_specific>
def _constant_cumulative_distribution(self, X): """Cumulative distribution for the degenerate case of constant distribution. Note that the output of this method will be an array whose unique values are 0 and 1. More information can be found here: https://en.wikipedia.org/wiki/Degenerate_distrib...
Cumulative distribution for the degenerate case of constant distribution. Note that the output of this method will be an array whose unique values are 0 and 1. More information can be found here: https://en.wikipedia.org/wiki/Degenerate_distribution Args: X (numpy.ndarray): Values ...
Cumulative distribution for the degenerate case of constant distribution. Note that the output of this method will be an array whose unique values are 0 and 1.
[ "Cumulative", "distribution", "for", "the", "degenerate", "case", "of", "constant", "distribution", ".", "Note", "that", "the", "output", "of", "this", "method", "will", "be", "an", "array", "whose", "unique", "values", "are", "0", "and", "1", "." ]
def _constant_cumulative_distribution(self, X): result = np.ones(X.shape) result[np.nonzero(X < self.constant_value)] = 0 return result
[ "def", "_constant_cumulative_distribution", "(", "self", ",", "X", ")", ":", "result", "=", "np", ".", "ones", "(", "X", ".", "shape", ")", "result", "[", "np", ".", "nonzero", "(", "X", "<", "self", ".", "constant_value", ")", "]", "=", "0", "return...
Cumulative distribution for the degenerate case of constant distribution.
[ "Cumulative", "distribution", "for", "the", "degenerate", "case", "of", "constant", "distribution", "." ]
[ "\"\"\"Cumulative distribution for the degenerate case of constant distribution.\n\n Note that the output of this method will be an array whose unique values are 0 and 1.\n More information can be found here: https://en.wikipedia.org/wiki/Degenerate_distribution\n\n Args:\n X (numpy....
[ { "param": "self", "type": null }, { "param": "X", "type": null } ]
{ "returns": [ { "docstring": "Cumulative distribution for the given values.", "docstring_tokens": [ "Cumulative", "distribution", "for", "the", "given", "values", "." ], "type": "numpy.ndarray" } ], "raises": [], "params": ...
936d5b026dfa1dfc0c304b2622fd53ffe262439f
faisalnawazmir/Copulas
copulas/univariate/base.py
[ "MIT" ]
Python
_constant_probability_density
<not_specific>
def _constant_probability_density(self, X): """Probability density for the degenerate case of constant distribution. Note that the output of this method will be an array whose unique values are 0 and 1. More information can be found here: https://en.wikipedia.org/wiki/Degenerate_distribution ...
Probability density for the degenerate case of constant distribution. Note that the output of this method will be an array whose unique values are 0 and 1. More information can be found here: https://en.wikipedia.org/wiki/Degenerate_distribution Args: X(numpy.ndarray): Values to co...
Probability density for the degenerate case of constant distribution. Note that the output of this method will be an array whose unique values are 0 and 1.
[ "Probability", "density", "for", "the", "degenerate", "case", "of", "constant", "distribution", ".", "Note", "that", "the", "output", "of", "this", "method", "will", "be", "an", "array", "whose", "unique", "values", "are", "0", "and", "1", "." ]
def _constant_probability_density(self, X): result = np.zeros(X.shape) result[np.nonzero(X == self.constant_value)] = 1 return result
[ "def", "_constant_probability_density", "(", "self", ",", "X", ")", ":", "result", "=", "np", ".", "zeros", "(", "X", ".", "shape", ")", "result", "[", "np", ".", "nonzero", "(", "X", "==", "self", ".", "constant_value", ")", "]", "=", "1", "return",...
Probability density for the degenerate case of constant distribution.
[ "Probability", "density", "for", "the", "degenerate", "case", "of", "constant", "distribution", "." ]
[ "\"\"\"Probability density for the degenerate case of constant distribution.\n\n Note that the output of this method will be an array whose unique values are 0 and 1.\n More information can be found here: https://en.wikipedia.org/wiki/Degenerate_distribution\n\n Args:\n X(numpy.ndarr...
[ { "param": "self", "type": null }, { "param": "X", "type": null } ]
{ "returns": [ { "docstring": "Probability densisty for the given values", "docstring_tokens": [ "Probability", "densisty", "for", "the", "given", "values" ], "type": "numpy.ndarray" } ], "raises": [], "params": [ { "ident...
936d5b026dfa1dfc0c304b2622fd53ffe262439f
faisalnawazmir/Copulas
copulas/univariate/base.py
[ "MIT" ]
Python
_constant_percent_point
<not_specific>
def _constant_percent_point(self, X): """Percent point for the degenerate case of constant distribution. Note that the output of this method will be an array whose unique values are `np.nan` and self.constant_value. More information can be found here: https://en.wikipedia.org/wiki/Degen...
Percent point for the degenerate case of constant distribution. Note that the output of this method will be an array whose unique values are `np.nan` and self.constant_value. More information can be found here: https://en.wikipedia.org/wiki/Degenerate_distribution Args: X(n...
Percent point for the degenerate case of constant distribution. Note that the output of this method will be an array whose unique values are `np.nan` and self.constant_value.
[ "Percent", "point", "for", "the", "degenerate", "case", "of", "constant", "distribution", ".", "Note", "that", "the", "output", "of", "this", "method", "will", "be", "an", "array", "whose", "unique", "values", "are", "`", "np", ".", "nan", "`", "and", "s...
def _constant_percent_point(self, X): return np.full(X.shape, self.constant_value)
[ "def", "_constant_percent_point", "(", "self", ",", "X", ")", ":", "return", "np", ".", "full", "(", "X", ".", "shape", ",", "self", ".", "constant_value", ")" ]
Percent point for the degenerate case of constant distribution.
[ "Percent", "point", "for", "the", "degenerate", "case", "of", "constant", "distribution", "." ]
[ "\"\"\"Percent point for the degenerate case of constant distribution.\n\n Note that the output of this method will be an array whose unique values are `np.nan`\n and self.constant_value.\n More information can be found here: https://en.wikipedia.org/wiki/Degenerate_distribution\n\n Args...
[ { "param": "self", "type": null }, { "param": "X", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "numpy.ndarray" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optiona...
936d5b026dfa1dfc0c304b2622fd53ffe262439f
faisalnawazmir/Copulas
copulas/univariate/base.py
[ "MIT" ]
Python
fit
null
def fit(self, X, *args, **kwargs): """Fit scipy model to an array of values. Args: X(`np.ndarray` or `pd.DataFrame`): Datapoints to be estimated from. Must be 1-d Returns: None """ self.constant_value = self._get_constant_value(X) if self.cons...
Fit scipy model to an array of values. Args: X(`np.ndarray` or `pd.DataFrame`): Datapoints to be estimated from. Must be 1-d Returns: None
Fit scipy model to an array of values.
[ "Fit", "scipy", "model", "to", "an", "array", "of", "values", "." ]
def fit(self, X, *args, **kwargs): self.constant_value = self._get_constant_value(X) if self.constant_value is None: if self.unfittable_model: self.model = getattr(scipy.stats, self.model_class)(*args, **kwargs) else: self.model = getattr(scipy.sta...
[ "def", "fit", "(", "self", ",", "X", ",", "*", "args", ",", "**", "kwargs", ")", ":", "self", ".", "constant_value", "=", "self", ".", "_get_constant_value", "(", "X", ")", "if", "self", ".", "constant_value", "is", "None", ":", "if", "self", ".", ...
Fit scipy model to an array of values.
[ "Fit", "scipy", "model", "to", "an", "array", "of", "values", "." ]
[ "\"\"\"Fit scipy model to an array of values.\n\n Args:\n X(`np.ndarray` or `pd.DataFrame`): Datapoints to be estimated from. Must be 1-d\n\n Returns:\n None\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "X", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
3b61497681ae679708ff21c72675e925b9c35ec9
faisalnawazmir/Copulas
copulas/__init__.py
[ "MIT" ]
Python
check_valid_values
<not_specific>
def check_valid_values(function): """Raises an exception if the given values are not supported. Args: function(callable): Method whose unique argument is a numpy.array-like object. Returns: callable: Decorated function Raises: ValueError: If there are missing or invalid values...
Raises an exception if the given values are not supported. Args: function(callable): Method whose unique argument is a numpy.array-like object. Returns: callable: Decorated function Raises: ValueError: If there are missing or invalid values or if the dataset is empty.
Raises an exception if the given values are not supported.
[ "Raises", "an", "exception", "if", "the", "given", "values", "are", "not", "supported", "." ]
def check_valid_values(function): def decorated(self, X, *args, **kwargs): if isinstance(X, pd.DataFrame): W = X.values else: W = X if not len(W): raise ValueError('Your dataset is empty.') if W.dtype not in [np.dtype('float64'), np.dtype('int64')]...
[ "def", "check_valid_values", "(", "function", ")", ":", "def", "decorated", "(", "self", ",", "X", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "isinstance", "(", "X", ",", "pd", ".", "DataFrame", ")", ":", "W", "=", "X", ".", "values", ...
Raises an exception if the given values are not supported.
[ "Raises", "an", "exception", "if", "the", "given", "values", "are", "not", "supported", "." ]
[ "\"\"\"Raises an exception if the given values are not supported.\n\n Args:\n function(callable): Method whose unique argument is a numpy.array-like object.\n\n Returns:\n callable: Decorated function\n\n Raises:\n ValueError: If there are missing or invalid values or if the dataset is...
[ { "param": "function", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "callable" } ], "raises": [ { "docstring": "If there are missing or invalid values or if the dataset is empty.", "docstring_tokens": [ "If", "there", "are", ...
7a0c0c2678f803e55fc48dd82edd5533874a87a5
faisalnawazmir/Copulas
copulas/multivariate/gaussian.py
[ "MIT" ]
Python
_get_covariance
<not_specific>
def _get_covariance(self, X): """Compute covariance matrix with transformed data. Args: X: `numpy.ndarray` or `pandas.DataFrame`. Returns: np.ndarray """ result = pd.DataFrame(index=range(len(X))) column_names = self.get_column_names(X) ...
Compute covariance matrix with transformed data. Args: X: `numpy.ndarray` or `pandas.DataFrame`. Returns: np.ndarray
Compute covariance matrix with transformed data.
[ "Compute", "covariance", "matrix", "with", "transformed", "data", "." ]
def _get_covariance(self, X): result = pd.DataFrame(index=range(len(X))) column_names = self.get_column_names(X) for column_name in column_names: column = self.get_column(X, column_name) distrib = self.distribs[column_name] cdf = distrib.cumulative_distributio...
[ "def", "_get_covariance", "(", "self", ",", "X", ")", ":", "result", "=", "pd", ".", "DataFrame", "(", "index", "=", "range", "(", "len", "(", "X", ")", ")", ")", "column_names", "=", "self", ".", "get_column_names", "(", "X", ")", "for", "column_nam...
Compute covariance matrix with transformed data.
[ "Compute", "covariance", "matrix", "with", "transformed", "data", "." ]
[ "\"\"\"Compute covariance matrix with transformed data.\n\n Args:\n X: `numpy.ndarray` or `pandas.DataFrame`.\n\n Returns:\n np.ndarray\n\n \"\"\"", "# get original distrib's cdf of the column", "# This is to avoid np.inf in the case the column is constant.", "# get ...
[ { "param": "self", "type": null }, { "param": "X", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
7a0c0c2678f803e55fc48dd82edd5533874a87a5
faisalnawazmir/Copulas
copulas/multivariate/gaussian.py
[ "MIT" ]
Python
fit
null
def fit(self, X): """Compute the distribution for each variable and then its covariance matrix. Args: X(numpy.ndarray or pandas.DataFrame): Data to model. Returns: None """ LOGGER.debug('Fitting Gaussian Copula') column_names = self.get_column_na...
Compute the distribution for each variable and then its covariance matrix. Args: X(numpy.ndarray or pandas.DataFrame): Data to model. Returns: None
Compute the distribution for each variable and then its covariance matrix.
[ "Compute", "the", "distribution", "for", "each", "variable", "and", "then", "its", "covariance", "matrix", "." ]
def fit(self, X): LOGGER.debug('Fitting Gaussian Copula') column_names = self.get_column_names(X) distribution_class = import_object(self.distribution) for column_name in column_names: self.distribs[column_name] = distribution_class() column = self.get_column(X, c...
[ "def", "fit", "(", "self", ",", "X", ")", ":", "LOGGER", ".", "debug", "(", "'Fitting Gaussian Copula'", ")", "column_names", "=", "self", ".", "get_column_names", "(", "X", ")", "distribution_class", "=", "import_object", "(", "self", ".", "distribution", "...
Compute the distribution for each variable and then its covariance matrix.
[ "Compute", "the", "distribution", "for", "each", "variable", "and", "then", "its", "covariance", "matrix", "." ]
[ "\"\"\"Compute the distribution for each variable and then its covariance matrix.\n\n Args:\n X(numpy.ndarray or pandas.DataFrame): Data to model.\n\n Returns:\n None\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "X", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
7a0c0c2678f803e55fc48dd82edd5533874a87a5
faisalnawazmir/Copulas
copulas/multivariate/gaussian.py
[ "MIT" ]
Python
probability_density
<not_specific>
def probability_density(self, X): """Compute probability density function for given copula family. Args: X: `numpy.ndarray` or `pandas.DataFrame` Returns: np.array: Probability density for the input values. """ self.check_fit() # make cov positi...
Compute probability density function for given copula family. Args: X: `numpy.ndarray` or `pandas.DataFrame` Returns: np.array: Probability density for the input values.
Compute probability density function for given copula family.
[ "Compute", "probability", "density", "function", "for", "given", "copula", "family", "." ]
def probability_density(self, X): self.check_fit() covariance = self.covariance * np.identity(self.covariance.shape[0]) return stats.multivariate_normal.pdf(X, cov=covariance)
[ "def", "probability_density", "(", "self", ",", "X", ")", ":", "self", ".", "check_fit", "(", ")", "covariance", "=", "self", ".", "covariance", "*", "np", ".", "identity", "(", "self", ".", "covariance", ".", "shape", "[", "0", "]", ")", "return", "...
Compute probability density function for given copula family.
[ "Compute", "probability", "density", "function", "for", "given", "copula", "family", "." ]
[ "\"\"\"Compute probability density function for given copula family.\n\n Args:\n X: `numpy.ndarray` or `pandas.DataFrame`\n\n Returns:\n np.array: Probability density for the input values.\n \"\"\"", "# make cov positive semi-definite" ]
[ { "param": "self", "type": null }, { "param": "X", "type": null } ]
{ "returns": [ { "docstring": "Probability density for the input values.", "docstring_tokens": [ "Probability", "density", "for", "the", "input", "values", "." ], "type": "np.array" } ], "raises": [], "params": [ { ...
7a0c0c2678f803e55fc48dd82edd5533874a87a5
faisalnawazmir/Copulas
copulas/multivariate/gaussian.py
[ "MIT" ]
Python
cumulative_distribution
<not_specific>
def cumulative_distribution(self, X): """Computes the cumulative distribution function for the copula Args: X: `numpy.ndarray` or `pandas.DataFrame` Returns: np.array: cumulative probability """ self.check_fit() # Wrapper for pdf to accept vecto...
Computes the cumulative distribution function for the copula Args: X: `numpy.ndarray` or `pandas.DataFrame` Returns: np.array: cumulative probability
Computes the cumulative distribution function for the copula
[ "Computes", "the", "cumulative", "distribution", "function", "for", "the", "copula" ]
def cumulative_distribution(self, X): self.check_fit() def func(*args): return self.probability_density(list(args)) lower_bound = self.get_lower_bound() ranges = [[lower_bound, val] for val in X] return integrate.nquad(func, ranges)[0]
[ "def", "cumulative_distribution", "(", "self", ",", "X", ")", ":", "self", ".", "check_fit", "(", ")", "def", "func", "(", "*", "args", ")", ":", "return", "self", ".", "probability_density", "(", "list", "(", "args", ")", ")", "lower_bound", "=", "sel...
Computes the cumulative distribution function for the copula
[ "Computes", "the", "cumulative", "distribution", "function", "for", "the", "copula" ]
[ "\"\"\"Computes the cumulative distribution function for the copula\n\n Args:\n X: `numpy.ndarray` or `pandas.DataFrame`\n\n Returns:\n np.array: cumulative probability\n \"\"\"", "# Wrapper for pdf to accept vector as args", "# Lower bound for integral, to split signi...
[ { "param": "self", "type": null }, { "param": "X", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "np.array" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": n...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
__sampleCells
<not_specific>
def __sampleCells(self, data, number_cells): """Sample a representative population of cells for rule inference - reduce memory requirements""" combined = np.apply_along_axis( lambda x: "".join(str(x)), axis=0, arr=data[1:, 1:] ) combined_weights = np.unique(combined, return_c...
Sample a representative population of cells for rule inference - reduce memory requirements
Sample a representative population of cells for rule inference - reduce memory requirements
[ "Sample", "a", "representative", "population", "of", "cells", "for", "rule", "inference", "-", "reduce", "memory", "requirements" ]
def __sampleCells(self, data, number_cells): combined = np.apply_along_axis( lambda x: "".join(str(x)), axis=0, arr=data[1:, 1:] ) combined_weights = np.unique(combined, return_counts=True)[1] / len(combined) sampled_cells = np.random.choice( range(len(combined_we...
[ "def", "__sampleCells", "(", "self", ",", "data", ",", "number_cells", ")", ":", "combined", "=", "np", ".", "apply_along_axis", "(", "lambda", "x", ":", "\"\"", ".", "join", "(", "str", "(", "x", ")", ")", ",", "axis", "=", "0", ",", "arr", "=", ...
Sample a representative population of cells for rule inference - reduce memory requirements
[ "Sample", "a", "representative", "population", "of", "cells", "for", "rule", "inference", "-", "reduce", "memory", "requirements" ]
[ "\"\"\"Sample a representative population of cells for rule inference - reduce memory requirements\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "data", "type": null }, { "param": "number_cells", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": [...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
__retrieveSubpop
<not_specific>
def __retrieveSubpop(self, cell): """Given a cell, retrieve the subpopulation information""" if hasattr(self, "subpopInfo"): return self.subpopInfo[cell] else: print("Please add subpopulation information first.") return None
Given a cell, retrieve the subpopulation information
Given a cell, retrieve the subpopulation information
[ "Given", "a", "cell", "retrieve", "the", "subpopulation", "information" ]
def __retrieveSubpop(self, cell): if hasattr(self, "subpopInfo"): return self.subpopInfo[cell] else: print("Please add subpopulation information first.") return None
[ "def", "__retrieveSubpop", "(", "self", ",", "cell", ")", ":", "if", "hasattr", "(", "self", ",", "\"subpopInfo\"", ")", ":", "return", "self", ".", "subpopInfo", "[", "cell", "]", "else", ":", "print", "(", "\"Please add subpopulation information first.\"", "...
Given a cell, retrieve the subpopulation information
[ "Given", "a", "cell", "retrieve", "the", "subpopulation", "information" ]
[ "\"\"\"Given a cell, retrieve the subpopulation information\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "cell", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cell", "type": null, "docstring": null, "docstring_tokens": [...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
__filterData
null
def __filterData(self, threshold): """Filter data based on CV cutoffs""" self.cvGenes = [] if threshold is not None: for i in range(0, self.expMat.get_shape()[0]): rowData = list(self.expMat.getrow(i).todense()) if np.std(rowData) / np.mean(rowData) >=...
Filter data based on CV cutoffs
Filter data based on CV cutoffs
[ "Filter", "data", "based", "on", "CV", "cutoffs" ]
def __filterData(self, threshold): self.cvGenes = [] if threshold is not None: for i in range(0, self.expMat.get_shape()[0]): rowData = list(self.expMat.getrow(i).todense()) if np.std(rowData) / np.mean(rowData) >= threshold: self.cvGenes.a...
[ "def", "__filterData", "(", "self", ",", "threshold", ")", ":", "self", ".", "cvGenes", "=", "[", "]", "if", "threshold", "is", "not", "None", ":", "for", "i", "in", "range", "(", "0", ",", "self", ".", "expMat", ".", "get_shape", "(", ")", "[", ...
Filter data based on CV cutoffs
[ "Filter", "data", "based", "on", "CV", "cutoffs" ]
[ "\"\"\"Filter data based on CV cutoffs\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "threshold", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "threshold", "type": null, "docstring": null, "docstring_token...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
__add_pathways
null
def __add_pathways( self, pathwayList=[], minOverlap=20, writeGraphml=True, removeSelfEdges=False ): """Add a list of pathways in graphml format to the singleCell object""" if hasattr(self, "cvGenes"): pathwayGenes = set(self.cvGenes) elif not hasattr(self, "cvGenes"): ...
Add a list of pathways in graphml format to the singleCell object
Add a list of pathways in graphml format to the singleCell object
[ "Add", "a", "list", "of", "pathways", "in", "graphml", "format", "to", "the", "singleCell", "object" ]
def __add_pathways( self, pathwayList=[], minOverlap=20, writeGraphml=True, removeSelfEdges=False ): if hasattr(self, "cvGenes"): pathwayGenes = set(self.cvGenes) elif not hasattr(self, "cvGenes"): print("You have not filtered genes by any criterion.") pat...
[ "def", "__add_pathways", "(", "self", ",", "pathwayList", "=", "[", "]", ",", "minOverlap", "=", "20", ",", "writeGraphml", "=", "True", ",", "removeSelfEdges", "=", "False", ")", ":", "if", "hasattr", "(", "self", ",", "\"cvGenes\"", ")", ":", "pathwayG...
Add a list of pathways in graphml format to the singleCell object
[ "Add", "a", "list", "of", "pathways", "in", "graphml", "format", "to", "the", "singleCell", "object" ]
[ "\"\"\"Add a list of pathways in graphml format to the singleCell object\"\"\"", "# list(glob.glob(\"*.graphml\")): # list(glob.glob('*[0-9].graphml')):", "# remove self loops", "# remove genes not in dataset", "# graph post-processing", "# remove singletons/isolates", "# To do: remove complexes, remov...
[ { "param": "self", "type": null }, { "param": "pathwayList", "type": null }, { "param": "minOverlap", "type": null }, { "param": "writeGraphml", "type": null }, { "param": "removeSelfEdges", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pathwayList", "type": null, "docstring": null, "docstring_tok...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
__scoreNodes
null
def __scoreNodes(self, graph): """Wrapper function - performs rule determination and node scoring in preparation for pathway analysis""" net = nx.read_graphml(graph) # print(self.geneList) # print(list(net)) netGenes = [ self.geneList.index(gene) for gene in list(net...
Wrapper function - performs rule determination and node scoring in preparation for pathway analysis
Wrapper function - performs rule determination and node scoring in preparation for pathway analysis
[ "Wrapper", "function", "-", "performs", "rule", "determination", "and", "node", "scoring", "in", "preparation", "for", "pathway", "analysis" ]
def __scoreNodes(self, graph): net = nx.read_graphml(graph) netGenes = [ self.geneList.index(gene) for gene in list(net) if gene in self.geneList ] print(netGenes) updateBooler = ctypes.cdll.LoadLibrary("./simulator.so") scSyncBoolC = updateBooler.scSyncBool ...
[ "def", "__scoreNodes", "(", "self", ",", "graph", ")", ":", "net", "=", "nx", ".", "read_graphml", "(", "graph", ")", "netGenes", "=", "[", "self", ".", "geneList", ".", "index", "(", "gene", ")", "for", "gene", "in", "list", "(", "net", ")", "if",...
Wrapper function - performs rule determination and node scoring in preparation for pathway analysis
[ "Wrapper", "function", "-", "performs", "rule", "determination", "and", "node", "scoring", "in", "preparation", "for", "pathway", "analysis" ]
[ "\"\"\"Wrapper function - performs rule determination and node scoring in preparation for pathway analysis\"\"\"", "# print(self.geneList)", "# print(list(net))", "# Genetic algorithm", "# Local search", "# Importance score calculation" ]
[ { "param": "self", "type": null }, { "param": "graph", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "graph", "type": null, "docstring": null, "docstring_tokens": ...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
__scorePathway
<not_specific>
def __scorePathway(self, RAs, pathImportances, pathname): """calculate z score for a given pathway""" CVdict = {} impactScore = {} score = 0 allNodes = list(RAs.keys()) for node in pathImportances: print("***Node: " + str(node) + "***") print("RA: ...
calculate z score for a given pathway
calculate z score for a given pathway
[ "calculate", "z", "score", "for", "a", "given", "pathway" ]
def __scorePathway(self, RAs, pathImportances, pathname): CVdict = {} impactScore = {} score = 0 allNodes = list(RAs.keys()) for node in pathImportances: print("***Node: " + str(node) + "***") print("RA: " + str(RAs[node])) print("IS: " + str(p...
[ "def", "__scorePathway", "(", "self", ",", "RAs", ",", "pathImportances", ",", "pathname", ")", ":", "CVdict", "=", "{", "}", "impactScore", "=", "{", "}", "score", "=", "0", "allNodes", "=", "list", "(", "RAs", ".", "keys", "(", ")", ")", "for", "...
calculate z score for a given pathway
[ "calculate", "z", "score", "for", "a", "given", "pathway" ]
[ "\"\"\"calculate z score for a given pathway\"\"\"", "# score+=abs(float(RAs[node]))*math.log(float(pathImportances[node]),2) #*CVdict[node]", "# score+=abs(float(RAs[node]))*float(pathImportances[node])", "# print(impactScore[node])", "# score+=(abs(float(RAs[node]))*float(pathImportances[node]))/nodeData_...
[ { "param": "self", "type": null }, { "param": "RAs", "type": null }, { "param": "pathImportances", "type": null }, { "param": "pathname", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "RAs", "type": null, "docstring": null, "docstring_tokens": []...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
processERS_minimalRule
<not_specific>
def processERS_minimalRule(self, equivsName): """Create an individual from the ERS generated by the local search, for importance score calculation""" ersFile = open(str(equivsName), "rb") ers = pickle.load(ersFile) ersFile.close() individual = [] for i in range(len(ers)):...
Create an individual from the ERS generated by the local search, for importance score calculation
Create an individual from the ERS generated by the local search, for importance score calculation
[ "Create", "an", "individual", "from", "the", "ERS", "generated", "by", "the", "local", "search", "for", "importance", "score", "calculation" ]
def processERS_minimalRule(self, equivsName): ersFile = open(str(equivsName), "rb") ers = pickle.load(ersFile) ersFile.close() individual = [] for i in range(len(ers)): ruleSet = ers[i] numOrRules = [sum(ruleSet[j]) for j in range(len(ruleSet))] ...
[ "def", "processERS_minimalRule", "(", "self", ",", "equivsName", ")", ":", "ersFile", "=", "open", "(", "str", "(", "equivsName", ")", ",", "\"rb\"", ")", "ers", "=", "pickle", ".", "load", "(", "ersFile", ")", "ersFile", ".", "close", "(", ")", "indiv...
Create an individual from the ERS generated by the local search, for importance score calculation
[ "Create", "an", "individual", "from", "the", "ERS", "generated", "by", "the", "local", "search", "for", "importance", "score", "calculation" ]
[ "\"\"\"Create an individual from the ERS generated by the local search, for importance score calculation\"\"\"", "# maximal or rules", "# rules with maximum or terms" ]
[ { "param": "self", "type": null }, { "param": "equivsName", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "equivsName", "type": null, "docstring": null, "docstring_toke...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
processERS
<not_specific>
def processERS(self, equivsName): """Create an individual from the ERS generated by the local search, for importance score calculation""" ersFile = open(str(equivsName), "rb") ers = pickle.load(ersFile) ersFile.close() individual = [] for i in range(len(ers)): ...
Create an individual from the ERS generated by the local search, for importance score calculation
Create an individual from the ERS generated by the local search, for importance score calculation
[ "Create", "an", "individual", "from", "the", "ERS", "generated", "by", "the", "local", "search", "for", "importance", "score", "calculation" ]
def processERS(self, equivsName): ersFile = open(str(equivsName), "rb") ers = pickle.load(ersFile) ersFile.close() individual = [] for i in range(len(ers)): ruleSet = ers[i] rand = random.randint(0, len(ruleSet) - 1) randomRule = ruleSet[rand] ...
[ "def", "processERS", "(", "self", ",", "equivsName", ")", ":", "ersFile", "=", "open", "(", "str", "(", "equivsName", ")", ",", "\"rb\"", ")", "ers", "=", "pickle", ".", "load", "(", "ersFile", ")", "ersFile", ".", "close", "(", ")", "individual", "=...
Create an individual from the ERS generated by the local search, for importance score calculation
[ "Create", "an", "individual", "from", "the", "ERS", "generated", "by", "the", "local", "search", "for", "importance", "score", "calculation" ]
[ "\"\"\"Create an individual from the ERS generated by the local search, for importance score calculation\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "equivsName", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "equivsName", "type": null, "docstring": null, "docstring_toke...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
assignAttractors
<not_specific>
def assignAttractors( self, pathwayFiles=[], useMinimalRuleSet=True, simSteps=10, removeZeroAttractors=True, ): """Takes a list of pathways to search the current working directory for the output of rule inference and to assign attractors for these networks. ...
Takes a list of pathways to search the current working directory for the output of rule inference and to assign attractors for these networks. Parameters ---------- pathwayFiles: list of strings Each string is a path to the processed graphml files for which rules have been inferred...
Takes a list of pathways to search the current working directory for the output of rule inference and to assign attractors for these networks. Parameters list of strings Each string is a path to the processed graphml files for which rules have been inferred useMinimalRuleSet: Boolean. Whether to use the minimal rule s...
[ "Takes", "a", "list", "of", "pathways", "to", "search", "the", "current", "working", "directory", "for", "the", "output", "of", "rule", "inference", "and", "to", "assign", "attractors", "for", "these", "networks", ".", "Parameters", "list", "of", "strings", ...
def assignAttractors( self, pathwayFiles=[], useMinimalRuleSet=True, simSteps=10, removeZeroAttractors=True, ): if len(pathwayFiles) == 0: pathwayFiles = glob.glob("*_processed.graphml") else: pathwayFiles = pathwayFiles feature...
[ "def", "assignAttractors", "(", "self", ",", "pathwayFiles", "=", "[", "]", ",", "useMinimalRuleSet", "=", "True", ",", "simSteps", "=", "10", ",", "removeZeroAttractors", "=", "True", ",", ")", ":", "if", "len", "(", "pathwayFiles", ")", "==", "0", ":",...
Takes a list of pathways to search the current working directory for the output of rule inference and to assign attractors for these networks.
[ "Takes", "a", "list", "of", "pathways", "to", "search", "the", "current", "working", "directory", "for", "the", "output", "of", "rule", "inference", "and", "to", "assign", "attractors", "for", "these", "networks", "." ]
[ "\"\"\"Takes a list of pathways to search the current working directory for the output of rule inference and to assign attractors for these networks.\n\n Parameters\n ----------\n\n pathwayFiles: list of strings\n Each string is a path to the processed graphml files for which rules h...
[ { "param": "self", "type": null }, { "param": "pathwayFiles", "type": null }, { "param": "useMinimalRuleSet", "type": null }, { "param": "simSteps", "type": null }, { "param": "removeZeroAttractors", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pathwayFiles", "type": null, "docstring": null, "docstring_to...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
makeAttractorAnalysisPlots
<not_specific>
def makeAttractorAnalysisPlots( self, plottingData, distanceDF, attractorsAttribute="decider", allAttractors=False, numberOfAttractorsToShow=2, cmap="colorblind", makeFrequencyPlots=True, frequencyGrouping="", freqplotsFile="", make...
Uses a dataframe of cells and the attractors to which they are assigned (usually the output of assignAttractors) to generate (a) a barplot showing the frequency of cells assigned to (selected) attractors, optionally faceted by user-specified variables and (b) a 2D scatterplot, such as a UMAP or tSNE plot, showing cells...
Uses a dataframe of cells and the attractors to which they are assigned (usually the output of assignAttractors) to generate (a) a barplot showing the frequency of cells assigned to (selected) attractors, optionally faceted by user-specified variables and (b) a 2D scatterplot, such as a UMAP or tSNE plot, showing cells...
[ "Uses", "a", "dataframe", "of", "cells", "and", "the", "attractors", "to", "which", "they", "are", "assigned", "(", "usually", "the", "output", "of", "assignAttractors", ")", "to", "generate", "(", "a", ")", "a", "barplot", "showing", "the", "frequency", "...
def makeAttractorAnalysisPlots( self, plottingData, distanceDF, attractorsAttribute="decider", allAttractors=False, numberOfAttractorsToShow=2, cmap="colorblind", makeFrequencyPlots=True, frequencyGrouping="", freqplotsFile="", make...
[ "def", "makeAttractorAnalysisPlots", "(", "self", ",", "plottingData", ",", "distanceDF", ",", "attractorsAttribute", "=", "\"decider\"", ",", "allAttractors", "=", "False", ",", "numberOfAttractorsToShow", "=", "2", ",", "cmap", "=", "\"colorblind\"", ",", "makeFre...
Uses a dataframe of cells and the attractors to which they are assigned (usually the output of assignAttractors) to generate (a) a barplot showing the frequency of cells assigned to (selected) attractors, optionally faceted by user-specified variables and (b) a 2D scatterplot, such as a UMAP or tSNE plot, showing cells...
[ "Uses", "a", "dataframe", "of", "cells", "and", "the", "attractors", "to", "which", "they", "are", "assigned", "(", "usually", "the", "output", "of", "assignAttractors", ")", "to", "generate", "(", "a", ")", "a", "barplot", "showing", "the", "frequency", "...
[ "\"\"\"Uses a dataframe of cells and the attractors to which they are assigned (usually the output of assignAttractors) to generate (a) a barplot showing the frequency of cells assigned to (selected) attractors, optionally faceted by user-specified variables and (b) a 2D scatterplot, such as a UMAP or tSNE plot, sh...
[ { "param": "self", "type": null }, { "param": "plottingData", "type": null }, { "param": "distanceDF", "type": null }, { "param": "attractorsAttribute", "type": null }, { "param": "allAttractors", "type": null }, { "param": "numberOfAttractorsToShow", ...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "plottingData", "type": null, "docstring": null, "docstring_to...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
makeBubblePlots
<not_specific>
def makeBubblePlots( pvalues=pd.DataFrame(), adjPValueThreshold=0.05, wrap=25, height=8, width=10, palette="colorblind", saveAsPDF=True, outputFile="", ): """Uses a dataframe of pathway names and adjusted p-values (usually the output of scBONI...
Uses a dataframe of pathway names and adjusted p-values (usually the output of scBONITA pathway analysis) to generate a bubbleplot showing the pathways and the -log10 of their adjusted p-values as calculated by scBONITA Parameters ---------- pvalues: pandas DataFrame Usually the ou...
Uses a dataframe of pathway names and adjusted p-values (usually the output of scBONITA pathway analysis) to generate a bubbleplot showing the pathways and the -log10 of their adjusted p-values as calculated by scBONITA Parameters Returns None
[ "Uses", "a", "dataframe", "of", "pathway", "names", "and", "adjusted", "p", "-", "values", "(", "usually", "the", "output", "of", "scBONITA", "pathway", "analysis", ")", "to", "generate", "a", "bubbleplot", "showing", "the", "pathways", "and", "the", "-", ...
def makeBubblePlots( pvalues=pd.DataFrame(), adjPValueThreshold=0.05, wrap=25, height=8, width=10, palette="colorblind", saveAsPDF=True, outputFile="", ): pvalues.loc[:, "log10pvals"] = [ -1 * np.log10(temp) for temp in pvalues.loc[...
[ "def", "makeBubblePlots", "(", "pvalues", "=", "pd", ".", "DataFrame", "(", ")", ",", "adjPValueThreshold", "=", "0.05", ",", "wrap", "=", "25", ",", "height", "=", "8", ",", "width", "=", "10", ",", "palette", "=", "\"colorblind\"", ",", "saveAsPDF", ...
Uses a dataframe of pathway names and adjusted p-values (usually the output of scBONITA pathway analysis) to generate a bubbleplot showing the pathways and the -log10 of their adjusted p-values as calculated by scBONITA Parameters
[ "Uses", "a", "dataframe", "of", "pathway", "names", "and", "adjusted", "p", "-", "values", "(", "usually", "the", "output", "of", "scBONITA", "pathway", "analysis", ")", "to", "generate", "a", "bubbleplot", "showing", "the", "pathways", "and", "the", "-", ...
[ "\"\"\"Uses a dataframe of pathway names and adjusted p-values (usually the output of scBONITA pathway analysis) to generate a bubbleplot showing the pathways and the -log10 of their adjusted p-values as calculated by scBONITA\n\n Parameters\n ----------\n\n pvalues: pandas DataFrame\n ...
[ { "param": "pvalues", "type": null }, { "param": "adjPValueThreshold", "type": null }, { "param": "wrap", "type": null }, { "param": "height", "type": null }, { "param": "width", "type": null }, { "param": "palette", "type": null }, { "para...
{ "returns": [], "raises": [], "params": [ { "identifier": "pvalues", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "adjPValueThreshold", "type": null, "docstring": null, "doc...
7f59f11afd85d340fd9040c2c2230f310d60e331
mgp13/scBONITA-1
src/scBONITA/singleCell.py
[ "MIT" ]
Python
ProcessLocalSearchOutput
<not_specific>
def ProcessLocalSearchOutput(self, graph, graphName): """ Processes the output of the local search component of scBONITA and returns a text file containing plain-text Boolean rules in the ERS, and other information such as in-degree and out-degree for each node in the network. Parameters: ...
Processes the output of the local search component of scBONITA and returns a text file containing plain-text Boolean rules in the ERS, and other information such as in-degree and out-degree for each node in the network. Parameters: graphName: name of the graphml file originally provided fo...
Processes the output of the local search component of scBONITA and returns a text file containing plain-text Boolean rules in the ERS, and other information such as in-degree and out-degree for each node in the network.
[ "Processes", "the", "output", "of", "the", "local", "search", "component", "of", "scBONITA", "and", "returns", "a", "text", "file", "containing", "plain", "-", "text", "Boolean", "rules", "in", "the", "ERS", "and", "other", "information", "such", "as", "in",...
def ProcessLocalSearchOutput(self, graph, graphName): equivs = graphName + "_processed.graphml_equivs1.pickle" print(Path(graphName), Path(equivs)) if ( Path(graphName).is_file() and Path(equivs).is_file() and Path(graphName + "_processed.graphml_importanceSco...
[ "def", "ProcessLocalSearchOutput", "(", "self", ",", "graph", ",", "graphName", ")", ":", "equivs", "=", "graphName", "+", "\"_processed.graphml_equivs1.pickle\"", "print", "(", "Path", "(", "graphName", ")", ",", "Path", "(", "equivs", ")", ")", "if", "(", ...
Processes the output of the local search component of scBONITA and returns a text file containing plain-text Boolean rules in the ERS, and other information such as in-degree and out-degree for each node in the network.
[ "Processes", "the", "output", "of", "the", "local", "search", "component", "of", "scBONITA", "and", "returns", "a", "text", "file", "containing", "plain", "-", "text", "Boolean", "rules", "in", "the", "ERS", "and", "other", "information", "such", "as", "in",...
[ "\"\"\"\n Processes the output of the local search component of scBONITA and returns a text file containing plain-text Boolean rules in the ERS, and other information such as in-degree and out-degree for each node in the network.\n\n Parameters:\n graphName: name of the graphml file origina...
[ { "param": "self", "type": null }, { "param": "graph", "type": null }, { "param": "graphName", "type": null } ]
{ "returns": [ { "docstring": "A Pandas DataFrame with the following columns:\n'Node': name of the node in the network\n'In_degree': in-degree in the processed network\n'Out_degree': out-degree in the processed network\n'Equivs_len'\n'Graph': the provided graphName\n'Number_of_Nodes': number of nodes in 'gr...
cf6ea8418a40daddc3e0121567fd5cd590b7dd3f
mgp13/scBONITA-1
src/scBONITA/classDefinitions.py
[ "MIT" ]
Python
Get_expanded_network
<not_specific>
def Get_expanded_network(rules, equal_sign="*="): """ The code is written by Gang Yang, Department of Physics, Penn State University if not specified. Return the expanded network for a given Boolean network model. The Boolean network model is a DiGraph object in the output format of form_network()...
The code is written by Gang Yang, Department of Physics, Penn State University if not specified. Return the expanded network for a given Boolean network model. The Boolean network model is a DiGraph object in the output format of form_network(). The Boolean network model can be generated through ...
The code is written by Gang Yang, Department of Physics, Penn State University if not specified. Return the expanded network for a given Boolean network model. The Boolean network model is a DiGraph object in the output format of form_network(). The Boolean network model can be generated through form_network function b...
[ "The", "code", "is", "written", "by", "Gang", "Yang", "Department", "of", "Physics", "Penn", "State", "University", "if", "not", "specified", ".", "Return", "the", "expanded", "network", "for", "a", "given", "Boolean", "network", "model", ".", "The", "Boolea...
def Get_expanded_network(rules, equal_sign="*="): composite_nodes = [] G_expand = nx.DiGraph() for line in rules: child, update_rule = line.split(equal_sign) print(child, update_rule) if child[0] == "~": normal_child = child[1:].strip() else: norma...
[ "def", "Get_expanded_network", "(", "rules", ",", "equal_sign", "=", "\"*=\"", ")", ":", "composite_nodes", "=", "[", "]", "G_expand", "=", "nx", ".", "DiGraph", "(", ")", "for", "line", "in", "rules", ":", "child", ",", "update_rule", "=", "line", ".", ...
The code is written by Gang Yang, Department of Physics, Penn State University if not specified.
[ "The", "code", "is", "written", "by", "Gang", "Yang", "Department", "of", "Physics", "Penn", "State", "University", "if", "not", "specified", "." ]
[ "\"\"\"\n The code is written by Gang Yang, Department of Physics, Penn State University if not specified.\n Return the expanded network for a given Boolean network model.\n The Boolean network model is a DiGraph object in the output format of form_network().\n The Boolean network model can be gen...
[ { "param": "rules", "type": null }, { "param": "equal_sign", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rules", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "equal_sign", "type": null, "docstring": null, "docstring_tok...
cf6ea8418a40daddc3e0121567fd5cd590b7dd3f
mgp13/scBONITA-1
src/scBONITA/classDefinitions.py
[ "MIT" ]
Python
cxTwoPointNode
<not_specific>
def cxTwoPointNode(self, ind1, ind2): # copied and modified from deap # needed to account for bistring only being one of two components of individual """Executes a two-point crossover on the input :term:`sequence` individuals. The two individuals are modified in place and both keep ...
Executes a two-point crossover on the input :term:`sequence` individuals. The two individuals are modified in place and both keep their original length. :returns: A tuple of two individuals. This function uses the :func:`~random.randint` function from the Python base :mod:`random...
Executes a two-point crossover on the input :term:`sequence` individuals. The two individuals are modified in place and both keep their original length.
[ "Executes", "a", "two", "-", "point", "crossover", "on", "the", "input", ":", "term", ":", "`", "sequence", "`", "individuals", ".", "The", "two", "individuals", "are", "modified", "in", "place", "and", "both", "keep", "their", "original", "length", "." ]
def cxTwoPointNode(self, ind1, ind2): size = len(ind1[0].nodeList) cxpointer1 = randint(1, size) cxpointer2 = randint(1, size - 1) if cxpointer2 >= cxpointer1: cxpointer2 += 1 else: cxpointer1, cxpointer2 = cxpointer2, cxpointer1 cxpoint1 = ind1[...
[ "def", "cxTwoPointNode", "(", "self", ",", "ind1", ",", "ind2", ")", ":", "size", "=", "len", "(", "ind1", "[", "0", "]", ".", "nodeList", ")", "cxpointer1", "=", "randint", "(", "1", ",", "size", ")", "cxpointer2", "=", "randint", "(", "1", ",", ...
Executes a two-point crossover on the input :term:`sequence` individuals.
[ "Executes", "a", "two", "-", "point", "crossover", "on", "the", "input", ":", "term", ":", "`", "sequence", "`", "individuals", "." ]
[ "# copied and modified from deap", "# needed to account for bistring only being one of two components of individual", "\"\"\"Executes a two-point crossover on the input :term:`sequence`\n individuals. The two individuals are modified in place and both keep\n their original length.\n :return...
[ { "param": "self", "type": null }, { "param": "ind1", "type": null }, { "param": "ind2", "type": null } ]
{ "returns": [ { "docstring": "A tuple of two individuals.\nThis function uses the :func:`~random.randint` function from the Python\nbase :mod:`random` module.\n\nModified to cross over between rules", "docstring_tokens": [ "A", "tuple", "of", "two", "individual...
cf6ea8418a40daddc3e0121567fd5cd590b7dd3f
mgp13/scBONITA-1
src/scBONITA/classDefinitions.py
[ "MIT" ]
Python
dominated
<not_specific>
def dominated(self, ind1, ind2): """Return true if each objective of *self* is not strictly worse than the corresponding objective of *other* and at least one objective is strictly better. :param obj: Slice indicating on which objectives the domination is tested. The ...
Return true if each objective of *self* is not strictly worse than the corresponding objective of *other* and at least one objective is strictly better. :param obj: Slice indicating on which objectives the domination is tested. The default value is `slice(None)`, representing...
Return true if each objective of *self* is not strictly worse than the corresponding objective of *other* and at least one objective is strictly better.
[ "Return", "true", "if", "each", "objective", "of", "*", "self", "*", "is", "not", "strictly", "worse", "than", "the", "corresponding", "objective", "of", "*", "other", "*", "and", "at", "least", "one", "objective", "is", "strictly", "better", "." ]
def dominated(self, ind1, ind2): not_equal = False mean1 = np.mean(ind1.wvalues) mean2 = np.mean(ind2.wvalues) std1 = np.std(ind1.wvalues) if mean1 > mean2: not_equal = True elif mean1 < mean2: return False return not_equal
[ "def", "dominated", "(", "self", ",", "ind1", ",", "ind2", ")", ":", "not_equal", "=", "False", "mean1", "=", "np", ".", "mean", "(", "ind1", ".", "wvalues", ")", "mean2", "=", "np", ".", "mean", "(", "ind2", ".", "wvalues", ")", "std1", "=", "np...
Return true if each objective of *self* is not strictly worse than the corresponding objective of *other* and at least one objective is strictly better.
[ "Return", "true", "if", "each", "objective", "of", "*", "self", "*", "is", "not", "strictly", "worse", "than", "the", "corresponding", "objective", "of", "*", "other", "*", "and", "at", "least", "one", "objective", "is", "strictly", "better", "." ]
[ "\"\"\"Return true if each objective of *self* is not strictly worse than\n the corresponding objective of *other* and at least one objective is\n strictly better.\n :param obj: Slice indicating on which objectives the domination is\n tested. The default value is `slice(None)...
[ { "param": "self", "type": null }, { "param": "ind1", "type": null }, { "param": "ind2", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ind1", "type": null, "docstring": null, "docstring_tokens": [...
cf6ea8418a40daddc3e0121567fd5cd590b7dd3f
mgp13/scBONITA-1
src/scBONITA/classDefinitions.py
[ "MIT" ]
Python
assignCrowdingDist
<not_specific>
def assignCrowdingDist(self, individuals): """Assign a crowding distance to each individual's fitness. The crowding distance can be retrieve via the :attr:`crowding_dist` attribute of each individual's fitness. """ if len(individuals) == 0: return distances =...
Assign a crowding distance to each individual's fitness. The crowding distance can be retrieve via the :attr:`crowding_dist` attribute of each individual's fitness.
Assign a crowding distance to each individual's fitness. The crowding distance can be retrieve via the :attr:`crowding_dist` attribute of each individual's fitness.
[ "Assign", "a", "crowding", "distance", "to", "each", "individual", "'", "s", "fitness", ".", "The", "crowding", "distance", "can", "be", "retrieve", "via", "the", ":", "attr", ":", "`", "crowding_dist", "`", "attribute", "of", "each", "individual", "'", "s...
def assignCrowdingDist(self, individuals): if len(individuals) == 0: return distances = [0.0] * len(individuals) crowd = [(ind.fitness.values, i) for i, ind in enumerate(individuals)] nobj = len(individuals[0].fitness.values) for i in range(nobj): crowd.so...
[ "def", "assignCrowdingDist", "(", "self", ",", "individuals", ")", ":", "if", "len", "(", "individuals", ")", "==", "0", ":", "return", "distances", "=", "[", "0.0", "]", "*", "len", "(", "individuals", ")", "crowd", "=", "[", "(", "ind", ".", "fitne...
Assign a crowding distance to each individual's fitness.
[ "Assign", "a", "crowding", "distance", "to", "each", "individual", "'", "s", "fitness", "." ]
[ "\"\"\"Assign a crowding distance to each individual's fitness. The\n crowding distance can be retrieve via the :attr:`crowding_dist`\n attribute of each individual's fitness.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "individuals", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "individuals", "type": null, "docstring": null, "docstring_tok...
cf6ea8418a40daddc3e0121567fd5cd590b7dd3f
mgp13/scBONITA-1
src/scBONITA/classDefinitions.py
[ "MIT" ]
Python
selNSGA2
<not_specific>
def selNSGA2(self, individuals, k): # NSGA2 selection taken from deap """Apply NSGA-II selection operator on the *individuals*. Usually, the size of *individuals* will be larger than *k* because any individual present in *individuals* will appear in the returned list at most once. ...
Apply NSGA-II selection operator on the *individuals*. Usually, the size of *individuals* will be larger than *k* because any individual present in *individuals* will appear in the returned list at most once. Having the size of *individuals* equals to *k* will have no effect other than s...
Apply NSGA-II selection operator on the *individuals*.
[ "Apply", "NSGA", "-", "II", "selection", "operator", "on", "the", "*", "individuals", "*", "." ]
def selNSGA2(self, individuals, k): pareto_fronts = self.sortNondominatedAdapt(individuals, k) for front in pareto_fronts: self.assignCrowdingDist(front) chosen = list(chain(*pareto_fronts[:-1])) k = k - len(chosen) if k > 0: sorted_front = sorted( ...
[ "def", "selNSGA2", "(", "self", ",", "individuals", ",", "k", ")", ":", "pareto_fronts", "=", "self", ".", "sortNondominatedAdapt", "(", "individuals", ",", "k", ")", "for", "front", "in", "pareto_fronts", ":", "self", ".", "assignCrowdingDist", "(", "front"...
Apply NSGA-II selection operator on the *individuals*.
[ "Apply", "NSGA", "-", "II", "selection", "operator", "on", "the", "*", "individuals", "*", "." ]
[ "# NSGA2 selection taken from deap", "\"\"\"Apply NSGA-II selection operator on the *individuals*. Usually, the\n size of *individuals* will be larger than *k* because any individual\n present in *individuals* will appear in the returned list at most once.\n Having the size of *individuals* e...
[ { "param": "self", "type": null }, { "param": "individuals", "type": null }, { "param": "k", "type": null } ]
{ "returns": [ { "docstring": "A list of selected individuals.\n[Deb2002] Deb, Pratab, Agarwal, and Meyarivan, \"A fast elitist\nnon-dominated sorting genetic algorithm for multi-objective\noptimization: NSGA-II\", 2002.", "docstring_tokens": [ "A", "list", "of", "selec...
cf6ea8418a40daddc3e0121567fd5cd590b7dd3f
mgp13/scBONITA-1
src/scBONITA/classDefinitions.py
[ "MIT" ]
Python
findInEdges
<not_specific>
def findInEdges(self, model, node): """find the incoming edges to each 'and' connection for a given node""" inEdges = [] for lister in model.andNodeList[node]: tempTup = tuple(lister) inEdges.append(set(tempTup)) return inEdges
find the incoming edges to each 'and' connection for a given node
find the incoming edges to each 'and' connection for a given node
[ "find", "the", "incoming", "edges", "to", "each", "'", "and", "'", "connection", "for", "a", "given", "node" ]
def findInEdges(self, model, node): inEdges = [] for lister in model.andNodeList[node]: tempTup = tuple(lister) inEdges.append(set(tempTup)) return inEdges
[ "def", "findInEdges", "(", "self", ",", "model", ",", "node", ")", ":", "inEdges", "=", "[", "]", "for", "lister", "in", "model", ".", "andNodeList", "[", "node", "]", ":", "tempTup", "=", "tuple", "(", "lister", ")", "inEdges", ".", "append", "(", ...
find the incoming edges to each 'and' connection for a given node
[ "find", "the", "incoming", "edges", "to", "each", "'", "and", "'", "connection", "for", "a", "given", "node" ]
[ "\"\"\"find the incoming edges to each 'and' connection for a given node\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "model", "type": null }, { "param": "node", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": ...
cf6ea8418a40daddc3e0121567fd5cd590b7dd3f
mgp13/scBONITA-1
src/scBONITA/classDefinitions.py
[ "MIT" ]
Python
simplifyRule
<not_specific>
def simplifyRule(self, rule, inEdges): """find the simplest form of a rule""" for i in range(len(rule)): if rule[i] == 1: for j in range(len(rule)): if rule[j] == 1 and not i == j: if inEdges[i].issubset(inEdges[j]): ...
find the simplest form of a rule
find the simplest form of a rule
[ "find", "the", "simplest", "form", "of", "a", "rule" ]
def simplifyRule(self, rule, inEdges): for i in range(len(rule)): if rule[i] == 1: for j in range(len(rule)): if rule[j] == 1 and not i == j: if inEdges[i].issubset(inEdges[j]): rule[j] = 0 return rule
[ "def", "simplifyRule", "(", "self", ",", "rule", ",", "inEdges", ")", ":", "for", "i", "in", "range", "(", "len", "(", "rule", ")", ")", ":", "if", "rule", "[", "i", "]", "==", "1", ":", "for", "j", "in", "range", "(", "len", "(", "rule", ")"...
find the simplest form of a rule
[ "find", "the", "simplest", "form", "of", "a", "rule" ]
[ "\"\"\"find the simplest form of a rule\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "rule", "type": null }, { "param": "inEdges", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rule", "type": null, "docstring": null, "docstring_tokens": [...
cf6ea8418a40daddc3e0121567fd5cd590b7dd3f
mgp13/scBONITA-1
src/scBONITA/classDefinitions.py
[ "MIT" ]
Python
filterData
null
def filterData(self, threshold): """Filter data based on CV cutoffs""" self.cvGenes = [] if threshold is not None: for i in range(0, self.expMat.get_shape()[0]): rowData = list(self.expMat.getrow(i).todense()) if np.std(rowData) / np.mean(rowData) >= t...
Filter data based on CV cutoffs
Filter data based on CV cutoffs
[ "Filter", "data", "based", "on", "CV", "cutoffs" ]
def filterData(self, threshold): self.cvGenes = [] if threshold is not None: for i in range(0, self.expMat.get_shape()[0]): rowData = list(self.expMat.getrow(i).todense()) if np.std(rowData) / np.mean(rowData) >= threshold: self.cvGenes.app...
[ "def", "filterData", "(", "self", ",", "threshold", ")", ":", "self", ".", "cvGenes", "=", "[", "]", "if", "threshold", "is", "not", "None", ":", "for", "i", "in", "range", "(", "0", ",", "self", ".", "expMat", ".", "get_shape", "(", ")", "[", "0...
Filter data based on CV cutoffs
[ "Filter", "data", "based", "on", "CV", "cutoffs" ]
[ "\"\"\"Filter data based on CV cutoffs\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "threshold", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "threshold", "type": null, "docstring": null, "docstring_token...
cf6ea8418a40daddc3e0121567fd5cd590b7dd3f
mgp13/scBONITA-1
src/scBONITA/classDefinitions.py
[ "MIT" ]
Python
find_pathways_from_gmt_LEGACY
null
def find_pathways_from_gmt_LEGACY(self, gmtFile, minOverlap=4): """LEGACY CODE: find list of pathways with at least four genes found in data""" if not hasattr(self, cvGenes): print("You have not filtered the genes; are you sure you want to proceed?") self.pathwayGraphs = [] i...
LEGACY CODE: find list of pathways with at least four genes found in data
LEGACY CODE: find list of pathways with at least four genes found in data
[ "LEGACY", "CODE", ":", "find", "list", "of", "pathways", "with", "at", "least", "four", "genes", "found", "in", "data" ]
def find_pathways_from_gmt_LEGACY(self, gmtFile, minOverlap=4): if not hasattr(self, cvGenes): print("You have not filtered the genes; are you sure you want to proceed?") self.pathwayGraphs = [] if hasattr(self, "cvGenes"): pathwayGenes = set(self.cvGenes) else: ...
[ "def", "find_pathways_from_gmt_LEGACY", "(", "self", ",", "gmtFile", ",", "minOverlap", "=", "4", ")", ":", "if", "not", "hasattr", "(", "self", ",", "cvGenes", ")", ":", "print", "(", "\"You have not filtered the genes; are you sure you want to proceed?\"", ")", "s...
LEGACY CODE: find list of pathways with at least four genes found in data
[ "LEGACY", "CODE", ":", "find", "list", "of", "pathways", "with", "at", "least", "four", "genes", "found", "in", "data" ]
[ "\"\"\"LEGACY CODE: find list of pathways with at least four genes found in data\"\"\"", "# ensure there are at least minOverlap nodes in both pathway and detected genes", "# Get the KEGG network" ]
[ { "param": "self", "type": null }, { "param": "gmtFile", "type": null }, { "param": "minOverlap", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gmtFile", "type": null, "docstring": null, "docstring_tokens"...
cf6ea8418a40daddc3e0121567fd5cd590b7dd3f
mgp13/scBONITA-1
src/scBONITA/classDefinitions.py
[ "MIT" ]
Python
read_gmt
<not_specific>
def read_gmt(filename): """read in file with pathway genes and names""" gmt_dict = {} inputfile = open(filename, "r") lines = inputfile.readlines() for line in lines: newline = line.split(" ") gmt_dict[newline[0]] = set(newline[2:]) return gmt_dict
read in file with pathway genes and names
read in file with pathway genes and names
[ "read", "in", "file", "with", "pathway", "genes", "and", "names" ]
def read_gmt(filename): gmt_dict = {} inputfile = open(filename, "r") lines = inputfile.readlines() for line in lines: newline = line.split(" ") gmt_dict[newline[0]] = set(newline[2:]) return gmt_dict
[ "def", "read_gmt", "(", "filename", ")", ":", "gmt_dict", "=", "{", "}", "inputfile", "=", "open", "(", "filename", ",", "\"r\"", ")", "lines", "=", "inputfile", ".", "readlines", "(", ")", "for", "line", "in", "lines", ":", "newline", "=", "line", "...
read in file with pathway genes and names
[ "read", "in", "file", "with", "pathway", "genes", "and", "names" ]
[ "\"\"\"read in file with pathway genes and names\"\"\"" ]
[ { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aaf21f84d1499d963dd0096a17b86513df395b01
mgp13/scBONITA-1
src/scBONITA/keggParser.py
[ "MIT" ]
Python
parseKEGGdict
<not_specific>
def parseKEGGdict(): """makes a dictionary to convert ko numbers from KEGG into real gene names #this is all file formatting. it reads a line, parses the string into the gene name and ko # then adds to a dict that identifies the two.""" converterDict = {} pathwayFile = requests.get("http://rest.kegg...
makes a dictionary to convert ko numbers from KEGG into real gene names #this is all file formatting. it reads a line, parses the string into the gene name and ko # then adds to a dict that identifies the two.
makes a dictionary to convert ko numbers from KEGG into real gene names this is all file formatting. it reads a line, parses the string into the gene name and ko # then adds to a dict that identifies the two.
[ "makes", "a", "dictionary", "to", "convert", "ko", "numbers", "from", "KEGG", "into", "real", "gene", "names", "this", "is", "all", "file", "formatting", ".", "it", "reads", "a", "line", "parses", "the", "string", "into", "the", "gene", "name", "and", "k...
def parseKEGGdict(): converterDict = {} pathwayFile = requests.get("http://rest.kegg.jp/get/br:ko00001", stream=True) for line in pathwayFile.iter_lines(): line = line.decode("utf-8") if ( len(line) > 1 and line[0] == "D" ): converter = re.split(r"\s+", re.s...
[ "def", "parseKEGGdict", "(", ")", ":", "converterDict", "=", "{", "}", "pathwayFile", "=", "requests", ".", "get", "(", "\"http://rest.kegg.jp/get/br:ko00001\"", ",", "stream", "=", "True", ")", "for", "line", "in", "pathwayFile", ".", "iter_lines", "(", ")", ...
makes a dictionary to convert ko numbers from KEGG into real gene names this is all file formatting.
[ "makes", "a", "dictionary", "to", "convert", "ko", "numbers", "from", "KEGG", "into", "real", "gene", "names", "this", "is", "all", "file", "formatting", "." ]
[ "\"\"\"makes a dictionary to convert ko numbers from KEGG into real gene names\r\n #this is all file formatting. it reads a line, parses the string into the gene name and ko # then adds to a dict that identifies the two.\"\"\"", "# lines which begin with D translate kegg codes to gene names\r", "# to split i...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
aaf21f84d1499d963dd0096a17b86513df395b01
mgp13/scBONITA-1
src/scBONITA/keggParser.py
[ "MIT" ]
Python
expand_groups
<not_specific>
def expand_groups(node_id, groups): """ node_id: a node ID that may be a group groups: store group IDs and list of sub-ids return value: a list that contains all group IDs deconvoluted """ node_list = [] if node_id in groups.keys(): for component_id in groups[node_id]: ...
node_id: a node ID that may be a group groups: store group IDs and list of sub-ids return value: a list that contains all group IDs deconvoluted
a node ID that may be a group groups: store group IDs and list of sub-ids return value: a list that contains all group IDs deconvoluted
[ "a", "node", "ID", "that", "may", "be", "a", "group", "groups", ":", "store", "group", "IDs", "and", "list", "of", "sub", "-", "ids", "return", "value", ":", "a", "list", "that", "contains", "all", "group", "IDs", "deconvoluted" ]
def expand_groups(node_id, groups): node_list = [] if node_id in groups.keys(): for component_id in groups[node_id]: node_list.extend(expand_groups(component_id, groups)) else: node_list.extend([node_id]) return node_list
[ "def", "expand_groups", "(", "node_id", ",", "groups", ")", ":", "node_list", "=", "[", "]", "if", "node_id", "in", "groups", ".", "keys", "(", ")", ":", "for", "component_id", "in", "groups", "[", "node_id", "]", ":", "node_list", ".", "extend", "(", ...
node_id: a node ID that may be a group groups: store group IDs and list of sub-ids return value: a list that contains all group IDs deconvoluted
[ "node_id", ":", "a", "node", "ID", "that", "may", "be", "a", "group", "groups", ":", "store", "group", "IDs", "and", "list", "of", "sub", "-", "ids", "return", "value", ":", "a", "list", "that", "contains", "all", "group", "IDs", "deconvoluted" ]
[ "\"\"\"\r\n node_id: a node ID that may be a group\r\n groups: store group IDs and list of sub-ids\r\n return value: a list that contains all group IDs deconvoluted\r\n \"\"\"" ]
[ { "param": "node_id", "type": null }, { "param": "groups", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "node_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "groups", "type": null, "docstring": null, "docstring_token...
aaf21f84d1499d963dd0096a17b86513df395b01
mgp13/scBONITA-1
src/scBONITA/keggParser.py
[ "MIT" ]
Python
find_pathways_kegg
<not_specific>
def find_pathways_kegg( geneList, preDefList=[], writeGraphml=True, organism="hsa", minimumOverlap=1 ): """ geneList = the list of genes included in dataset writeGraphml = whether or not to write out a graphml (usually true) organism = organism code from kegg. Eg human = 'hsa', mouse = 'mus'...
geneList = the list of genes included in dataset writeGraphml = whether or not to write out a graphml (usually true) organism = organism code from kegg. Eg human = 'hsa', mouse = 'mus'
geneList = the list of genes included in dataset writeGraphml = whether or not to write out a graphml (usually true) organism = organism code from kegg. Eg human = 'hsa', mouse = 'mus'
[ "geneList", "=", "the", "list", "of", "genes", "included", "in", "dataset", "writeGraphml", "=", "whether", "or", "not", "to", "write", "out", "a", "graphml", "(", "usually", "true", ")", "organism", "=", "organism", "code", "from", "kegg", ".", "Eg", "h...
def find_pathways_kegg( geneList, preDefList=[], writeGraphml=True, organism="hsa", minimumOverlap=1 ): koDict = parseKEGGdict() try: url = requests.get("http://rest.kegg.jp/list/" + organism, stream=True) aliasDict = {} orgDict = {} for line in url.iter_lines(): ...
[ "def", "find_pathways_kegg", "(", "geneList", ",", "preDefList", "=", "[", "]", ",", "writeGraphml", "=", "True", ",", "organism", "=", "\"hsa\"", ",", "minimumOverlap", "=", "1", ")", ":", "koDict", "=", "parseKEGGdict", "(", ")", "try", ":", "url", "="...
geneList = the list of genes included in dataset writeGraphml = whether or not to write out a graphml (usually true) organism = organism code from kegg.
[ "geneList", "=", "the", "list", "of", "genes", "included", "in", "dataset", "writeGraphml", "=", "whether", "or", "not", "to", "write", "out", "a", "graphml", "(", "usually", "true", ")", "organism", "=", "organism", "code", "from", "kegg", "." ]
[ "\"\"\"\r\n geneList = the list of genes included in dataset\r\n writeGraphml = whether or not to write out a graphml (usually true)\r\n organism = organism code from kegg. Eg human = 'hsa', mouse = 'mus'\r\n \"\"\"", "# parse the dictionary of ko codes\r", "# try to retrieve and parse the dictionar...
[ { "param": "geneList", "type": null }, { "param": "preDefList", "type": null }, { "param": "writeGraphml", "type": null }, { "param": "organism", "type": null }, { "param": "minimumOverlap", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "geneList", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "preDefList", "type": null, "docstring": null, "docstring_...
f3ab4eeeae22ae7ccf64716f2007f11f3b1a802b
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/utilities/basemodel.py
[ "MIT" ]
Python
validate
<not_specific>
def validate(cls, value): """Validate the class as itself.""" if isinstance(value, cls): return value else: return cls(**dict_validator(value))
Validate the class as itself.
Validate the class as itself.
[ "Validate", "the", "class", "as", "itself", "." ]
def validate(cls, value): if isinstance(value, cls): return value else: return cls(**dict_validator(value))
[ "def", "validate", "(", "cls", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "cls", ")", ":", "return", "value", "else", ":", "return", "cls", "(", "**", "dict_validator", "(", "value", ")", ")" ]
Validate the class as itself.
[ "Validate", "the", "class", "as", "itself", "." ]
[ "\"\"\"Validate the class as itself.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "value", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": null, "docstring": null, "docstring_tokens": [...
f3ab4eeeae22ae7ccf64716f2007f11f3b1a802b
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/utilities/basemodel.py
[ "MIT" ]
Python
dict
<not_specific>
def dict(self, *, include=None, exclude=None, by_alias: bool = False, skip_defaults: bool = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False,): """Return the objec...
Return the object as a dictionary.
Return the object as a dictionary.
[ "Return", "the", "object", "as", "a", "dictionary", "." ]
def dict(self, *, include=None, exclude=None, by_alias: bool = False, skip_defaults: bool = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False,): attribs = super().d...
[ "def", "dict", "(", "self", ",", "*", ",", "include", "=", "None", ",", "exclude", "=", "None", ",", "by_alias", ":", "bool", "=", "False", ",", "skip_defaults", ":", "bool", "=", "None", ",", "exclude_unset", ":", "bool", "=", "False", ",", "exclude...
Return the object as a dictionary.
[ "Return", "the", "object", "as", "a", "dictionary", "." ]
[ "\"\"\"Return the object as a dictionary.\"\"\"", "# type: ignore", "# Include and exclude properties", "# Update the attribute dict with the properties" ]
[ { "param": "self", "type": null }, { "param": "include", "type": null }, { "param": "exclude", "type": null }, { "param": "by_alias", "type": "bool" }, { "param": "skip_defaults", "type": "bool" }, { "param": "exclude_unset", "type": "bool" }, ...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "include", "type": null, "docstring": null, "docstring_tokens"...
a52e1fa14a378b7c6b0d6586f0705664edd0ba45
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/_base/authenticators/session.py
[ "MIT" ]
Python
redirect_if_authenticated
<not_specific>
def redirect_if_authenticated(self, auth_state, redirect='/'): """Redirect to a target if authenticated.""" if auth_state.is_authenticated(): self.logger.info(f'Logged in, redirecting to {redirect}') else: redirect = '/login' return RedirectResponse(redirect)
Redirect to a target if authenticated.
Redirect to a target if authenticated.
[ "Redirect", "to", "a", "target", "if", "authenticated", "." ]
def redirect_if_authenticated(self, auth_state, redirect='/'): if auth_state.is_authenticated(): self.logger.info(f'Logged in, redirecting to {redirect}') else: redirect = '/login' return RedirectResponse(redirect)
[ "def", "redirect_if_authenticated", "(", "self", ",", "auth_state", ",", "redirect", "=", "'/'", ")", ":", "if", "auth_state", ".", "is_authenticated", "(", ")", ":", "self", ".", "logger", ".", "info", "(", "f'Logged in, redirecting to {redirect}'", ")", "else"...
Redirect to a target if authenticated.
[ "Redirect", "to", "a", "target", "if", "authenticated", "." ]
[ "\"\"\"Redirect to a target if authenticated.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "auth_state", "type": null }, { "param": "redirect", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "auth_state", "type": null, "docstring": null, "docstring_toke...
a52e1fa14a378b7c6b0d6586f0705664edd0ba45
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/_base/authenticators/session.py
[ "MIT" ]
Python
redirect_to_provider_login
<not_specific>
def redirect_to_provider_login(self, auth_state, request): """Redirect to the provider login.""" self.logger.debug(f'state {auth_state}') auth_state.save_to_session(self._session_validator._session_serializer, request.session) authorization_url = self._get_authorization_url(request, auth...
Redirect to the provider login.
Redirect to the provider login.
[ "Redirect", "to", "the", "provider", "login", "." ]
def redirect_to_provider_login(self, auth_state, request): self.logger.debug(f'state {auth_state}') auth_state.save_to_session(self._session_validator._session_serializer, request.session) authorization_url = self._get_authorization_url(request, auth_state.session_state) return RedirectR...
[ "def", "redirect_to_provider_login", "(", "self", ",", "auth_state", ",", "request", ")", ":", "self", ".", "logger", ".", "debug", "(", "f'state {auth_state}'", ")", "auth_state", ".", "save_to_session", "(", "self", ".", "_session_validator", ".", "_session_seri...
Redirect to the provider login.
[ "Redirect", "to", "the", "provider", "login", "." ]
[ "\"\"\"Redirect to the provider login.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "auth_state", "type": null }, { "param": "request", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "auth_state", "type": null, "docstring": null, "docstring_toke...
a52e1fa14a378b7c6b0d6586f0705664edd0ba45
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/_base/authenticators/session.py
[ "MIT" ]
Python
process_login_request
<not_specific>
def process_login_request(self, request, force=False, redirect='/'): """Process the provider login request.""" self.logger.debug(f'Logging in - request url {request.url}') auth_state = self._session_validator.get_state_from_session(request) force = request.query_params.get('force', force...
Process the provider login request.
Process the provider login request.
[ "Process", "the", "provider", "login", "request", "." ]
def process_login_request(self, request, force=False, redirect='/'): self.logger.debug(f'Logging in - request url {request.url}') auth_state = self._session_validator.get_state_from_session(request) force = request.query_params.get('force', force) if auth_state.is_authenticated() and not...
[ "def", "process_login_request", "(", "self", ",", "request", ",", "force", "=", "False", ",", "redirect", "=", "'/'", ")", ":", "self", ".", "logger", ".", "debug", "(", "f'Logging in - request url {request.url}'", ")", "auth_state", "=", "self", ".", "_sessio...
Process the provider login request.
[ "Process", "the", "provider", "login", "request", "." ]
[ "\"\"\"Process the provider login request.\"\"\"", "# Set the redirect parameter here" ]
[ { "param": "self", "type": null }, { "param": "request", "type": null }, { "param": "force", "type": null }, { "param": "redirect", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "request", "type": null, "docstring": null, "docstring_tokens"...
a52e1fa14a378b7c6b0d6586f0705664edd0ba45
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/_base/authenticators/session.py
[ "MIT" ]
Python
process_login_callback
<not_specific>
def process_login_callback(self, request): """Process the provider login callback.""" if 'error' in request.query_params: error_args = [request.query_params['error'], ] if 'error_description' in request.query_params: error_args.append(request.query_params['error_d...
Process the provider login callback.
Process the provider login callback.
[ "Process", "the", "provider", "login", "callback", "." ]
def process_login_callback(self, request): if 'error' in request.query_params: error_args = [request.query_params['error'], ] if 'error_description' in request.query_params: error_args.append(request.query_params['error_description']) raise ConfigurationError(...
[ "def", "process_login_callback", "(", "self", ",", "request", ")", ":", "if", "'error'", "in", "request", ".", "query_params", ":", "error_args", "=", "[", "request", ".", "query_params", "[", "'error'", "]", ",", "]", "if", "'error_description'", "in", "req...
Process the provider login callback.
[ "Process", "the", "provider", "login", "callback", "." ]
[ "\"\"\"Process the provider login callback.\"\"\"", "# not authenticated" ]
[ { "param": "self", "type": null }, { "param": "request", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "request", "type": null, "docstring": null, "docstring_tokens"...
65c59393bbdecbff4fe50b7decfe443ad54dae9c
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/oauth/aad.py
[ "MIT" ]
Python
from_config
<not_specific>
def from_config(cls, config: Config): """Load the auth backend from a config. Args: config: Loaded configuration Keyword Args: user_klass: The class to use as a user """ session_validator = _SessionValidator.get_session_serializer(config.auth_session.sec...
Load the auth backend from a config. Args: config: Loaded configuration Keyword Args: user_klass: The class to use as a user
Load the auth backend from a config.
[ "Load", "the", "auth", "backend", "from", "a", "config", "." ]
def from_config(cls, config: Config): session_validator = _SessionValidator.get_session_serializer(config.auth_session.secret.get_secret_value(), config.auth_session.salt.get_secret_value()) provider = super().from_config(session_valid...
[ "def", "from_config", "(", "cls", ",", "config", ":", "Config", ")", ":", "session_validator", "=", "_SessionValidator", ".", "get_session_serializer", "(", "config", ".", "auth_session", ".", "secret", ".", "get_secret_value", "(", ")", ",", "config", ".", "a...
Load the auth backend from a config.
[ "Load", "the", "auth", "backend", "from", "a", "config", "." ]
[ "\"\"\"Load the auth backend from a config.\n\n Args:\n config: Loaded configuration\n\n Keyword Args:\n user_klass: The class to use as a user\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "config", "type": "Config" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config", "type": "Config", "docstring": null, "docstring_token...
b09a9b674075611f7528ed523a20c88ba8808813
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/_base/validators/session.py
[ "MIT" ]
Python
check
<not_specific>
def check(self, request): """Check the authentication from the request.""" try: state = AuthenticationState.load_from_session(self._session_serializer, request.session) except Exception: state = AuthenticationState.as_unauthenticated(self._session_serializer, request.sess...
Check the authentication from the request.
Check the authentication from the request.
[ "Check", "the", "authentication", "from", "the", "request", "." ]
def check(self, request): try: state = AuthenticationState.load_from_session(self._session_serializer, request.session) except Exception: state = AuthenticationState.as_unauthenticated(self._session_serializer, request.session) self.logger.exception('Error authenticat...
[ "def", "check", "(", "self", ",", "request", ")", ":", "try", ":", "state", "=", "AuthenticationState", ".", "load_from_session", "(", "self", ".", "_session_serializer", ",", "request", ".", "session", ")", "except", "Exception", ":", "state", "=", "Authent...
Check the authentication from the request.
[ "Check", "the", "authentication", "from", "the", "request", "." ]
[ "\"\"\"Check the authentication from the request.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "request", "type": null, "docstring": null, "docstring_tokens"...
b09a9b674075611f7528ed523a20c88ba8808813
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/_base/validators/session.py
[ "MIT" ]
Python
is_valid_redirect
<not_specific>
def is_valid_redirect(self, redirect): """Check if the redirect is not to endpoints that we don't want to redirect to.""" if redirect is None: return False return not any(map(partial(fnmatch.fnmatch, redirect), self._ignore_redirect_routes))
Check if the redirect is not to endpoints that we don't want to redirect to.
Check if the redirect is not to endpoints that we don't want to redirect to.
[ "Check", "if", "the", "redirect", "is", "not", "to", "endpoints", "that", "we", "don", "'", "t", "want", "to", "redirect", "to", "." ]
def is_valid_redirect(self, redirect): if redirect is None: return False return not any(map(partial(fnmatch.fnmatch, redirect), self._ignore_redirect_routes))
[ "def", "is_valid_redirect", "(", "self", ",", "redirect", ")", ":", "if", "redirect", "is", "None", ":", "return", "False", "return", "not", "any", "(", "map", "(", "partial", "(", "fnmatch", ".", "fnmatch", ",", "redirect", ")", ",", "self", ".", "_ig...
Check if the redirect is not to endpoints that we don't want to redirect to.
[ "Check", "if", "the", "redirect", "is", "not", "to", "endpoints", "that", "we", "don", "'", "t", "want", "to", "redirect", "to", "." ]
[ "\"\"\"Check if the redirect is not to endpoints that we don't want to redirect to.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "redirect", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "redirect", "type": null, "docstring": null, "docstring_tokens...
95aeac0c9725717a275469dd722b5e99eedf1865
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/_base/provider.py
[ "MIT" ]
Python
redirect_url
<not_specific>
def redirect_url(self): """Get the login redirect url.""" if self._redirect_url is None: self._redirect_url = self._build_oauth_url(self.oauth_base_route, 'redirect') return self._redirect_url
Get the login redirect url.
Get the login redirect url.
[ "Get", "the", "login", "redirect", "url", "." ]
def redirect_url(self): if self._redirect_url is None: self._redirect_url = self._build_oauth_url(self.oauth_base_route, 'redirect') return self._redirect_url
[ "def", "redirect_url", "(", "self", ")", ":", "if", "self", ".", "_redirect_url", "is", "None", ":", "self", ".", "_redirect_url", "=", "self", ".", "_build_oauth_url", "(", "self", ".", "oauth_base_route", ",", "'redirect'", ")", "return", "self", ".", "_...
Get the login redirect url.
[ "Get", "the", "login", "redirect", "url", "." ]
[ "\"\"\"Get the login redirect url.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
74d0996aa6001060e73650101f57a0a51c4ce1cf
oerpli/fastapi_aad_auth
src/fastapi_aad_auth/mixins/not_authenticated.py
[ "MIT" ]
Python
not_authenticated
<not_specific>
def not_authenticated(self): """Create an error for unauthenticated requests.""" return HTTPException( status_code=HTTP_401_UNAUTHORIZED, detail="Not authenticated", headers={"WWW-Authenticate": "Bearer"}, )
Create an error for unauthenticated requests.
Create an error for unauthenticated requests.
[ "Create", "an", "error", "for", "unauthenticated", "requests", "." ]
def not_authenticated(self): return HTTPException( status_code=HTTP_401_UNAUTHORIZED, detail="Not authenticated", headers={"WWW-Authenticate": "Bearer"}, )
[ "def", "not_authenticated", "(", "self", ")", ":", "return", "HTTPException", "(", "status_code", "=", "HTTP_401_UNAUTHORIZED", ",", "detail", "=", "\"Not authenticated\"", ",", "headers", "=", "{", "\"WWW-Authenticate\"", ":", "\"Bearer\"", "}", ",", ")" ]
Create an error for unauthenticated requests.
[ "Create", "an", "error", "for", "unauthenticated", "requests", "." ]
[ "\"\"\"Create an error for unauthenticated requests.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7816d7608b609d78c39cfc15ea102d37a33eca7c
louispotok/countrynames
countrynames/__init__.py
[ "MIT", "Unlicense" ]
Python
_load_data
None
def _load_data() -> None: """Load known aliases from a YAML file. Internal.""" data_file = os.path.join(os.path.dirname(__file__), "data.yaml") with open(data_file, "r", encoding="utf-8") as fh: for code, names in yaml.load(fh, Loader=Loader).items(): code = code.strip().upper() ...
Load known aliases from a YAML file. Internal.
Load known aliases from a YAML file. Internal.
[ "Load", "known", "aliases", "from", "a", "YAML", "file", ".", "Internal", "." ]
def _load_data() -> None: data_file = os.path.join(os.path.dirname(__file__), "data.yaml") with open(data_file, "r", encoding="utf-8") as fh: for code, names in yaml.load(fh, Loader=Loader).items(): code = code.strip().upper() name = _normalize_name(code) if name is n...
[ "def", "_load_data", "(", ")", "->", "None", ":", "data_file", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "\"data.yaml\"", ")", "with", "open", "(", "data_file", ",", "\"r\"", ",", "encodin...
Load known aliases from a YAML file.
[ "Load", "known", "aliases", "from", "a", "YAML", "file", "." ]
[ "\"\"\"Load known aliases from a YAML file. Internal.\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7816d7608b609d78c39cfc15ea102d37a33eca7c
louispotok/countrynames
countrynames/__init__.py
[ "MIT", "Unlicense" ]
Python
to_code
Optional[str]
def to_code(country_name: Any, fuzzy: bool = False) -> Optional[str]: """Given a human name for a country, return a two letter code. Arguments: ``fuzzy``: Try fuzzy matching based on Levenshtein distance. """ # Lazy load country list if not len(COUNTRY_NAMES): _load_data() # sh...
Given a human name for a country, return a two letter code. Arguments: ``fuzzy``: Try fuzzy matching based on Levenshtein distance.
Given a human name for a country, return a two letter code.
[ "Given", "a", "human", "name", "for", "a", "country", "return", "a", "two", "letter", "code", "." ]
def to_code(country_name: Any, fuzzy: bool = False) -> Optional[str]: if not len(COUNTRY_NAMES): _load_data() if isinstance(country_name, str): country_name = country_name.upper().strip() if country_name in COUNTRY_NAMES.values(): return country_name name = _normalize_nam...
[ "def", "to_code", "(", "country_name", ":", "Any", ",", "fuzzy", ":", "bool", "=", "False", ")", "->", "Optional", "[", "str", "]", ":", "if", "not", "len", "(", "COUNTRY_NAMES", ")", ":", "_load_data", "(", ")", "if", "isinstance", "(", "country_name"...
Given a human name for a country, return a two letter code.
[ "Given", "a", "human", "name", "for", "a", "country", "return", "a", "two", "letter", "code", "." ]
[ "\"\"\"Given a human name for a country, return a two letter code.\n\n Arguments:\n ``fuzzy``: Try fuzzy matching based on Levenshtein distance.\n \"\"\"", "# Lazy load country list", "# shortcut before costly ICU stuff", "# Check if the input is actually an ISO code:", "# Transliterate and cle...
[ { "param": "country_name", "type": "Any" }, { "param": "fuzzy", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "country_name", "type": "Any", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fuzzy", "type": "bool", "docstring": null, "docstrin...
7816d7608b609d78c39cfc15ea102d37a33eca7c
louispotok/countrynames
countrynames/__init__.py
[ "MIT", "Unlicense" ]
Python
to_code_3
Optional[str]
def to_code_3(country_name: Any, fuzzy: bool = False) -> Optional[str]: """Given a human name for a country, return a three letter code. Arguments: ``fuzzy``: Try fuzzy matching based on Levenshtein distance. """ code = to_code(country_name, fuzzy=fuzzy) if code and len(code) > 2: r...
Given a human name for a country, return a three letter code. Arguments: ``fuzzy``: Try fuzzy matching based on Levenshtein distance.
Given a human name for a country, return a three letter code.
[ "Given", "a", "human", "name", "for", "a", "country", "return", "a", "three", "letter", "code", "." ]
def to_code_3(country_name: Any, fuzzy: bool = False) -> Optional[str]: code = to_code(country_name, fuzzy=fuzzy) if code and len(code) > 2: return code elif code is None: return code else: return mappings[code]
[ "def", "to_code_3", "(", "country_name", ":", "Any", ",", "fuzzy", ":", "bool", "=", "False", ")", "->", "Optional", "[", "str", "]", ":", "code", "=", "to_code", "(", "country_name", ",", "fuzzy", "=", "fuzzy", ")", "if", "code", "and", "len", "(", ...
Given a human name for a country, return a three letter code.
[ "Given", "a", "human", "name", "for", "a", "country", "return", "a", "three", "letter", "code", "." ]
[ "\"\"\"Given a human name for a country, return a three letter code.\n\n Arguments:\n ``fuzzy``: Try fuzzy matching based on Levenshtein distance.\n \"\"\"" ]
[ { "param": "country_name", "type": "Any" }, { "param": "fuzzy", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "country_name", "type": "Any", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fuzzy", "type": "bool", "docstring": null, "docstrin...
e6aa8131d5d0372e16ba0e932a1e02b31b98d6bc
vuiseng9/nncf_pytorch
nncf/experimental/tensorflow/graph/argprovider.py
[ "Apache-2.0" ]
Python
replace_value_by_index
Tuple[Any, ...]
def replace_value_by_index(xs: Tuple[Any, ...], pos: int, value: Any) -> Tuple[Any, ...]: """ Return a new instance of the tuple replacing the specified position with the new value. :param xs: A tuple. :param pos: Zero-based index of the item which should be replaced. :param value: New value. ...
Return a new instance of the tuple replacing the specified position with the new value. :param xs: A tuple. :param pos: Zero-based index of the item which should be replaced. :param value: New value.
Return a new instance of the tuple replacing the specified position with the new value.
[ "Return", "a", "new", "instance", "of", "the", "tuple", "replacing", "the", "specified", "position", "with", "the", "new", "value", "." ]
def replace_value_by_index(xs: Tuple[Any, ...], pos: int, value: Any) -> Tuple[Any, ...]: return tuple(value if idx == pos else elem for idx, elem in enumerate(xs))
[ "def", "replace_value_by_index", "(", "xs", ":", "Tuple", "[", "Any", ",", "...", "]", ",", "pos", ":", "int", ",", "value", ":", "Any", ")", "->", "Tuple", "[", "Any", ",", "...", "]", ":", "return", "tuple", "(", "value", "if", "idx", "==", "po...
Return a new instance of the tuple replacing the specified position with the new value.
[ "Return", "a", "new", "instance", "of", "the", "tuple", "replacing", "the", "specified", "position", "with", "the", "new", "value", "." ]
[ "\"\"\"\n Return a new instance of the tuple replacing the specified\n position with the new value.\n\n :param xs: A tuple.\n :param pos: Zero-based index of the item which should be replaced.\n :param value: New value.\n \"\"\"" ]
[ { "param": "xs", "type": "Tuple[Any, ...]" }, { "param": "pos", "type": "int" }, { "param": "value", "type": "Any" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "xs", "type": "Tuple[Any, ...]", "docstring": null, "docstring_tokens": [ "None" ], "default": null, "is_optional": null }, { "identifier": "pos", "type": "int", "docstring": ...
211882f0b6a096b409e25793c59b3e683e076a97
vuiseng9/nncf_pytorch
nncf/experimental/tensorflow/graph/model_transformer.py
[ "Apache-2.0" ]
Python
transform
NNCFNetwork
def transform(self, transformation_layout: TFTransformationLayoutV2) -> NNCFNetwork: """ Applies transformations to the model. :param transformation_layout: An instance of `TransformationLayout` that includes a list of transformations to be applied to the NNCF network. :retu...
Applies transformations to the model. :param transformation_layout: An instance of `TransformationLayout` that includes a list of transformations to be applied to the NNCF network. :return: The transformed NNCF network.
Applies transformations to the model.
[ "Applies", "transformations", "to", "the", "model", "." ]
def transform(self, transformation_layout: TFTransformationLayoutV2) -> NNCFNetwork: for command in transformation_layout.transformations: if command.type == TransformationType.INSERT: self._model.insert_at_point(command.target_point, command.insertion_objects) elif comma...
[ "def", "transform", "(", "self", ",", "transformation_layout", ":", "TFTransformationLayoutV2", ")", "->", "NNCFNetwork", ":", "for", "command", "in", "transformation_layout", ".", "transformations", ":", "if", "command", ".", "type", "==", "TransformationType", "."...
Applies transformations to the model.
[ "Applies", "transformations", "to", "the", "model", "." ]
[ "\"\"\"\n Applies transformations to the model.\n\n :param transformation_layout: An instance of `TransformationLayout` that\n includes a list of transformations to be applied to the NNCF network.\n :return: The transformed NNCF network.\n \"\"\"", "# TODO(andrey-churkin): A...
[ { "param": "self", "type": null }, { "param": "transformation_layout", "type": "TFTransformationLayoutV2" } ]
{ "returns": [ { "docstring": "The transformed NNCF network.", "docstring_tokens": [ "The", "transformed", "NNCF", "network", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "do...
8d551547db2eea4c4c67cfe2ac84367504d32f38
vuiseng9/nncf_pytorch
nncf/torch/layers.py
[ "Apache-2.0" ]
Python
_reverse_repeat_tuple
<not_specific>
def _reverse_repeat_tuple(t, n): r"""Reverse the order of `t` and repeat each element for `n` times. This can be used to translate padding arg used by Conv and Pooling modules to the ones used by `F.pad`. """ return tuple(x for x in reversed(t) for _ in range...
r"""Reverse the order of `t` and repeat each element for `n` times. This can be used to translate padding arg used by Conv and Pooling modules to the ones used by `F.pad`.
r"""Reverse the order of `t` and repeat each element for `n` times. This can be used to translate padding arg used by Conv and Pooling modules to the ones used by `F.pad`.
[ "r", "\"", "\"", "\"", "Reverse", "the", "order", "of", "`", "t", "`", "and", "repeat", "each", "element", "for", "`", "n", "`", "times", ".", "This", "can", "be", "used", "to", "translate", "padding", "arg", "used", "by", "Conv", "and", "Pooling", ...
def _reverse_repeat_tuple(t, n): return tuple(x for x in reversed(t) for _ in range(n))
[ "def", "_reverse_repeat_tuple", "(", "t", ",", "n", ")", ":", "return", "tuple", "(", "x", "for", "x", "in", "reversed", "(", "t", ")", "for", "_", "in", "range", "(", "n", ")", ")" ]
r"""Reverse the order of `t` and repeat each element for `n` times.
[ "r", "\"", "\"", "\"", "Reverse", "the", "order", "of", "`", "t", "`", "and", "repeat", "each", "element", "for", "`", "n", "`", "times", "." ]
[ "r\"\"\"Reverse the order of `t` and repeat each element for `n` times.\n\n This can be used to translate padding arg used by Conv and Pooling modules\n to the ones used by `F.pad`.\n \"\"\"" ]
[ { "param": "t", "type": null }, { "param": "n", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "t", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n", "type": null, "docstring": null, "docstring_tokens": [], ...
3bc12eda4f365cc04a9be02a55cbacdc55b57200
vuiseng9/nncf_pytorch
nncf/torch/pruning/utils.py
[ "Apache-2.0" ]
Python
init_output_masks_in_graph
null
def init_output_masks_in_graph(graph: NNCFGraph, nodes: List): """ Initialize masks in graph for mask propagation algorithm :param graph: NNCFNetwork :param nodes: list with pruned nodes """ for node in graph.get_all_nodes(): node.data.pop('output_mask', None) for minfo in nodes: ...
Initialize masks in graph for mask propagation algorithm :param graph: NNCFNetwork :param nodes: list with pruned nodes
Initialize masks in graph for mask propagation algorithm
[ "Initialize", "masks", "in", "graph", "for", "mask", "propagation", "algorithm" ]
def init_output_masks_in_graph(graph: NNCFGraph, nodes: List): for node in graph.get_all_nodes(): node.data.pop('output_mask', None) for minfo in nodes: mask = minfo.operand.binary_filter_pruning_mask nncf_node = graph.get_node_by_id(minfo.nncf_node_id) nncf_node.data['output_mas...
[ "def", "init_output_masks_in_graph", "(", "graph", ":", "NNCFGraph", ",", "nodes", ":", "List", ")", ":", "for", "node", "in", "graph", ".", "get_all_nodes", "(", ")", ":", "node", ".", "data", ".", "pop", "(", "'output_mask'", ",", "None", ")", "for", ...
Initialize masks in graph for mask propagation algorithm
[ "Initialize", "masks", "in", "graph", "for", "mask", "propagation", "algorithm" ]
[ "\"\"\"\n Initialize masks in graph for mask propagation algorithm\n\n :param graph: NNCFNetwork\n :param nodes: list with pruned nodes\n \"\"\"" ]
[ { "param": "graph", "type": "NNCFGraph" }, { "param": "nodes", "type": "List" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "graph", "type": "NNCFGraph", "docstring": null, "docstring_tokens": [ "None" ], "default": null, "is_optional": null }, { "identifier": "nodes", "type": "List", "docstring": ...
3bc12eda4f365cc04a9be02a55cbacdc55b57200
vuiseng9/nncf_pytorch
nncf/torch/pruning/utils.py
[ "Apache-2.0" ]
Python
_calculate_output_shape
Tuple[int, ...]
def _calculate_output_shape(graph: NNCFGraph, node: NNCFNode) -> Tuple[int, ...]: """ Calculates output shape of convolution layer by input edge. :param graph: the model graph :param node: node from NNCF graph :return: output shape """ in_edge = graph.get_input_edges(node)[0] shape = li...
Calculates output shape of convolution layer by input edge. :param graph: the model graph :param node: node from NNCF graph :return: output shape
Calculates output shape of convolution layer by input edge.
[ "Calculates", "output", "shape", "of", "convolution", "layer", "by", "input", "edge", "." ]
def _calculate_output_shape(graph: NNCFGraph, node: NNCFNode) -> Tuple[int, ...]: in_edge = graph.get_input_edges(node)[0] shape = list(in_edge.tensor_shape)[2:] attrs = node.layer_attributes assert isinstance(attrs, ConvolutionLayerAttributes) for i, _ in enumerate(shape): if attrs.transpos...
[ "def", "_calculate_output_shape", "(", "graph", ":", "NNCFGraph", ",", "node", ":", "NNCFNode", ")", "->", "Tuple", "[", "int", ",", "...", "]", ":", "in_edge", "=", "graph", ".", "get_input_edges", "(", "node", ")", "[", "0", "]", "shape", "=", "list"...
Calculates output shape of convolution layer by input edge.
[ "Calculates", "output", "shape", "of", "convolution", "layer", "by", "input", "edge", "." ]
[ "\"\"\"\n Calculates output shape of convolution layer by input edge.\n\n :param graph: the model graph\n :param node: node from NNCF graph\n :return: output shape\n \"\"\"" ]
[ { "param": "graph", "type": "NNCFGraph" }, { "param": "node", "type": "NNCFNode" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "graph", "type": "NNCFGraph", "docstring": "the model graph", "docstring_tokens": [ "the", "model", ...
3bc12eda4f365cc04a9be02a55cbacdc55b57200
vuiseng9/nncf_pytorch
nncf/torch/pruning/utils.py
[ "Apache-2.0" ]
Python
collect_output_shapes
Dict[NNCFNodeName, List[int]]
def collect_output_shapes(graph: NNCFGraph) -> Dict[NNCFNodeName, List[int]]: """ Collects output dimension shapes for convolutions and fully connected layers from the connected edges in the NNCFGraph. :param graph: NNCFGraph. :return: Dictionary of output dimension shapes. E.g {node_name: (height,...
Collects output dimension shapes for convolutions and fully connected layers from the connected edges in the NNCFGraph. :param graph: NNCFGraph. :return: Dictionary of output dimension shapes. E.g {node_name: (height, width)}
Collects output dimension shapes for convolutions and fully connected layers from the connected edges in the NNCFGraph.
[ "Collects", "output", "dimension", "shapes", "for", "convolutions", "and", "fully", "connected", "layers", "from", "the", "connected", "edges", "in", "the", "NNCFGraph", "." ]
def collect_output_shapes(graph: NNCFGraph) -> Dict[NNCFNodeName, List[int]]: modules_out_shapes = {} for node in graph.get_nodes_by_types([v.op_func_name for v in NNCF_GENERAL_CONV_MODULES_DICT]): output_edges = graph.get_output_edges(node) if output_edges: out_edge = output_edges[0...
[ "def", "collect_output_shapes", "(", "graph", ":", "NNCFGraph", ")", "->", "Dict", "[", "NNCFNodeName", ",", "List", "[", "int", "]", "]", ":", "modules_out_shapes", "=", "{", "}", "for", "node", "in", "graph", ".", "get_nodes_by_types", "(", "[", "v", "...
Collects output dimension shapes for convolutions and fully connected layers from the connected edges in the NNCFGraph.
[ "Collects", "output", "dimension", "shapes", "for", "convolutions", "and", "fully", "connected", "layers", "from", "the", "connected", "edges", "in", "the", "NNCFGraph", "." ]
[ "\"\"\"\n Collects output dimension shapes for convolutions and fully connected layers\n from the connected edges in the NNCFGraph.\n\n :param graph: NNCFGraph.\n :return: Dictionary of output dimension shapes. E.g {node_name: (height, width)}\n \"\"\"", "# For disconnected NNCFGraph when node have...
[ { "param": "graph", "type": "NNCFGraph" } ]
{ "returns": [ { "docstring": "Dictionary of output dimension shapes. E.g {node_name: (height, width)}", "docstring_tokens": [ "Dictionary", "of", "output", "dimension", "shapes", ".", "E", ".", "g", "{", "node_nam...
3bc12eda4f365cc04a9be02a55cbacdc55b57200
vuiseng9/nncf_pytorch
nncf/torch/pruning/utils.py
[ "Apache-2.0" ]
Python
collect_input_shapes
Dict[NNCFNodeName, List[int]]
def collect_input_shapes(graph: NNCFGraph) -> Dict[NNCFNodeName, List[int]]: """ Collects input dimension shapes for fully connected layers from the connected edges in the NNCFGraph. :param graph: NNCFGraph. :return: Dictionary of input dimension shapes. E.g {node_name: (height, width)} """ mod...
Collects input dimension shapes for fully connected layers from the connected edges in the NNCFGraph. :param graph: NNCFGraph. :return: Dictionary of input dimension shapes. E.g {node_name: (height, width)}
Collects input dimension shapes for fully connected layers from the connected edges in the NNCFGraph.
[ "Collects", "input", "dimension", "shapes", "for", "fully", "connected", "layers", "from", "the", "connected", "edges", "in", "the", "NNCFGraph", "." ]
def collect_input_shapes(graph: NNCFGraph) -> Dict[NNCFNodeName, List[int]]: modules_in_shapes = {} for node in graph.get_nodes_by_types([v.op_func_name for v in NNCF_LINEAR_MODULES_DICT]): in_edge = graph.get_input_edges(node)[0] in_shape = in_edge.tensor_shape if len(in_shape) == 1: ...
[ "def", "collect_input_shapes", "(", "graph", ":", "NNCFGraph", ")", "->", "Dict", "[", "NNCFNodeName", ",", "List", "[", "int", "]", "]", ":", "modules_in_shapes", "=", "{", "}", "for", "node", "in", "graph", ".", "get_nodes_by_types", "(", "[", "v", "."...
Collects input dimension shapes for fully connected layers from the connected edges in the NNCFGraph.
[ "Collects", "input", "dimension", "shapes", "for", "fully", "connected", "layers", "from", "the", "connected", "edges", "in", "the", "NNCFGraph", "." ]
[ "\"\"\"\n Collects input dimension shapes for fully connected layers from the connected edges in the NNCFGraph.\n\n :param graph: NNCFGraph.\n :return: Dictionary of input dimension shapes. E.g {node_name: (height, width)}\n \"\"\"" ]
[ { "param": "graph", "type": "NNCFGraph" } ]
{ "returns": [ { "docstring": "Dictionary of input dimension shapes. E.g {node_name: (height, width)}", "docstring_tokens": [ "Dictionary", "of", "input", "dimension", "shapes", ".", "E", ".", "g", "{", "node_name"...
d81179dedd0506b298d8237dabe854863b824727
vuiseng9/nncf_pytorch
nncf/experimental/onnx/graph/nncf_graph_builder.py
[ "Apache-2.0" ]
Python
create_nncf_graph
NNCFGraph
def create_nncf_graph(onnx_model: ModelProto) -> NNCFGraph: """ Adds all ONNX nodes from 'onnx_model' and then adds thr special input_nodes and output_nodes. """ nncf_graph = NNCFGraph() onnx_graph = ONNXGraph(onnx_model) for i, node in enumerate(onnx_graph.get_all_nodes...
Adds all ONNX nodes from 'onnx_model' and then adds thr special input_nodes and output_nodes.
Adds all ONNX nodes from 'onnx_model' and then adds thr special input_nodes and output_nodes.
[ "Adds", "all", "ONNX", "nodes", "from", "'", "onnx_model", "'", "and", "then", "adds", "thr", "special", "input_nodes", "and", "output_nodes", "." ]
def create_nncf_graph(onnx_model: ModelProto) -> NNCFGraph: nncf_graph = NNCFGraph() onnx_graph = ONNXGraph(onnx_model) for i, node in enumerate(onnx_graph.get_all_nodes()): node_name = node.name node_type = node.op_type metatype = ONNX_OPERATION_METATYPES.get...
[ "def", "create_nncf_graph", "(", "onnx_model", ":", "ModelProto", ")", "->", "NNCFGraph", ":", "nncf_graph", "=", "NNCFGraph", "(", ")", "onnx_graph", "=", "ONNXGraph", "(", "onnx_model", ")", "for", "i", ",", "node", "in", "enumerate", "(", "onnx_graph", "....
Adds all ONNX nodes from 'onnx_model' and then adds thr special input_nodes and output_nodes.
[ "Adds", "all", "ONNX", "nodes", "from", "'", "onnx_model", "'", "and", "then", "adds", "thr", "special", "input_nodes", "and", "output_nodes", "." ]
[ "\"\"\"\n Adds all ONNX nodes from 'onnx_model' and then adds thr special input_nodes and output_nodes.\n \"\"\"", "# We don't need to quantize Constants", "# if this node is output", "# This exception raised because ONNX format allows to not have shape field.", "# Model example - effecienet-v...
[ { "param": "onnx_model", "type": "ModelProto" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "onnx_model", "type": "ModelProto", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9490cf196abb9aab63855411c8c28c7594b29c2e
vuiseng9/nncf_pytorch
nncf/torch/exporter.py
[ "Apache-2.0" ]
Python
parse_format
Tuple[str, dict]
def parse_format(save_format: str) -> Tuple[str, dict]: """ Parse saving format to a short form and additional arguments. :param save_format: Saving format. :return str: short form of the save_format dict: additional arguments for exporter """ if...
Parse saving format to a short form and additional arguments. :param save_format: Saving format. :return str: short form of the save_format dict: additional arguments for exporter
Parse saving format to a short form and additional arguments.
[ "Parse", "saving", "format", "to", "a", "short", "form", "and", "additional", "arguments", "." ]
def parse_format(save_format: str) -> Tuple[str, dict]: if save_format.startswith(PTExporter._ONNX_FORMAT): split_format = save_format.split('_') opset = None if len(split_format) == 1: opset = PTExporter._ONNX_DEFAULT_OPSET elif len(split_format) ...
[ "def", "parse_format", "(", "save_format", ":", "str", ")", "->", "Tuple", "[", "str", ",", "dict", "]", ":", "if", "save_format", ".", "startswith", "(", "PTExporter", ".", "_ONNX_FORMAT", ")", ":", "split_format", "=", "save_format", ".", "split", "(", ...
Parse saving format to a short form and additional arguments.
[ "Parse", "saving", "format", "to", "a", "short", "form", "and", "additional", "arguments", "." ]
[ "\"\"\"\n Parse saving format to a short form and additional arguments.\n\n :param save_format: Saving format.\n\n :return\n str: short form of the save_format\n dict: additional arguments for exporter\n \"\"\"" ]
[ { "param": "save_format", "type": "str" } ]
{ "returns": [ { "docstring": "short form of the save_format\ndict: additional arguments for exporter", "docstring_tokens": [ "short", "form", "of", "the", "save_format", "dict", ":", "additional", "arguments", "for", ...
9490cf196abb9aab63855411c8c28c7594b29c2e
vuiseng9/nncf_pytorch
nncf/torch/exporter.py
[ "Apache-2.0" ]
Python
export_model
None
def export_model(self, save_path: str, save_format: Optional[str] = None) -> None: """ Exports the compressed model to the specified format. :param save_path: The path where the model will be saved. :param save_format: Saving format. One of the following: - `...
Exports the compressed model to the specified format. :param save_path: The path where the model will be saved. :param save_format: Saving format. One of the following: - `onnx` for export to the ONNX format. - `onnx_<opset_version>` for export to th...
Exports the compressed model to the specified format.
[ "Exports", "the", "compressed", "model", "to", "the", "specified", "format", "." ]
def export_model(self, save_path: str, save_format: Optional[str] = None) -> None: fn_args = {'save_path': save_path} if save_format is None: save_format = PTExporter._ONNX_FORMAT save_format, extra_args = PTExporter.parse_format(save_format) fn_args.update(extra_args) ...
[ "def", "export_model", "(", "self", ",", "save_path", ":", "str", ",", "save_format", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "fn_args", "=", "{", "'save_path'", ":", "save_path", "}", "if", "save_format", "is", "None", "...
Exports the compressed model to the specified format.
[ "Exports", "the", "compressed", "model", "to", "the", "specified", "format", "." ]
[ "\"\"\"\n Exports the compressed model to the specified format.\n\n :param save_path: The path where the model will be saved.\n :param save_format: Saving format.\n One of the following:\n - `onnx` for export to the ONNX format.\n - `onnx_<opset_version>...
[ { "param": "self", "type": null }, { "param": "save_path", "type": "str" }, { "param": "save_format", "type": "Optional[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "save_path", "type": "str", "docstring": "The path where the model w...
9490cf196abb9aab63855411c8c28c7594b29c2e
vuiseng9/nncf_pytorch
nncf/torch/exporter.py
[ "Apache-2.0" ]
Python
_export_to_onnx
None
def _export_to_onnx(self, save_path: str, opset_version: int) -> None: """ Exports the compressed model to the ONNX format. :param save_path: The path where the model will be saved. """ original_device = get_model_device(self._model) model = self._model.eval().cpu() ...
Exports the compressed model to the ONNX format. :param save_path: The path where the model will be saved.
Exports the compressed model to the ONNX format.
[ "Exports", "the", "compressed", "model", "to", "the", "ONNX", "format", "." ]
def _export_to_onnx(self, save_path: str, opset_version: int) -> None: original_device = get_model_device(self._model) model = self._model.eval().cpu() input_tensor_list = [] for info in self._model.input_infos: single_batch_info = copy(info) input_shape = tuple([...
[ "def", "_export_to_onnx", "(", "self", ",", "save_path", ":", "str", ",", "opset_version", ":", "int", ")", "->", "None", ":", "original_device", "=", "get_model_device", "(", "self", ".", "_model", ")", "model", "=", "self", ".", "_model", ".", "eval", ...
Exports the compressed model to the ONNX format.
[ "Exports", "the", "compressed", "model", "to", "the", "ONNX", "format", "." ]
[ "\"\"\"\n Exports the compressed model to the ONNX format.\n\n :param save_path: The path where the model will be saved.\n \"\"\"", "# pylint:disable=unexpected-keyword-arg", "# Should call this, otherwise the operations executed during export will end up in the graph.", "# Will have to r...
[ { "param": "self", "type": null }, { "param": "save_path", "type": "str" }, { "param": "opset_version", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "save_path", "type": "str", "docstring": "The path where the model w...
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
is_merged
bool
def is_merged(self) -> bool: """ Returns value that the node is merged. """ return self.data.get(SearchGraph.IS_MERGED_NODE_ATTR)
Returns value that the node is merged.
Returns value that the node is merged.
[ "Returns", "value", "that", "the", "node", "is", "merged", "." ]
def is_merged(self) -> bool: return self.data.get(SearchGraph.IS_MERGED_NODE_ATTR)
[ "def", "is_merged", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "data", ".", "get", "(", "SearchGraph", ".", "IS_MERGED_NODE_ATTR", ")" ]
Returns value that the node is merged.
[ "Returns", "value", "that", "the", "node", "is", "merged", "." ]
[ "\"\"\"\n Returns value that the node is merged.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
is_dummy
bool
def is_dummy(self) -> bool: """ Returns value that the node is dummy. """ return self.data.get(SearchGraph.IS_DUMMY_NODE_ATTR)
Returns value that the node is dummy.
Returns value that the node is dummy.
[ "Returns", "value", "that", "the", "node", "is", "dummy", "." ]
def is_dummy(self) -> bool: return self.data.get(SearchGraph.IS_DUMMY_NODE_ATTR)
[ "def", "is_dummy", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "data", ".", "get", "(", "SearchGraph", ".", "IS_DUMMY_NODE_ATTR", ")" ]
Returns value that the node is dummy.
[ "Returns", "value", "that", "the", "node", "is", "dummy", "." ]
[ "\"\"\"\n Returns value that the node is dummy.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
layer_name
str
def layer_name(self) -> str: """ Returns the name of the layer to which the node corresponds. """ return self.data.get(NNCFGraph.LAYER_NAME_ATTR)
Returns the name of the layer to which the node corresponds.
Returns the name of the layer to which the node corresponds.
[ "Returns", "the", "name", "of", "the", "layer", "to", "which", "the", "node", "corresponds", "." ]
def layer_name(self) -> str: return self.data.get(NNCFGraph.LAYER_NAME_ATTR)
[ "def", "layer_name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "data", ".", "get", "(", "NNCFGraph", ".", "LAYER_NAME_ATTR", ")" ]
Returns the name of the layer to which the node corresponds.
[ "Returns", "the", "name", "of", "the", "layer", "to", "which", "the", "node", "corresponds", "." ]
[ "\"\"\"\n Returns the name of the layer to which the node corresponds.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
main_id
int
def main_id(self) -> int: """ Returns the id of node. In case if the node is merged returns id of the first node from merged node list. """ if not self.is_merged: return self.data.get('id') return self.data.get(SearchGraph.MERGED_NODES_NODE_ATTR)[0].get('id')
Returns the id of node. In case if the node is merged returns id of the first node from merged node list.
Returns the id of node. In case if the node is merged returns id of the first node from merged node list.
[ "Returns", "the", "id", "of", "node", ".", "In", "case", "if", "the", "node", "is", "merged", "returns", "id", "of", "the", "first", "node", "from", "merged", "node", "list", "." ]
def main_id(self) -> int: if not self.is_merged: return self.data.get('id') return self.data.get(SearchGraph.MERGED_NODES_NODE_ATTR)[0].get('id')
[ "def", "main_id", "(", "self", ")", "->", "int", ":", "if", "not", "self", ".", "is_merged", ":", "return", "self", ".", "data", ".", "get", "(", "'id'", ")", "return", "self", ".", "data", ".", "get", "(", "SearchGraph", ".", "MERGED_NODES_NODE_ATTR",...
Returns the id of node.
[ "Returns", "the", "id", "of", "node", "." ]
[ "\"\"\"\n Returns the id of node. In case if the node is merged returns id of the first node from merged node list.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
bottom_id
int
def bottom_id(self) -> int: """ Returns the id of node. In case if the node is merged returns id of the last node from merged node list. """ if not self.is_merged: return self.data.get('id') return self.data.get(SearchGraph.MERGED_NODES_NODE_ATTR)[-1].get('id')
Returns the id of node. In case if the node is merged returns id of the last node from merged node list.
Returns the id of node. In case if the node is merged returns id of the last node from merged node list.
[ "Returns", "the", "id", "of", "node", ".", "In", "case", "if", "the", "node", "is", "merged", "returns", "id", "of", "the", "last", "node", "from", "merged", "node", "list", "." ]
def bottom_id(self) -> int: if not self.is_merged: return self.data.get('id') return self.data.get(SearchGraph.MERGED_NODES_NODE_ATTR)[-1].get('id')
[ "def", "bottom_id", "(", "self", ")", "->", "int", ":", "if", "not", "self", ".", "is_merged", ":", "return", "self", ".", "data", ".", "get", "(", "'id'", ")", "return", "self", ".", "data", ".", "get", "(", "SearchGraph", ".", "MERGED_NODES_NODE_ATTR...
Returns the id of node.
[ "Returns", "the", "id", "of", "node", "." ]
[ "\"\"\"\n Returns the id of node. In case if the node is merged returns id of the last node from merged node list.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
from_state
'BuildingBlock'
def from_state(cls, state: Dict[str, Any]) -> 'BuildingBlock': """ Creates the object from its state. :param state: Output of `get_state()` method. """ return BuildingBlock(**state)
Creates the object from its state. :param state: Output of `get_state()` method.
Creates the object from its state.
[ "Creates", "the", "object", "from", "its", "state", "." ]
def from_state(cls, state: Dict[str, Any]) -> 'BuildingBlock': return BuildingBlock(**state)
[ "def", "from_state", "(", "cls", ",", "state", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "'BuildingBlock'", ":", "return", "BuildingBlock", "(", "**", "state", ")" ]
Creates the object from its state.
[ "Creates", "the", "object", "from", "its", "state", "." ]
[ "\"\"\"\n Creates the object from its state.\n\n :param state: Output of `get_state()` method.\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "state", "type": "Dict[str, Any]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "Dict[str, Any]", "docstring": "Output of `get_state...
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
add_node_to_aux_struct
null
def add_node_to_aux_struct(node: SearchGraphNode, shape: List[int], shape_map: ShapeVsNodesMap): """ Add to shape_map key of node for corresponds shape. """ str_shape = str(shape) if str_shape in shape_map: shape_map[str_shape].add(node) else: shape_map[str_shape] = {node}
Add to shape_map key of node for corresponds shape.
Add to shape_map key of node for corresponds shape.
[ "Add", "to", "shape_map", "key", "of", "node", "for", "corresponds", "shape", "." ]
def add_node_to_aux_struct(node: SearchGraphNode, shape: List[int], shape_map: ShapeVsNodesMap): str_shape = str(shape) if str_shape in shape_map: shape_map[str_shape].add(node) else: shape_map[str_shape] = {node}
[ "def", "add_node_to_aux_struct", "(", "node", ":", "SearchGraphNode", ",", "shape", ":", "List", "[", "int", "]", ",", "shape_map", ":", "ShapeVsNodesMap", ")", ":", "str_shape", "=", "str", "(", "shape", ")", "if", "str_shape", "in", "shape_map", ":", "sh...
Add to shape_map key of node for corresponds shape.
[ "Add", "to", "shape_map", "key", "of", "node", "for", "corresponds", "shape", "." ]
[ "\"\"\"\n Add to shape_map key of node for corresponds shape.\n \"\"\"" ]
[ { "param": "node", "type": "SearchGraphNode" }, { "param": "shape", "type": "List[int]" }, { "param": "shape_map", "type": "ShapeVsNodesMap" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "node", "type": "SearchGraphNode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "shape", "type": "List[int]", "docstring": null, ...
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
check_graph_has_no_hanging_edges_after_block_removal
bool
def check_graph_has_no_hanging_edges_after_block_removal(graph: SearchGraph, start_node: SearchGraphNode, end_node: SearchGraphNode) -> bool: """ The subgraph is traversed starting with the start_no...
The subgraph is traversed starting with the start_node and ending with the end_node to determine that after deleting such a block there are no dangling edges in the graph.
The subgraph is traversed starting with the start_node and ending with the end_node to determine that after deleting such a block there are no dangling edges in the graph.
[ "The", "subgraph", "is", "traversed", "starting", "with", "the", "start_node", "and", "ending", "with", "the", "end_node", "to", "determine", "that", "after", "deleting", "such", "a", "block", "there", "are", "no", "dangling", "edges", "in", "the", "graph", ...
def check_graph_has_no_hanging_edges_after_block_removal(graph: SearchGraph, start_node: SearchGraphNode, end_node: SearchGraphNode) -> bool: q = deque([start_node]) addit_nodes = set() nodes = ...
[ "def", "check_graph_has_no_hanging_edges_after_block_removal", "(", "graph", ":", "SearchGraph", ",", "start_node", ":", "SearchGraphNode", ",", "end_node", ":", "SearchGraphNode", ")", "->", "bool", ":", "q", "=", "deque", "(", "[", "start_node", "]", ")", "addit...
The subgraph is traversed starting with the start_node and ending with the end_node to determine that after deleting such a block there are no dangling edges in the graph.
[ "The", "subgraph", "is", "traversed", "starting", "with", "the", "start_node", "and", "ending", "with", "the", "end_node", "to", "determine", "that", "after", "deleting", "such", "a", "block", "there", "are", "no", "dangling", "edges", "in", "the", "graph", ...
[ "\"\"\"\n The subgraph is traversed starting with the start_node and ending with the end_node\n to determine that after deleting such a block there are no dangling edges in the graph.\n \"\"\"", "# A", "# / \\", "# / \\", "# / \\", "# start_node | ...
[ { "param": "graph", "type": "SearchGraph" }, { "param": "start_node", "type": "SearchGraphNode" }, { "param": "end_node", "type": "SearchGraphNode" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "graph", "type": "SearchGraph", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start_node", "type": "SearchGraphNode", "docstring": null...
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
check_graph_has_no_duplicate_edges_after_block_removal
bool
def check_graph_has_no_duplicate_edges_after_block_removal(sgraph: SearchGraph, start_node: SearchGraphNode, end_node: SearchGraphNode) -> bool: """ This rule ensures that no duplicate edges wil...
This rule ensures that no duplicate edges will be created in the graph after a block is deleted.
This rule ensures that no duplicate edges will be created in the graph after a block is deleted.
[ "This", "rule", "ensures", "that", "no", "duplicate", "edges", "will", "be", "created", "in", "the", "graph", "after", "a", "block", "is", "deleted", "." ]
def check_graph_has_no_duplicate_edges_after_block_removal(sgraph: SearchGraph, start_node: SearchGraphNode, end_node: SearchGraphNode) -> bool: if start_node.is_dummy: next_end_node = sgrap...
[ "def", "check_graph_has_no_duplicate_edges_after_block_removal", "(", "sgraph", ":", "SearchGraph", ",", "start_node", ":", "SearchGraphNode", ",", "end_node", ":", "SearchGraphNode", ")", "->", "bool", ":", "if", "start_node", ".", "is_dummy", ":", "next_end_node", "...
This rule ensures that no duplicate edges will be created in the graph after a block is deleted.
[ "This", "rule", "ensures", "that", "no", "duplicate", "edges", "will", "be", "created", "in", "the", "graph", "after", "a", "block", "is", "deleted", "." ]
[ "\"\"\"\n This rule ensures that no duplicate edges will be created in the graph after a block is deleted.\n \"\"\"", "# A A", "# / \\ / \\", "# / \\ / \\", "# block | => \\ /", "# \\ / \\ /", "# \\ / ...
[ { "param": "sgraph", "type": "SearchGraph" }, { "param": "start_node", "type": "SearchGraphNode" }, { "param": "end_node", "type": "SearchGraphNode" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sgraph", "type": "SearchGraph", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start_node", "type": "SearchGraphNode", "docstring": nul...
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
check_graph_has_no_act_layer_duplication_after_block_removal
bool
def check_graph_has_no_act_layer_duplication_after_block_removal(sgraph: SearchGraph, start_node: SearchGraphNode, end_node: SearchGraphNode) -> bool: """ This rule ensures that afte...
This rule ensures that after the block is deleted there will be no duplication of activation layers.
This rule ensures that after the block is deleted there will be no duplication of activation layers.
[ "This", "rule", "ensures", "that", "after", "the", "block", "is", "deleted", "there", "will", "be", "no", "duplication", "of", "activation", "layers", "." ]
def check_graph_has_no_act_layer_duplication_after_block_removal(sgraph: SearchGraph, start_node: SearchGraphNode, end_node: SearchGraphNode) -> bool: pred_start_node = sgraph.get_prev_n...
[ "def", "check_graph_has_no_act_layer_duplication_after_block_removal", "(", "sgraph", ":", "SearchGraph", ",", "start_node", ":", "SearchGraphNode", ",", "end_node", ":", "SearchGraphNode", ")", "->", "bool", ":", "pred_start_node", "=", "sgraph", ".", "get_prev_nodes", ...
This rule ensures that after the block is deleted there will be no duplication of activation layers.
[ "This", "rule", "ensures", "that", "after", "the", "block", "is", "deleted", "there", "will", "be", "no", "duplication", "of", "activation", "layers", "." ]
[ "\"\"\"\n This rule ensures that after the block is deleted there will be no duplication of activation layers.\n \"\"\"", "# A A", "# | |", "# relu relu", "# | => |", "# block relu", "# |", "# ...
[ { "param": "sgraph", "type": "SearchGraph" }, { "param": "start_node", "type": "SearchGraphNode" }, { "param": "end_node", "type": "SearchGraphNode" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sgraph", "type": "SearchGraph", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start_node", "type": "SearchGraphNode", "docstring": nul...
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
compare_for_building_block
<not_specific>
def compare_for_building_block(a: PotentialBuildingBlock, b: PotentialBuildingBlock): """ Orders the blocks in ascending order of the end node index. If the indices of the end nodes are the same, the blocks are ordered by the index of the start node. """ if a.end_node.bottom_id != b.end_node.bot...
Orders the blocks in ascending order of the end node index. If the indices of the end nodes are the same, the blocks are ordered by the index of the start node.
Orders the blocks in ascending order of the end node index. If the indices of the end nodes are the same, the blocks are ordered by the index of the start node.
[ "Orders", "the", "blocks", "in", "ascending", "order", "of", "the", "end", "node", "index", ".", "If", "the", "indices", "of", "the", "end", "nodes", "are", "the", "same", "the", "blocks", "are", "ordered", "by", "the", "index", "of", "the", "start", "...
def compare_for_building_block(a: PotentialBuildingBlock, b: PotentialBuildingBlock): if a.end_node.bottom_id != b.end_node.bottom_id: return a.end_node.bottom_id - b.end_node.bottom_id return b.start_node.main_id - a.start_node.main_id
[ "def", "compare_for_building_block", "(", "a", ":", "PotentialBuildingBlock", ",", "b", ":", "PotentialBuildingBlock", ")", ":", "if", "a", ".", "end_node", ".", "bottom_id", "!=", "b", ".", "end_node", ".", "bottom_id", ":", "return", "a", ".", "end_node", ...
Orders the blocks in ascending order of the end node index.
[ "Orders", "the", "blocks", "in", "ascending", "order", "of", "the", "end", "node", "index", "." ]
[ "\"\"\"\n Orders the blocks in ascending order of the end node index.\n If the indices of the end nodes are the same, the blocks are ordered by the\n index of the start node.\n \"\"\"" ]
[ { "param": "a", "type": "PotentialBuildingBlock" }, { "param": "b", "type": "PotentialBuildingBlock" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "PotentialBuildingBlock", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b", "type": "PotentialBuildingBlock", "docstring":...
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
check_blocks_combination_is_block
bool
def check_blocks_combination_is_block(block: PotentialBuildingBlock, combination: Tuple[PotentialBuildingBlock]) -> bool: """ Checks that a combination of blocks is a given block. """ if block.start_node.main_id != combination[0].start_node.main_id: return F...
Checks that a combination of blocks is a given block.
Checks that a combination of blocks is a given block.
[ "Checks", "that", "a", "combination", "of", "blocks", "is", "a", "given", "block", "." ]
def check_blocks_combination_is_block(block: PotentialBuildingBlock, combination: Tuple[PotentialBuildingBlock]) -> bool: if block.start_node.main_id != combination[0].start_node.main_id: return False if block.end_node.bottom_id != combination[-1].end_node.bottom_id...
[ "def", "check_blocks_combination_is_block", "(", "block", ":", "PotentialBuildingBlock", ",", "combination", ":", "Tuple", "[", "PotentialBuildingBlock", "]", ")", "->", "bool", ":", "if", "block", ".", "start_node", ".", "main_id", "!=", "combination", "[", "0", ...
Checks that a combination of blocks is a given block.
[ "Checks", "that", "a", "combination", "of", "blocks", "is", "a", "given", "block", "." ]
[ "\"\"\"\n Checks that a combination of blocks is a given block.\n \"\"\"" ]
[ { "param": "block", "type": "PotentialBuildingBlock" }, { "param": "combination", "type": "Tuple[PotentialBuildingBlock]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "PotentialBuildingBlock", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "combination", "type": "Tuple[PotentialBuildingBlock]...
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
search_lin_combination
bool
def search_lin_combination(block: PotentialBuildingBlock, blocks: List[PotentialBuildingBlock]) -> bool: """ Checks that a given block is linear combination of some blocks. A linear combination of blocks is a sequence of blocks following each other in the graph and connected by one edge. """ max...
Checks that a given block is linear combination of some blocks. A linear combination of blocks is a sequence of blocks following each other in the graph and connected by one edge.
Checks that a given block is linear combination of some blocks. A linear combination of blocks is a sequence of blocks following each other in the graph and connected by one edge.
[ "Checks", "that", "a", "given", "block", "is", "linear", "combination", "of", "some", "blocks", ".", "A", "linear", "combination", "of", "blocks", "is", "a", "sequence", "of", "blocks", "following", "each", "other", "in", "the", "graph", "and", "connected", ...
def search_lin_combination(block: PotentialBuildingBlock, blocks: List[PotentialBuildingBlock]) -> bool: max_num = len(blocks) for i in range(max_num, 1, -1): all_combinations = list(combinations(blocks, i)) for combo in all_combinations: if check_blocks_combination_is_block(block, c...
[ "def", "search_lin_combination", "(", "block", ":", "PotentialBuildingBlock", ",", "blocks", ":", "List", "[", "PotentialBuildingBlock", "]", ")", "->", "bool", ":", "max_num", "=", "len", "(", "blocks", ")", "for", "i", "in", "range", "(", "max_num", ",", ...
Checks that a given block is linear combination of some blocks.
[ "Checks", "that", "a", "given", "block", "is", "linear", "combination", "of", "some", "blocks", "." ]
[ "\"\"\"\n Checks that a given block is linear combination of some blocks.\n A linear combination of blocks is a sequence of blocks following each other in the graph\n and connected by one edge.\n \"\"\"" ]
[ { "param": "block", "type": "PotentialBuildingBlock" }, { "param": "blocks", "type": "List[PotentialBuildingBlock]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "PotentialBuildingBlock", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "blocks", "type": "List[PotentialBuildingBlock]", ...
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
remove_linear_combination
List[PotentialBuildingBlock]
def remove_linear_combination(sorted_building_blocks: List[PotentialBuildingBlock]) -> List[PotentialBuildingBlock]: """ Search and remove of block which is a combination of other blocks following each other. """ result_blocks = [] start_to_idx = {} last_node = None for block in sorted_build...
Search and remove of block which is a combination of other blocks following each other.
Search and remove of block which is a combination of other blocks following each other.
[ "Search", "and", "remove", "of", "block", "which", "is", "a", "combination", "of", "other", "blocks", "following", "each", "other", "." ]
def remove_linear_combination(sorted_building_blocks: List[PotentialBuildingBlock]) -> List[PotentialBuildingBlock]: result_blocks = [] start_to_idx = {} last_node = None for block in sorted_building_blocks: if last_node == block.end_node: if block.start_node.main_id in start_to_idx:...
[ "def", "remove_linear_combination", "(", "sorted_building_blocks", ":", "List", "[", "PotentialBuildingBlock", "]", ")", "->", "List", "[", "PotentialBuildingBlock", "]", ":", "result_blocks", "=", "[", "]", "start_to_idx", "=", "{", "}", "last_node", "=", "None",...
Search and remove of block which is a combination of other blocks following each other.
[ "Search", "and", "remove", "of", "block", "which", "is", "a", "combination", "of", "other", "blocks", "following", "each", "other", "." ]
[ "\"\"\"\n Search and remove of block which is a combination of other blocks following each other.\n \"\"\"" ]
[ { "param": "sorted_building_blocks", "type": "List[PotentialBuildingBlock]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sorted_building_blocks", "type": "List[PotentialBuildingBlock]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
restore_node_name_in_orig_graph
Tuple[BuildingBlocks, OrdinalIDs]
def restore_node_name_in_orig_graph(building_blocks: List[PotentialBuildingBlock], orig_graph: PTNNCFGraph) -> Tuple[BuildingBlocks, OrdinalIDs]: """ Restore the original names and ids of the start and end of the block in original graph. """ building_block_in_orig_for...
Restore the original names and ids of the start and end of the block in original graph.
Restore the original names and ids of the start and end of the block in original graph.
[ "Restore", "the", "original", "names", "and", "ids", "of", "the", "start", "and", "end", "of", "the", "block", "in", "original", "graph", "." ]
def restore_node_name_in_orig_graph(building_blocks: List[PotentialBuildingBlock], orig_graph: PTNNCFGraph) -> Tuple[BuildingBlocks, OrdinalIDs]: building_block_in_orig_format = [] ordinal_ids = [] for block in building_blocks: id_st = block.start_node.bottom_id ...
[ "def", "restore_node_name_in_orig_graph", "(", "building_blocks", ":", "List", "[", "PotentialBuildingBlock", "]", ",", "orig_graph", ":", "PTNNCFGraph", ")", "->", "Tuple", "[", "BuildingBlocks", ",", "OrdinalIDs", "]", ":", "building_block_in_orig_format", "=", "[",...
Restore the original names and ids of the start and end of the block in original graph.
[ "Restore", "the", "original", "names", "and", "ids", "of", "the", "start", "and", "end", "of", "the", "block", "in", "original", "graph", "." ]
[ "\"\"\"\n Restore the original names and ids of the start and end of the block in original graph.\n \"\"\"", "# dummy node" ]
[ { "param": "building_blocks", "type": "List[PotentialBuildingBlock]" }, { "param": "orig_graph", "type": "PTNNCFGraph" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "building_blocks", "type": "List[PotentialBuildingBlock]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "orig_graph", "type": "PTNNCFGraph", ...
dae36acd3d3087c7a53c57072cc9c56a37e01078
vuiseng9/nncf_pytorch
nncf/experimental/torch/search_building_blocks/search_blocks.py
[ "Apache-2.0" ]
Python
remove_nested_blocks
List[PotentialBuildingBlock]
def remove_nested_blocks(sorted_blocks: List[PotentialBuildingBlock]) -> List[PotentialBuildingBlock]: """ Remove nested building blocks. :param: List of building blocks. :return: List of building blocks without nested blocks. """ return [list(group_block)[-1] for _, group_block in groupby(sort...
Remove nested building blocks. :param: List of building blocks. :return: List of building blocks without nested blocks.
Remove nested building blocks. :param: List of building blocks. :return: List of building blocks without nested blocks.
[ "Remove", "nested", "building", "blocks", ".", ":", "param", ":", "List", "of", "building", "blocks", ".", ":", "return", ":", "List", "of", "building", "blocks", "without", "nested", "blocks", "." ]
def remove_nested_blocks(sorted_blocks: List[PotentialBuildingBlock]) -> List[PotentialBuildingBlock]: return [list(group_block)[-1] for _, group_block in groupby(sorted_blocks, lambda block: block.start_node.main_id)]
[ "def", "remove_nested_blocks", "(", "sorted_blocks", ":", "List", "[", "PotentialBuildingBlock", "]", ")", "->", "List", "[", "PotentialBuildingBlock", "]", ":", "return", "[", "list", "(", "group_block", ")", "[", "-", "1", "]", "for", "_", ",", "group_bloc...
Remove nested building blocks.
[ "Remove", "nested", "building", "blocks", "." ]
[ "\"\"\"\n Remove nested building blocks.\n\n :param: List of building blocks.\n :return: List of building blocks without nested blocks.\n \"\"\"" ]
[ { "param": "sorted_blocks", "type": "List[PotentialBuildingBlock]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sorted_blocks", "type": "List[PotentialBuildingBlock]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c6607121f43dfda9aba0bd19f421f2efe0ddef0d
vuiseng9/nncf_pytorch
nncf/tensorflow/helpers/model_manager.py
[ "Apache-2.0" ]
Python
_create_model_manager
<not_specific>
def _create_model_manager(model_fn, nncf_config, *args, **kwargs): """ Creates model manager depending on the algorithm name. :param model_fn: Function for model creation. :param nncf_config: NNCF config. :return: Model manager. """ if is_experimental_quantizatio...
Creates model manager depending on the algorithm name. :param model_fn: Function for model creation. :param nncf_config: NNCF config. :return: Model manager.
Creates model manager depending on the algorithm name.
[ "Creates", "model", "manager", "depending", "on", "the", "algorithm", "name", "." ]
def _create_model_manager(model_fn, nncf_config, *args, **kwargs): if is_experimental_quantization(nncf_config): return TFWithoutModelManager(model_fn, *args, **kwargs) return TFOriginalModelManager(model_fn, *args, **kwargs)
[ "def", "_create_model_manager", "(", "model_fn", ",", "nncf_config", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "is_experimental_quantization", "(", "nncf_config", ")", ":", "return", "TFWithoutModelManager", "(", "model_fn", ",", "*", "args", ",", ...
Creates model manager depending on the algorithm name.
[ "Creates", "model", "manager", "depending", "on", "the", "algorithm", "name", "." ]
[ "\"\"\"\n Creates model manager depending on the algorithm name.\n\n :param model_fn: Function for model creation.\n :param nncf_config: NNCF config.\n :return: Model manager.\n \"\"\"" ]
[ { "param": "model_fn", "type": null }, { "param": "nncf_config", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "model_fn", "type": null, "docstring": "Function for model creation.", "docstring_tokens": [ "Function", ...
2d4522398b76dceb95f27462ede21372a121d74b
vuiseng9/nncf_pytorch
nncf/experimental/torch/nas/bootstrapNAS/elasticity/base_handler.py
[ "Apache-2.0" ]
Python
activate_supernet
None
def activate_supernet(self) -> None: """ Activates the Supernet - the original network to which elasticity was applied. The Supernet is usually a maximum Subnet. But it might be not the case if maximum value of elastic properties is limited for efficiency of search. For instance, a super...
Activates the Supernet - the original network to which elasticity was applied. The Supernet is usually a maximum Subnet. But it might be not the case if maximum value of elastic properties is limited for efficiency of search. For instance, a supernet may contain 32 convolutional channels, ...
Activates the Supernet - the original network to which elasticity was applied. The Supernet is usually a maximum Subnet. But it might be not the case if maximum value of elastic properties is limited for efficiency of search. For instance, a supernet may contain 32 convolutional channels, but maximum subnet can be rest...
[ "Activates", "the", "Supernet", "-", "the", "original", "network", "to", "which", "elasticity", "was", "applied", ".", "The", "Supernet", "is", "usually", "a", "maximum", "Subnet", ".", "But", "it", "might", "be", "not", "the", "case", "if", "maximum", "va...
def activate_supernet(self) -> None:
[ "def", "activate_supernet", "(", "self", ")", "->", "None", ":" ]
Activates the Supernet - the original network to which elasticity was applied.
[ "Activates", "the", "Supernet", "-", "the", "original", "network", "to", "which", "elasticity", "was", "applied", "." ]
[ "\"\"\"\n Activates the Supernet - the original network to which elasticity was applied.\n The Supernet is usually a maximum Subnet. But it might be not the case if maximum value of elastic properties\n is limited for efficiency of search. For instance, a supernet may contain 32 convolutional c...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2d4522398b76dceb95f27462ede21372a121d74b
vuiseng9/nncf_pytorch
nncf/experimental/torch/nas/bootstrapNAS/elasticity/base_handler.py
[ "Apache-2.0" ]
Python
activate_subnet_for_config
None
def activate_subnet_for_config(self, config: ElasticityConfig) -> None: """ Activates a Subnet that corresponds to the given elasticity configuration :param config: elasticity configuration """
Activates a Subnet that corresponds to the given elasticity configuration :param config: elasticity configuration
Activates a Subnet that corresponds to the given elasticity configuration
[ "Activates", "a", "Subnet", "that", "corresponds", "to", "the", "given", "elasticity", "configuration" ]
def activate_subnet_for_config(self, config: ElasticityConfig) -> None:
[ "def", "activate_subnet_for_config", "(", "self", ",", "config", ":", "ElasticityConfig", ")", "->", "None", ":" ]
Activates a Subnet that corresponds to the given elasticity configuration
[ "Activates", "a", "Subnet", "that", "corresponds", "to", "the", "given", "elasticity", "configuration" ]
[ "\"\"\"\n Activates a Subnet that corresponds to the given elasticity configuration\n\n :param config: elasticity configuration\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "config", "type": "ElasticityConfig" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config", "type": "ElasticityConfig", "docstring": null, "docs...
2d4522398b76dceb95f27462ede21372a121d74b
vuiseng9/nncf_pytorch
nncf/experimental/torch/nas/bootstrapNAS/elasticity/base_handler.py
[ "Apache-2.0" ]
Python
activate_random_subnet
None
def activate_random_subnet(self) -> None: """ Activates a Subnet with random values of elastic properties. """ config = self.get_random_config() self.activate_subnet_for_config(config)
Activates a Subnet with random values of elastic properties.
Activates a Subnet with random values of elastic properties.
[ "Activates", "a", "Subnet", "with", "random", "values", "of", "elastic", "properties", "." ]
def activate_random_subnet(self) -> None: config = self.get_random_config() self.activate_subnet_for_config(config)
[ "def", "activate_random_subnet", "(", "self", ")", "->", "None", ":", "config", "=", "self", ".", "get_random_config", "(", ")", "self", ".", "activate_subnet_for_config", "(", "config", ")" ]
Activates a Subnet with random values of elastic properties.
[ "Activates", "a", "Subnet", "with", "random", "values", "of", "elastic", "properties", "." ]
[ "\"\"\"\n Activates a Subnet with random values of elastic properties.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2d4522398b76dceb95f27462ede21372a121d74b
vuiseng9/nncf_pytorch
nncf/experimental/torch/nas/bootstrapNAS/elasticity/base_handler.py
[ "Apache-2.0" ]
Python
activate_minimum_subnet
None
def activate_minimum_subnet(self) -> None: """ Activates a minimum Subnet that corresponds to the minimum values of elastic properties. """ config = self.get_minimum_config() self.activate_subnet_for_config(config)
Activates a minimum Subnet that corresponds to the minimum values of elastic properties.
Activates a minimum Subnet that corresponds to the minimum values of elastic properties.
[ "Activates", "a", "minimum", "Subnet", "that", "corresponds", "to", "the", "minimum", "values", "of", "elastic", "properties", "." ]
def activate_minimum_subnet(self) -> None: config = self.get_minimum_config() self.activate_subnet_for_config(config)
[ "def", "activate_minimum_subnet", "(", "self", ")", "->", "None", ":", "config", "=", "self", ".", "get_minimum_config", "(", ")", "self", ".", "activate_subnet_for_config", "(", "config", ")" ]
Activates a minimum Subnet that corresponds to the minimum values of elastic properties.
[ "Activates", "a", "minimum", "Subnet", "that", "corresponds", "to", "the", "minimum", "values", "of", "elastic", "properties", "." ]
[ "\"\"\"\n Activates a minimum Subnet that corresponds to the minimum values of elastic properties.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2d4522398b76dceb95f27462ede21372a121d74b
vuiseng9/nncf_pytorch
nncf/experimental/torch/nas/bootstrapNAS/elasticity/base_handler.py
[ "Apache-2.0" ]
Python
activate_maximum_subnet
None
def activate_maximum_subnet(self) -> None: """ Activates a maximum Subnet that corresponds to the maximum values of elastic properties. """ config = self.get_maximum_config() self.activate_subnet_for_config(config)
Activates a maximum Subnet that corresponds to the maximum values of elastic properties.
Activates a maximum Subnet that corresponds to the maximum values of elastic properties.
[ "Activates", "a", "maximum", "Subnet", "that", "corresponds", "to", "the", "maximum", "values", "of", "elastic", "properties", "." ]
def activate_maximum_subnet(self) -> None: config = self.get_maximum_config() self.activate_subnet_for_config(config)
[ "def", "activate_maximum_subnet", "(", "self", ")", "->", "None", ":", "config", "=", "self", ".", "get_maximum_config", "(", ")", "self", ".", "activate_subnet_for_config", "(", "config", ")" ]
Activates a maximum Subnet that corresponds to the maximum values of elastic properties.
[ "Activates", "a", "maximum", "Subnet", "that", "corresponds", "to", "the", "maximum", "values", "of", "elastic", "properties", "." ]
[ "\"\"\"\n Activates a maximum Subnet that corresponds to the maximum values of elastic properties.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2d4522398b76dceb95f27462ede21372a121d74b
vuiseng9/nncf_pytorch
nncf/experimental/torch/nas/bootstrapNAS/elasticity/base_handler.py
[ "Apache-2.0" ]
Python
resolve_conflicts_with_other_elasticities
ElasticityConfig
def resolve_conflicts_with_other_elasticities(self, config: ElasticityConfig, elasticity_handlers: ELASTICITY_HANDLERS_MAP) -> ElasticityConfig: """ Resolves a conflict between the given elasticity config...
Resolves a conflict between the given elasticity config and active elasticity configs of the given handlers. For example, elastic width configuration may contradict to elastic depth one. When we activate some configuration in the Elastic Width Handler, i.e. define number of output channels for ...
Resolves a conflict between the given elasticity config and active elasticity configs of the given handlers. For example, elastic width configuration may contradict to elastic depth one. When we activate some configuration in the Elastic Width Handler, i.e. define number of output channels for some layers, we change ou...
[ "Resolves", "a", "conflict", "between", "the", "given", "elasticity", "config", "and", "active", "elasticity", "configs", "of", "the", "given", "handlers", ".", "For", "example", "elastic", "width", "configuration", "may", "contradict", "to", "elastic", "depth", ...
def resolve_conflicts_with_other_elasticities(self, config: ElasticityConfig, elasticity_handlers: ELASTICITY_HANDLERS_MAP) -> ElasticityConfig:
[ "def", "resolve_conflicts_with_other_elasticities", "(", "self", ",", "config", ":", "ElasticityConfig", ",", "elasticity_handlers", ":", "ELASTICITY_HANDLERS_MAP", ")", "->", "ElasticityConfig", ":" ]
Resolves a conflict between the given elasticity config and active elasticity configs of the given handlers.
[ "Resolves", "a", "conflict", "between", "the", "given", "elasticity", "config", "and", "active", "elasticity", "configs", "of", "the", "given", "handlers", "." ]
[ "\"\"\"\n Resolves a conflict between the given elasticity config and active elasticity configs of the given handlers.\n For example, elastic width configuration may contradict to elastic depth one. When we activate some\n configuration in the Elastic Width Handler, i.e. define number of output...
[ { "param": "self", "type": null }, { "param": "config", "type": "ElasticityConfig" }, { "param": "elasticity_handlers", "type": "ELASTICITY_HANDLERS_MAP" } ]
{ "returns": [ { "docstring": "elasticity configuration without conflicts with other active configs of other elasticity handlers", "docstring_tokens": [ "elasticity", "configuration", "without", "conflicts", "with", "other", "active", "co...
2d4522398b76dceb95f27462ede21372a121d74b
vuiseng9/nncf_pytorch
nncf/experimental/torch/nas/bootstrapNAS/elasticity/base_handler.py
[ "Apache-2.0" ]
Python
load_state
None
def load_state(self, state: Dict[str, Any]) -> None: """ Initializes object from the state. :param state: Output of `get_state()` method. """ active_config = state[self._state_names.ACTIVE_CONFIG] self.activate_subnet_for_config(active_config)
Initializes object from the state. :param state: Output of `get_state()` method.
Initializes object from the state.
[ "Initializes", "object", "from", "the", "state", "." ]
def load_state(self, state: Dict[str, Any]) -> None: active_config = state[self._state_names.ACTIVE_CONFIG] self.activate_subnet_for_config(active_config)
[ "def", "load_state", "(", "self", ",", "state", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "active_config", "=", "state", "[", "self", ".", "_state_names", ".", "ACTIVE_CONFIG", "]", "self", ".", "activate_subnet_for_config", "(", ...
Initializes object from the state.
[ "Initializes", "object", "from", "the", "state", "." ]
[ "\"\"\"\n Initializes object from the state.\n\n :param state: Output of `get_state()` method.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "state", "type": "Dict[str, Any]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "Dict[str, Any]", "docstring": "Output of `get_stat...
2d4522398b76dceb95f27462ede21372a121d74b
vuiseng9/nncf_pytorch
nncf/experimental/torch/nas/bootstrapNAS/elasticity/base_handler.py
[ "Apache-2.0" ]
Python
from_state
'BaseElasticityParams'
def from_state(cls, state: Dict[str, Any]) -> 'BaseElasticityParams': """ Creates the object from its state. :param state: Output of `get_state()` method. """
Creates the object from its state. :param state: Output of `get_state()` method.
Creates the object from its state.
[ "Creates", "the", "object", "from", "its", "state", "." ]
def from_state(cls, state: Dict[str, Any]) -> 'BaseElasticityParams':
[ "def", "from_state", "(", "cls", ",", "state", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "'BaseElasticityParams'", ":" ]
Creates the object from its state.
[ "Creates", "the", "object", "from", "its", "state", "." ]
[ "\"\"\"\n Creates the object from its state.\n\n :param state: Output of `get_state()` method.\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "state", "type": "Dict[str, Any]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "Dict[str, Any]", "docstring": "Output of `get_state...
2d4522398b76dceb95f27462ede21372a121d74b
vuiseng9/nncf_pytorch
nncf/experimental/torch/nas/bootstrapNAS/elasticity/base_handler.py
[ "Apache-2.0" ]
Python
build
SingleElasticityHandler
def build(self, target_model: NNCFNetwork) -> SingleElasticityHandler: """ Creates modifications to the given NNCFNetwork for introducing elasticity and creates a handler object that can manipulate this elasticity. :param target_model: a target NNCFNetwork for adding modifications ...
Creates modifications to the given NNCFNetwork for introducing elasticity and creates a handler object that can manipulate this elasticity. :param target_model: a target NNCFNetwork for adding modifications :return: a handler object that can manipulate the elasticity.
Creates modifications to the given NNCFNetwork for introducing elasticity and creates a handler object that can manipulate this elasticity.
[ "Creates", "modifications", "to", "the", "given", "NNCFNetwork", "for", "introducing", "elasticity", "and", "creates", "a", "handler", "object", "that", "can", "manipulate", "this", "elasticity", "." ]
def build(self, target_model: NNCFNetwork) -> SingleElasticityHandler:
[ "def", "build", "(", "self", ",", "target_model", ":", "NNCFNetwork", ")", "->", "SingleElasticityHandler", ":" ]
Creates modifications to the given NNCFNetwork for introducing elasticity and creates a handler object that can manipulate this elasticity.
[ "Creates", "modifications", "to", "the", "given", "NNCFNetwork", "for", "introducing", "elasticity", "and", "creates", "a", "handler", "object", "that", "can", "manipulate", "this", "elasticity", "." ]
[ "\"\"\"\n Creates modifications to the given NNCFNetwork for introducing elasticity and creates a handler object that\n can manipulate this elasticity.\n\n :param target_model: a target NNCFNetwork for adding modifications\n :return: a handler object that can manipulate the elasticity.\n...
[ { "param": "self", "type": null }, { "param": "target_model", "type": "NNCFNetwork" } ]
{ "returns": [ { "docstring": "a handler object that can manipulate the elasticity.", "docstring_tokens": [ "a", "handler", "object", "that", "can", "manipulate", "the", "elasticity", "." ], "type": null } ], "...
d1c52a26cb7ece8ef99c09976cae22ce0d111723
vuiseng9/nncf_pytorch
nncf/common/tensor_statistics/collectors.py
[ "Apache-2.0" ]
Python
reduce_min
NNCFTensor
def reduce_min(x: NNCFTensor, axis: Union[int, tuple, list]) -> NNCFTensor: """ Computes minimum of elements across dimensions of NNCFTensor. :param x: NNCFTensor to reduce :param axis: The dimensions to reduce. :return: Reduced NNCFTensor. """
Computes minimum of elements across dimensions of NNCFTensor. :param x: NNCFTensor to reduce :param axis: The dimensions to reduce. :return: Reduced NNCFTensor.
Computes minimum of elements across dimensions of NNCFTensor.
[ "Computes", "minimum", "of", "elements", "across", "dimensions", "of", "NNCFTensor", "." ]
def reduce_min(x: NNCFTensor, axis: Union[int, tuple, list]) -> NNCFTensor:
[ "def", "reduce_min", "(", "x", ":", "NNCFTensor", ",", "axis", ":", "Union", "[", "int", ",", "tuple", ",", "list", "]", ")", "->", "NNCFTensor", ":" ]
Computes minimum of elements across dimensions of NNCFTensor.
[ "Computes", "minimum", "of", "elements", "across", "dimensions", "of", "NNCFTensor", "." ]
[ "\"\"\"\n Computes minimum of elements across dimensions of NNCFTensor.\n\n :param x: NNCFTensor to reduce\n :param axis: The dimensions to reduce.\n :return: Reduced NNCFTensor.\n \"\"\"" ]
[ { "param": "x", "type": "NNCFTensor" }, { "param": "axis", "type": "Union[int, tuple, list]" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "x", "type": "NNCFTensor", "docstring": "NNCFTensor to reduce", "docstring_tokens": [ "NNCFTensor", ...
d1c52a26cb7ece8ef99c09976cae22ce0d111723
vuiseng9/nncf_pytorch
nncf/common/tensor_statistics/collectors.py
[ "Apache-2.0" ]
Python
reduce_max
NNCFTensor
def reduce_max(x: NNCFTensor, axis: Union[int, tuple, list]) -> NNCFTensor: """ Computes maximum of elements across dimensions of NNCFTensor. :param x: NNCFTensor to reduce :param axis: The dimensions to reduce. :return: Reduced NNCFTensor. """
Computes maximum of elements across dimensions of NNCFTensor. :param x: NNCFTensor to reduce :param axis: The dimensions to reduce. :return: Reduced NNCFTensor.
Computes maximum of elements across dimensions of NNCFTensor.
[ "Computes", "maximum", "of", "elements", "across", "dimensions", "of", "NNCFTensor", "." ]
def reduce_max(x: NNCFTensor, axis: Union[int, tuple, list]) -> NNCFTensor:
[ "def", "reduce_max", "(", "x", ":", "NNCFTensor", ",", "axis", ":", "Union", "[", "int", ",", "tuple", ",", "list", "]", ")", "->", "NNCFTensor", ":" ]
Computes maximum of elements across dimensions of NNCFTensor.
[ "Computes", "maximum", "of", "elements", "across", "dimensions", "of", "NNCFTensor", "." ]
[ "\"\"\"\n Computes maximum of elements across dimensions of NNCFTensor.\n\n :param x: NNCFTensor to reduce\n :param axis: The dimensions to reduce.\n :return: Reduced NNCFTensor.\n \"\"\"" ]
[ { "param": "x", "type": "NNCFTensor" }, { "param": "axis", "type": "Union[int, tuple, list]" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "x", "type": "NNCFTensor", "docstring": "NNCFTensor to reduce", "docstring_tokens": [ "NNCFTensor", ...
d1c52a26cb7ece8ef99c09976cae22ce0d111723
vuiseng9/nncf_pytorch
nncf/common/tensor_statistics/collectors.py
[ "Apache-2.0" ]
Python
abs
NNCFTensor
def abs(x: NNCFTensor) -> NNCFTensor: """ Computes the absolute value of a NNCFTensor. :param x: NNCFTensor :return: Absolute value of a NNCFTensor """
Computes the absolute value of a NNCFTensor. :param x: NNCFTensor :return: Absolute value of a NNCFTensor
Computes the absolute value of a NNCFTensor.
[ "Computes", "the", "absolute", "value", "of", "a", "NNCFTensor", "." ]
def abs(x: NNCFTensor) -> NNCFTensor:
[ "def", "abs", "(", "x", ":", "NNCFTensor", ")", "->", "NNCFTensor", ":" ]
Computes the absolute value of a NNCFTensor.
[ "Computes", "the", "absolute", "value", "of", "a", "NNCFTensor", "." ]
[ "\"\"\"\n Computes the absolute value of a NNCFTensor.\n\n :param x: NNCFTensor\n :return: Absolute value of a NNCFTensor\n \"\"\"" ]
[ { "param": "x", "type": "NNCFTensor" } ]
{ "returns": [ { "docstring": "Absolute value of a NNCFTensor", "docstring_tokens": [ "Absolute", "value", "of", "a", "NNCFTensor" ], "type": null } ], "raises": [], "params": [ { "identifier": "x", "type": "NNCFTensor", ...
d1c52a26cb7ece8ef99c09976cae22ce0d111723
vuiseng9/nncf_pytorch
nncf/common/tensor_statistics/collectors.py
[ "Apache-2.0" ]
Python
min
NNCFTensor
def min(x1: NNCFTensor, x2: NNCFTensor) -> NNCFTensor: """ Returns the min of x1 and x2. :param x1: NNCFTensor to compare. :param x2: NNCFTensor to compare. :return: Compared Tensor. """
Returns the min of x1 and x2. :param x1: NNCFTensor to compare. :param x2: NNCFTensor to compare. :return: Compared Tensor.
Returns the min of x1 and x2.
[ "Returns", "the", "min", "of", "x1", "and", "x2", "." ]
def min(x1: NNCFTensor, x2: NNCFTensor) -> NNCFTensor:
[ "def", "min", "(", "x1", ":", "NNCFTensor", ",", "x2", ":", "NNCFTensor", ")", "->", "NNCFTensor", ":" ]
Returns the min of x1 and x2.
[ "Returns", "the", "min", "of", "x1", "and", "x2", "." ]
[ "\"\"\"\n Returns the min of x1 and x2.\n\n :param x1: NNCFTensor to compare.\n :param x2: NNCFTensor to compare.\n :return: Compared Tensor.\n \"\"\"" ]
[ { "param": "x1", "type": "NNCFTensor" }, { "param": "x2", "type": "NNCFTensor" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "x1", "type": "NNCFTensor", "docstring": "NNCFTensor to compare.", "docstring_tokens": [ "NNCFTensor", ...
d1c52a26cb7ece8ef99c09976cae22ce0d111723
vuiseng9/nncf_pytorch
nncf/common/tensor_statistics/collectors.py
[ "Apache-2.0" ]
Python
max
NNCFTensor
def max(x1: NNCFTensor, x2: NNCFTensor) -> NNCFTensor: """ Returns the max of x1 and x2. :param x1: NNCFTensor to compare. :param x2: NNCFTensor to compare. :return: Compared NNCFTensor. """
Returns the max of x1 and x2. :param x1: NNCFTensor to compare. :param x2: NNCFTensor to compare. :return: Compared NNCFTensor.
Returns the max of x1 and x2.
[ "Returns", "the", "max", "of", "x1", "and", "x2", "." ]
def max(x1: NNCFTensor, x2: NNCFTensor) -> NNCFTensor:
[ "def", "max", "(", "x1", ":", "NNCFTensor", ",", "x2", ":", "NNCFTensor", ")", "->", "NNCFTensor", ":" ]
Returns the max of x1 and x2.
[ "Returns", "the", "max", "of", "x1", "and", "x2", "." ]
[ "\"\"\"\n Returns the max of x1 and x2.\n\n :param x1: NNCFTensor to compare.\n :param x2: NNCFTensor to compare.\n :return: Compared NNCFTensor.\n \"\"\"" ]
[ { "param": "x1", "type": "NNCFTensor" }, { "param": "x2", "type": "NNCFTensor" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "x1", "type": "NNCFTensor", "docstring": "NNCFTensor to compare.", "docstring_tokens": [ "NNCFTensor", ...