Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
_get_linear_ramps | (padded, axis, width_pair, end_value_pair) |
Construct linear ramps for empty-padded array in given dimension.
Parameters
----------
padded : ndarray
Empty-padded array.
axis : int
Dimension in which the ramps are constructed.
width_pair : (int, int)
Pair of widths that mark the pad area on both sides in the given... |
Construct linear ramps for empty-padded array in given dimension. | def _get_linear_ramps(padded, axis, width_pair, end_value_pair):
"""
Construct linear ramps for empty-padded array in given dimension.
Parameters
----------
padded : ndarray
Empty-padded array.
axis : int
Dimension in which the ramps are constructed.
width_pair : (int, int)
... | [
"def",
"_get_linear_ramps",
"(",
"padded",
",",
"axis",
",",
"width_pair",
",",
"end_value_pair",
")",
":",
"edge_pair",
"=",
"_get_edges",
"(",
"padded",
",",
"axis",
",",
"width_pair",
")",
"left_ramp",
"=",
"np",
".",
"linspace",
"(",
"start",
"=",
"end... | [
187,
0
] | [
231,
32
] | python | en | ['en', 'error', 'th'] | False |
_get_stats | (padded, axis, width_pair, length_pair, stat_func) |
Calculate statistic for the empty-padded array in given dimnsion.
Parameters
----------
padded : ndarray
Empty-padded array.
axis : int
Dimension in which the statistic is calculated.
width_pair : (int, int)
Pair of widths that mark the pad area on both sides in the giv... |
Calculate statistic for the empty-padded array in given dimnsion. | def _get_stats(padded, axis, width_pair, length_pair, stat_func):
"""
Calculate statistic for the empty-padded array in given dimnsion.
Parameters
----------
padded : ndarray
Empty-padded array.
axis : int
Dimension in which the statistic is calculated.
width_pair : (int, in... | [
"def",
"_get_stats",
"(",
"padded",
",",
"axis",
",",
"width_pair",
",",
"length_pair",
",",
"stat_func",
")",
":",
"# Calculate indices of the edges of the area with original values",
"left_index",
"=",
"width_pair",
"[",
"0",
"]",
"right_index",
"=",
"padded",
".",
... | [
234,
0
] | [
290,
32
] | python | en | ['en', 'error', 'th'] | False |
_set_reflect_both | (padded, axis, width_pair, method, include_edge=False) |
Pad `axis` of `arr` with reflection.
Parameters
----------
padded : ndarray
Input array of arbitrary shape.
axis : int
Axis along which to pad `arr`.
width_pair : (int, int)
Pair of widths that mark the pad area on both sides in the given
dimension.
method :... |
Pad `axis` of `arr` with reflection. | def _set_reflect_both(padded, axis, width_pair, method, include_edge=False):
"""
Pad `axis` of `arr` with reflection.
Parameters
----------
padded : ndarray
Input array of arbitrary shape.
axis : int
Axis along which to pad `arr`.
width_pair : (int, int)
Pair of widt... | [
"def",
"_set_reflect_both",
"(",
"padded",
",",
"axis",
",",
"width_pair",
",",
"method",
",",
"include_edge",
"=",
"False",
")",
":",
"left_pad",
",",
"right_pad",
"=",
"width_pair",
"old_length",
"=",
"padded",
".",
"shape",
"[",
"axis",
"]",
"-",
"right... | [
293,
0
] | [
375,
30
] | python | en | ['en', 'error', 'th'] | False |
_set_wrap_both | (padded, axis, width_pair) |
Pad `axis` of `arr` with wrapped values.
Parameters
----------
padded : ndarray
Input array of arbitrary shape.
axis : int
Axis along which to pad `arr`.
width_pair : (int, int)
Pair of widths that mark the pad area on both sides in the given
dimension.
Ret... |
Pad `axis` of `arr` with wrapped values. | def _set_wrap_both(padded, axis, width_pair):
"""
Pad `axis` of `arr` with wrapped values.
Parameters
----------
padded : ndarray
Input array of arbitrary shape.
axis : int
Axis along which to pad `arr`.
width_pair : (int, int)
Pair of widths that mark the pad area o... | [
"def",
"_set_wrap_both",
"(",
"padded",
",",
"axis",
",",
"width_pair",
")",
":",
"left_pad",
",",
"right_pad",
"=",
"width_pair",
"period",
"=",
"padded",
".",
"shape",
"[",
"axis",
"]",
"-",
"right_pad",
"-",
"left_pad",
"# If the current dimension of `arr` do... | [
378,
0
] | [
448,
38
] | python | en | ['en', 'error', 'th'] | False |
_as_pairs | (x, ndim, as_index=False) |
Broadcast `x` to an array with the shape (`ndim`, 2).
A helper function for `pad` that prepares and validates arguments like
`pad_width` for iteration in pairs.
Parameters
----------
x : {None, scalar, array-like}
The object to broadcast to the shape (`ndim`, 2).
ndim : int
... |
Broadcast `x` to an array with the shape (`ndim`, 2). | def _as_pairs(x, ndim, as_index=False):
"""
Broadcast `x` to an array with the shape (`ndim`, 2).
A helper function for `pad` that prepares and validates arguments like
`pad_width` for iteration in pairs.
Parameters
----------
x : {None, scalar, array-like}
The object to broadcast ... | [
"def",
"_as_pairs",
"(",
"x",
",",
"ndim",
",",
"as_index",
"=",
"False",
")",
":",
"if",
"x",
"is",
"None",
":",
"# Pass through None as a special case, otherwise np.round(x) fails",
"# with an AttributeError",
"return",
"(",
"(",
"None",
",",
"None",
")",
",",
... | [
451,
0
] | [
515,
49
] | python | en | ['en', 'error', 'th'] | False |
pad | (array, pad_width, mode='constant', **kwargs) |
Pad an array.
Parameters
----------
array : array_like of rank N
The array to pad.
pad_width : {sequence, array_like, int}
Number of values padded to the edges of each axis.
((before_1, after_1), ... (before_N, after_N)) unique pad widths
for each axis.
((be... |
Pad an array. | def pad(array, pad_width, mode='constant', **kwargs):
"""
Pad an array.
Parameters
----------
array : array_like of rank N
The array to pad.
pad_width : {sequence, array_like, int}
Number of values padded to the edges of each axis.
((before_1, after_1), ... (before_N, af... | [
"def",
"pad",
"(",
"array",
",",
"pad_width",
",",
"mode",
"=",
"'constant'",
",",
"*",
"*",
"kwargs",
")",
":",
"array",
"=",
"np",
".",
"asarray",
"(",
"array",
")",
"pad_width",
"=",
"np",
".",
"asarray",
"(",
"pad_width",
")",
"if",
"not",
"pad... | [
527,
0
] | [
873,
17
] | python | en | ['en', 'error', 'th'] | False |
precision_at_k | (model, test_interactions, train_interactions=None,
k=10, user_features=None, item_features=None,
preserve_rows=False, num_threads=1) |
Measure the precision at k metric for a model: the fraction of known
positives in the first k positions of the ranked list of results.
A perfect score is 1.0.
Parameters
----------
model: LightFM instance
the model to be evaluated
test_interactions: np.float32 csr_matrix of shape... |
Measure the precision at k metric for a model: the fraction of known
positives in the first k positions of the ranked list of results.
A perfect score is 1.0. | def precision_at_k(model, test_interactions, train_interactions=None,
k=10, user_features=None, item_features=None,
preserve_rows=False, num_threads=1):
"""
Measure the precision at k metric for a model: the fraction of known
positives in the first k positions of the ra... | [
"def",
"precision_at_k",
"(",
"model",
",",
"test_interactions",
",",
"train_interactions",
"=",
"None",
",",
"k",
"=",
"10",
",",
"user_features",
"=",
"None",
",",
"item_features",
"=",
"None",
",",
"preserve_rows",
"=",
"False",
",",
"num_threads",
"=",
"... | [
17,
0
] | [
72,
20
] | python | en | ['en', 'error', 'th'] | False |
recall_at_k | (model, test_interactions, train_interactions=None,
k=10, user_features=None, item_features=None,
preserve_rows=False, num_threads=1) |
Measure the recall at k metric for a model: the number of positive items in
the first k positions of the ranked list of results divided by the number
of positive items in the test period. A perfect score is 1.0.
Parameters
----------
model: LightFM instance
the model to be evaluated
... |
Measure the recall at k metric for a model: the number of positive items in
the first k positions of the ranked list of results divided by the number
of positive items in the test period. A perfect score is 1.0. | def recall_at_k(model, test_interactions, train_interactions=None,
k=10, user_features=None, item_features=None,
preserve_rows=False, num_threads=1):
"""
Measure the recall at k metric for a model: the number of positive items in
the first k positions of the ranked list of re... | [
"def",
"recall_at_k",
"(",
"model",
",",
"test_interactions",
",",
"train_interactions",
"=",
"None",
",",
"k",
"=",
"10",
",",
"user_features",
"=",
"None",
",",
"item_features",
"=",
"None",
",",
"preserve_rows",
"=",
"False",
",",
"num_threads",
"=",
"1",... | [
75,
0
] | [
133,
26
] | python | en | ['en', 'error', 'th'] | False |
auc_score | (model, test_interactions, train_interactions=None,
user_features=None, item_features=None,
preserve_rows=False, num_threads=1) |
Measure the ROC AUC metric for a model: the probability that a randomly
chosen positive example has a higher score than a randomly chosen negative
example.
A perfect score is 1.0.
Parameters
----------
model: LightFM instance
the model to be evaluated
test_interactions: np.fl... |
Measure the ROC AUC metric for a model: the probability that a randomly
chosen positive example has a higher score than a randomly chosen negative
example.
A perfect score is 1.0. | def auc_score(model, test_interactions, train_interactions=None,
user_features=None, item_features=None,
preserve_rows=False, num_threads=1):
"""
Measure the ROC AUC metric for a model: the probability that a randomly
chosen positive example has a higher score than a randomly cho... | [
"def",
"auc_score",
"(",
"model",
",",
"test_interactions",
",",
"train_interactions",
"=",
"None",
",",
"user_features",
"=",
"None",
",",
"item_features",
"=",
"None",
",",
"preserve_rows",
"=",
"False",
",",
"num_threads",
"=",
"1",
")",
":",
"ranks",
"="... | [
136,
0
] | [
207,
14
] | python | en | ['en', 'error', 'th'] | False |
reciprocal_rank | (model, test_interactions, train_interactions=None,
user_features=None, item_features=None,
preserve_rows=False, num_threads=1) |
Measure the reciprocal rank metric for a model: 1 / the rank of the highest
ranked positive example. A perfect score is 1.0.
Parameters
----------
model: LightFM instance
the model to be evaluated
test_interactions: np.float32 csr_matrix of shape [n_users, n_items]
Non-zero ... |
Measure the reciprocal rank metric for a model: 1 / the rank of the highest
ranked positive example. A perfect score is 1.0. | def reciprocal_rank(model, test_interactions, train_interactions=None,
user_features=None, item_features=None,
preserve_rows=False, num_threads=1):
"""
Measure the reciprocal rank metric for a model: 1 / the rank of the highest
ranked positive example. A perfect score... | [
"def",
"reciprocal_rank",
"(",
"model",
",",
"test_interactions",
",",
"train_interactions",
"=",
"None",
",",
"user_features",
"=",
"None",
",",
"item_features",
"=",
"None",
",",
"preserve_rows",
"=",
"False",
",",
"num_threads",
"=",
"1",
")",
":",
"ranks",... | [
210,
0
] | [
263,
16
] | python | en | ['en', 'error', 'th'] | False |
hamming_distance | (preds: torch.Tensor, target: torch.Tensor, threshold: float = 0.5) | r"""
Computes the average `Hamming distance <https://en.wikipedia.org/wiki/Hamming_distance>`_ (also
known as Hamming loss) between targets and predictions:
.. math::
\text{Hamming distance} = \frac{1}{N \cdot L} \sum_i^N \sum_l^L 1(y_{il} \neq \hat{y}_{il})
Where :math:`y` is a tensor of targ... | r"""
Computes the average `Hamming distance <https://en.wikipedia.org/wiki/Hamming_distance>`_ (also
known as Hamming loss) between targets and predictions: | def hamming_distance(preds: torch.Tensor, target: torch.Tensor, threshold: float = 0.5) -> torch.Tensor:
r"""
Computes the average `Hamming distance <https://en.wikipedia.org/wiki/Hamming_distance>`_ (also
known as Hamming loss) between targets and predictions:
.. math::
\text{Hamming distance}... | [
"def",
"hamming_distance",
"(",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"threshold",
":",
"float",
"=",
"0.5",
")",
"->",
"torch",
".",
"Tensor",
":",
"correct",
",",
"total",
"=",
"_hamming_distance_update",
... | [
37,
0
] | [
73,
52
] | python | cy | ['en', 'cy', 'hi'] | False |
createMessageWithAttachment | (
sender, to, subject, msgHtml, msgPlain, attachmentFile) | Create a message for an email.
Args:
sender: Email address of the sender.
to: Email address of the receiver.
subject: The subject of the email message.
msgHtml: Html message to be sent
msgPlain: Alternative plain text message for older email clients
attachmentFile: T... | Create a message for an email. | def createMessageWithAttachment(
sender, to, subject, msgHtml, msgPlain, attachmentFile):
"""Create a message for an email.
Args:
sender: Email address of the sender.
to: Email address of the receiver.
subject: The subject of the email message.
msgHtml: Html message to be se... | [
"def",
"createMessageWithAttachment",
"(",
"sender",
",",
"to",
",",
"subject",
",",
"msgHtml",
",",
"msgPlain",
",",
"attachmentFile",
")",
":",
"message",
"=",
"MIMEMultipart",
"(",
"'mixed'",
")",
"message",
"[",
"'to'",
"]",
"=",
"to",
"message",
"[",
... | [
65,
0
] | [
121,
65
] | python | en | ['en', 'en', 'en'] | True |
FortranLibrary.addIgnorableRoutine | (self, rname) | Add a routine that we don't want to consider when looking at
dependencies.
| Add a routine that we don't want to consider when looking at
dependencies.
| def addIgnorableRoutine(self, rname):
"""Add a routine that we don't want to consider when looking at
dependencies.
"""
rname = rname.lower()
routine = UnknownFortranRoutine(rname)
self.names_to_routines[rname] = routine | [
"def",
"addIgnorableRoutine",
"(",
"self",
",",
"rname",
")",
":",
"rname",
"=",
"rname",
".",
"lower",
"(",
")",
"routine",
"=",
"UnknownFortranRoutine",
"(",
"rname",
")",
"self",
".",
"names_to_routines",
"[",
"rname",
"]",
"=",
"routine"
] | [
117,
4
] | [
123,
47
] | python | en | ['en', 'en', 'en'] | True |
FortranLibrary.addRoutine | (self, rname) | Add a routine to the library.
| Add a routine to the library.
| def addRoutine(self, rname):
"""Add a routine to the library.
"""
self.getRoutine(rname) | [
"def",
"addRoutine",
"(",
"self",
",",
"rname",
")",
":",
"self",
".",
"getRoutine",
"(",
"rname",
")"
] | [
125,
4
] | [
128,
30
] | python | en | ['en', 'en', 'en'] | True |
FortranLibrary.getRoutine | (self, rname) | Get a routine from the library. Will add if it's not found.
| Get a routine from the library. Will add if it's not found.
| def getRoutine(self, rname):
"""Get a routine from the library. Will add if it's not found.
"""
unique = []
rname = rname.lower()
routine = self.names_to_routines.get(rname, unique)
if routine is unique:
routine = self._findRoutine(rname)
self.name... | [
"def",
"getRoutine",
"(",
"self",
",",
"rname",
")",
":",
"unique",
"=",
"[",
"]",
"rname",
"=",
"rname",
".",
"lower",
"(",
")",
"routine",
"=",
"self",
".",
"names_to_routines",
".",
"get",
"(",
"rname",
",",
"unique",
")",
"if",
"routine",
"is",
... | [
130,
4
] | [
139,
22
] | python | en | ['en', 'en', 'en'] | True |
FortranLibrary.allRoutineNames | (self) | Return the names of all the routines.
| Return the names of all the routines.
| def allRoutineNames(self):
"""Return the names of all the routines.
"""
return list(self.names_to_routines.keys()) | [
"def",
"allRoutineNames",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"names_to_routines",
".",
"keys",
"(",
")",
")"
] | [
141,
4
] | [
144,
50
] | python | en | ['en', 'en', 'en'] | True |
FortranLibrary.allRoutines | (self) | Return all the routines.
| Return all the routines.
| def allRoutines(self):
"""Return all the routines.
"""
return list(self.names_to_routines.values()) | [
"def",
"allRoutines",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"names_to_routines",
".",
"values",
"(",
")",
")"
] | [
146,
4
] | [
149,
52
] | python | en | ['en', 'en', 'en'] | True |
FortranLibrary.resolveAllDependencies | (self) | Try to add routines to the library to satisfy all the dependencies
for each routine in the library.
Returns a set of routine names that have the dependencies unresolved.
| Try to add routines to the library to satisfy all the dependencies
for each routine in the library. | def resolveAllDependencies(self):
"""Try to add routines to the library to satisfy all the dependencies
for each routine in the library.
Returns a set of routine names that have the dependencies unresolved.
"""
done_this = set()
last_todo = set()
while True:
... | [
"def",
"resolveAllDependencies",
"(",
"self",
")",
":",
"done_this",
"=",
"set",
"(",
")",
"last_todo",
"=",
"set",
"(",
")",
"while",
"True",
":",
"todo",
"=",
"set",
"(",
"self",
".",
"allRoutineNames",
"(",
")",
")",
"-",
"done_this",
"if",
"todo",
... | [
151,
4
] | [
170,
19
] | python | en | ['en', 'en', 'en'] | True |
explained_variance | (
preds: torch.Tensor,
target: torch.Tensor,
multioutput: str = 'uniform_average',
) |
Computes explained variance.
Args:
preds: estimated labels
target: ground truth labels
multioutput: Defines aggregation in the case of multiple output scores. Can be one
of the following strings (default is `'uniform_average'`.):
* `'raw_values'` returns full s... |
Computes explained variance. | def explained_variance(
preds: torch.Tensor,
target: torch.Tensor,
multioutput: str = 'uniform_average',
) -> Union[torch.Tensor, Sequence[torch.Tensor]]:
"""
Computes explained variance.
Args:
preds: estimated labels
target: ground truth labels
multioutput: Defines aggr... | [
"def",
"explained_variance",
"(",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"multioutput",
":",
"str",
"=",
"'uniform_average'",
",",
")",
"->",
"Union",
"[",
"torch",
".",
"Tensor",
",",
"Sequence",
"[",
"tor... | [
55,
0
] | [
87,
66
] | python | en | ['en', 'error', 'th'] | False |
from_argparse_args | (cls, args: Union[Namespace, ArgumentParser], **kwargs) |
Create an instance from CLI arguments.
Eventually use varibles from OS environement which are defined as "PL_<CLASS-NAME>_<CLASS_ARUMENT_NAME>"
Args:
cls: Lightning class
args: The parser or namespace to take arguments from. Only known arguments will be
parsed and passed to the... |
Create an instance from CLI arguments.
Eventually use varibles from OS environement which are defined as "PL_<CLASS-NAME>_<CLASS_ARUMENT_NAME>" | def from_argparse_args(cls, args: Union[Namespace, ArgumentParser], **kwargs):
"""
Create an instance from CLI arguments.
Eventually use varibles from OS environement which are defined as "PL_<CLASS-NAME>_<CLASS_ARUMENT_NAME>"
Args:
cls: Lightning class
args: The parser or namespace to ... | [
"def",
"from_argparse_args",
"(",
"cls",
",",
"args",
":",
"Union",
"[",
"Namespace",
",",
"ArgumentParser",
"]",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"args",
",",
"ArgumentParser",
")",
":",
"args",
"=",
"cls",
".",
"parse_argpars... | [
22,
0
] | [
52,
32
] | python | en | ['en', 'error', 'th'] | False |
parse_argparser | (cls, arg_parser: Union[ArgumentParser, Namespace]) | Parse CLI arguments, required for custom bool types. | Parse CLI arguments, required for custom bool types. | def parse_argparser(cls, arg_parser: Union[ArgumentParser, Namespace]) -> Namespace:
"""Parse CLI arguments, required for custom bool types."""
args = arg_parser.parse_args() if isinstance(arg_parser, ArgumentParser) else arg_parser
types_default = {arg: (arg_types, arg_default) for arg, arg_types, arg_def... | [
"def",
"parse_argparser",
"(",
"cls",
",",
"arg_parser",
":",
"Union",
"[",
"ArgumentParser",
",",
"Namespace",
"]",
")",
"->",
"Namespace",
":",
"args",
"=",
"arg_parser",
".",
"parse_args",
"(",
")",
"if",
"isinstance",
"(",
"arg_parser",
",",
"ArgumentPar... | [
55,
0
] | [
77,
37
] | python | en | ['en', 'en', 'en'] | True |
parse_env_variables | (cls, template: str = "PL_%(cls_name)s_%(cls_argument)s") | Parse environment arguments if they are defined.
Example:
>>> from pytorch_lightning import Trainer
>>> parse_env_variables(Trainer)
Namespace()
>>> import os
>>> os.environ["PL_TRAINER_GPUS"] = '42'
>>> os.environ["PL_TRAINER_BLABLABLA"] = '1.23'
>>> parse_e... | Parse environment arguments if they are defined. | def parse_env_variables(cls, template: str = "PL_%(cls_name)s_%(cls_argument)s") -> Namespace:
"""Parse environment arguments if they are defined.
Example:
>>> from pytorch_lightning import Trainer
>>> parse_env_variables(Trainer)
Namespace()
>>> import os
>>> os.environ... | [
"def",
"parse_env_variables",
"(",
"cls",
",",
"template",
":",
"str",
"=",
"\"PL_%(cls_name)s_%(cls_argument)s\"",
")",
"->",
"Namespace",
":",
"cls_arg_defaults",
"=",
"get_init_arguments_and_types",
"(",
"cls",
")",
"env_args",
"=",
"{",
"}",
"for",
"arg_name",
... | [
80,
0
] | [
106,
32
] | python | en | ['en', 'en', 'en'] | True |
get_init_arguments_and_types | (cls) | r"""Scans the Trainer signature and returns argument names, types and default values.
Returns:
List with tuples of 3 values:
(argument name, set with argument types, argument default value).
Examples:
>>> from pytorch_lightning import Trainer
>>> args = get_init_arguments_and_... | r"""Scans the Trainer signature and returns argument names, types and default values. | def get_init_arguments_and_types(cls) -> List[Tuple[str, Tuple, Any]]:
r"""Scans the Trainer signature and returns argument names, types and default values.
Returns:
List with tuples of 3 values:
(argument name, set with argument types, argument default value).
Examples:
>>> from ... | [
"def",
"get_init_arguments_and_types",
"(",
"cls",
")",
"->",
"List",
"[",
"Tuple",
"[",
"str",
",",
"Tuple",
",",
"Any",
"]",
"]",
":",
"trainer_default_params",
"=",
"inspect",
".",
"signature",
"(",
"cls",
")",
".",
"parameters",
"name_type_default",
"=",... | [
109,
0
] | [
134,
28
] | python | en | ['en', 'en', 'en'] | True |
add_argparse_args | (cls, parent_parser: ArgumentParser) | r"""Extends existing argparse by default `Trainer` attributes.
Args:
cls: Lightning class
parent_parser:
The custom cli arguments parser, which will be extended by
the Trainer default arguments.
Only arguments of the allowed types (str, float, int, bool) will
extend... | r"""Extends existing argparse by default `Trainer` attributes. | def add_argparse_args(cls, parent_parser: ArgumentParser) -> ArgumentParser:
r"""Extends existing argparse by default `Trainer` attributes.
Args:
cls: Lightning class
parent_parser:
The custom cli arguments parser, which will be extended by
the Trainer default arguments.... | [
"def",
"add_argparse_args",
"(",
"cls",
",",
"parent_parser",
":",
"ArgumentParser",
")",
"->",
"ArgumentParser",
":",
"parser",
"=",
"ArgumentParser",
"(",
"parents",
"=",
"[",
"parent_parser",
"]",
",",
"add_help",
"=",
"False",
",",
")",
"blacklist",
"=",
... | [
137,
0
] | [
207,
17
] | python | en | ['en', 'en', 'en'] | True |
_check_keys_contain | (result_keys, target_keys) | Check if all elements in target_keys is in result_keys. | Check if all elements in target_keys is in result_keys. | def _check_keys_contain(result_keys, target_keys):
"""Check if all elements in target_keys is in result_keys."""
return set(target_keys).issubset(set(result_keys)) | [
"def",
"_check_keys_contain",
"(",
"result_keys",
",",
"target_keys",
")",
":",
"return",
"set",
"(",
"target_keys",
")",
".",
"issubset",
"(",
"set",
"(",
"result_keys",
")",
")"
] | [
14,
0
] | [
16,
54
] | python | en | ['en', 'en', 'en'] | True |
_check_flip | (origin_imgs, result_imgs) | Check if the origin_imgs are flipped correctly. | Check if the origin_imgs are flipped correctly. | def _check_flip(origin_imgs, result_imgs):
"""Check if the origin_imgs are flipped correctly."""
h, w, c = origin_imgs.shape
for i in range(h):
for j in range(w):
for k in range(c):
if result_imgs[i, j, k] != origin_imgs[i, w - 1 - j, k]:
return False
... | [
"def",
"_check_flip",
"(",
"origin_imgs",
",",
"result_imgs",
")",
":",
"h",
",",
"w",
",",
"c",
"=",
"origin_imgs",
".",
"shape",
"for",
"i",
"in",
"range",
"(",
"h",
")",
":",
"for",
"j",
"in",
"range",
"(",
"w",
")",
":",
"for",
"k",
"in",
"... | [
19,
0
] | [
27,
15
] | python | en | ['en', 'en', 'en'] | True |
_check_normalize | (origin_imgs, result_imgs, norm_cfg) | Check if the origin_imgs are normalized correctly into result_imgs in a
given norm_cfg. | Check if the origin_imgs are normalized correctly into result_imgs in a
given norm_cfg. | def _check_normalize(origin_imgs, result_imgs, norm_cfg):
"""Check if the origin_imgs are normalized correctly into result_imgs in a
given norm_cfg."""
target_imgs = result_imgs.copy()
for i in range(3):
target_imgs[i] *= norm_cfg['std'][i]
target_imgs[i] += norm_cfg['mean'][i]
asser... | [
"def",
"_check_normalize",
"(",
"origin_imgs",
",",
"result_imgs",
",",
"norm_cfg",
")",
":",
"target_imgs",
"=",
"result_imgs",
".",
"copy",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"3",
")",
":",
"target_imgs",
"[",
"i",
"]",
"*=",
"norm_cfg",
"[",
... | [
38,
0
] | [
45,
66
] | python | en | ['en', 'en', 'en'] | True |
zipfile_factory | (file, *args, **kwargs) |
Create a ZipFile.
Allows for Zip64, and the `file` argument can accept file, str, or
pathlib.Path objects. `args` and `kwargs` are passed to the zipfile.ZipFile
constructor.
|
Create a ZipFile. | def zipfile_factory(file, *args, **kwargs):
"""
Create a ZipFile.
Allows for Zip64, and the `file` argument can accept file, str, or
pathlib.Path objects. `args` and `kwargs` are passed to the zipfile.ZipFile
constructor.
"""
if not hasattr(file, 'read'):
file = os_fspath(file)
... | [
"def",
"zipfile_factory",
"(",
"file",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"hasattr",
"(",
"file",
",",
"'read'",
")",
":",
"file",
"=",
"os_fspath",
"(",
"file",
")",
"import",
"zipfile",
"kwargs",
"[",
"'allowZip64'",
... | [
106,
0
] | [
118,
49
] | python | en | ['en', 'error', 'th'] | False |
load | (file, mmap_mode=None, allow_pickle=False, fix_imports=True,
encoding='ASCII') |
Load arrays or pickled objects from ``.npy``, ``.npz`` or pickled files.
.. warning:: Loading files that contain object arrays uses the ``pickle``
module, which is not secure against erroneous or maliciously
constructed data. Consider passing ``allow_pickle=False`` to
... |
Load arrays or pickled objects from ``.npy``, ``.npz`` or pickled files. | def load(file, mmap_mode=None, allow_pickle=False, fix_imports=True,
encoding='ASCII'):
"""
Load arrays or pickled objects from ``.npy``, ``.npz`` or pickled files.
.. warning:: Loading files that contain object arrays uses the ``pickle``
module, which is not secure against errone... | [
"def",
"load",
"(",
"file",
",",
"mmap_mode",
"=",
"None",
",",
"allow_pickle",
"=",
"False",
",",
"fix_imports",
"=",
"True",
",",
"encoding",
"=",
"'ASCII'",
")",
":",
"if",
"encoding",
"not",
"in",
"(",
"'ASCII'",
",",
"'latin1'",
",",
"'bytes'",
")... | [
291,
0
] | [
465,
23
] | python | en | ['en', 'error', 'th'] | False |
save | (file, arr, allow_pickle=True, fix_imports=True) |
Save an array to a binary file in NumPy ``.npy`` format.
Parameters
----------
file : file, str, or pathlib.Path
File or filename to which the data is saved. If file is a file-object,
then the filename is unchanged. If file is a string or Path, a ``.npy``
extension will be ap... |
Save an array to a binary file in NumPy ``.npy`` format. | def save(file, arr, allow_pickle=True, fix_imports=True):
"""
Save an array to a binary file in NumPy ``.npy`` format.
Parameters
----------
file : file, str, or pathlib.Path
File or filename to which the data is saved. If file is a file-object,
then the filename is unchanged. If ... | [
"def",
"save",
"(",
"file",
",",
"arr",
",",
"allow_pickle",
"=",
"True",
",",
"fix_imports",
"=",
"True",
")",
":",
"own_fid",
"=",
"False",
"if",
"hasattr",
"(",
"file",
",",
"'write'",
")",
":",
"fid",
"=",
"file",
"else",
":",
"file",
"=",
"os_... | [
473,
0
] | [
544,
23
] | python | en | ['en', 'error', 'th'] | False |
savez | (file, *args, **kwds) |
Save several arrays into a single file in uncompressed ``.npz`` format.
If arguments are passed in with no keywords, the corresponding variable
names, in the ``.npz`` file, are 'arr_0', 'arr_1', etc. If keyword
arguments are given, the corresponding variable names, in the ``.npz``
file will match ... |
Save several arrays into a single file in uncompressed ``.npz`` format. | def savez(file, *args, **kwds):
"""
Save several arrays into a single file in uncompressed ``.npz`` format.
If arguments are passed in with no keywords, the corresponding variable
names, in the ``.npz`` file, are 'arr_0', 'arr_1', etc. If keyword
arguments are given, the corresponding variable name... | [
"def",
"savez",
"(",
"file",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"_savez",
"(",
"file",
",",
"args",
",",
"kwds",
",",
"False",
")"
] | [
555,
0
] | [
631,
35
] | python | en | ['en', 'error', 'th'] | False |
savez_compressed | (file, *args, **kwds) |
Save several arrays into a single file in compressed ``.npz`` format.
If keyword arguments are given, then filenames are taken from the keywords.
If arguments are passed in with no keywords, then stored file names are
arr_0, arr_1, etc.
Parameters
----------
file : str or file
Eit... |
Save several arrays into a single file in compressed ``.npz`` format. | def savez_compressed(file, *args, **kwds):
"""
Save several arrays into a single file in compressed ``.npz`` format.
If keyword arguments are given, then filenames are taken from the keywords.
If arguments are passed in with no keywords, then stored file names are
arr_0, arr_1, etc.
Parameters... | [
"def",
"savez_compressed",
"(",
"file",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"_savez",
"(",
"file",
",",
"args",
",",
"kwds",
",",
"True",
")"
] | [
642,
0
] | [
703,
34
] | python | en | ['en', 'error', 'th'] | False |
_getconv | (dtype) | Find the correct dtype converter. Adapted from matplotlib | Find the correct dtype converter. Adapted from matplotlib | def _getconv(dtype):
""" Find the correct dtype converter. Adapted from matplotlib """
def floatconv(x):
x.lower()
if '0x' in x:
return float.fromhex(x)
return float(x)
typ = dtype.type
if issubclass(typ, np.bool_):
return lambda x: bool(int(x))
if issub... | [
"def",
"_getconv",
"(",
"dtype",
")",
":",
"def",
"floatconv",
"(",
"x",
")",
":",
"x",
".",
"lower",
"(",
")",
"if",
"'0x'",
"in",
"x",
":",
"return",
"float",
".",
"fromhex",
"(",
"x",
")",
"return",
"float",
"(",
"x",
")",
"typ",
"=",
"dtype... | [
773,
0
] | [
802,
20
] | python | en | ['en', 'en', 'en'] | True |
loadtxt | (fname, dtype=float, comments='#', delimiter=None,
converters=None, skiprows=0, usecols=None, unpack=False,
ndmin=0, encoding='bytes', max_rows=None) |
Load data from a text file.
Each row in the text file must have the same number of values.
Parameters
----------
fname : file, str, or pathlib.Path
File, filename, or generator to read. If the filename extension is
``.gz`` or ``.bz2``, the file is first decompressed. Note that
... |
Load data from a text file. | def loadtxt(fname, dtype=float, comments='#', delimiter=None,
converters=None, skiprows=0, usecols=None, unpack=False,
ndmin=0, encoding='bytes', max_rows=None):
"""
Load data from a text file.
Each row in the text file must have the same number of values.
Parameters
------... | [
"def",
"loadtxt",
"(",
"fname",
",",
"dtype",
"=",
"float",
",",
"comments",
"=",
"'#'",
",",
"delimiter",
"=",
"None",
",",
"converters",
"=",
"None",
",",
"skiprows",
"=",
"0",
",",
"usecols",
"=",
"None",
",",
"unpack",
"=",
"False",
",",
"ndmin",... | [
809,
0
] | [
1188,
16
] | python | en | ['en', 'error', 'th'] | False |
savetxt | (fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='',
footer='', comments='# ', encoding=None) |
Save an array to a text file.
Parameters
----------
fname : filename or file handle
If the filename ends in ``.gz``, the file is automatically saved in
compressed gzip format. `loadtxt` understands gzipped files
transparently.
X : 1D or 2D array_like
Data to be sav... |
Save an array to a text file. | def savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='',
footer='', comments='# ', encoding=None):
"""
Save an array to a text file.
Parameters
----------
fname : filename or file handle
If the filename ends in ``.gz``, the file is automatically saved in
... | [
"def",
"savetxt",
"(",
"fname",
",",
"X",
",",
"fmt",
"=",
"'%.18e'",
",",
"delimiter",
"=",
"' '",
",",
"newline",
"=",
"'\\n'",
",",
"header",
"=",
"''",
",",
"footer",
"=",
"''",
",",
"comments",
"=",
"'# '",
",",
"encoding",
"=",
"None",
")",
... | [
1198,
0
] | [
1445,
22
] | python | en | ['en', 'error', 'th'] | False |
fromregex | (file, regexp, dtype, encoding=None) |
Construct an array from a text file, using regular expression parsing.
The returned array is always a structured array, and is constructed from
all matches of the regular expression in the file. Groups in the regular
expression are converted to fields of the structured array.
Parameters
-----... |
Construct an array from a text file, using regular expression parsing. | def fromregex(file, regexp, dtype, encoding=None):
"""
Construct an array from a text file, using regular expression parsing.
The returned array is always a structured array, and is constructed from
all matches of the regular expression in the file. Groups in the regular
expression are converted to... | [
"def",
"fromregex",
"(",
"file",
",",
"regexp",
",",
"dtype",
",",
"encoding",
"=",
"None",
")",
":",
"own_fh",
"=",
"False",
"if",
"not",
"hasattr",
"(",
"file",
",",
"\"read\"",
")",
":",
"file",
"=",
"np",
".",
"lib",
".",
"_datasource",
".",
"o... | [
1449,
0
] | [
1539,
24
] | python | en | ['en', 'error', 'th'] | False |
genfromtxt | (fname, dtype=float, comments='#', delimiter=None,
skip_header=0, skip_footer=0, converters=None,
missing_values=None, filling_values=None, usecols=None,
names=None, excludelist=None,
deletechars=''.join(sorted(NameValidator.defaultdeletechars)),
... |
Load data from a text file, with missing values handled as specified.
Each line past the first `skip_header` lines is split at the `delimiter`
character, and characters following the `comments` character are discarded.
Parameters
----------
fname : file, str, pathlib.Path, list of str, genera... |
Load data from a text file, with missing values handled as specified. | def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
skip_header=0, skip_footer=0, converters=None,
missing_values=None, filling_values=None, usecols=None,
names=None, excludelist=None,
deletechars=''.join(sorted(NameValidator.defaultdeletechars)),... | [
"def",
"genfromtxt",
"(",
"fname",
",",
"dtype",
"=",
"float",
",",
"comments",
"=",
"'#'",
",",
"delimiter",
"=",
"None",
",",
"skip_header",
"=",
"0",
",",
"skip_footer",
"=",
"0",
",",
"converters",
"=",
"None",
",",
"missing_values",
"=",
"None",
"... | [
1548,
0
] | [
2239,
27
] | python | en | ['en', 'error', 'th'] | False |
ndfromtxt | (fname, **kwargs) |
Load ASCII data stored in a file and return it as a single array.
.. deprecated:: 1.17
ndfromtxt` is a deprecated alias of `genfromtxt` which
overwrites the ``usemask`` argument with `False` even when
explicitly called as ``ndfromtxt(..., usemask=True)``.
Use `genfromtxt` inste... |
Load ASCII data stored in a file and return it as a single array. | def ndfromtxt(fname, **kwargs):
"""
Load ASCII data stored in a file and return it as a single array.
.. deprecated:: 1.17
ndfromtxt` is a deprecated alias of `genfromtxt` which
overwrites the ``usemask`` argument with `False` even when
explicitly called as ``ndfromtxt(..., usemask=... | [
"def",
"ndfromtxt",
"(",
"fname",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'usemask'",
"]",
"=",
"False",
"# Numpy 1.17",
"warnings",
".",
"warn",
"(",
"\"np.ndfromtxt is a deprecated alias of np.genfromtxt, \"",
"\"prefer the latter.\"",
",",
"DeprecationWa... | [
2242,
0
] | [
2267,
38
] | python | en | ['en', 'error', 'th'] | False |
mafromtxt | (fname, **kwargs) |
Load ASCII data stored in a text file and return a masked array.
.. deprecated:: 1.17
np.mafromtxt is a deprecated alias of `genfromtxt` which
overwrites the ``usemask`` argument with `True` even when
explicitly called as ``mafromtxt(..., usemask=False)``.
Use `genfromtxt` inst... |
Load ASCII data stored in a text file and return a masked array. | def mafromtxt(fname, **kwargs):
"""
Load ASCII data stored in a text file and return a masked array.
.. deprecated:: 1.17
np.mafromtxt is a deprecated alias of `genfromtxt` which
overwrites the ``usemask`` argument with `True` even when
explicitly called as ``mafromtxt(..., usemask=... | [
"def",
"mafromtxt",
"(",
"fname",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'usemask'",
"]",
"=",
"True",
"# Numpy 1.17",
"warnings",
".",
"warn",
"(",
"\"np.mafromtxt is a deprecated alias of np.genfromtxt, \"",
"\"prefer the latter.\"",
",",
"DeprecationWar... | [
2270,
0
] | [
2295,
38
] | python | en | ['en', 'error', 'th'] | False |
recfromtxt | (fname, **kwargs) |
Load ASCII data from a file and return it in a record array.
If ``usemask=False`` a standard `recarray` is returned,
if ``usemask=True`` a MaskedRecords array is returned.
Parameters
----------
fname, kwargs : For a description of input parameters, see `genfromtxt`.
See Also
--------... |
Load ASCII data from a file and return it in a record array. | def recfromtxt(fname, **kwargs):
"""
Load ASCII data from a file and return it in a record array.
If ``usemask=False`` a standard `recarray` is returned,
if ``usemask=True`` a MaskedRecords array is returned.
Parameters
----------
fname, kwargs : For a description of input parameters, see ... | [
"def",
"recfromtxt",
"(",
"fname",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"\"dtype\"",
",",
"None",
")",
"usemask",
"=",
"kwargs",
".",
"get",
"(",
"'usemask'",
",",
"False",
")",
"output",
"=",
"genfromtxt",
"(",
"fname",... | [
2298,
0
] | [
2327,
17
] | python | en | ['en', 'error', 'th'] | False |
recfromcsv | (fname, **kwargs) |
Load ASCII data stored in a comma-separated file.
The returned array is a record array (if ``usemask=False``, see
`recarray`) or a masked record array (if ``usemask=True``,
see `ma.mrecords.MaskedRecords`).
Parameters
----------
fname, kwargs : For a description of input parameters, see `... |
Load ASCII data stored in a comma-separated file. | def recfromcsv(fname, **kwargs):
"""
Load ASCII data stored in a comma-separated file.
The returned array is a record array (if ``usemask=False``, see
`recarray`) or a masked record array (if ``usemask=True``,
see `ma.mrecords.MaskedRecords`).
Parameters
----------
fname, kwargs : For ... | [
"def",
"recfromcsv",
"(",
"fname",
",",
"*",
"*",
"kwargs",
")",
":",
"# Set default kwargs for genfromtxt as relevant to csv import.",
"kwargs",
".",
"setdefault",
"(",
"\"case_sensitive\"",
",",
"\"lower\"",
")",
"kwargs",
".",
"setdefault",
"(",
"\"names\"",
",",
... | [
2330,
0
] | [
2365,
17
] | python | en | ['en', 'error', 'th'] | False |
BagObj.__dir__ | (self) |
Enables dir(bagobj) to list the files in an NpzFile.
This also enables tab-completion in an interpreter or IPython.
|
Enables dir(bagobj) to list the files in an NpzFile. | def __dir__(self):
"""
Enables dir(bagobj) to list the files in an NpzFile.
This also enables tab-completion in an interpreter or IPython.
"""
return list(object.__getattribute__(self, '_obj').keys()) | [
"def",
"__dir__",
"(",
"self",
")",
":",
"return",
"list",
"(",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"'_obj'",
")",
".",
"keys",
"(",
")",
")"
] | [
97,
4
] | [
103,
65
] | python | en | ['en', 'error', 'th'] | False |
NpzFile.close | (self) |
Close the file.
|
Close the file. | def close(self):
"""
Close the file.
"""
if self.zip is not None:
self.zip.close()
self.zip = None
if self.fid is not None:
self.fid.close()
self.fid = None
self.f = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"zip",
"is",
"not",
"None",
":",
"self",
".",
"zip",
".",
"close",
"(",
")",
"self",
".",
"zip",
"=",
"None",
"if",
"self",
".",
"fid",
"is",
"not",
"None",
":",
"self",
".",
"fid",
".... | [
215,
4
] | [
226,
21
] | python | en | ['en', 'error', 'th'] | False |
eq_ | (a, b, msg=None) | Assert a == b, with repr messaging on failure. | Assert a == b, with repr messaging on failure. | def eq_(a, b, msg=None):
"""Assert a == b, with repr messaging on failure."""
assert a == b, msg or "%r != %r" % (a, b) | [
"def",
"eq_",
"(",
"a",
",",
"b",
",",
"msg",
"=",
"None",
")",
":",
"assert",
"a",
"==",
"b",
",",
"msg",
"or",
"\"%r != %r\"",
"%",
"(",
"a",
",",
"b",
")"
] | [
8,
0
] | [
10,
45
] | python | en | ['en', 'lb', 'en'] | True |
is_ | (a, b, msg=None) | Assert a is b, with repr messaging on failure. | Assert a is b, with repr messaging on failure. | def is_(a, b, msg=None):
"""Assert a is b, with repr messaging on failure."""
assert a is b, msg or "%r is not %r" % (a, b) | [
"def",
"is_",
"(",
"a",
",",
"b",
",",
"msg",
"=",
"None",
")",
":",
"assert",
"a",
"is",
"b",
",",
"msg",
"or",
"\"%r is not %r\"",
"%",
"(",
"a",
",",
"b",
")"
] | [
13,
0
] | [
15,
49
] | python | en | ['en', 'en', 'en'] | True |
ne_ | (a, b, msg=None) | Assert a != b, with repr messaging on failure. | Assert a != b, with repr messaging on failure. | def ne_(a, b, msg=None):
"""Assert a != b, with repr messaging on failure."""
assert a != b, msg or "%r == %r" % (a, b) | [
"def",
"ne_",
"(",
"a",
",",
"b",
",",
"msg",
"=",
"None",
")",
":",
"assert",
"a",
"!=",
"b",
",",
"msg",
"or",
"\"%r == %r\"",
"%",
"(",
"a",
",",
"b",
")"
] | [
18,
0
] | [
20,
45
] | python | en | ['en', 'lb', 'en'] | True |
is_id | (smth) | checks if input string is a number | checks if input string is a number | def is_id(smth):
''' checks if input string is a number '''
if str(smth).isdigit():
return True
return False | [
"def",
"is_id",
"(",
"smth",
")",
":",
"if",
"str",
"(",
"smth",
")",
".",
"isdigit",
"(",
")",
":",
"return",
"True",
"return",
"False"
] | [
3,
0
] | [
7,
16
] | python | en | ['en', 'en', 'en'] | True |
issequence | (seq) |
Is seq a sequence (ndarray, list or tuple)?
|
Is seq a sequence (ndarray, list or tuple)? | def issequence(seq):
"""
Is seq a sequence (ndarray, list or tuple)?
"""
return isinstance(seq, (ndarray, tuple, list)) | [
"def",
"issequence",
"(",
"seq",
")",
":",
"return",
"isinstance",
"(",
"seq",
",",
"(",
"ndarray",
",",
"tuple",
",",
"list",
")",
")"
] | [
44,
0
] | [
49,
50
] | python | en | ['en', 'error', 'th'] | False |
count_masked | (arr, axis=None) |
Count the number of masked elements along the given axis.
Parameters
----------
arr : array_like
An array with (possibly) masked elements.
axis : int, optional
Axis along which to count. If None (default), a flattened
version of the array is used.
Returns
-------
... |
Count the number of masked elements along the given axis. | def count_masked(arr, axis=None):
"""
Count the number of masked elements along the given axis.
Parameters
----------
arr : array_like
An array with (possibly) masked elements.
axis : int, optional
Axis along which to count. If None (default), a flattened
version of the ... | [
"def",
"count_masked",
"(",
"arr",
",",
"axis",
"=",
"None",
")",
":",
"m",
"=",
"getmaskarray",
"(",
"arr",
")",
"return",
"m",
".",
"sum",
"(",
"axis",
")"
] | [
52,
0
] | [
103,
22
] | python | en | ['en', 'error', 'th'] | False |
masked_all | (shape, dtype=float) |
Empty masked array with all elements masked.
Return an empty masked array of the given shape and dtype, where all the
data are masked.
Parameters
----------
shape : tuple
Shape of the required MaskedArray.
dtype : dtype, optional
Data type of the output.
Returns
-... |
Empty masked array with all elements masked. | def masked_all(shape, dtype=float):
"""
Empty masked array with all elements masked.
Return an empty masked array of the given shape and dtype, where all the
data are masked.
Parameters
----------
shape : tuple
Shape of the required MaskedArray.
dtype : dtype, optional
... | [
"def",
"masked_all",
"(",
"shape",
",",
"dtype",
"=",
"float",
")",
":",
"a",
"=",
"masked_array",
"(",
"np",
".",
"empty",
"(",
"shape",
",",
"dtype",
")",
",",
"mask",
"=",
"np",
".",
"ones",
"(",
"shape",
",",
"make_mask_descr",
"(",
"dtype",
")... | [
106,
0
] | [
155,
12
] | python | en | ['en', 'error', 'th'] | False |
masked_all_like | (arr) |
Empty masked array with the properties of an existing array.
Return an empty masked array of the same shape and dtype as
the array `arr`, where all the data are masked.
Parameters
----------
arr : ndarray
An array describing the shape and dtype of the required MaskedArray.
Return... |
Empty masked array with the properties of an existing array. | def masked_all_like(arr):
"""
Empty masked array with the properties of an existing array.
Return an empty masked array of the same shape and dtype as
the array `arr`, where all the data are masked.
Parameters
----------
arr : ndarray
An array describing the shape and dtype of the ... | [
"def",
"masked_all_like",
"(",
"arr",
")",
":",
"a",
"=",
"np",
".",
"empty_like",
"(",
"arr",
")",
".",
"view",
"(",
"MaskedArray",
")",
"a",
".",
"_mask",
"=",
"np",
".",
"ones",
"(",
"a",
".",
"shape",
",",
"dtype",
"=",
"make_mask_descr",
"(",
... | [
158,
0
] | [
210,
12
] | python | en | ['en', 'error', 'th'] | False |
flatten_inplace | (seq) | Flatten a sequence in place. | Flatten a sequence in place. | def flatten_inplace(seq):
"""Flatten a sequence in place."""
k = 0
while (k != len(seq)):
while hasattr(seq[k], '__iter__'):
seq[k:(k + 1)] = seq[k]
k += 1
return seq | [
"def",
"flatten_inplace",
"(",
"seq",
")",
":",
"k",
"=",
"0",
"while",
"(",
"k",
"!=",
"len",
"(",
"seq",
")",
")",
":",
"while",
"hasattr",
"(",
"seq",
"[",
"k",
"]",
",",
"'__iter__'",
")",
":",
"seq",
"[",
"k",
":",
"(",
"k",
"+",
"1",
... | [
368,
0
] | [
375,
14
] | python | en | ['en', 'en', 'it'] | True |
apply_along_axis | (func1d, axis, arr, *args, **kwargs) |
(This docstring should be overwritten)
|
(This docstring should be overwritten)
| def apply_along_axis(func1d, axis, arr, *args, **kwargs):
"""
(This docstring should be overwritten)
"""
arr = array(arr, copy=False, subok=True)
nd = arr.ndim
axis = normalize_axis_index(axis, nd)
ind = [0] * (nd - 1)
i = np.zeros(nd, 'O')
indlist = list(range(nd))
indlist.remov... | [
"def",
"apply_along_axis",
"(",
"func1d",
",",
"axis",
",",
"arr",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"arr",
"=",
"array",
"(",
"arr",
",",
"copy",
"=",
"False",
",",
"subok",
"=",
"True",
")",
"nd",
"=",
"arr",
".",
"ndim",
"... | [
378,
0
] | [
457,
17
] | python | en | ['en', 'error', 'th'] | False |
apply_over_axes | (func, a, axes) |
(This docstring will be overwritten)
|
(This docstring will be overwritten)
| def apply_over_axes(func, a, axes):
"""
(This docstring will be overwritten)
"""
val = asarray(a)
N = a.ndim
if array(axes).ndim == 0:
axes = (axes,)
for axis in axes:
if axis < 0:
axis = N + axis
args = (val, axis)
res = func(*args)
if res... | [
"def",
"apply_over_axes",
"(",
"func",
",",
"a",
",",
"axes",
")",
":",
"val",
"=",
"asarray",
"(",
"a",
")",
"N",
"=",
"a",
".",
"ndim",
"if",
"array",
"(",
"axes",
")",
".",
"ndim",
"==",
"0",
":",
"axes",
"=",
"(",
"axes",
",",
")",
"for",... | [
461,
0
] | [
483,
14
] | python | en | ['en', 'error', 'th'] | False |
average | (a, axis=None, weights=None, returned=False) |
Return the weighted average of array over the given axis.
Parameters
----------
a : array_like
Data to be averaged.
Masked entries are not taken into account in the computation.
axis : int, optional
Axis along which to average `a`. If `None`, averaging is done over
... |
Return the weighted average of array over the given axis. | def average(a, axis=None, weights=None, returned=False):
"""
Return the weighted average of array over the given axis.
Parameters
----------
a : array_like
Data to be averaged.
Masked entries are not taken into account in the computation.
axis : int, optional
Axis along ... | [
"def",
"average",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"weights",
"=",
"None",
",",
"returned",
"=",
"False",
")",
":",
"a",
"=",
"asarray",
"(",
"a",
")",
"m",
"=",
"getmask",
"(",
"a",
")",
"# inspired by 'average' in numpy/lib/function_base.py",
"... | [
534,
0
] | [
634,
18
] | python | en | ['en', 'error', 'th'] | False |
median | (a, axis=None, out=None, overwrite_input=False, keepdims=False) |
Compute the median along the specified axis.
Returns the median of the array elements.
Parameters
----------
a : array_like
Input array or object that can be converted to an array.
axis : int, optional
Axis along which the medians are computed. The default (None) is
to... |
Compute the median along the specified axis. | def median(a, axis=None, out=None, overwrite_input=False, keepdims=False):
"""
Compute the median along the specified axis.
Returns the median of the array elements.
Parameters
----------
a : array_like
Input array or object that can be converted to an array.
axis : int, optional
... | [
"def",
"median",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"overwrite_input",
"=",
"False",
",",
"keepdims",
"=",
"False",
")",
":",
"if",
"not",
"hasattr",
"(",
"a",
",",
"'mask'",
")",
":",
"m",
"=",
"np",
".",
"median",... | [
637,
0
] | [
717,
16
] | python | en | ['en', 'error', 'th'] | False |
compress_nd | (x, axis=None) | Suppress slices from multiple dimensions which contain masked values.
Parameters
----------
x : array_like, MaskedArray
The array to operate on. If not a MaskedArray instance (or if no array
elements are masked, `x` is interpreted as a MaskedArray with `mask`
set to `nomask`.
ax... | Suppress slices from multiple dimensions which contain masked values. | def compress_nd(x, axis=None):
"""Suppress slices from multiple dimensions which contain masked values.
Parameters
----------
x : array_like, MaskedArray
The array to operate on. If not a MaskedArray instance (or if no array
elements are masked, `x` is interpreted as a MaskedArray with ... | [
"def",
"compress_nd",
"(",
"x",
",",
"axis",
"=",
"None",
")",
":",
"x",
"=",
"asarray",
"(",
"x",
")",
"m",
"=",
"getmask",
"(",
"x",
")",
"# Set axis to tuple of ints",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"tuple",
"(",
"range",
"(",
"x"... | [
805,
0
] | [
845,
15
] | python | en | ['en', 'en', 'en'] | True |
compress_rowcols | (x, axis=None) |
Suppress the rows and/or columns of a 2-D array that contain
masked values.
The suppression behavior is selected with the `axis` parameter.
- If axis is None, both rows and columns are suppressed.
- If axis is 0, only rows are suppressed.
- If axis is 1 or -1, only columns are suppressed.
... |
Suppress the rows and/or columns of a 2-D array that contain
masked values. | def compress_rowcols(x, axis=None):
"""
Suppress the rows and/or columns of a 2-D array that contain
masked values.
The suppression behavior is selected with the `axis` parameter.
- If axis is None, both rows and columns are suppressed.
- If axis is 0, only rows are suppressed.
- If axis i... | [
"def",
"compress_rowcols",
"(",
"x",
",",
"axis",
"=",
"None",
")",
":",
"if",
"asarray",
"(",
"x",
")",
".",
"ndim",
"!=",
"2",
":",
"raise",
"NotImplementedError",
"(",
"\"compress_rowcols works for 2D arrays only.\"",
")",
"return",
"compress_nd",
"(",
"x",... | [
847,
0
] | [
899,
36
] | python | en | ['en', 'error', 'th'] | False |
compress_rows | (a) |
Suppress whole rows of a 2-D array that contain masked values.
This is equivalent to ``np.ma.compress_rowcols(a, 0)``, see
`extras.compress_rowcols` for details.
See Also
--------
extras.compress_rowcols
|
Suppress whole rows of a 2-D array that contain masked values. | def compress_rows(a):
"""
Suppress whole rows of a 2-D array that contain masked values.
This is equivalent to ``np.ma.compress_rowcols(a, 0)``, see
`extras.compress_rowcols` for details.
See Also
--------
extras.compress_rowcols
"""
a = asarray(a)
if a.ndim != 2:
rais... | [
"def",
"compress_rows",
"(",
"a",
")",
":",
"a",
"=",
"asarray",
"(",
"a",
")",
"if",
"a",
".",
"ndim",
"!=",
"2",
":",
"raise",
"NotImplementedError",
"(",
"\"compress_rows works for 2D arrays only.\"",
")",
"return",
"compress_rowcols",
"(",
"a",
",",
"0",... | [
902,
0
] | [
917,
33
] | python | en | ['en', 'error', 'th'] | False |
compress_cols | (a) |
Suppress whole columns of a 2-D array that contain masked values.
This is equivalent to ``np.ma.compress_rowcols(a, 1)``, see
`extras.compress_rowcols` for details.
See Also
--------
extras.compress_rowcols
|
Suppress whole columns of a 2-D array that contain masked values. | def compress_cols(a):
"""
Suppress whole columns of a 2-D array that contain masked values.
This is equivalent to ``np.ma.compress_rowcols(a, 1)``, see
`extras.compress_rowcols` for details.
See Also
--------
extras.compress_rowcols
"""
a = asarray(a)
if a.ndim != 2:
r... | [
"def",
"compress_cols",
"(",
"a",
")",
":",
"a",
"=",
"asarray",
"(",
"a",
")",
"if",
"a",
".",
"ndim",
"!=",
"2",
":",
"raise",
"NotImplementedError",
"(",
"\"compress_cols works for 2D arrays only.\"",
")",
"return",
"compress_rowcols",
"(",
"a",
",",
"1",... | [
919,
0
] | [
934,
33
] | python | en | ['en', 'error', 'th'] | False |
mask_rows | (a, axis=None) |
Mask rows of a 2D array that contain masked values.
This function is a shortcut to ``mask_rowcols`` with `axis` equal to 0.
See Also
--------
mask_rowcols : Mask rows and/or columns of a 2D array.
masked_where : Mask where a condition is met.
Examples
--------
>>> import numpy.ma... |
Mask rows of a 2D array that contain masked values. | def mask_rows(a, axis=None):
"""
Mask rows of a 2D array that contain masked values.
This function is a shortcut to ``mask_rowcols`` with `axis` equal to 0.
See Also
--------
mask_rowcols : Mask rows and/or columns of a 2D array.
masked_where : Mask where a condition is met.
Examples
... | [
"def",
"mask_rows",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"return",
"mask_rowcols",
"(",
"a",
",",
"0",
")"
] | [
936,
0
] | [
978,
29
] | python | en | ['en', 'error', 'th'] | False |
mask_cols | (a, axis=None) |
Mask columns of a 2D array that contain masked values.
This function is a shortcut to ``mask_rowcols`` with `axis` equal to 1.
See Also
--------
mask_rowcols : Mask rows and/or columns of a 2D array.
masked_where : Mask where a condition is met.
Examples
--------
>>> import numpy... |
Mask columns of a 2D array that contain masked values. | def mask_cols(a, axis=None):
"""
Mask columns of a 2D array that contain masked values.
This function is a shortcut to ``mask_rowcols`` with `axis` equal to 1.
See Also
--------
mask_rowcols : Mask rows and/or columns of a 2D array.
masked_where : Mask where a condition is met.
Exampl... | [
"def",
"mask_cols",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"return",
"mask_rowcols",
"(",
"a",
",",
"1",
")"
] | [
980,
0
] | [
1021,
29
] | python | en | ['en', 'error', 'th'] | False |
ediff1d | (arr, to_end=None, to_begin=None) |
Compute the differences between consecutive elements of an array.
This function is the equivalent of `numpy.ediff1d` that takes masked
values into account, see `numpy.ediff1d` for details.
See Also
--------
numpy.ediff1d : Equivalent function for ndarrays.
|
Compute the differences between consecutive elements of an array. | def ediff1d(arr, to_end=None, to_begin=None):
"""
Compute the differences between consecutive elements of an array.
This function is the equivalent of `numpy.ediff1d` that takes masked
values into account, see `numpy.ediff1d` for details.
See Also
--------
numpy.ediff1d : Equivalent functi... | [
"def",
"ediff1d",
"(",
"arr",
",",
"to_end",
"=",
"None",
",",
"to_begin",
"=",
"None",
")",
":",
"arr",
"=",
"ma",
".",
"asanyarray",
"(",
"arr",
")",
".",
"flat",
"ed",
"=",
"arr",
"[",
"1",
":",
"]",
"-",
"arr",
"[",
":",
"-",
"1",
"]",
... | [
1028,
0
] | [
1054,
13
] | python | en | ['en', 'error', 'th'] | False |
unique | (ar1, return_index=False, return_inverse=False) |
Finds the unique elements of an array.
Masked values are considered the same element (masked). The output array
is always a masked array. See `numpy.unique` for more details.
See Also
--------
numpy.unique : Equivalent function for ndarrays.
|
Finds the unique elements of an array. | def unique(ar1, return_index=False, return_inverse=False):
"""
Finds the unique elements of an array.
Masked values are considered the same element (masked). The output array
is always a masked array. See `numpy.unique` for more details.
See Also
--------
numpy.unique : Equivalent function... | [
"def",
"unique",
"(",
"ar1",
",",
"return_index",
"=",
"False",
",",
"return_inverse",
"=",
"False",
")",
":",
"output",
"=",
"np",
".",
"unique",
"(",
"ar1",
",",
"return_index",
"=",
"return_index",
",",
"return_inverse",
"=",
"return_inverse",
")",
"if"... | [
1057,
0
] | [
1078,
17
] | python | en | ['en', 'error', 'th'] | False |
intersect1d | (ar1, ar2, assume_unique=False) |
Returns the unique elements common to both arrays.
Masked values are considered equal one to the other.
The output is always a masked array.
See `numpy.intersect1d` for more details.
See Also
--------
numpy.intersect1d : Equivalent function for ndarrays.
Examples
--------
>>... |
Returns the unique elements common to both arrays. | def intersect1d(ar1, ar2, assume_unique=False):
"""
Returns the unique elements common to both arrays.
Masked values are considered equal one to the other.
The output is always a masked array.
See `numpy.intersect1d` for more details.
See Also
--------
numpy.intersect1d : Equivalent f... | [
"def",
"intersect1d",
"(",
"ar1",
",",
"ar2",
",",
"assume_unique",
"=",
"False",
")",
":",
"if",
"assume_unique",
":",
"aux",
"=",
"ma",
".",
"concatenate",
"(",
"(",
"ar1",
",",
"ar2",
")",
")",
"else",
":",
"# Might be faster than unique( intersect1d( ar1... | [
1081,
0
] | [
1110,
40
] | python | en | ['en', 'error', 'th'] | False |
setxor1d | (ar1, ar2, assume_unique=False) |
Set exclusive-or of 1-D arrays with unique elements.
The output is always a masked array. See `numpy.setxor1d` for more details.
See Also
--------
numpy.setxor1d : Equivalent function for ndarrays.
|
Set exclusive-or of 1-D arrays with unique elements. | def setxor1d(ar1, ar2, assume_unique=False):
"""
Set exclusive-or of 1-D arrays with unique elements.
The output is always a masked array. See `numpy.setxor1d` for more details.
See Also
--------
numpy.setxor1d : Equivalent function for ndarrays.
"""
if not assume_unique:
ar1 ... | [
"def",
"setxor1d",
"(",
"ar1",
",",
"ar2",
",",
"assume_unique",
"=",
"False",
")",
":",
"if",
"not",
"assume_unique",
":",
"ar1",
"=",
"unique",
"(",
"ar1",
")",
"ar2",
"=",
"unique",
"(",
"ar2",
")",
"aux",
"=",
"ma",
".",
"concatenate",
"(",
"("... | [
1113,
0
] | [
1137,
21
] | python | en | ['en', 'error', 'th'] | False |
in1d | (ar1, ar2, assume_unique=False, invert=False) |
Test whether each element of an array is also present in a second
array.
The output is always a masked array. See `numpy.in1d` for more details.
We recommend using :func:`isin` instead of `in1d` for new code.
See Also
--------
isin : Version of this function that preserves the shap... |
Test whether each element of an array is also present in a second
array. | def in1d(ar1, ar2, assume_unique=False, invert=False):
"""
Test whether each element of an array is also present in a second
array.
The output is always a masked array. See `numpy.in1d` for more details.
We recommend using :func:`isin` instead of `in1d` for new code.
See Also
--------
... | [
"def",
"in1d",
"(",
"ar1",
",",
"ar2",
",",
"assume_unique",
"=",
"False",
",",
"invert",
"=",
"False",
")",
":",
"if",
"not",
"assume_unique",
":",
"ar1",
",",
"rev_idx",
"=",
"unique",
"(",
"ar1",
",",
"return_inverse",
"=",
"True",
")",
"ar2",
"="... | [
1140,
0
] | [
1179,
34
] | python | en | ['en', 'error', 'th'] | False |
isin | (element, test_elements, assume_unique=False, invert=False) |
Calculates `element in test_elements`, broadcasting over
`element` only.
The output is always a masked array of the same shape as `element`.
See `numpy.isin` for more details.
See Also
--------
in1d : Flattened version of this function.
numpy.isin : Equivalent function for ndarr... |
Calculates `element in test_elements`, broadcasting over
`element` only. | def isin(element, test_elements, assume_unique=False, invert=False):
"""
Calculates `element in test_elements`, broadcasting over
`element` only.
The output is always a masked array of the same shape as `element`.
See `numpy.isin` for more details.
See Also
--------
in1d : Flatte... | [
"def",
"isin",
"(",
"element",
",",
"test_elements",
",",
"assume_unique",
"=",
"False",
",",
"invert",
"=",
"False",
")",
":",
"element",
"=",
"ma",
".",
"asarray",
"(",
"element",
")",
"return",
"in1d",
"(",
"element",
",",
"test_elements",
",",
"assum... | [
1182,
0
] | [
1202,
53
] | python | en | ['en', 'error', 'th'] | False |
union1d | (ar1, ar2) |
Union of two arrays.
The output is always a masked array. See `numpy.union1d` for more details.
See also
--------
numpy.union1d : Equivalent function for ndarrays.
|
Union of two arrays. | def union1d(ar1, ar2):
"""
Union of two arrays.
The output is always a masked array. See `numpy.union1d` for more details.
See also
--------
numpy.union1d : Equivalent function for ndarrays.
"""
return unique(ma.concatenate((ar1, ar2), axis=None)) | [
"def",
"union1d",
"(",
"ar1",
",",
"ar2",
")",
":",
"return",
"unique",
"(",
"ma",
".",
"concatenate",
"(",
"(",
"ar1",
",",
"ar2",
")",
",",
"axis",
"=",
"None",
")",
")"
] | [
1205,
0
] | [
1216,
56
] | python | en | ['en', 'error', 'th'] | False |
setdiff1d | (ar1, ar2, assume_unique=False) |
Set difference of 1D arrays with unique elements.
The output is always a masked array. See `numpy.setdiff1d` for more
details.
See Also
--------
numpy.setdiff1d : Equivalent function for ndarrays.
Examples
--------
>>> x = np.ma.array([1, 2, 3, 4], mask=[0, 1, 0, 1])
>>> np.m... |
Set difference of 1D arrays with unique elements. | def setdiff1d(ar1, ar2, assume_unique=False):
"""
Set difference of 1D arrays with unique elements.
The output is always a masked array. See `numpy.setdiff1d` for more
details.
See Also
--------
numpy.setdiff1d : Equivalent function for ndarrays.
Examples
--------
>>> x = np.m... | [
"def",
"setdiff1d",
"(",
"ar1",
",",
"ar2",
",",
"assume_unique",
"=",
"False",
")",
":",
"if",
"assume_unique",
":",
"ar1",
"=",
"ma",
".",
"asarray",
"(",
"ar1",
")",
".",
"ravel",
"(",
")",
"else",
":",
"ar1",
"=",
"unique",
"(",
"ar1",
")",
"... | [
1219,
0
] | [
1244,
63
] | python | en | ['en', 'error', 'th'] | False |
_covhelper | (x, y=None, rowvar=True, allow_masked=True) |
Private function for the computation of covariance and correlation
coefficients.
|
Private function for the computation of covariance and correlation
coefficients. | def _covhelper(x, y=None, rowvar=True, allow_masked=True):
"""
Private function for the computation of covariance and correlation
coefficients.
"""
x = ma.array(x, ndmin=2, copy=True, dtype=float)
xmask = ma.getmaskarray(x)
# Quick exit if we can't process masked data
if not allow_maske... | [
"def",
"_covhelper",
"(",
"x",
",",
"y",
"=",
"None",
",",
"rowvar",
"=",
"True",
",",
"allow_masked",
"=",
"True",
")",
":",
"x",
"=",
"ma",
".",
"array",
"(",
"x",
",",
"ndmin",
"=",
"2",
",",
"copy",
"=",
"True",
",",
"dtype",
"=",
"float",
... | [
1252,
0
] | [
1292,
32
] | python | en | ['en', 'error', 'th'] | False |
cov | (x, y=None, rowvar=True, bias=False, allow_masked=True, ddof=None) |
Estimate the covariance matrix.
Except for the handling of missing data this function does the same as
`numpy.cov`. For more details and examples, see `numpy.cov`.
By default, masked values are recognized as such. If `x` and `y` have the
same shape, a common mask is allocated: if ``x[i,j]`` is ma... |
Estimate the covariance matrix. | def cov(x, y=None, rowvar=True, bias=False, allow_masked=True, ddof=None):
"""
Estimate the covariance matrix.
Except for the handling of missing data this function does the same as
`numpy.cov`. For more details and examples, see `numpy.cov`.
By default, masked values are recognized as such. If `x... | [
"def",
"cov",
"(",
"x",
",",
"y",
"=",
"None",
",",
"rowvar",
"=",
"True",
",",
"bias",
"=",
"False",
",",
"allow_masked",
"=",
"True",
",",
"ddof",
"=",
"None",
")",
":",
"# Check inputs",
"if",
"ddof",
"is",
"not",
"None",
"and",
"ddof",
"!=",
... | [
1295,
0
] | [
1365,
17
] | python | en | ['en', 'error', 'th'] | False |
corrcoef | (x, y=None, rowvar=True, bias=np._NoValue, allow_masked=True,
ddof=np._NoValue) |
Return Pearson product-moment correlation coefficients.
Except for the handling of missing data this function does the same as
`numpy.corrcoef`. For more details and examples, see `numpy.corrcoef`.
Parameters
----------
x : array_like
A 1-D or 2-D array containing multiple variables a... |
Return Pearson product-moment correlation coefficients. | def corrcoef(x, y=None, rowvar=True, bias=np._NoValue, allow_masked=True,
ddof=np._NoValue):
"""
Return Pearson product-moment correlation coefficients.
Except for the handling of missing data this function does the same as
`numpy.corrcoef`. For more details and examples, see `numpy.corrco... | [
"def",
"corrcoef",
"(",
"x",
",",
"y",
"=",
"None",
",",
"rowvar",
"=",
"True",
",",
"bias",
"=",
"np",
".",
"_NoValue",
",",
"allow_masked",
"=",
"True",
",",
"ddof",
"=",
"np",
".",
"_NoValue",
")",
":",
"msg",
"=",
"'bias and ddof have no effect and... | [
1368,
0
] | [
1452,
21
] | python | en | ['en', 'error', 'th'] | False |
flatnotmasked_edges | (a) |
Find the indices of the first and last unmasked values.
Expects a 1-D `MaskedArray`, returns None if all values are masked.
Parameters
----------
a : array_like
Input 1-D `MaskedArray`
Returns
-------
edges : ndarray or None
The indices of first and last non-masked va... |
Find the indices of the first and last unmasked values. | def flatnotmasked_edges(a):
"""
Find the indices of the first and last unmasked values.
Expects a 1-D `MaskedArray`, returns None if all values are masked.
Parameters
----------
a : array_like
Input 1-D `MaskedArray`
Returns
-------
edges : ndarray or None
The indi... | [
"def",
"flatnotmasked_edges",
"(",
"a",
")",
":",
"m",
"=",
"getmask",
"(",
"a",
")",
"if",
"m",
"is",
"nomask",
"or",
"not",
"np",
".",
"any",
"(",
"m",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"0",
",",
"a",
".",
"size",
"-",
"1",
... | [
1515,
0
] | [
1567,
19
] | python | en | ['en', 'error', 'th'] | False |
notmasked_edges | (a, axis=None) |
Find the indices of the first and last unmasked values along an axis.
If all values are masked, return None. Otherwise, return a list
of two tuples, corresponding to the indices of the first and last
unmasked values respectively.
Parameters
----------
a : array_like
The input arr... |
Find the indices of the first and last unmasked values along an axis. | def notmasked_edges(a, axis=None):
"""
Find the indices of the first and last unmasked values along an axis.
If all values are masked, return None. Otherwise, return a list
of two tuples, corresponding to the indices of the first and last
unmasked values respectively.
Parameters
---------... | [
"def",
"notmasked_edges",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"a",
"=",
"asarray",
"(",
"a",
")",
"if",
"axis",
"is",
"None",
"or",
"a",
".",
"ndim",
"==",
"1",
":",
"return",
"flatnotmasked_edges",
"(",
"a",
")",
"m",
"=",
"getmaskarray"... | [
1570,
0
] | [
1618,
76
] | python | en | ['en', 'error', 'th'] | False |
flatnotmasked_contiguous | (a) |
Find contiguous unmasked data in a masked array along the given axis.
Parameters
----------
a : narray
The input array.
Returns
-------
slice_list : list
A sorted sequence of `slice` objects (start index, end index).
..versionchanged:: 1.15.0
Now retur... |
Find contiguous unmasked data in a masked array along the given axis. | def flatnotmasked_contiguous(a):
"""
Find contiguous unmasked data in a masked array along the given axis.
Parameters
----------
a : narray
The input array.
Returns
-------
slice_list : list
A sorted sequence of `slice` objects (start index, end index).
..versi... | [
"def",
"flatnotmasked_contiguous",
"(",
"a",
")",
":",
"m",
"=",
"getmask",
"(",
"a",
")",
"if",
"m",
"is",
"nomask",
":",
"return",
"[",
"slice",
"(",
"0",
",",
"a",
".",
"size",
")",
"]",
"i",
"=",
"0",
"result",
"=",
"[",
"]",
"for",
"(",
... | [
1621,
0
] | [
1675,
17
] | python | en | ['en', 'error', 'th'] | False |
notmasked_contiguous | (a, axis=None) |
Find contiguous unmasked data in a masked array along the given axis.
Parameters
----------
a : array_like
The input array.
axis : int, optional
Axis along which to perform the operation.
If None (default), applies to a flattened version of the array, and this
is th... |
Find contiguous unmasked data in a masked array along the given axis. | def notmasked_contiguous(a, axis=None):
"""
Find contiguous unmasked data in a masked array along the given axis.
Parameters
----------
a : array_like
The input array.
axis : int, optional
Axis along which to perform the operation.
If None (default), applies to a flatten... | [
"def",
"notmasked_contiguous",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"a",
"=",
"asarray",
"(",
"a",
")",
"nd",
"=",
"a",
".",
"ndim",
"if",
"nd",
">",
"2",
":",
"raise",
"NotImplementedError",
"(",
"\"Currently limited to atmost 2D array.\"",
")",
... | [
1677,
0
] | [
1751,
17
] | python | en | ['en', 'error', 'th'] | False |
_ezclump | (mask) |
Finds the clumps (groups of data with the same values) for a 1D bool array.
Returns a series of slices.
|
Finds the clumps (groups of data with the same values) for a 1D bool array. | def _ezclump(mask):
"""
Finds the clumps (groups of data with the same values) for a 1D bool array.
Returns a series of slices.
"""
if mask.ndim > 1:
mask = mask.ravel()
idx = (mask[1:] ^ mask[:-1]).nonzero()
idx = idx[0] + 1
if mask[0]:
if len(idx) == 0:
re... | [
"def",
"_ezclump",
"(",
"mask",
")",
":",
"if",
"mask",
".",
"ndim",
">",
"1",
":",
"mask",
"=",
"mask",
".",
"ravel",
"(",
")",
"idx",
"=",
"(",
"mask",
"[",
"1",
":",
"]",
"^",
"mask",
"[",
":",
"-",
"1",
"]",
")",
".",
"nonzero",
"(",
... | [
1754,
0
] | [
1780,
12
] | python | en | ['en', 'error', 'th'] | False |
clump_unmasked | (a) |
Return list of slices corresponding to the unmasked clumps of a 1-D array.
(A "clump" is defined as a contiguous region of the array).
Parameters
----------
a : ndarray
A one-dimensional masked array.
Returns
-------
slices : list of slice
The list of slices, one for e... |
Return list of slices corresponding to the unmasked clumps of a 1-D array.
(A "clump" is defined as a contiguous region of the array). | def clump_unmasked(a):
"""
Return list of slices corresponding to the unmasked clumps of a 1-D array.
(A "clump" is defined as a contiguous region of the array).
Parameters
----------
a : ndarray
A one-dimensional masked array.
Returns
-------
slices : list of slice
... | [
"def",
"clump_unmasked",
"(",
"a",
")",
":",
"mask",
"=",
"getattr",
"(",
"a",
",",
"'_mask'",
",",
"nomask",
")",
"if",
"mask",
"is",
"nomask",
":",
"return",
"[",
"slice",
"(",
"0",
",",
"a",
".",
"size",
")",
"]",
"return",
"_ezclump",
"(",
"~... | [
1783,
0
] | [
1819,
26
] | python | en | ['en', 'error', 'th'] | False |
clump_masked | (a) |
Returns a list of slices corresponding to the masked clumps of a 1-D array.
(A "clump" is defined as a contiguous region of the array).
Parameters
----------
a : ndarray
A one-dimensional masked array.
Returns
-------
slices : list of slice
The list of slices, one for ... |
Returns a list of slices corresponding to the masked clumps of a 1-D array.
(A "clump" is defined as a contiguous region of the array). | def clump_masked(a):
"""
Returns a list of slices corresponding to the masked clumps of a 1-D array.
(A "clump" is defined as a contiguous region of the array).
Parameters
----------
a : ndarray
A one-dimensional masked array.
Returns
-------
slices : list of slice
... | [
"def",
"clump_masked",
"(",
"a",
")",
":",
"mask",
"=",
"ma",
".",
"getmask",
"(",
"a",
")",
"if",
"mask",
"is",
"nomask",
":",
"return",
"[",
"]",
"return",
"_ezclump",
"(",
"mask",
")"
] | [
1822,
0
] | [
1858,
25
] | python | en | ['en', 'error', 'th'] | False |
vander | (x, n=None) |
Masked values in the input array result in rows of zeros.
|
Masked values in the input array result in rows of zeros. | def vander(x, n=None):
"""
Masked values in the input array result in rows of zeros.
"""
_vander = np.vander(x, n)
m = getmask(x)
if m is not nomask:
_vander[m] = 0
return _vander | [
"def",
"vander",
"(",
"x",
",",
"n",
"=",
"None",
")",
":",
"_vander",
"=",
"np",
".",
"vander",
"(",
"x",
",",
"n",
")",
"m",
"=",
"getmask",
"(",
"x",
")",
"if",
"m",
"is",
"not",
"nomask",
":",
"_vander",
"[",
"m",
"]",
"=",
"0",
"return... | [
1866,
0
] | [
1875,
18
] | python | en | ['en', 'error', 'th'] | False |
polyfit | (x, y, deg, rcond=None, full=False, w=None, cov=False) |
Any masked values in x is propagated in y, and vice-versa.
|
Any masked values in x is propagated in y, and vice-versa. | def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False):
"""
Any masked values in x is propagated in y, and vice-versa.
"""
x = asarray(x)
y = asarray(y)
m = getmask(x)
if y.ndim == 1:
m = mask_or(m, getmask(y))
elif y.ndim == 2:
my = getmask(mask_rows(y))
... | [
"def",
"polyfit",
"(",
"x",
",",
"y",
",",
"deg",
",",
"rcond",
"=",
"None",
",",
"full",
"=",
"False",
",",
"w",
"=",
"None",
",",
"cov",
"=",
"False",
")",
":",
"x",
"=",
"asarray",
"(",
"x",
")",
"y",
"=",
"asarray",
"(",
"y",
")",
"m",
... | [
1880,
0
] | [
1912,
57
] | python | en | ['en', 'error', 'th'] | False |
_fromnxfunction.getdoc | (self) |
Retrieve the docstring and signature from the function.
The ``__doc__`` attribute of the function is used as the docstring for
the new masked array version of the function. A note on application
of the function to the mask is appended.
.. warning::
If the function do... |
Retrieve the docstring and signature from the function. | def getdoc(self):
"""
Retrieve the docstring and signature from the function.
The ``__doc__`` attribute of the function is used as the docstring for
the new masked array version of the function. A note on application
of the function to the mask is appended.
.. warning::... | [
"def",
"getdoc",
"(",
"self",
")",
":",
"npfunc",
"=",
"getattr",
"(",
"np",
",",
"self",
".",
"__name__",
",",
"None",
")",
"doc",
"=",
"getattr",
"(",
"npfunc",
",",
"'__doc__'",
",",
"None",
")",
"if",
"doc",
":",
"sig",
"=",
"self",
".",
"__n... | [
240,
4
] | [
265,
14
] | python | en | ['en', 'error', 'th'] | False |
TestIndexErrors.test_arraytypes_fasttake | (self) | take from a 0-length dimension | take from a 0-length dimension | def test_arraytypes_fasttake(self):
'take from a 0-length dimension'
x = np.empty((2, 3, 0, 4))
assert_raises(IndexError, x.take, [0], axis=2)
assert_raises(IndexError, x.take, [1], axis=2)
assert_raises(IndexError, x.take, [0], axis=2, mode='wrap')
assert_raises(IndexErr... | [
"def",
"test_arraytypes_fasttake",
"(",
"self",
")",
":",
"x",
"=",
"np",
".",
"empty",
"(",
"(",
"2",
",",
"3",
",",
"0",
",",
"4",
")",
")",
"assert_raises",
"(",
"IndexError",
",",
"x",
".",
"take",
",",
"[",
"0",
"]",
",",
"axis",
"=",
"2",... | [
8,
4
] | [
14,
67
] | python | en | ['en', 'en', 'en'] | True |
TestIndexErrors.test_iterators_exceptions | (self) | cases in iterators.c | cases in iterators.c | def test_iterators_exceptions(self):
"cases in iterators.c"
def assign(obj, ind, val):
obj[ind] = val
a = np.zeros([1, 2, 3])
assert_raises(IndexError, lambda: a[0, 5, None, 2])
assert_raises(IndexError, lambda: a[0, 5, 0, 2])
assert_raises(IndexError, lambda... | [
"def",
"test_iterators_exceptions",
"(",
"self",
")",
":",
"def",
"assign",
"(",
"obj",
",",
"ind",
",",
"val",
")",
":",
"obj",
"[",
"ind",
"]",
"=",
"val",
"a",
"=",
"np",
".",
"zeros",
"(",
"[",
"1",
",",
"2",
",",
"3",
"]",
")",
"assert_rai... | [
50,
4
] | [
84,
76
] | python | en | ['en', 'la', 'it'] | False |
TestIndexErrors.test_mapping | (self) | cases from mapping.c | cases from mapping.c | def test_mapping(self):
"cases from mapping.c"
def assign(obj, ind, val):
obj[ind] = val
a = np.zeros((0, 10))
assert_raises(IndexError, lambda: a[12])
a = np.zeros((3, 5))
assert_raises(IndexError, lambda: a[(10, 20)])
assert_raises(IndexError, lam... | [
"def",
"test_mapping",
"(",
"self",
")",
":",
"def",
"assign",
"(",
"obj",
",",
"ind",
",",
"val",
")",
":",
"obj",
"[",
"ind",
"]",
"=",
"val",
"a",
"=",
"np",
".",
"zeros",
"(",
"(",
"0",
",",
"10",
")",
")",
"assert_raises",
"(",
"IndexError... | [
86,
4
] | [
112,
68
] | python | en | ['en', 'en', 'en'] | True |
TestIndexErrors.test_methods | (self) | cases from methods.c | cases from methods.c | def test_methods(self):
"cases from methods.c"
a = np.zeros((3, 3))
assert_raises(IndexError, lambda: a.item(100))
assert_raises(IndexError, lambda: a.itemset(100, 1))
a = np.zeros((0, 3))
assert_raises(IndexError, lambda: a.item(100))
assert_raises(IndexError, l... | [
"def",
"test_methods",
"(",
"self",
")",
":",
"a",
"=",
"np",
".",
"zeros",
"(",
"(",
"3",
",",
"3",
")",
")",
"assert_raises",
"(",
"IndexError",
",",
"lambda",
":",
"a",
".",
"item",
"(",
"100",
")",
")",
"assert_raises",
"(",
"IndexError",
",",
... | [
114,
4
] | [
122,
60
] | python | en | ['en', 'en', 'en'] | True |
compute_similarity_transform | (source_points, target_points) | Computes a similarity transform (sR, t) that takes a set of 3D points
source_points (N x 3) closest to a set of 3D points target_points, where R
is an 3x3 rotation matrix, t 3x1 translation, s scale. And return the
transformed 3D points source_points_hat (N x 3). i.e. solves the orthogonal
Procrutes pro... | Computes a similarity transform (sR, t) that takes a set of 3D points
source_points (N x 3) closest to a set of 3D points target_points, where R
is an 3x3 rotation matrix, t 3x1 translation, s scale. And return the
transformed 3D points source_points_hat (N x 3). i.e. solves the orthogonal
Procrutes pro... | def compute_similarity_transform(source_points, target_points):
"""Computes a similarity transform (sR, t) that takes a set of 3D points
source_points (N x 3) closest to a set of 3D points target_points, where R
is an 3x3 rotation matrix, t 3x1 translation, s scale. And return the
transformed 3D points ... | [
"def",
"compute_similarity_transform",
"(",
"source_points",
",",
"target_points",
")",
":",
"assert",
"target_points",
".",
"shape",
"[",
"0",
"]",
"==",
"source_points",
".",
"shape",
"[",
"0",
"]",
"assert",
"target_points",
".",
"shape",
"[",
"1",
"]",
"... | [
8,
0
] | [
65,
28
] | python | en | ['en', 'en', 'en'] | True |
make_preprocessing | (filepath: str) | Clean and prepare the dataframe of the input filepath to train machine learning models.
:param filepath: String with the filepath of the dataframe to be preprocessed
:type filepath: str
:return: A pandas Dataframe with the data preprocessed
:rtype: pd.DataFrame
| Clean and prepare the dataframe of the input filepath to train machine learning models. | def make_preprocessing(filepath: str) -> pd.DataFrame:
"""Clean and prepare the dataframe of the input filepath to train machine learning models.
:param filepath: String with the filepath of the dataframe to be preprocessed
:type filepath: str
:return: A pandas Dataframe with the data preprocessed
... | [
"def",
"make_preprocessing",
"(",
"filepath",
":",
"str",
")",
"->",
"pd",
".",
"DataFrame",
":",
"# Load a dataframe to preprocess from the given filepath",
"data",
"=",
"prp",
".",
"read_dataset",
"(",
"filepath",
")",
"# Clean the dataset of lost values",
"drop_duplica... | [
19,
0
] | [
122,
41
] | python | en | ['en', 'en', 'en'] | True |
train_models | (X: np.ndarray, t: np.ndarray) | Train different models using the dataset and its labels.
:param X: Input values of the dataset
:type X: numpy.ndarray
:param t: Label values for the exit of the dataset
:type t: numpy.ndarray
:return: A tuple containing the results of the training, and the best_models and best_DNN tuples of the mod... | Train different models using the dataset and its labels. | def train_models(X: np.ndarray, t: np.ndarray) -> tuple:
"""Train different models using the dataset and its labels.
:param X: Input values of the dataset
:type X: numpy.ndarray
:param t: Label values for the exit of the dataset
:type t: numpy.ndarray
:return: A tuple containing the results of ... | [
"def",
"train_models",
"(",
"X",
":",
"np",
".",
"ndarray",
",",
"t",
":",
"np",
".",
"ndarray",
")",
"->",
"tuple",
":",
"# Wrapper function of optimize_models and optimize_DNN functions in hyperparameters modules",
"# Ask user for the training trials, epochs, folds and if usi... | [
125,
0
] | [
163,
51
] | python | en | ['en', 'en', 'en'] | True |
make_report | (
df_dict: dict,
features_list: list,
results: pd.DataFrame,
best_models: tuple,
best_DNN: tuple,
time_log: tuple,
) | Generate a report taking into account the given data.
:param df_dict: Dictionary with pandas Dataframes to be included in the report
:type df_dict: dict
:param features_list: List with the features taken from the preprocessing
:type features_list: list
:param results: Pandas Dataframe with the resu... | Generate a report taking into account the given data. | def make_report(
df_dict: dict,
features_list: list,
results: pd.DataFrame,
best_models: tuple,
best_DNN: tuple,
time_log: tuple,
):
"""Generate a report taking into account the given data.
:param df_dict: Dictionary with pandas Dataframes to be included in the report
:type df_dict:... | [
"def",
"make_report",
"(",
"df_dict",
":",
"dict",
",",
"features_list",
":",
"list",
",",
"results",
":",
"pd",
".",
"DataFrame",
",",
"best_models",
":",
"tuple",
",",
"best_DNN",
":",
"tuple",
",",
"time_log",
":",
"tuple",
",",
")",
":",
"# Processin... | [
166,
0
] | [
471,
40
] | python | en | ['en', 'en', 'en'] | True |
InceptionV3.__init__ | (self,
output_blocks=[DEFAULT_BLOCK_INDEX],
resize_input=False,
normalize_input=True,
requires_grad=False) | Build pretrained InceptionV3
Parameters
----------
output_blocks : list of int
Indices of blocks to return features of. Possible values are:
- 0: corresponds to output of first max pooling
- 1: corresponds to output of second max pooling
... | Build pretrained InceptionV3 | def __init__(self,
output_blocks=[DEFAULT_BLOCK_INDEX],
resize_input=False,
normalize_input=True,
requires_grad=False):
"""Build pretrained InceptionV3
Parameters
----------
output_blocks : list of int
Indic... | [
"def",
"__init__",
"(",
"self",
",",
"output_blocks",
"=",
"[",
"DEFAULT_BLOCK_INDEX",
"]",
",",
"resize_input",
"=",
"False",
",",
"normalize_input",
"=",
"True",
",",
"requires_grad",
"=",
"False",
")",
":",
"super",
"(",
"InceptionV3",
",",
"self",
")",
... | [
20,
4
] | [
111,
47
] | python | en | ['en', 'it', 'en'] | True |
InceptionV3.forward | (self, inp) | Get Inception feature maps
Parameters
----------
inp : torch.autograd.Variable
Input tensor of shape Bx3xHxW. Values are expected to be in
range (0, 1)
Returns
-------
List of torch.autograd.Variable, corresponding to the selected output
... | Get Inception feature maps | def forward(self, inp):
"""Get Inception feature maps
Parameters
----------
inp : torch.autograd.Variable
Input tensor of shape Bx3xHxW. Values are expected to be in
range (0, 1)
Returns
-------
List of torch.autograd.Variable, correspond... | [
"def",
"forward",
"(",
"self",
",",
"inp",
")",
":",
"outp",
"=",
"[",
"]",
"x",
"=",
"inp",
"if",
"self",
".",
"resize_input",
":",
"x",
"=",
"F",
".",
"upsample",
"(",
"x",
",",
"size",
"=",
"(",
"299",
",",
"299",
")",
",",
"mode",
"=",
... | [
113,
4
] | [
147,
19
] | python | en | ['de', 'en', 'en'] | True |
test_wrong_params | (reduce, mdmc_reduce, num_classes, inputs, ignore_index) | Test a combination of parameters that are invalid and should raise an error.
This includes invalid ``reduce`` and ``mdmc_reduce`` parameter values, not setting
``num_classes`` when ``reduce='macro'`, not setting ``mdmc_reduce`` when inputs
are multi-dim multi-class``, setting ``ignore_index`` when inputs a... | Test a combination of parameters that are invalid and should raise an error. | def test_wrong_params(reduce, mdmc_reduce, num_classes, inputs, ignore_index):
"""Test a combination of parameters that are invalid and should raise an error.
This includes invalid ``reduce`` and ``mdmc_reduce`` parameter values, not setting
``num_classes`` when ``reduce='macro'`, not setting ``mdmc_reduce... | [
"def",
"test_wrong_params",
"(",
"reduce",
",",
"mdmc_reduce",
",",
"num_classes",
",",
"inputs",
",",
"ignore_index",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
")",
":",
"stat_scores",
"(",
"inputs",
".",
"preds",
"[",
"0",
"]",
",",
... | [
94,
0
] | [
109,
46
] | python | en | ['en', 'en', 'en'] | True |
test_top_k | (k: int, preds: torch.Tensor, target: torch.Tensor, reduce: str, expected: torch.Tensor) | A simple test to check that top_k works as expected | A simple test to check that top_k works as expected | def test_top_k(k: int, preds: torch.Tensor, target: torch.Tensor, reduce: str, expected: torch.Tensor):
""" A simple test to check that top_k works as expected """
class_metric = StatScores(top_k=k, reduce=reduce, num_classes=3)
class_metric.update(preds, target)
assert torch.equal(class_metric.comput... | [
"def",
"test_top_k",
"(",
"k",
":",
"int",
",",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"reduce",
":",
"str",
",",
"expected",
":",
"torch",
".",
"Tensor",
")",
":",
"class_metric",
"=",
"StatScores",
"(... | [
247,
0
] | [
254,
101
] | python | en | ['en', 'en', 'en'] | True |
main | (args: argparse.Namespace) | Train the model.
Args:
args: Model hyper-parameters
Note:
For the sake of the example, the images dataset will be downloaded
to a temporary directory.
| Train the model. | def main(args: argparse.Namespace) -> None:
"""Train the model.
Args:
args: Model hyper-parameters
Note:
For the sake of the example, the images dataset will be downloaded
to a temporary directory.
"""
datamodule = CatDogImageDataModule(
dl_path=os.path.join(args.r... | [
"def",
"main",
"(",
"args",
":",
"argparse",
".",
"Namespace",
")",
"->",
"None",
":",
"datamodule",
"=",
"CatDogImageDataModule",
"(",
"dl_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"args",
".",
"root_data_path",
",",
"'data'",
")",
",",
"batch_si... | [
307,
0
] | [
333,
45
] | python | en | ['en', 'it', 'en'] | True |
CatDogImageDataModule.prepare_data | (self) | Download images and prepare images datasets. | Download images and prepare images datasets. | def prepare_data(self):
"""Download images and prepare images datasets."""
download_and_extract_archive(url=DATA_URL, download_root=self._dl_path, remove_finished=True) | [
"def",
"prepare_data",
"(",
"self",
")",
":",
"download_and_extract_archive",
"(",
"url",
"=",
"DATA_URL",
",",
"download_root",
"=",
"self",
".",
"_dl_path",
",",
"remove_finished",
"=",
"True",
")"
] | [
103,
4
] | [
105,
101
] | python | en | ['en', 'en', 'en'] | True |
CatDogImageDataModule.__dataloader | (self, train: bool) | Train/validation loaders. | Train/validation loaders. | def __dataloader(self, train: bool):
"""Train/validation loaders."""
if train:
dataset = self.create_dataset(self.data_path.joinpath("train"), self.train_transform)
else:
dataset = self.create_dataset(self.data_path.joinpath("validation"), self.valid_transform)
re... | [
"def",
"__dataloader",
"(",
"self",
",",
"train",
":",
"bool",
")",
":",
"if",
"train",
":",
"dataset",
"=",
"self",
".",
"create_dataset",
"(",
"self",
".",
"data_path",
".",
"joinpath",
"(",
"\"train\"",
")",
",",
"self",
".",
"train_transform",
")",
... | [
130,
4
] | [
136,
117
] | python | en | ['es', 'et', 'en'] | False |
TransferLearningModel.__init__ | (
self,
backbone: str = "resnet50",
train_bn: bool = True,
milestones: tuple = (5, 10),
batch_size: int = 32,
lr: float = 1e-2,
lr_scheduler_gamma: float = 1e-1,
num_workers: int = 6,
**kwargs,
) |
Args:
dl_path: Path where the data will be downloaded
|
Args:
dl_path: Path where the data will be downloaded
| def __init__(
self,
backbone: str = "resnet50",
train_bn: bool = True,
milestones: tuple = (5, 10),
batch_size: int = 32,
lr: float = 1e-2,
lr_scheduler_gamma: float = 1e-1,
num_workers: int = 6,
**kwargs,
) -> None:
"""
Args:
... | [
"def",
"__init__",
"(",
"self",
",",
"backbone",
":",
"str",
"=",
"\"resnet50\"",
",",
"train_bn",
":",
"bool",
"=",
"True",
",",
"milestones",
":",
"tuple",
"=",
"(",
"5",
",",
"10",
")",
",",
"batch_size",
":",
"int",
"=",
"32",
",",
"lr",
":",
... | [
163,
4
] | [
191,
35
] | python | en | ['en', 'error', 'th'] | False |
TransferLearningModel.__build_model | (self) | Define model layers & loss. | Define model layers & loss. | def __build_model(self):
"""Define model layers & loss."""
# 1. Load pre-trained network:
model_func = getattr(models, self.backbone)
backbone = model_func(pretrained=True)
_layers = list(backbone.children())[:-1]
self.feature_extractor = nn.Sequential(*_layers)
... | [
"def",
"__build_model",
"(",
"self",
")",
":",
"# 1. Load pre-trained network:",
"model_func",
"=",
"getattr",
"(",
"models",
",",
"self",
".",
"backbone",
")",
"backbone",
"=",
"model_func",
"(",
"pretrained",
"=",
"True",
")",
"_layers",
"=",
"list",
"(",
... | [
193,
4
] | [
213,
59
] | python | en | ['es', 'it', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.