repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
albahnsen/CostSensitiveClassification | costcla/models/bagging.py | BaseBagging._fit_stacking_model | def _fit_stacking_model(self,X, y, cost_mat, max_iter=100):
"""Private function used to fit the stacking model."""
self.f_staking = CostSensitiveLogisticRegression(verbose=self.verbose, max_iter=max_iter)
X_stacking = _create_stacking_set(self.estimators_, self.estimators_features_,
... | python | def _fit_stacking_model(self,X, y, cost_mat, max_iter=100):
"""Private function used to fit the stacking model."""
self.f_staking = CostSensitiveLogisticRegression(verbose=self.verbose, max_iter=max_iter)
X_stacking = _create_stacking_set(self.estimators_, self.estimators_features_,
... | [
"def",
"_fit_stacking_model",
"(",
"self",
",",
"X",
",",
"y",
",",
"cost_mat",
",",
"max_iter",
"=",
"100",
")",
":",
"self",
".",
"f_staking",
"=",
"CostSensitiveLogisticRegression",
"(",
"verbose",
"=",
"self",
".",
"verbose",
",",
"max_iter",
"=",
"max... | Private function used to fit the stacking model. | [
"Private",
"function",
"used",
"to",
"fit",
"the",
"stacking",
"model",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/bagging.py#L302-L308 | train |
albahnsen/CostSensitiveClassification | costcla/models/bagging.py | BaseBagging._evaluate_oob_savings | def _evaluate_oob_savings(self, X, y, cost_mat):
"""Private function used to calculate the OOB Savings of each estimator."""
estimators_weight = []
for estimator, samples, features in zip(self.estimators_, self.estimators_samples_,
self.estimators_... | python | def _evaluate_oob_savings(self, X, y, cost_mat):
"""Private function used to calculate the OOB Savings of each estimator."""
estimators_weight = []
for estimator, samples, features in zip(self.estimators_, self.estimators_samples_,
self.estimators_... | [
"def",
"_evaluate_oob_savings",
"(",
"self",
",",
"X",
",",
"y",
",",
"cost_mat",
")",
":",
"estimators_weight",
"=",
"[",
"]",
"for",
"estimator",
",",
"samples",
",",
"features",
"in",
"zip",
"(",
"self",
".",
"estimators_",
",",
"self",
".",
"estimato... | Private function used to calculate the OOB Savings of each estimator. | [
"Private",
"function",
"used",
"to",
"calculate",
"the",
"OOB",
"Savings",
"of",
"each",
"estimator",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/bagging.py#L311-L334 | train |
albahnsen/CostSensitiveClassification | costcla/models/bagging.py | BaggingClassifier.predict | def predict(self, X, cost_mat=None):
"""Predict class for X.
The predicted class of an input sample is computed as the class with
the highest mean predicted probability. If base estimators do not
implement a ``predict_proba`` method, then it resorts to voting.
Parameters
... | python | def predict(self, X, cost_mat=None):
"""Predict class for X.
The predicted class of an input sample is computed as the class with
the highest mean predicted probability. If base estimators do not
implement a ``predict_proba`` method, then it resorts to voting.
Parameters
... | [
"def",
"predict",
"(",
"self",
",",
"X",
",",
"cost_mat",
"=",
"None",
")",
":",
"if",
"self",
".",
"n_features_",
"!=",
"X",
".",
"shape",
"[",
"1",
"]",
":",
"raise",
"ValueError",
"(",
"\"Number of features of the model must \"",
"\"match the input. Model n... | Predict class for X.
The predicted class of an input sample is computed as the class with
the highest mean predicted probability. If base estimators do not
implement a ``predict_proba`` method, then it resorts to voting.
Parameters
----------
X : {array-like, sparse mat... | [
"Predict",
"class",
"for",
"X",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/bagging.py#L491-L554 | train |
albahnsen/CostSensitiveClassification | costcla/models/bagging.py | BaggingClassifier.predict_proba | def predict_proba(self, X):
"""Predict class probabilities for X.
The predicted class probabilities of an input sample is computed as
the mean predicted class probabilities of the base estimators in the
ensemble. If base estimators do not implement a ``predict_proba``
method, th... | python | def predict_proba(self, X):
"""Predict class probabilities for X.
The predicted class probabilities of an input sample is computed as
the mean predicted class probabilities of the base estimators in the
ensemble. If base estimators do not implement a ``predict_proba``
method, th... | [
"def",
"predict_proba",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"n_features_",
"!=",
"X",
".",
"shape",
"[",
"1",
"]",
":",
"raise",
"ValueError",
"(",
"\"Number of features of the model must \"",
"\"match the input. Model n_features is {0} and \"",
"\"i... | Predict class probabilities for X.
The predicted class probabilities of an input sample is computed as
the mean predicted class probabilities of the base estimators in the
ensemble. If base estimators do not implement a ``predict_proba``
method, then it resorts to voting and the predict... | [
"Predict",
"class",
"probabilities",
"for",
"X",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/bagging.py#L556-L610 | train |
albahnsen/CostSensitiveClassification | costcla/sampling/cost_sampling.py | cost_sampling | def cost_sampling(X, y, cost_mat, method='RejectionSampling', oversampling_norm=0.1, max_wc=97.5):
"""Cost-proportionate sampling.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y : array-like of shape = [n_samples]
Ground... | python | def cost_sampling(X, y, cost_mat, method='RejectionSampling', oversampling_norm=0.1, max_wc=97.5):
"""Cost-proportionate sampling.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y : array-like of shape = [n_samples]
Ground... | [
"def",
"cost_sampling",
"(",
"X",
",",
"y",
",",
"cost_mat",
",",
"method",
"=",
"'RejectionSampling'",
",",
"oversampling_norm",
"=",
"0.1",
",",
"max_wc",
"=",
"97.5",
")",
":",
"cost_mis",
"=",
"cost_mat",
"[",
":",
",",
"0",
"]",
"cost_mis",
"[",
"... | Cost-proportionate sampling.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y : array-like of shape = [n_samples]
Ground truth (correct) labels.
cost_mat : array-like of shape = [n_samples, 4]
Cost matrix ... | [
"Cost",
"-",
"proportionate",
"sampling",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/sampling/cost_sampling.py#L11-L123 | train |
albahnsen/CostSensitiveClassification | costcla/datasets/base.py | _creditscoring_costmat | def _creditscoring_costmat(income, debt, pi_1, cost_mat_parameters):
""" Private function to calculate the cost matrix of credit scoring models.
Parameters
----------
income : array of shape = [n_samples]
Monthly income of each example
debt : array of shape = [n_samples]
Debt ratio... | python | def _creditscoring_costmat(income, debt, pi_1, cost_mat_parameters):
""" Private function to calculate the cost matrix of credit scoring models.
Parameters
----------
income : array of shape = [n_samples]
Monthly income of each example
debt : array of shape = [n_samples]
Debt ratio... | [
"def",
"_creditscoring_costmat",
"(",
"income",
",",
"debt",
",",
"pi_1",
",",
"cost_mat_parameters",
")",
":",
"def",
"calculate_a",
"(",
"cl_i",
",",
"int_",
",",
"n_term",
")",
":",
"return",
"cl_i",
"*",
"(",
"(",
"int_",
"*",
"(",
"1",
"+",
"int_"... | Private function to calculate the cost matrix of credit scoring models.
Parameters
----------
income : array of shape = [n_samples]
Monthly income of each example
debt : array of shape = [n_samples]
Debt ratio each example
pi_1 : float
Percentage of positives in the traini... | [
"Private",
"function",
"to",
"calculate",
"the",
"cost",
"matrix",
"of",
"credit",
"scoring",
"models",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/datasets/base.py#L336-L415 | train |
albahnsen/CostSensitiveClassification | costcla/probcal/probcal.py | ROCConvexHull.predict_proba | def predict_proba(self, p):
""" Calculate the calibrated probabilities
Parameters
----------
y_prob : array-like of shape = [n_samples, 2]
Predicted probabilities to be calibrated using calibration map
Returns
-------
y_prob_cal : array-like of shape... | python | def predict_proba(self, p):
""" Calculate the calibrated probabilities
Parameters
----------
y_prob : array-like of shape = [n_samples, 2]
Predicted probabilities to be calibrated using calibration map
Returns
-------
y_prob_cal : array-like of shape... | [
"def",
"predict_proba",
"(",
"self",
",",
"p",
")",
":",
"if",
"p",
".",
"size",
"!=",
"p",
".",
"shape",
"[",
"0",
"]",
":",
"p",
"=",
"p",
"[",
":",
",",
"1",
"]",
"calibrated_proba",
"=",
"np",
".",
"zeros",
"(",
"p",
".",
"shape",
"[",
... | Calculate the calibrated probabilities
Parameters
----------
y_prob : array-like of shape = [n_samples, 2]
Predicted probabilities to be calibrated using calibration map
Returns
-------
y_prob_cal : array-like of shape = [n_samples, 1]
Predicted ... | [
"Calculate",
"the",
"calibrated",
"probabilities"
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/probcal/probcal.py#L137-L161 | train |
albahnsen/CostSensitiveClassification | costcla/utils/cross_validation.py | cross_val_score | def cross_val_score(estimator, X, y=None, scoring=None, cv=None, n_jobs=1,
verbose=0, fit_params=None, pre_dispatch='2*n_jobs'):
"""Evaluate a score by cross-validation
Parameters
----------
estimator : estimator object implementing 'fit'
The object to use to fit the data.
... | python | def cross_val_score(estimator, X, y=None, scoring=None, cv=None, n_jobs=1,
verbose=0, fit_params=None, pre_dispatch='2*n_jobs'):
"""Evaluate a score by cross-validation
Parameters
----------
estimator : estimator object implementing 'fit'
The object to use to fit the data.
... | [
"def",
"cross_val_score",
"(",
"estimator",
",",
"X",
",",
"y",
"=",
"None",
",",
"scoring",
"=",
"None",
",",
"cv",
"=",
"None",
",",
"n_jobs",
"=",
"1",
",",
"verbose",
"=",
"0",
",",
"fit_params",
"=",
"None",
",",
"pre_dispatch",
"=",
"'2*n_jobs'... | Evaluate a score by cross-validation
Parameters
----------
estimator : estimator object implementing 'fit'
The object to use to fit the data.
X : array-like
The data to fit. Can be, for example a list, or an array at least 2d.
y : array-like, optional, default: None
The ta... | [
"Evaluate",
"a",
"score",
"by",
"cross",
"-",
"validation"
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/utils/cross_validation.py#L1080-L1151 | train |
albahnsen/CostSensitiveClassification | costcla/utils/cross_validation.py | _safe_split | def _safe_split(estimator, X, y, indices, train_indices=None):
"""Create subset of dataset and properly handle kernels."""
if hasattr(estimator, 'kernel') and isinstance(estimator.kernel, collections.Callable):
# cannot compute the kernel values with custom function
raise ValueError("Cannot use ... | python | def _safe_split(estimator, X, y, indices, train_indices=None):
"""Create subset of dataset and properly handle kernels."""
if hasattr(estimator, 'kernel') and isinstance(estimator.kernel, collections.Callable):
# cannot compute the kernel values with custom function
raise ValueError("Cannot use ... | [
"def",
"_safe_split",
"(",
"estimator",
",",
"X",
",",
"y",
",",
"indices",
",",
"train_indices",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"estimator",
",",
"'kernel'",
")",
"and",
"isinstance",
"(",
"estimator",
".",
"kernel",
",",
"collections",
".... | Create subset of dataset and properly handle kernels. | [
"Create",
"subset",
"of",
"dataset",
"and",
"properly",
"handle",
"kernels",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/utils/cross_validation.py#L1258-L1287 | train |
albahnsen/CostSensitiveClassification | costcla/utils/cross_validation.py | _score | def _score(estimator, X_test, y_test, scorer):
"""Compute the score of an estimator on a given test set."""
if y_test is None:
score = scorer(estimator, X_test)
else:
score = scorer(estimator, X_test, y_test)
if not isinstance(score, numbers.Number):
raise ValueError("scoring mus... | python | def _score(estimator, X_test, y_test, scorer):
"""Compute the score of an estimator on a given test set."""
if y_test is None:
score = scorer(estimator, X_test)
else:
score = scorer(estimator, X_test, y_test)
if not isinstance(score, numbers.Number):
raise ValueError("scoring mus... | [
"def",
"_score",
"(",
"estimator",
",",
"X_test",
",",
"y_test",
",",
"scorer",
")",
":",
"if",
"y_test",
"is",
"None",
":",
"score",
"=",
"scorer",
"(",
"estimator",
",",
"X_test",
")",
"else",
":",
"score",
"=",
"scorer",
"(",
"estimator",
",",
"X_... | Compute the score of an estimator on a given test set. | [
"Compute",
"the",
"score",
"of",
"an",
"estimator",
"on",
"a",
"given",
"test",
"set",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/utils/cross_validation.py#L1290-L1299 | train |
albahnsen/CostSensitiveClassification | costcla/utils/cross_validation.py | _shuffle | def _shuffle(y, labels, random_state):
"""Return a shuffled copy of y eventually shuffle among same labels."""
if labels is None:
ind = random_state.permutation(len(y))
else:
ind = np.arange(len(labels))
for label in np.unique(labels):
this_mask = (labels == label)
... | python | def _shuffle(y, labels, random_state):
"""Return a shuffled copy of y eventually shuffle among same labels."""
if labels is None:
ind = random_state.permutation(len(y))
else:
ind = np.arange(len(labels))
for label in np.unique(labels):
this_mask = (labels == label)
... | [
"def",
"_shuffle",
"(",
"y",
",",
"labels",
",",
"random_state",
")",
":",
"if",
"labels",
"is",
"None",
":",
"ind",
"=",
"random_state",
".",
"permutation",
"(",
"len",
"(",
"y",
")",
")",
"else",
":",
"ind",
"=",
"np",
".",
"arange",
"(",
"len",
... | Return a shuffled copy of y eventually shuffle among same labels. | [
"Return",
"a",
"shuffled",
"copy",
"of",
"y",
"eventually",
"shuffle",
"among",
"same",
"labels",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/utils/cross_validation.py#L1311-L1320 | train |
albahnsen/CostSensitiveClassification | costcla/utils/cross_validation.py | check_cv | def check_cv(cv, X=None, y=None, classifier=False):
"""Input checker utility for building a CV in a user friendly way.
Parameters
----------
cv : int, a cv generator instance, or None
The input specifying which cv generator to use. It can be an
integer, in which case it is the number of... | python | def check_cv(cv, X=None, y=None, classifier=False):
"""Input checker utility for building a CV in a user friendly way.
Parameters
----------
cv : int, a cv generator instance, or None
The input specifying which cv generator to use. It can be an
integer, in which case it is the number of... | [
"def",
"check_cv",
"(",
"cv",
",",
"X",
"=",
"None",
",",
"y",
"=",
"None",
",",
"classifier",
"=",
"False",
")",
":",
"return",
"_check_cv",
"(",
"cv",
",",
"X",
"=",
"X",
",",
"y",
"=",
"y",
",",
"classifier",
"=",
"classifier",
",",
"warn_mask... | Input checker utility for building a CV in a user friendly way.
Parameters
----------
cv : int, a cv generator instance, or None
The input specifying which cv generator to use. It can be an
integer, in which case it is the number of folds in a KFold,
None, in which case 3 fold is us... | [
"Input",
"checker",
"utility",
"for",
"building",
"a",
"CV",
"in",
"a",
"user",
"friendly",
"way",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/utils/cross_validation.py#L1323-L1350 | train |
albahnsen/CostSensitiveClassification | costcla/sampling/_smote.py | _borderlineSMOTE | def _borderlineSMOTE(X, y, minority_target, N, k):
"""
Returns synthetic minority samples.
Parameters
----------
X : array-like, shape = [n__samples, n_features]
Holds the minority and majority samples
y : array-like, shape = [n__samples]
Holds the class targets for samples
... | python | def _borderlineSMOTE(X, y, minority_target, N, k):
"""
Returns synthetic minority samples.
Parameters
----------
X : array-like, shape = [n__samples, n_features]
Holds the minority and majority samples
y : array-like, shape = [n__samples]
Holds the class targets for samples
... | [
"def",
"_borderlineSMOTE",
"(",
"X",
",",
"y",
",",
"minority_target",
",",
"N",
",",
"k",
")",
":",
"n_samples",
",",
"_",
"=",
"X",
".",
"shape",
"neigh",
"=",
"NearestNeighbors",
"(",
"n_neighbors",
"=",
"k",
")",
"neigh",
".",
"fit",
"(",
"X",
... | Returns synthetic minority samples.
Parameters
----------
X : array-like, shape = [n__samples, n_features]
Holds the minority and majority samples
y : array-like, shape = [n__samples]
Holds the class targets for samples
minority_target : value for minority class
N : percetange o... | [
"Returns",
"synthetic",
"minority",
"samples",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/sampling/_smote.py#L91-L147 | train |
albahnsen/CostSensitiveClassification | costcla/models/directcost.py | BayesMinimumRiskClassifier.fit | def fit(self,y_true_cal=None, y_prob_cal=None):
""" If calibration, then train the calibration of probabilities
Parameters
----------
y_true_cal : array-like of shape = [n_samples], optional default = None
True class to be used for calibrating the probabilities
y_pr... | python | def fit(self,y_true_cal=None, y_prob_cal=None):
""" If calibration, then train the calibration of probabilities
Parameters
----------
y_true_cal : array-like of shape = [n_samples], optional default = None
True class to be used for calibrating the probabilities
y_pr... | [
"def",
"fit",
"(",
"self",
",",
"y_true_cal",
"=",
"None",
",",
"y_prob_cal",
"=",
"None",
")",
":",
"if",
"self",
".",
"calibration",
":",
"self",
".",
"cal",
"=",
"ROCConvexHull",
"(",
")",
"self",
".",
"cal",
".",
"fit",
"(",
"y_true_cal",
",",
... | If calibration, then train the calibration of probabilities
Parameters
----------
y_true_cal : array-like of shape = [n_samples], optional default = None
True class to be used for calibrating the probabilities
y_prob_cal : array-like of shape = [n_samples, 2], optional defa... | [
"If",
"calibration",
"then",
"train",
"the",
"calibration",
"of",
"probabilities"
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/directcost.py#L56-L74 | train |
albahnsen/CostSensitiveClassification | costcla/models/directcost.py | ThresholdingOptimization.fit | def fit(self, y_prob, cost_mat, y_true):
""" Calculate the optimal threshold using the ThresholdingOptimization.
Parameters
----------
y_prob : array-like of shape = [n_samples, 2]
Predicted probabilities.
cost_mat : array-like of shape = [n_samples, 4]
... | python | def fit(self, y_prob, cost_mat, y_true):
""" Calculate the optimal threshold using the ThresholdingOptimization.
Parameters
----------
y_prob : array-like of shape = [n_samples, 2]
Predicted probabilities.
cost_mat : array-like of shape = [n_samples, 4]
... | [
"def",
"fit",
"(",
"self",
",",
"y_prob",
",",
"cost_mat",
",",
"y_true",
")",
":",
"if",
"self",
".",
"calibration",
":",
"cal",
"=",
"ROCConvexHull",
"(",
")",
"cal",
".",
"fit",
"(",
"y_true",
",",
"y_prob",
"[",
":",
",",
"1",
"]",
")",
"y_pr... | Calculate the optimal threshold using the ThresholdingOptimization.
Parameters
----------
y_prob : array-like of shape = [n_samples, 2]
Predicted probabilities.
cost_mat : array-like of shape = [n_samples, 4]
Cost matrix of the classification problem
... | [
"Calculate",
"the",
"optimal",
"threshold",
"using",
"the",
"ThresholdingOptimization",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/directcost.py#L199-L238 | train |
albahnsen/CostSensitiveClassification | costcla/models/directcost.py | ThresholdingOptimization.predict | def predict(self, y_prob):
""" Calculate the prediction using the ThresholdingOptimization.
Parameters
----------
y_prob : array-like of shape = [n_samples, 2]
Predicted probabilities.
Returns
-------
y_pred : array-like of shape = [n_samples]
... | python | def predict(self, y_prob):
""" Calculate the prediction using the ThresholdingOptimization.
Parameters
----------
y_prob : array-like of shape = [n_samples, 2]
Predicted probabilities.
Returns
-------
y_pred : array-like of shape = [n_samples]
... | [
"def",
"predict",
"(",
"self",
",",
"y_prob",
")",
":",
"y_pred",
"=",
"np",
".",
"floor",
"(",
"y_prob",
"[",
":",
",",
"1",
"]",
"+",
"(",
"1",
"-",
"self",
".",
"threshold_",
")",
")",
"return",
"y_pred"
] | Calculate the prediction using the ThresholdingOptimization.
Parameters
----------
y_prob : array-like of shape = [n_samples, 2]
Predicted probabilities.
Returns
-------
y_pred : array-like of shape = [n_samples]
Predicted class | [
"Calculate",
"the",
"prediction",
"using",
"the",
"ThresholdingOptimization",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/directcost.py#L240-L255 | train |
albahnsen/CostSensitiveClassification | costcla/sampling/sampling.py | undersampling | def undersampling(X, y, cost_mat=None, per=0.5):
"""Under-sampling.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y : array-like of shape = [n_samples]
Ground truth (correct) labels.
cost_mat : array-like of shap... | python | def undersampling(X, y, cost_mat=None, per=0.5):
"""Under-sampling.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y : array-like of shape = [n_samples]
Ground truth (correct) labels.
cost_mat : array-like of shap... | [
"def",
"undersampling",
"(",
"X",
",",
"y",
",",
"cost_mat",
"=",
"None",
",",
"per",
"=",
"0.5",
")",
":",
"n_samples",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
"num_y1",
"=",
"y",
".",
"sum",
"(",
")",
"num_y0",
"=",
"n_samples",
"-",
"num_y1",
... | Under-sampling.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y : array-like of shape = [n_samples]
Ground truth (correct) labels.
cost_mat : array-like of shape = [n_samples, 4], optional (default=None)
... | [
"Under",
"-",
"sampling",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/sampling/sampling.py#L11-L57 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier._node_cost | def _node_cost(self, y_true, cost_mat):
""" Private function to calculate the cost of a node.
Parameters
----------
y_true : array indicator matrix
Ground truth (correct) labels.
cost_mat : array-like of shape = [n_samples, 4]
Cost matrix of the classifi... | python | def _node_cost(self, y_true, cost_mat):
""" Private function to calculate the cost of a node.
Parameters
----------
y_true : array indicator matrix
Ground truth (correct) labels.
cost_mat : array-like of shape = [n_samples, 4]
Cost matrix of the classifi... | [
"def",
"_node_cost",
"(",
"self",
",",
"y_true",
",",
"cost_mat",
")",
":",
"n_samples",
"=",
"len",
"(",
"y_true",
")",
"costs",
"=",
"np",
".",
"zeros",
"(",
"2",
")",
"costs",
"[",
"0",
"]",
"=",
"cost_loss",
"(",
"y_true",
",",
"np",
".",
"ze... | Private function to calculate the cost of a node.
Parameters
----------
y_true : array indicator matrix
Ground truth (correct) labels.
cost_mat : array-like of shape = [n_samples, 4]
Cost matrix of the classification problem
Where the columns represe... | [
"Private",
"function",
"to",
"calculate",
"the",
"cost",
"of",
"a",
"node",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L138-L183 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier._calculate_gain | def _calculate_gain(self, cost_base, y_true, X, cost_mat, split):
""" Private function to calculate the gain in cost of using split in the
current node.
Parameters
----------
cost_base : float
Cost of the naive prediction
y_true : array indicator matrix
... | python | def _calculate_gain(self, cost_base, y_true, X, cost_mat, split):
""" Private function to calculate the gain in cost of using split in the
current node.
Parameters
----------
cost_base : float
Cost of the naive prediction
y_true : array indicator matrix
... | [
"def",
"_calculate_gain",
"(",
"self",
",",
"cost_base",
",",
"y_true",
",",
"X",
",",
"cost_mat",
",",
"split",
")",
":",
"if",
"cost_base",
"==",
"0.0",
":",
"return",
"0.0",
",",
"int",
"(",
"np",
".",
"sign",
"(",
"y_true",
".",
"mean",
"(",
")... | Private function to calculate the gain in cost of using split in the
current node.
Parameters
----------
cost_base : float
Cost of the naive prediction
y_true : array indicator matrix
Ground truth (correct) labels.
X : array-like of shape = [n_... | [
"Private",
"function",
"to",
"calculate",
"the",
"gain",
"in",
"cost",
"of",
"using",
"split",
"in",
"the",
"current",
"node",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L185-L242 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier._best_split | def _best_split(self, y_true, X, cost_mat):
""" Private function to calculate the split that gives the best gain.
Parameters
----------
y_true : array indicator matrix
Ground truth (correct) labels.
X : array-like of shape = [n_samples, n_features]
The i... | python | def _best_split(self, y_true, X, cost_mat):
""" Private function to calculate the split that gives the best gain.
Parameters
----------
y_true : array indicator matrix
Ground truth (correct) labels.
X : array-like of shape = [n_samples, n_features]
The i... | [
"def",
"_best_split",
"(",
"self",
",",
"y_true",
",",
"X",
",",
"cost_mat",
")",
":",
"n_samples",
",",
"n_features",
"=",
"X",
".",
"shape",
"num_pct",
"=",
"self",
".",
"num_pct",
"cost_base",
",",
"y_pred",
",",
"y_prob",
"=",
"self",
".",
"_node_c... | Private function to calculate the split that gives the best gain.
Parameters
----------
y_true : array indicator matrix
Ground truth (correct) labels.
X : array-like of shape = [n_samples, n_features]
The input samples.
cost_mat : array-like of shape = ... | [
"Private",
"function",
"to",
"calculate",
"the",
"split",
"that",
"gives",
"the",
"best",
"gain",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L244-L302 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier._tree_grow | def _tree_grow(self, y_true, X, cost_mat, level=0):
""" Private recursive function to grow the decision tree.
Parameters
----------
y_true : array indicator matrix
Ground truth (correct) labels.
X : array-like of shape = [n_samples, n_features]
The input... | python | def _tree_grow(self, y_true, X, cost_mat, level=0):
""" Private recursive function to grow the decision tree.
Parameters
----------
y_true : array indicator matrix
Ground truth (correct) labels.
X : array-like of shape = [n_samples, n_features]
The input... | [
"def",
"_tree_grow",
"(",
"self",
",",
"y_true",
",",
"X",
",",
"cost_mat",
",",
"level",
"=",
"0",
")",
":",
"if",
"len",
"(",
"X",
".",
"shape",
")",
"==",
"1",
":",
"tree",
"=",
"dict",
"(",
"y_pred",
"=",
"y_true",
",",
"y_prob",
"=",
"0.5"... | Private recursive function to grow the decision tree.
Parameters
----------
y_true : array indicator matrix
Ground truth (correct) labels.
X : array-like of shape = [n_samples, n_features]
The input samples.
cost_mat : array-like of shape = [n_samples, ... | [
"Private",
"recursive",
"function",
"to",
"grow",
"the",
"decision",
"tree",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L304-L369 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier._nodes | def _nodes(self, tree):
""" Private function that find the number of nodes in a tree.
Parameters
----------
tree : object
Returns
-------
nodes : array like of shape [n_nodes]
"""
def recourse(temp_tree_, nodes):
if isinstance(temp_tr... | python | def _nodes(self, tree):
""" Private function that find the number of nodes in a tree.
Parameters
----------
tree : object
Returns
-------
nodes : array like of shape [n_nodes]
"""
def recourse(temp_tree_, nodes):
if isinstance(temp_tr... | [
"def",
"_nodes",
"(",
"self",
",",
"tree",
")",
":",
"def",
"recourse",
"(",
"temp_tree_",
",",
"nodes",
")",
":",
"if",
"isinstance",
"(",
"temp_tree_",
",",
"dict",
")",
":",
"if",
"temp_tree_",
"[",
"'split'",
"]",
"!=",
"-",
"1",
":",
"nodes",
... | Private function that find the number of nodes in a tree.
Parameters
----------
tree : object
Returns
-------
nodes : array like of shape [n_nodes] | [
"Private",
"function",
"that",
"find",
"the",
"number",
"of",
"nodes",
"in",
"a",
"tree",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L444-L466 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier._classify | def _classify(self, X, tree, proba=False):
""" Private function that classify a dataset using tree.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
tree : object
proba : bool, optional (default=False)
... | python | def _classify(self, X, tree, proba=False):
""" Private function that classify a dataset using tree.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
tree : object
proba : bool, optional (default=False)
... | [
"def",
"_classify",
"(",
"self",
",",
"X",
",",
"tree",
",",
"proba",
"=",
"False",
")",
":",
"n_samples",
",",
"n_features",
"=",
"X",
".",
"shape",
"predicted",
"=",
"np",
".",
"ones",
"(",
"n_samples",
")",
"if",
"tree",
"[",
"'split'",
"]",
"==... | Private function that classify a dataset using tree.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
tree : object
proba : bool, optional (default=False)
If True then return probabilities else return class
... | [
"Private",
"function",
"that",
"classify",
"a",
"dataset",
"using",
"tree",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L468-L513 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier.predict | def predict(self, X):
""" Predict class of X.
The predicted class for each sample in X is returned.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
Returns
-------
y : array of shape = [n_samples]
... | python | def predict(self, X):
""" Predict class of X.
The predicted class for each sample in X is returned.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
Returns
-------
y : array of shape = [n_samples]
... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"pruned",
":",
"tree_",
"=",
"self",
".",
"tree_",
".",
"tree_pruned",
"else",
":",
"tree_",
"=",
"self",
".",
"tree_",
".",
"tree",
"return",
"self",
".",
"_classify",
"(",
"X",... | Predict class of X.
The predicted class for each sample in X is returned.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
Returns
-------
y : array of shape = [n_samples]
The predicted classes, | [
"Predict",
"class",
"of",
"X",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L515-L537 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier.predict_proba | def predict_proba(self, X):
"""Predict class probabilities of the input samples X.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
Returns
-------
prob : array of shape = [n_samples, 2]
The class... | python | def predict_proba(self, X):
"""Predict class probabilities of the input samples X.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
Returns
-------
prob : array of shape = [n_samples, 2]
The class... | [
"def",
"predict_proba",
"(",
"self",
",",
"X",
")",
":",
"n_samples",
",",
"n_features",
"=",
"X",
".",
"shape",
"prob",
"=",
"np",
".",
"zeros",
"(",
"(",
"n_samples",
",",
"2",
")",
")",
"if",
"self",
".",
"pruned",
":",
"tree_",
"=",
"self",
"... | Predict class probabilities of the input samples X.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
Returns
-------
prob : array of shape = [n_samples, 2]
The class probabilities of the input samples. | [
"Predict",
"class",
"probabilities",
"of",
"the",
"input",
"samples",
"X",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L539-L564 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier._delete_node | def _delete_node(self, tree, node):
""" Private function that eliminate node from tree.
Parameters
----------
tree : object
node : int
node to be eliminated from tree
Returns
-------
pruned_tree : object
"""
# Calculate gai... | python | def _delete_node(self, tree, node):
""" Private function that eliminate node from tree.
Parameters
----------
tree : object
node : int
node to be eliminated from tree
Returns
-------
pruned_tree : object
"""
# Calculate gai... | [
"def",
"_delete_node",
"(",
"self",
",",
"tree",
",",
"node",
")",
":",
"temp_tree",
"=",
"copy",
".",
"deepcopy",
"(",
"tree",
")",
"def",
"recourse",
"(",
"temp_tree_",
",",
"del_node",
")",
":",
"if",
"isinstance",
"(",
"temp_tree_",
",",
"dict",
")... | Private function that eliminate node from tree.
Parameters
----------
tree : object
node : int
node to be eliminated from tree
Returns
-------
pruned_tree : object | [
"Private",
"function",
"that",
"eliminate",
"node",
"from",
"tree",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L566-L599 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier._pruning | def _pruning(self, X, y_true, cost_mat):
""" Private function that prune the decision tree.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y_true : array indicator matrix
Ground truth (correct) labels.
... | python | def _pruning(self, X, y_true, cost_mat):
""" Private function that prune the decision tree.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y_true : array indicator matrix
Ground truth (correct) labels.
... | [
"def",
"_pruning",
"(",
"self",
",",
"X",
",",
"y_true",
",",
"cost_mat",
")",
":",
"nodes",
"=",
"self",
".",
"_nodes",
"(",
"self",
".",
"tree_",
".",
"tree_pruned",
")",
"n_nodes",
"=",
"len",
"(",
"nodes",
")",
"gains",
"=",
"np",
".",
"zeros",... | Private function that prune the decision tree.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y_true : array indicator matrix
Ground truth (correct) labels.
cost_mat : array-like of shape = [n_samples, 4]
... | [
"Private",
"function",
"that",
"prune",
"the",
"decision",
"tree",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L601-L652 | train |
albahnsen/CostSensitiveClassification | costcla/models/cost_tree.py | CostSensitiveDecisionTreeClassifier.pruning | def pruning(self, X, y, cost_mat):
""" Function that prune the decision tree.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y_true : array indicator matrix
Ground truth (correct) labels.
cost_mat : a... | python | def pruning(self, X, y, cost_mat):
""" Function that prune the decision tree.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y_true : array indicator matrix
Ground truth (correct) labels.
cost_mat : a... | [
"def",
"pruning",
"(",
"self",
",",
"X",
",",
"y",
",",
"cost_mat",
")",
":",
"self",
".",
"tree_",
".",
"tree_pruned",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"tree_",
".",
"tree",
")",
"if",
"self",
".",
"tree_",
".",
"n_nodes",
">",
"0... | Function that prune the decision tree.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
y_true : array indicator matrix
Ground truth (correct) labels.
cost_mat : array-like of shape = [n_samples, 4]
... | [
"Function",
"that",
"prune",
"the",
"decision",
"tree",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L654-L676 | train |
albahnsen/CostSensitiveClassification | costcla/metrics/costs.py | cost_loss | def cost_loss(y_true, y_pred, cost_mat):
#TODO: update description
"""Cost classification loss.
This function calculates the cost of using y_pred on y_true with
cost-matrix cost-mat. It differ from traditional classification evaluation
measures since measures such as accuracy asing the same cost to... | python | def cost_loss(y_true, y_pred, cost_mat):
#TODO: update description
"""Cost classification loss.
This function calculates the cost of using y_pred on y_true with
cost-matrix cost-mat. It differ from traditional classification evaluation
measures since measures such as accuracy asing the same cost to... | [
"def",
"cost_loss",
"(",
"y_true",
",",
"y_pred",
",",
"cost_mat",
")",
":",
"y_true",
"=",
"column_or_1d",
"(",
"y_true",
")",
"y_true",
"=",
"(",
"y_true",
"==",
"1",
")",
".",
"astype",
"(",
"np",
".",
"float",
")",
"y_pred",
"=",
"column_or_1d",
... | Cost classification loss.
This function calculates the cost of using y_pred on y_true with
cost-matrix cost-mat. It differ from traditional classification evaluation
measures since measures such as accuracy asing the same cost to different
errors, but that is not the real case in several real-world cla... | [
"Cost",
"classification",
"loss",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/metrics/costs.py#L19-L81 | train |
albahnsen/CostSensitiveClassification | costcla/metrics/costs.py | savings_score | def savings_score(y_true, y_pred, cost_mat):
#TODO: update description
"""Savings score.
This function calculates the savings cost of using y_pred on y_true with
cost-matrix cost-mat, as the difference of y_pred and the cost_loss of a naive
classification model.
Parameters
----------
y... | python | def savings_score(y_true, y_pred, cost_mat):
#TODO: update description
"""Savings score.
This function calculates the savings cost of using y_pred on y_true with
cost-matrix cost-mat, as the difference of y_pred and the cost_loss of a naive
classification model.
Parameters
----------
y... | [
"def",
"savings_score",
"(",
"y_true",
",",
"y_pred",
",",
"cost_mat",
")",
":",
"y_true",
"=",
"column_or_1d",
"(",
"y_true",
")",
"y_pred",
"=",
"column_or_1d",
"(",
"y_pred",
")",
"n_samples",
"=",
"len",
"(",
"y_true",
")",
"cost_base",
"=",
"min",
"... | Savings score.
This function calculates the savings cost of using y_pred on y_true with
cost-matrix cost-mat, as the difference of y_pred and the cost_loss of a naive
classification model.
Parameters
----------
y_true : array-like or label indicator matrix
Ground truth (correct) labels... | [
"Savings",
"score",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/metrics/costs.py#L84-L143 | train |
albahnsen/CostSensitiveClassification | costcla/metrics/costs.py | brier_score_loss | def brier_score_loss(y_true, y_prob):
"""Compute the Brier score
The smaller the Brier score, the better, hence the naming with "loss".
Across all items in a set N predictions, the Brier score measures the
mean squared difference between (1) the predicted probability assigned
to the possible outco... | python | def brier_score_loss(y_true, y_prob):
"""Compute the Brier score
The smaller the Brier score, the better, hence the naming with "loss".
Across all items in a set N predictions, the Brier score measures the
mean squared difference between (1) the predicted probability assigned
to the possible outco... | [
"def",
"brier_score_loss",
"(",
"y_true",
",",
"y_prob",
")",
":",
"y_true",
"=",
"column_or_1d",
"(",
"y_true",
")",
"y_prob",
"=",
"column_or_1d",
"(",
"y_prob",
")",
"return",
"np",
".",
"mean",
"(",
"(",
"y_true",
"-",
"y_prob",
")",
"**",
"2",
")"... | Compute the Brier score
The smaller the Brier score, the better, hence the naming with "loss".
Across all items in a set N predictions, the Brier score measures the
mean squared difference between (1) the predicted probability assigned
to the possible outcomes for item i, and (2) the actual outcome.
... | [
"Compute",
"the",
"Brier",
"score"
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/metrics/costs.py#L149-L200 | train |
albahnsen/CostSensitiveClassification | costcla/models/regression.py | _logistic_cost_loss | def _logistic_cost_loss(w, X, y, cost_mat, alpha):
"""Computes the logistic loss.
Parameters
----------
w : array-like, shape (n_w, n_features,) or (n_w, n_features + 1,)
Coefficient vector or matrix of coefficient.
X : array-like, shape (n_samples, n_features)
Training data.
... | python | def _logistic_cost_loss(w, X, y, cost_mat, alpha):
"""Computes the logistic loss.
Parameters
----------
w : array-like, shape (n_w, n_features,) or (n_w, n_features + 1,)
Coefficient vector or matrix of coefficient.
X : array-like, shape (n_samples, n_features)
Training data.
... | [
"def",
"_logistic_cost_loss",
"(",
"w",
",",
"X",
",",
"y",
",",
"cost_mat",
",",
"alpha",
")",
":",
"if",
"w",
".",
"shape",
"[",
"0",
"]",
"==",
"w",
".",
"size",
":",
"return",
"_logistic_cost_loss_i",
"(",
"w",
",",
"X",
",",
"y",
",",
"cost_... | Computes the logistic loss.
Parameters
----------
w : array-like, shape (n_w, n_features,) or (n_w, n_features + 1,)
Coefficient vector or matrix of coefficient.
X : array-like, shape (n_samples, n_features)
Training data.
y : ndarray, shape (n_samples,)
Array of labels.
... | [
"Computes",
"the",
"logistic",
"loss",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/regression.py#L58-L98 | train |
albahnsen/CostSensitiveClassification | costcla/models/regression.py | CostSensitiveLogisticRegression.predict | def predict(self, X, cut_point=0.5):
"""Predicted class.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples]
Returns the prediction of the sample..
"""
return np.fl... | python | def predict(self, X, cut_point=0.5):
"""Predicted class.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples]
Returns the prediction of the sample..
"""
return np.fl... | [
"def",
"predict",
"(",
"self",
",",
"X",
",",
"cut_point",
"=",
"0.5",
")",
":",
"return",
"np",
".",
"floor",
"(",
"self",
".",
"predict_proba",
"(",
"X",
")",
"[",
":",
",",
"1",
"]",
"+",
"(",
"1",
"-",
"cut_point",
")",
")"
] | Predicted class.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples]
Returns the prediction of the sample.. | [
"Predicted",
"class",
"."
] | 75778ae32c70671c0cdde6c4651277b6a8b58871 | https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/regression.py#L278-L290 | train |
MozillaSecurity/laniakea | laniakea/core/userdata.py | UserData.list_tags | def list_tags(userdata):
"""List all used macros within a UserData script.
:param userdata: The UserData script.
:type userdata: str
"""
macros = re.findall('@(.*?)@', userdata)
logging.info('List of available macros:')
for macro in macros:
logging.in... | python | def list_tags(userdata):
"""List all used macros within a UserData script.
:param userdata: The UserData script.
:type userdata: str
"""
macros = re.findall('@(.*?)@', userdata)
logging.info('List of available macros:')
for macro in macros:
logging.in... | [
"def",
"list_tags",
"(",
"userdata",
")",
":",
"macros",
"=",
"re",
".",
"findall",
"(",
"'@(.*?)@'",
",",
"userdata",
")",
"logging",
".",
"info",
"(",
"'List of available macros:'",
")",
"for",
"macro",
"in",
"macros",
":",
"logging",
".",
"info",
"(",
... | List all used macros within a UserData script.
:param userdata: The UserData script.
:type userdata: str | [
"List",
"all",
"used",
"macros",
"within",
"a",
"UserData",
"script",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/userdata.py#L54-L63 | train |
MozillaSecurity/laniakea | laniakea/core/userdata.py | UserData.handle_tags | def handle_tags(userdata, macros):
"""Insert macro values or auto export variables in UserData scripts.
:param userdata: The UserData script.
:type userdata: str
:param macros: UserData macros as key value pair.
:type macros: dict
:return: UserData script with the macros... | python | def handle_tags(userdata, macros):
"""Insert macro values or auto export variables in UserData scripts.
:param userdata: The UserData script.
:type userdata: str
:param macros: UserData macros as key value pair.
:type macros: dict
:return: UserData script with the macros... | [
"def",
"handle_tags",
"(",
"userdata",
",",
"macros",
")",
":",
"macro_vars",
"=",
"re",
".",
"findall",
"(",
"'@(.*?)@'",
",",
"userdata",
")",
"for",
"macro_var",
"in",
"macro_vars",
":",
"if",
"macro_var",
"==",
"'!all_macros_export'",
":",
"macro_var_expor... | Insert macro values or auto export variables in UserData scripts.
:param userdata: The UserData script.
:type userdata: str
:param macros: UserData macros as key value pair.
:type macros: dict
:return: UserData script with the macros replaced with their values.
:rtype: s... | [
"Insert",
"macro",
"values",
"or",
"auto",
"export",
"variables",
"in",
"UserData",
"scripts",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/userdata.py#L66-L109 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.retry_on_ec2_error | def retry_on_ec2_error(self, func, *args, **kwargs):
"""
Call the given method with the given arguments, retrying if the call
failed due to an EC2ResponseError. This method will wait at most 30
seconds and perform up to 6 retries. If the method still fails, it will
propagate the ... | python | def retry_on_ec2_error(self, func, *args, **kwargs):
"""
Call the given method with the given arguments, retrying if the call
failed due to an EC2ResponseError. This method will wait at most 30
seconds and perform up to 6 retries. If the method still fails, it will
propagate the ... | [
"def",
"retry_on_ec2_error",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"exception_retry_count",
"=",
"6",
"while",
"True",
":",
"try",
":",
"return",
"func",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"except",
"(",
... | Call the given method with the given arguments, retrying if the call
failed due to an EC2ResponseError. This method will wait at most 30
seconds and perform up to 6 retries. If the method still fails, it will
propagate the error.
:param func: Function to call
:type func: functio... | [
"Call",
"the",
"given",
"method",
"with",
"the",
"given",
"arguments",
"retrying",
"if",
"the",
"call",
"failed",
"due",
"to",
"an",
"EC2ResponseError",
".",
"This",
"method",
"will",
"wait",
"at",
"most",
"30",
"seconds",
"and",
"perform",
"up",
"to",
"6"... | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L36-L54 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.connect | def connect(self, region, **kw_params):
"""Connect to a EC2.
:param region: The name of the region to connect to.
:type region: str
:param kw_params:
:type kw_params: dict
"""
self.ec2 = boto.ec2.connect_to_region(region, **kw_params)
if not self.ec2:
... | python | def connect(self, region, **kw_params):
"""Connect to a EC2.
:param region: The name of the region to connect to.
:type region: str
:param kw_params:
:type kw_params: dict
"""
self.ec2 = boto.ec2.connect_to_region(region, **kw_params)
if not self.ec2:
... | [
"def",
"connect",
"(",
"self",
",",
"region",
",",
"**",
"kw_params",
")",
":",
"self",
".",
"ec2",
"=",
"boto",
".",
"ec2",
".",
"connect_to_region",
"(",
"region",
",",
"**",
"kw_params",
")",
"if",
"not",
"self",
".",
"ec2",
":",
"raise",
"EC2Mana... | Connect to a EC2.
:param region: The name of the region to connect to.
:type region: str
:param kw_params:
:type kw_params: dict | [
"Connect",
"to",
"a",
"EC2",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L56-L72 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.resolve_image_name | def resolve_image_name(self, image_name):
"""Look up an AMI for the connected region based on an image name.
:param image_name: The name of the image to resolve.
:type image_name: str
:return: The AMI for the given image.
:rtype: str
"""
# look at each scope in o... | python | def resolve_image_name(self, image_name):
"""Look up an AMI for the connected region based on an image name.
:param image_name: The name of the image to resolve.
:type image_name: str
:return: The AMI for the given image.
:rtype: str
"""
# look at each scope in o... | [
"def",
"resolve_image_name",
"(",
"self",
",",
"image_name",
")",
":",
"scopes",
"=",
"[",
"'self'",
",",
"'amazon'",
",",
"'aws-marketplace'",
"]",
"if",
"image_name",
"in",
"self",
".",
"remote_images",
":",
"return",
"self",
".",
"remote_images",
"[",
"im... | Look up an AMI for the connected region based on an image name.
:param image_name: The name of the image to resolve.
:type image_name: str
:return: The AMI for the given image.
:rtype: str | [
"Look",
"up",
"an",
"AMI",
"for",
"the",
"connected",
"region",
"based",
"on",
"an",
"image",
"name",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L74-L92 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.create_on_demand | def create_on_demand(self,
instance_type='default',
tags=None,
root_device_type='ebs',
size='default',
vol_type='gp2',
delete_on_termination=False):
"""Create one... | python | def create_on_demand(self,
instance_type='default',
tags=None,
root_device_type='ebs',
size='default',
vol_type='gp2',
delete_on_termination=False):
"""Create one... | [
"def",
"create_on_demand",
"(",
"self",
",",
"instance_type",
"=",
"'default'",
",",
"tags",
"=",
"None",
",",
"root_device_type",
"=",
"'ebs'",
",",
"size",
"=",
"'default'",
",",
"vol_type",
"=",
"'gp2'",
",",
"delete_on_termination",
"=",
"False",
")",
":... | Create one or more EC2 on-demand instances.
:param size: Size of root device
:type size: int
:param delete_on_termination:
:type delete_on_termination: boolean
:param vol_type:
:type vol_type: str
:param root_device_type: The type of the root device.
:typ... | [
"Create",
"one",
"or",
"more",
"EC2",
"on",
"-",
"demand",
"instances",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L94-L144 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.create_spot_requests | def create_spot_requests(self,
price,
instance_type='default',
root_device_type='ebs',
size='default',
vol_type='gp2',
delete_on_termination=False... | python | def create_spot_requests(self,
price,
instance_type='default',
root_device_type='ebs',
size='default',
vol_type='gp2',
delete_on_termination=False... | [
"def",
"create_spot_requests",
"(",
"self",
",",
"price",
",",
"instance_type",
"=",
"'default'",
",",
"root_device_type",
"=",
"'ebs'",
",",
"size",
"=",
"'default'",
",",
"vol_type",
"=",
"'gp2'",
",",
"delete_on_termination",
"=",
"False",
",",
"timeout",
"... | Request creation of one or more EC2 spot instances.
:param size:
:param vol_type:
:param delete_on_termination:
:param root_device_type: The type of the root device.
:type root_device_type: str
:param price: Max price to pay for spot instance per hour.
:type pric... | [
"Request",
"creation",
"of",
"one",
"or",
"more",
"EC2",
"spot",
"instances",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L146-L181 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.check_spot_requests | def check_spot_requests(self, requests, tags=None):
"""Check status of one or more EC2 spot instance requests.
:param requests: List of EC2 spot instance request IDs.
:type requests: list
:param tags:
:type tags: dict
:return: List of boto.ec2.instance.Instance's created... | python | def check_spot_requests(self, requests, tags=None):
"""Check status of one or more EC2 spot instance requests.
:param requests: List of EC2 spot instance request IDs.
:type requests: list
:param tags:
:type tags: dict
:return: List of boto.ec2.instance.Instance's created... | [
"def",
"check_spot_requests",
"(",
"self",
",",
"requests",
",",
"tags",
"=",
"None",
")",
":",
"instances",
"=",
"[",
"None",
"]",
"*",
"len",
"(",
"requests",
")",
"ec2_requests",
"=",
"self",
".",
"retry_on_ec2_error",
"(",
"self",
".",
"ec2",
".",
... | Check status of one or more EC2 spot instance requests.
:param requests: List of EC2 spot instance request IDs.
:type requests: list
:param tags:
:type tags: dict
:return: List of boto.ec2.instance.Instance's created, order corresponding to requests param (None if request
... | [
"Check",
"status",
"of",
"one",
"or",
"more",
"EC2",
"spot",
"instance",
"requests",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L183-L221 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.cancel_spot_requests | def cancel_spot_requests(self, requests):
"""Cancel one or more EC2 spot instance requests.
:param requests: List of EC2 spot instance request IDs.
:type requests: list
"""
ec2_requests = self.retry_on_ec2_error(self.ec2.get_all_spot_instance_requests, request_ids=requests)
... | python | def cancel_spot_requests(self, requests):
"""Cancel one or more EC2 spot instance requests.
:param requests: List of EC2 spot instance request IDs.
:type requests: list
"""
ec2_requests = self.retry_on_ec2_error(self.ec2.get_all_spot_instance_requests, request_ids=requests)
... | [
"def",
"cancel_spot_requests",
"(",
"self",
",",
"requests",
")",
":",
"ec2_requests",
"=",
"self",
".",
"retry_on_ec2_error",
"(",
"self",
".",
"ec2",
".",
"get_all_spot_instance_requests",
",",
"request_ids",
"=",
"requests",
")",
"for",
"req",
"in",
"ec2_requ... | Cancel one or more EC2 spot instance requests.
:param requests: List of EC2 spot instance request IDs.
:type requests: list | [
"Cancel",
"one",
"or",
"more",
"EC2",
"spot",
"instance",
"requests",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L223-L232 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.create_spot | def create_spot(self,
price,
instance_type='default',
tags=None,
root_device_type='ebs',
size='default',
vol_type='gp2',
delete_on_termination=False,
timeout=No... | python | def create_spot(self,
price,
instance_type='default',
tags=None,
root_device_type='ebs',
size='default',
vol_type='gp2',
delete_on_termination=False,
timeout=No... | [
"def",
"create_spot",
"(",
"self",
",",
"price",
",",
"instance_type",
"=",
"'default'",
",",
"tags",
"=",
"None",
",",
"root_device_type",
"=",
"'ebs'",
",",
"size",
"=",
"'default'",
",",
"vol_type",
"=",
"'gp2'",
",",
"delete_on_termination",
"=",
"False"... | Create one or more EC2 spot instances.
:param root_device_type:
:param size:
:param vol_type:
:param delete_on_termination:
:param timeout:
:param price: Max price to pay for spot instance per hour.
:type price: float
:param instance_type: A section name ... | [
"Create",
"one",
"or",
"more",
"EC2",
"spot",
"instances",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L234-L294 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager._scale_down | def _scale_down(self, instances, count):
"""Return a list of |count| last created instances by launch time.
:param instances: A list of instances.
:type instances: list
:param count: Number of instances to scale down.
:type count: integer
:return: List of instances to be... | python | def _scale_down(self, instances, count):
"""Return a list of |count| last created instances by launch time.
:param instances: A list of instances.
:type instances: list
:param count: Number of instances to scale down.
:type count: integer
:return: List of instances to be... | [
"def",
"_scale_down",
"(",
"self",
",",
"instances",
",",
"count",
")",
":",
"i",
"=",
"sorted",
"(",
"instances",
",",
"key",
"=",
"lambda",
"i",
":",
"i",
".",
"launch_time",
",",
"reverse",
"=",
"True",
")",
"if",
"not",
"i",
":",
"return",
"[",... | Return a list of |count| last created instances by launch time.
:param instances: A list of instances.
:type instances: list
:param count: Number of instances to scale down.
:type count: integer
:return: List of instances to be scaled down.
:rtype: list | [
"Return",
"a",
"list",
"of",
"|count|",
"last",
"created",
"instances",
"by",
"launch",
"time",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L296-L315 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager._configure_ebs_volume | def _configure_ebs_volume(self, vol_type, name, size, delete_on_termination):
"""Sets the desired root EBS size, otherwise the default EC2 value is used.
:param vol_type: Type of EBS storage - gp2 (SSD), io1 or standard (magnetic)
:type vol_type: str
:param size: Desired root EBS size.
... | python | def _configure_ebs_volume(self, vol_type, name, size, delete_on_termination):
"""Sets the desired root EBS size, otherwise the default EC2 value is used.
:param vol_type: Type of EBS storage - gp2 (SSD), io1 or standard (magnetic)
:type vol_type: str
:param size: Desired root EBS size.
... | [
"def",
"_configure_ebs_volume",
"(",
"self",
",",
"vol_type",
",",
"name",
",",
"size",
",",
"delete_on_termination",
")",
":",
"root_dev",
"=",
"boto",
".",
"ec2",
".",
"blockdevicemapping",
".",
"BlockDeviceType",
"(",
")",
"root_dev",
".",
"delete_on_terminat... | Sets the desired root EBS size, otherwise the default EC2 value is used.
:param vol_type: Type of EBS storage - gp2 (SSD), io1 or standard (magnetic)
:type vol_type: str
:param size: Desired root EBS size.
:type size: int
:param delete_on_termination: Toggle this flag to delete ... | [
"Sets",
"the",
"desired",
"root",
"EBS",
"size",
"otherwise",
"the",
"default",
"EC2",
"value",
"is",
"used",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L337-L357 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.stop | def stop(self, instances, count=0):
"""Stop each provided running instance.
:param count:
:param instances: A list of instances.
:type instances: list
"""
if not instances:
return
if count > 0:
instances = self._scale_down(instances, count... | python | def stop(self, instances, count=0):
"""Stop each provided running instance.
:param count:
:param instances: A list of instances.
:type instances: list
"""
if not instances:
return
if count > 0:
instances = self._scale_down(instances, count... | [
"def",
"stop",
"(",
"self",
",",
"instances",
",",
"count",
"=",
"0",
")",
":",
"if",
"not",
"instances",
":",
"return",
"if",
"count",
">",
"0",
":",
"instances",
"=",
"self",
".",
"_scale_down",
"(",
"instances",
",",
"count",
")",
"self",
".",
"... | Stop each provided running instance.
:param count:
:param instances: A list of instances.
:type instances: list | [
"Stop",
"each",
"provided",
"running",
"instance",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L359-L370 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.terminate | def terminate(self, instances, count=0):
"""Terminate each provided running or stopped instance.
:param count:
:param instances: A list of instances.
:type instances: list
"""
if not instances:
return
if count > 0:
instances = self._scale_... | python | def terminate(self, instances, count=0):
"""Terminate each provided running or stopped instance.
:param count:
:param instances: A list of instances.
:type instances: list
"""
if not instances:
return
if count > 0:
instances = self._scale_... | [
"def",
"terminate",
"(",
"self",
",",
"instances",
",",
"count",
"=",
"0",
")",
":",
"if",
"not",
"instances",
":",
"return",
"if",
"count",
">",
"0",
":",
"instances",
"=",
"self",
".",
"_scale_down",
"(",
"instances",
",",
"count",
")",
"self",
"."... | Terminate each provided running or stopped instance.
:param count:
:param instances: A list of instances.
:type instances: list | [
"Terminate",
"each",
"provided",
"running",
"or",
"stopped",
"instance",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L372-L383 | train |
MozillaSecurity/laniakea | laniakea/core/providers/ec2/manager.py | EC2Manager.find | def find(self, instance_ids=None, filters=None):
"""Flatten list of reservations to a list of instances.
:param instance_ids: A list of instance ids to filter by
:type instance_ids: list
:param filters: A dict of Filter.N values defined in http://goo.gl/jYNej9
:type filters: dic... | python | def find(self, instance_ids=None, filters=None):
"""Flatten list of reservations to a list of instances.
:param instance_ids: A list of instance ids to filter by
:type instance_ids: list
:param filters: A dict of Filter.N values defined in http://goo.gl/jYNej9
:type filters: dic... | [
"def",
"find",
"(",
"self",
",",
"instance_ids",
"=",
"None",
",",
"filters",
"=",
"None",
")",
":",
"instances",
"=",
"[",
"]",
"reservations",
"=",
"self",
".",
"retry_on_ec2_error",
"(",
"self",
".",
"ec2",
".",
"get_all_instances",
",",
"instance_ids",... | Flatten list of reservations to a list of instances.
:param instance_ids: A list of instance ids to filter by
:type instance_ids: list
:param filters: A dict of Filter.N values defined in http://goo.gl/jYNej9
:type filters: dict
:return: A flattened list of filtered instances.
... | [
"Flatten",
"list",
"of",
"reservations",
"to",
"a",
"list",
"of",
"instances",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/ec2/manager.py#L385-L399 | train |
MozillaSecurity/laniakea | laniakea/core/common.py | ModuleLoader.load | def load(self, root, module_path, pkg_name):
"""Load modules dynamically.
"""
root = os.path.join(root, module_path)
import_name = os.path.join(pkg_name, module_path).replace(os.sep, '.')
for (_, name, _) in pkgutil.iter_modules([root]):
self.modules[name] = import_mo... | python | def load(self, root, module_path, pkg_name):
"""Load modules dynamically.
"""
root = os.path.join(root, module_path)
import_name = os.path.join(pkg_name, module_path).replace(os.sep, '.')
for (_, name, _) in pkgutil.iter_modules([root]):
self.modules[name] = import_mo... | [
"def",
"load",
"(",
"self",
",",
"root",
",",
"module_path",
",",
"pkg_name",
")",
":",
"root",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"module_path",
")",
"import_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pkg_name",
",",
"mo... | Load modules dynamically. | [
"Load",
"modules",
"dynamically",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/common.py#L155-L162 | train |
MozillaSecurity/laniakea | laniakea/core/common.py | ModuleLoader.command_line_interfaces | def command_line_interfaces(self):
"""Return the CommandLine classes from each provider.
"""
interfaces = []
for _, module in self.modules.items():
for entry in dir(module):
if entry.endswith('CommandLine'):
interfaces.append((module, entry... | python | def command_line_interfaces(self):
"""Return the CommandLine classes from each provider.
"""
interfaces = []
for _, module in self.modules.items():
for entry in dir(module):
if entry.endswith('CommandLine'):
interfaces.append((module, entry... | [
"def",
"command_line_interfaces",
"(",
"self",
")",
":",
"interfaces",
"=",
"[",
"]",
"for",
"_",
",",
"module",
"in",
"self",
".",
"modules",
".",
"items",
"(",
")",
":",
"for",
"entry",
"in",
"dir",
"(",
"module",
")",
":",
"if",
"entry",
".",
"e... | Return the CommandLine classes from each provider. | [
"Return",
"the",
"CommandLine",
"classes",
"from",
"each",
"provider",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/common.py#L164-L172 | train |
MozillaSecurity/laniakea | laniakea/core/common.py | Common.pluralize | def pluralize(item):
"""Nothing to see here.
"""
assert isinstance(item, (int, list))
if isinstance(item, int):
return 's' if item > 1 else ''
if isinstance(item, list):
return 's' if len(item) > 1 else ''
return '' | python | def pluralize(item):
"""Nothing to see here.
"""
assert isinstance(item, (int, list))
if isinstance(item, int):
return 's' if item > 1 else ''
if isinstance(item, list):
return 's' if len(item) > 1 else ''
return '' | [
"def",
"pluralize",
"(",
"item",
")",
":",
"assert",
"isinstance",
"(",
"item",
",",
"(",
"int",
",",
"list",
")",
")",
"if",
"isinstance",
"(",
"item",
",",
"int",
")",
":",
"return",
"'s'",
"if",
"item",
">",
"1",
"else",
"''",
"if",
"isinstance"... | Nothing to see here. | [
"Nothing",
"to",
"see",
"here",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/common.py#L190-L198 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketConfiguration.validate | def validate(self):
"""Perform some basic configuration validation.
"""
if not self.conf.get('auth_token'):
raise PacketManagerException('The auth token for Packet is not defined but required.')
if not self.conf.get('projects'):
raise PacketManagerException('Requi... | python | def validate(self):
"""Perform some basic configuration validation.
"""
if not self.conf.get('auth_token'):
raise PacketManagerException('The auth token for Packet is not defined but required.')
if not self.conf.get('projects'):
raise PacketManagerException('Requi... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"conf",
".",
"get",
"(",
"'auth_token'",
")",
":",
"raise",
"PacketManagerException",
"(",
"'The auth token for Packet is not defined but required.'",
")",
"if",
"not",
"self",
".",
"conf",
".",... | Perform some basic configuration validation. | [
"Perform",
"some",
"basic",
"configuration",
"validation",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L31-L49 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.print_projects | def print_projects(self, projects):
"""Print method for projects.
"""
for project in projects:
print('{}: {}'.format(project.name, project.id)) | python | def print_projects(self, projects):
"""Print method for projects.
"""
for project in projects:
print('{}: {}'.format(project.name, project.id)) | [
"def",
"print_projects",
"(",
"self",
",",
"projects",
")",
":",
"for",
"project",
"in",
"projects",
":",
"print",
"(",
"'{}: {}'",
".",
"format",
"(",
"project",
".",
"name",
",",
"project",
".",
"id",
")",
")"
] | Print method for projects. | [
"Print",
"method",
"for",
"projects",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L76-L80 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.print_operating_systems | def print_operating_systems(self, operating_systems):
"""Print method for operating systems.
"""
for _os in operating_systems:
print('{}: {}'.format(_os.name, _os.slug)) | python | def print_operating_systems(self, operating_systems):
"""Print method for operating systems.
"""
for _os in operating_systems:
print('{}: {}'.format(_os.name, _os.slug)) | [
"def",
"print_operating_systems",
"(",
"self",
",",
"operating_systems",
")",
":",
"for",
"_os",
"in",
"operating_systems",
":",
"print",
"(",
"'{}: {}'",
".",
"format",
"(",
"_os",
".",
"name",
",",
"_os",
".",
"slug",
")",
")"
] | Print method for operating systems. | [
"Print",
"method",
"for",
"operating",
"systems",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L89-L93 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.print_plans | def print_plans(self, plans):
"""Print method for plans.
"""
for plan in plans:
print('Name: {} "{}" Price: {} USD'.format(plan.name, plan.slug, plan.pricing['hour']))
self.pprint(plan.specs)
print('\n') | python | def print_plans(self, plans):
"""Print method for plans.
"""
for plan in plans:
print('Name: {} "{}" Price: {} USD'.format(plan.name, plan.slug, plan.pricing['hour']))
self.pprint(plan.specs)
print('\n') | [
"def",
"print_plans",
"(",
"self",
",",
"plans",
")",
":",
"for",
"plan",
"in",
"plans",
":",
"print",
"(",
"'Name: {} \"{}\" Price: {} USD'",
".",
"format",
"(",
"plan",
".",
"name",
",",
"plan",
".",
"slug",
",",
"plan",
".",
"pricing",
"[",
"'hour'",
... | Print method for plans. | [
"Print",
"method",
"for",
"plans",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L102-L108 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.print_facilities | def print_facilities(self, facilities):
"""Print method for facilities.
"""
for facility in facilities:
print('{} - ({}): {}'.format(facility.code, facility.name, ",".join(facility.features))) | python | def print_facilities(self, facilities):
"""Print method for facilities.
"""
for facility in facilities:
print('{} - ({}): {}'.format(facility.code, facility.name, ",".join(facility.features))) | [
"def",
"print_facilities",
"(",
"self",
",",
"facilities",
")",
":",
"for",
"facility",
"in",
"facilities",
":",
"print",
"(",
"'{} - ({}): {}'",
".",
"format",
"(",
"facility",
".",
"code",
",",
"facility",
".",
"name",
",",
"\",\"",
".",
"join",
"(",
"... | Print method for facilities. | [
"Print",
"method",
"for",
"facilities",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L117-L121 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.list_devices | def list_devices(self, project_id, conditions=None, params=None):
"""Retrieve list of devices in a project by one of more conditions.
"""
default_params = {'per_page': 1000}
if params:
default_params.update(params)
data = self.api('projects/%s/devices' % project_id, p... | python | def list_devices(self, project_id, conditions=None, params=None):
"""Retrieve list of devices in a project by one of more conditions.
"""
default_params = {'per_page': 1000}
if params:
default_params.update(params)
data = self.api('projects/%s/devices' % project_id, p... | [
"def",
"list_devices",
"(",
"self",
",",
"project_id",
",",
"conditions",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"default_params",
"=",
"{",
"'per_page'",
":",
"1000",
"}",
"if",
"params",
":",
"default_params",
".",
"update",
"(",
"params",
... | Retrieve list of devices in a project by one of more conditions. | [
"Retrieve",
"list",
"of",
"devices",
"in",
"a",
"project",
"by",
"one",
"of",
"more",
"conditions",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L134-L144 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.print_devices | def print_devices(self, devices):
"""Print method for devices.
"""
for device in devices:
print('ID: {} OS: {} IP: {} State: {} ({}) Tags: {}'
.format(device.id,
device.operating_system.slug,
self.get_public_ip(dev... | python | def print_devices(self, devices):
"""Print method for devices.
"""
for device in devices:
print('ID: {} OS: {} IP: {} State: {} ({}) Tags: {}'
.format(device.id,
device.operating_system.slug,
self.get_public_ip(dev... | [
"def",
"print_devices",
"(",
"self",
",",
"devices",
")",
":",
"for",
"device",
"in",
"devices",
":",
"print",
"(",
"'ID: {} OS: {} IP: {} State: {} ({}) Tags: {}'",
".",
"format",
"(",
"device",
".",
"id",
",",
"device",
".",
"operating_system",
".",
"slug",
... | Print method for devices. | [
"Print",
"method",
"for",
"devices",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L146-L156 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.filter | def filter(criterias, devices): # pylint: disable=too-many-branches
"""Filter a device by criterias on the root level of the dictionary.
"""
if not criterias:
return devices
result = []
for device in devices: # pylint: disable=too-many-nested-blocks
for ... | python | def filter(criterias, devices): # pylint: disable=too-many-branches
"""Filter a device by criterias on the root level of the dictionary.
"""
if not criterias:
return devices
result = []
for device in devices: # pylint: disable=too-many-nested-blocks
for ... | [
"def",
"filter",
"(",
"criterias",
",",
"devices",
")",
":",
"if",
"not",
"criterias",
":",
"return",
"devices",
"result",
"=",
"[",
"]",
"for",
"device",
"in",
"devices",
":",
"for",
"criteria_name",
",",
"criteria_values",
"in",
"criterias",
".",
"items"... | Filter a device by criterias on the root level of the dictionary. | [
"Filter",
"a",
"device",
"by",
"criterias",
"on",
"the",
"root",
"level",
"of",
"the",
"dictionary",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L159-L183 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.get_public_ip | def get_public_ip(addresses, version=4):
"""Return either the devices public IPv4 or IPv6 address.
"""
for addr in addresses:
if addr['public'] and addr['address_family'] == version:
return addr.get('address')
return None | python | def get_public_ip(addresses, version=4):
"""Return either the devices public IPv4 or IPv6 address.
"""
for addr in addresses:
if addr['public'] and addr['address_family'] == version:
return addr.get('address')
return None | [
"def",
"get_public_ip",
"(",
"addresses",
",",
"version",
"=",
"4",
")",
":",
"for",
"addr",
"in",
"addresses",
":",
"if",
"addr",
"[",
"'public'",
"]",
"and",
"addr",
"[",
"'address_family'",
"]",
"==",
"version",
":",
"return",
"addr",
".",
"get",
"(... | Return either the devices public IPv4 or IPv6 address. | [
"Return",
"either",
"the",
"devices",
"public",
"IPv4",
"or",
"IPv6",
"address",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L192-L198 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.validate_capacity | def validate_capacity(self, servers):
"""Validates if a deploy can be fulfilled.
"""
try:
return self.manager.validate_capacity(servers)
except packet.baseapi.Error as msg:
raise PacketManagerException(msg) | python | def validate_capacity(self, servers):
"""Validates if a deploy can be fulfilled.
"""
try:
return self.manager.validate_capacity(servers)
except packet.baseapi.Error as msg:
raise PacketManagerException(msg) | [
"def",
"validate_capacity",
"(",
"self",
",",
"servers",
")",
":",
"try",
":",
"return",
"self",
".",
"manager",
".",
"validate_capacity",
"(",
"servers",
")",
"except",
"packet",
".",
"baseapi",
".",
"Error",
"as",
"msg",
":",
"raise",
"PacketManagerExcepti... | Validates if a deploy can be fulfilled. | [
"Validates",
"if",
"a",
"deploy",
"can",
"be",
"fulfilled",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L200-L206 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.create_volume | def create_volume(self, project_id, plan, size, facility, label=""):
"""Creates a new volume.
"""
try:
return self.manager.create_volume(project_id, label, plan, size, facility)
except packet.baseapi.Error as msg:
raise PacketManagerException(msg) | python | def create_volume(self, project_id, plan, size, facility, label=""):
"""Creates a new volume.
"""
try:
return self.manager.create_volume(project_id, label, plan, size, facility)
except packet.baseapi.Error as msg:
raise PacketManagerException(msg) | [
"def",
"create_volume",
"(",
"self",
",",
"project_id",
",",
"plan",
",",
"size",
",",
"facility",
",",
"label",
"=",
"\"\"",
")",
":",
"try",
":",
"return",
"self",
".",
"manager",
".",
"create_volume",
"(",
"project_id",
",",
"label",
",",
"plan",
",... | Creates a new volume. | [
"Creates",
"a",
"new",
"volume",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L208-L214 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.attach_volume_to_device | def attach_volume_to_device(self, volume_id, device_id):
"""Attaches the created Volume to a Device.
"""
try:
volume = self.manager.get_volume(volume_id)
volume.attach(device_id)
except packet.baseapi.Error as msg:
raise PacketManagerException(msg)
... | python | def attach_volume_to_device(self, volume_id, device_id):
"""Attaches the created Volume to a Device.
"""
try:
volume = self.manager.get_volume(volume_id)
volume.attach(device_id)
except packet.baseapi.Error as msg:
raise PacketManagerException(msg)
... | [
"def",
"attach_volume_to_device",
"(",
"self",
",",
"volume_id",
",",
"device_id",
")",
":",
"try",
":",
"volume",
"=",
"self",
".",
"manager",
".",
"get_volume",
"(",
"volume_id",
")",
"volume",
".",
"attach",
"(",
"device_id",
")",
"except",
"packet",
".... | Attaches the created Volume to a Device. | [
"Attaches",
"the",
"created",
"Volume",
"to",
"a",
"Device",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L216-L224 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.create_demand | def create_demand(self,
project_id,
facility,
plan,
operating_system,
tags=None,
userdata='',
hostname=None,
count=1):
"""Create a new o... | python | def create_demand(self,
project_id,
facility,
plan,
operating_system,
tags=None,
userdata='',
hostname=None,
count=1):
"""Create a new o... | [
"def",
"create_demand",
"(",
"self",
",",
"project_id",
",",
"facility",
",",
"plan",
",",
"operating_system",
",",
"tags",
"=",
"None",
",",
"userdata",
"=",
"''",
",",
"hostname",
"=",
"None",
",",
"count",
"=",
"1",
")",
":",
"tags",
"=",
"{",
"}"... | Create a new on demand device under the given project. | [
"Create",
"a",
"new",
"on",
"demand",
"device",
"under",
"the",
"given",
"project",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L226-L260 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.stop | def stop(self, devices):
"""Power-Off one or more running devices.
"""
for device in devices:
self.logger.info('Stopping: %s', device.id)
try:
device.power_off()
except packet.baseapi.Error:
raise PacketManagerException('Unable ... | python | def stop(self, devices):
"""Power-Off one or more running devices.
"""
for device in devices:
self.logger.info('Stopping: %s', device.id)
try:
device.power_off()
except packet.baseapi.Error:
raise PacketManagerException('Unable ... | [
"def",
"stop",
"(",
"self",
",",
"devices",
")",
":",
"for",
"device",
"in",
"devices",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Stopping: %s'",
",",
"device",
".",
"id",
")",
"try",
":",
"device",
".",
"power_off",
"(",
")",
"except",
"packet... | Power-Off one or more running devices. | [
"Power",
"-",
"Off",
"one",
"or",
"more",
"running",
"devices",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L302-L310 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.reboot | def reboot(self, devices):
"""Reboot one or more devices.
"""
for device in devices:
self.logger.info('Rebooting: %s', device.id)
try:
device.reboot()
except packet.baseapi.Error:
raise PacketManagerException('Unable to reboot i... | python | def reboot(self, devices):
"""Reboot one or more devices.
"""
for device in devices:
self.logger.info('Rebooting: %s', device.id)
try:
device.reboot()
except packet.baseapi.Error:
raise PacketManagerException('Unable to reboot i... | [
"def",
"reboot",
"(",
"self",
",",
"devices",
")",
":",
"for",
"device",
"in",
"devices",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Rebooting: %s'",
",",
"device",
".",
"id",
")",
"try",
":",
"device",
".",
"reboot",
"(",
")",
"except",
"packet... | Reboot one or more devices. | [
"Reboot",
"one",
"or",
"more",
"devices",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L312-L320 | train |
MozillaSecurity/laniakea | laniakea/core/providers/packet/manager.py | PacketManager.terminate | def terminate(self, devices):
"""Terminate one or more running or stopped instances.
"""
for device in devices:
self.logger.info('Terminating: %s', device.id)
try:
device.delete()
except packet.baseapi.Error:
raise PacketManager... | python | def terminate(self, devices):
"""Terminate one or more running or stopped instances.
"""
for device in devices:
self.logger.info('Terminating: %s', device.id)
try:
device.delete()
except packet.baseapi.Error:
raise PacketManager... | [
"def",
"terminate",
"(",
"self",
",",
"devices",
")",
":",
"for",
"device",
"in",
"devices",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Terminating: %s'",
",",
"device",
".",
"id",
")",
"try",
":",
"device",
".",
"delete",
"(",
")",
"except",
"p... | Terminate one or more running or stopped instances. | [
"Terminate",
"one",
"or",
"more",
"running",
"or",
"stopped",
"instances",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/packet/manager.py#L322-L330 | train |
MozillaSecurity/laniakea | laniakea/__init__.py | LaniakeaCommandLine.parse_args | def parse_args(cls):
"""Main argument parser of Laniakea.
"""
# Initialize configuration and userdata directories.
dirs = appdirs.AppDirs(__title__, 'Mozilla Security')
if not os.path.isdir(dirs.user_config_dir):
shutil.copytree(os.path.join(cls.HOME, 'examples'), dir... | python | def parse_args(cls):
"""Main argument parser of Laniakea.
"""
# Initialize configuration and userdata directories.
dirs = appdirs.AppDirs(__title__, 'Mozilla Security')
if not os.path.isdir(dirs.user_config_dir):
shutil.copytree(os.path.join(cls.HOME, 'examples'), dir... | [
"def",
"parse_args",
"(",
"cls",
")",
":",
"dirs",
"=",
"appdirs",
".",
"AppDirs",
"(",
"__title__",
",",
"'Mozilla Security'",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"dirs",
".",
"user_config_dir",
")",
":",
"shutil",
".",
"copytree",
... | Main argument parser of Laniakea. | [
"Main",
"argument",
"parser",
"of",
"Laniakea",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/__init__.py#L31-L108 | train |
MozillaSecurity/laniakea | laniakea/__init__.py | LaniakeaCommandLine.main | def main(cls):
"""Main entry point of Laniakea.
"""
args = cls.parse_args()
if args.focus:
Focus.init()
else:
Focus.disable()
logging.basicConfig(format='[Laniakea] %(asctime)s %(levelname)s: %(message)s',
level=args.v... | python | def main(cls):
"""Main entry point of Laniakea.
"""
args = cls.parse_args()
if args.focus:
Focus.init()
else:
Focus.disable()
logging.basicConfig(format='[Laniakea] %(asctime)s %(levelname)s: %(message)s',
level=args.v... | [
"def",
"main",
"(",
"cls",
")",
":",
"args",
"=",
"cls",
".",
"parse_args",
"(",
")",
"if",
"args",
".",
"focus",
":",
"Focus",
".",
"init",
"(",
")",
"else",
":",
"Focus",
".",
"disable",
"(",
")",
"logging",
".",
"basicConfig",
"(",
"format",
"... | Main entry point of Laniakea. | [
"Main",
"entry",
"point",
"of",
"Laniakea",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/__init__.py#L111-L161 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | Filter.tags | def tags(self, tags=None):
"""Filter by tags.
:param tags: Tags to filter.
:type tags: ``list``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node`
"""
if tags is None or not tags:
return self
nodes = []
for node in... | python | def tags(self, tags=None):
"""Filter by tags.
:param tags: Tags to filter.
:type tags: ``list``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node`
"""
if tags is None or not tags:
return self
nodes = []
for node in... | [
"def",
"tags",
"(",
"self",
",",
"tags",
"=",
"None",
")",
":",
"if",
"tags",
"is",
"None",
"or",
"not",
"tags",
":",
"return",
"self",
"nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"nodes",
":",
"if",
"any",
"(",
"tag",
"in",
"node... | Filter by tags.
:param tags: Tags to filter.
:type tags: ``list``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node` | [
"Filter",
"by",
"tags",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L31-L47 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | Filter.state | def state(self, states=None):
"""Filter by state.
:param tags: States to filter.
:type tags: ``list``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node`
"""
if states is None or not states:
return self
nodes = []
f... | python | def state(self, states=None):
"""Filter by state.
:param tags: States to filter.
:type tags: ``list``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node`
"""
if states is None or not states:
return self
nodes = []
f... | [
"def",
"state",
"(",
"self",
",",
"states",
"=",
"None",
")",
":",
"if",
"states",
"is",
"None",
"or",
"not",
"states",
":",
"return",
"self",
"nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"nodes",
":",
"if",
"any",
"(",
"state",
".",... | Filter by state.
:param tags: States to filter.
:type tags: ``list``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node` | [
"Filter",
"by",
"state",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L49-L65 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | Filter.name | def name(self, names=None):
"""Filter by node name.
:param names: Node names to filter.
:type names: ``list``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node`
"""
if names is None or not names:
return self
nodes = []
... | python | def name(self, names=None):
"""Filter by node name.
:param names: Node names to filter.
:type names: ``list``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node`
"""
if names is None or not names:
return self
nodes = []
... | [
"def",
"name",
"(",
"self",
",",
"names",
"=",
"None",
")",
":",
"if",
"names",
"is",
"None",
"or",
"not",
"names",
":",
"return",
"self",
"nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"nodes",
":",
"if",
"any",
"(",
"name",
"==",
"... | Filter by node name.
:param names: Node names to filter.
:type names: ``list``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node` | [
"Filter",
"by",
"node",
"name",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L67-L83 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | Filter.is_preemptible | def is_preemptible(self):
"""Filter by preemptible scheduling.
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node`
"""
nodes = []
for node in self.nodes:
if Kurz.is_preemtible(node):
nodes.append(node)
return self | python | def is_preemptible(self):
"""Filter by preemptible scheduling.
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node`
"""
nodes = []
for node in self.nodes:
if Kurz.is_preemtible(node):
nodes.append(node)
return self | [
"def",
"is_preemptible",
"(",
"self",
")",
":",
"nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"nodes",
":",
"if",
"Kurz",
".",
"is_preemtible",
"(",
"node",
")",
":",
"nodes",
".",
"append",
"(",
"node",
")",
"return",
"self"
] | Filter by preemptible scheduling.
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node` | [
"Filter",
"by",
"preemptible",
"scheduling",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L85-L95 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | Filter.expr | def expr(self, callback):
"""Filter by custom expression.
:param callback: Callback for custom expression.
:type name: ``function``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node`
"""
nodes = []
for node in self.nodes:
... | python | def expr(self, callback):
"""Filter by custom expression.
:param callback: Callback for custom expression.
:type name: ``function``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node`
"""
nodes = []
for node in self.nodes:
... | [
"def",
"expr",
"(",
"self",
",",
"callback",
")",
":",
"nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"nodes",
":",
"if",
"callback",
"(",
"node",
")",
":",
"nodes",
".",
"append",
"(",
"node",
")",
"self",
".",
"nodes",
"=",
"nodes",
... | Filter by custom expression.
:param callback: Callback for custom expression.
:type name: ``function``
:return: A list of Node objects.
:rtype: ``list`` of :class:`Node` | [
"Filter",
"by",
"custom",
"expression",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L97-L111 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.connect | def connect(self, **kwargs):
"""Connect to Google Compute Engine.
"""
try:
self.gce = get_driver(Provider.GCE)(
self.user_id,
self.key,
project=self.project,
**kwargs)
except:
raise ComputeEngineManag... | python | def connect(self, **kwargs):
"""Connect to Google Compute Engine.
"""
try:
self.gce = get_driver(Provider.GCE)(
self.user_id,
self.key,
project=self.project,
**kwargs)
except:
raise ComputeEngineManag... | [
"def",
"connect",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"gce",
"=",
"get_driver",
"(",
"Provider",
".",
"GCE",
")",
"(",
"self",
".",
"user_id",
",",
"self",
".",
"key",
",",
"project",
"=",
"self",
".",
"project",
... | Connect to Google Compute Engine. | [
"Connect",
"to",
"Google",
"Compute",
"Engine",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L160-L170 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.is_connected | def is_connected(self, attempts=3):
"""Try to reconnect if neccessary.
:param attempts: The amount of tries to reconnect if neccessary.
:type attempts: ``int``
"""
if self.gce is None:
while attempts > 0:
self.logger.info("Attempting to connect .... | python | def is_connected(self, attempts=3):
"""Try to reconnect if neccessary.
:param attempts: The amount of tries to reconnect if neccessary.
:type attempts: ``int``
"""
if self.gce is None:
while attempts > 0:
self.logger.info("Attempting to connect .... | [
"def",
"is_connected",
"(",
"self",
",",
"attempts",
"=",
"3",
")",
":",
"if",
"self",
".",
"gce",
"is",
"None",
":",
"while",
"attempts",
">",
"0",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Attempting to connect ...\"",
")",
"try",
":",
"self",... | Try to reconnect if neccessary.
:param attempts: The amount of tries to reconnect if neccessary.
:type attempts: ``int`` | [
"Try",
"to",
"reconnect",
"if",
"neccessary",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L172-L191 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.create | def create(self, size, number, meta, name=None, image=None, attempts=3):
"""Create container VM nodes. Uses a container declaration which is undocumented.
:param size: The machine type to use.
:type size: ``str`` or :class:`GCENodeSize`
:param number: Amount of nodes to be spawn... | python | def create(self, size, number, meta, name=None, image=None, attempts=3):
"""Create container VM nodes. Uses a container declaration which is undocumented.
:param size: The machine type to use.
:type size: ``str`` or :class:`GCENodeSize`
:param number: Amount of nodes to be spawn... | [
"def",
"create",
"(",
"self",
",",
"size",
",",
"number",
",",
"meta",
",",
"name",
"=",
"None",
",",
"image",
"=",
"None",
",",
"attempts",
"=",
"3",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"Common",
".",
"get_random_hostname",
"("... | Create container VM nodes. Uses a container declaration which is undocumented.
:param size: The machine type to use.
:type size: ``str`` or :class:`GCENodeSize`
:param number: Amount of nodes to be spawned.
:type number: ``int``
:param meta: Metadata dictionary for... | [
"Create",
"container",
"VM",
"nodes",
".",
"Uses",
"a",
"container",
"declaration",
"which",
"is",
"undocumented",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L193-L247 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.stop | def stop(self, nodes=None):
"""Stop one or many nodes.
:param nodes: Nodes to be stopped.
:type nodes: ``list``
"""
if not self.is_connected():
return None
nodes = nodes or self.nodes
result = []
for node in nodes:
if node.s... | python | def stop(self, nodes=None):
"""Stop one or many nodes.
:param nodes: Nodes to be stopped.
:type nodes: ``list``
"""
if not self.is_connected():
return None
nodes = nodes or self.nodes
result = []
for node in nodes:
if node.s... | [
"def",
"stop",
"(",
"self",
",",
"nodes",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"is_connected",
"(",
")",
":",
"return",
"None",
"nodes",
"=",
"nodes",
"or",
"self",
".",
"nodes",
"result",
"=",
"[",
"]",
"for",
"node",
"in",
"nodes",
... | Stop one or many nodes.
:param nodes: Nodes to be stopped.
:type nodes: ``list`` | [
"Stop",
"one",
"or",
"many",
"nodes",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L249-L272 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.start | def start(self, nodes=None):
"""Start one or many nodes.
:param nodes: Nodes to be started.
:type nodes: ``list``
"""
if not self.is_connected():
return None
nodes = nodes or self.nodes
result = []
for node in nodes:
if node... | python | def start(self, nodes=None):
"""Start one or many nodes.
:param nodes: Nodes to be started.
:type nodes: ``list``
"""
if not self.is_connected():
return None
nodes = nodes or self.nodes
result = []
for node in nodes:
if node... | [
"def",
"start",
"(",
"self",
",",
"nodes",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"is_connected",
"(",
")",
":",
"return",
"None",
"nodes",
"=",
"nodes",
"or",
"self",
".",
"nodes",
"result",
"=",
"[",
"]",
"for",
"node",
"in",
"nodes",
... | Start one or many nodes.
:param nodes: Nodes to be started.
:type nodes: ``list`` | [
"Start",
"one",
"or",
"many",
"nodes",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L274-L297 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.reboot | def reboot(self, nodes=None):
"""Reboot one or many nodes.
:param nodes: Nodes to be rebooted.
:type nodes: ``list``
"""
if not self.is_connected():
return None
nodes = nodes or self.nodes
result = []
for node in nodes:
if n... | python | def reboot(self, nodes=None):
"""Reboot one or many nodes.
:param nodes: Nodes to be rebooted.
:type nodes: ``list``
"""
if not self.is_connected():
return None
nodes = nodes or self.nodes
result = []
for node in nodes:
if n... | [
"def",
"reboot",
"(",
"self",
",",
"nodes",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"is_connected",
"(",
")",
":",
"return",
"None",
"nodes",
"=",
"nodes",
"or",
"self",
".",
"nodes",
"result",
"=",
"[",
"]",
"for",
"node",
"in",
"nodes",
... | Reboot one or many nodes.
:param nodes: Nodes to be rebooted.
:type nodes: ``list`` | [
"Reboot",
"one",
"or",
"many",
"nodes",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L299-L322 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.terminate | def terminate(self, nodes=None):
"""Destroy one or many nodes.
:param nodes: Nodes to be destroyed.
:type nodes: ``list``
:return: List of nodes which failed to terminate.
:rtype: ``list``
"""
if not self.is_connected():
return None
no... | python | def terminate(self, nodes=None):
"""Destroy one or many nodes.
:param nodes: Nodes to be destroyed.
:type nodes: ``list``
:return: List of nodes which failed to terminate.
:rtype: ``list``
"""
if not self.is_connected():
return None
no... | [
"def",
"terminate",
"(",
"self",
",",
"nodes",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"is_connected",
"(",
")",
":",
"return",
"None",
"nodes",
"=",
"nodes",
"or",
"self",
".",
"nodes",
"failed_kill",
"=",
"[",
"]",
"result",
"=",
"self",
... | Destroy one or many nodes.
:param nodes: Nodes to be destroyed.
:type nodes: ``list``
:return: List of nodes which failed to terminate.
:rtype: ``list`` | [
"Destroy",
"one",
"or",
"many",
"nodes",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L324-L349 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.terminate_with_threads | def terminate_with_threads(self, nodes=None):
"""Destroy one or many nodes threaded.
:param nodes: Nodes to be destroyed.
:type nodes: ``list``
:return: List of nodes which failed to terminate.
:rtype: ``list``
"""
if not self.is_connected():
r... | python | def terminate_with_threads(self, nodes=None):
"""Destroy one or many nodes threaded.
:param nodes: Nodes to be destroyed.
:type nodes: ``list``
:return: List of nodes which failed to terminate.
:rtype: ``list``
"""
if not self.is_connected():
r... | [
"def",
"terminate_with_threads",
"(",
"self",
",",
"nodes",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"is_connected",
"(",
")",
":",
"return",
"None",
"nodes",
"=",
"nodes",
"or",
"self",
".",
"nodes",
"failed_kill",
"=",
"[",
"]",
"def",
"worke... | Destroy one or many nodes threaded.
:param nodes: Nodes to be destroyed.
:type nodes: ``list``
:return: List of nodes which failed to terminate.
:rtype: ``list`` | [
"Destroy",
"one",
"or",
"many",
"nodes",
"threaded",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L351-L382 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.terminate_ex | def terminate_ex(self, nodes, threads=False, attempts=3):
"""Wrapper method for terminate.
:param nodes: Nodes to be destroyed.
:type nodes: ``list``
:param attempts: The amount of attempts for retrying to terminate failed instances.
:type attempts: ``int``
:... | python | def terminate_ex(self, nodes, threads=False, attempts=3):
"""Wrapper method for terminate.
:param nodes: Nodes to be destroyed.
:type nodes: ``list``
:param attempts: The amount of attempts for retrying to terminate failed instances.
:type attempts: ``int``
:... | [
"def",
"terminate_ex",
"(",
"self",
",",
"nodes",
",",
"threads",
"=",
"False",
",",
"attempts",
"=",
"3",
")",
":",
"while",
"nodes",
"and",
"attempts",
">",
"0",
":",
"if",
"threads",
":",
"nodes",
"=",
"self",
".",
"terminate_with_threads",
"(",
"no... | Wrapper method for terminate.
:param nodes: Nodes to be destroyed.
:type nodes: ``list``
:param attempts: The amount of attempts for retrying to terminate failed instances.
:type attempts: ``int``
:param threads: Whether to use the threaded approach or not.
... | [
"Wrapper",
"method",
"for",
"terminate",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L384-L405 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.build_bootdisk | def build_bootdisk(self, image, size=10, auto_delete=True):
"""Buid a disk struct.
:param image: Base image name.
:type image: ``str``
:param size: Persistent disk size.
:type size: ``int``
:param auto_delete: Wether to auto delete disk on instance termination.
... | python | def build_bootdisk(self, image, size=10, auto_delete=True):
"""Buid a disk struct.
:param image: Base image name.
:type image: ``str``
:param size: Persistent disk size.
:type size: ``int``
:param auto_delete: Wether to auto delete disk on instance termination.
... | [
"def",
"build_bootdisk",
"(",
"self",
",",
"image",
",",
"size",
"=",
"10",
",",
"auto_delete",
"=",
"True",
")",
":",
"if",
"image",
"is",
"None",
":",
"raise",
"ComputeEngineManagerException",
"(",
"\"Image must not be None.\"",
")",
"return",
"{",
"'boot'",... | Buid a disk struct.
:param image: Base image name.
:type image: ``str``
:param size: Persistent disk size.
:type size: ``int``
:param auto_delete: Wether to auto delete disk on instance termination.
:type auto_delete: ``bool`` | [
"Buid",
"a",
"disk",
"struct",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L407-L428 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.build_container_vm | def build_container_vm(self, container, disk, zone="us-east1-b", tags=None, preemptible=True):
"""Build kwargs for a container VM.
:param container: Container declaration.
:type container: ``dict``
:param disk: Disk definition structure.
:type disk: ``dict``
... | python | def build_container_vm(self, container, disk, zone="us-east1-b", tags=None, preemptible=True):
"""Build kwargs for a container VM.
:param container: Container declaration.
:type container: ``dict``
:param disk: Disk definition structure.
:type disk: ``dict``
... | [
"def",
"build_container_vm",
"(",
"self",
",",
"container",
",",
"disk",
",",
"zone",
"=",
"\"us-east1-b\"",
",",
"tags",
"=",
"None",
",",
"preemptible",
"=",
"True",
")",
":",
"if",
"tags",
"is",
"None",
":",
"tags",
"=",
"[",
"]",
"if",
"container",... | Build kwargs for a container VM.
:param container: Container declaration.
:type container: ``dict``
:param disk: Disk definition structure.
:type disk: ``dict``
:param zone: The zone in which the instance should run.
:type zone: ``str``
:param ... | [
"Build",
"kwargs",
"for",
"a",
"container",
"VM",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L430-L463 | train |
MozillaSecurity/laniakea | laniakea/core/providers/gce/manager.py | ComputeEngineManager.filter | def filter(self, zone='all'):
"""Filter nodes by their attributes.
:param zone: A zone containing nodes.
:type zone: ``str``
:return: A chainable filter object.
:rtype: ``object`` of :class:`Filter`
"""
if not self.is_connected():
return None
... | python | def filter(self, zone='all'):
"""Filter nodes by their attributes.
:param zone: A zone containing nodes.
:type zone: ``str``
:return: A chainable filter object.
:rtype: ``object`` of :class:`Filter`
"""
if not self.is_connected():
return None
... | [
"def",
"filter",
"(",
"self",
",",
"zone",
"=",
"'all'",
")",
":",
"if",
"not",
"self",
".",
"is_connected",
"(",
")",
":",
"return",
"None",
"nodes",
"=",
"self",
".",
"gce",
".",
"list_nodes",
"(",
"zone",
")",
"return",
"Filter",
"(",
"nodes",
"... | Filter nodes by their attributes.
:param zone: A zone containing nodes.
:type zone: ``str``
:return: A chainable filter object.
:rtype: ``object`` of :class:`Filter` | [
"Filter",
"nodes",
"by",
"their",
"attributes",
"."
] | 7e80adc6ae92c6c1332d4c08473bb271fb3b6833 | https://github.com/MozillaSecurity/laniakea/blob/7e80adc6ae92c6c1332d4c08473bb271fb3b6833/laniakea/core/providers/gce/manager.py#L465-L478 | train |
scivision/pymap3d | pymap3d/enu.py | enu2aer | def enu2aer(e: np.ndarray, n: np.ndarray, u: np.ndarray, deg: bool = True) -> Tuple[float, float, float]:
"""
ENU to Azimuth, Elevation, Range
Parameters
----------
e : float or np.ndarray of float
ENU East coordinate (meters)
n : float or np.ndarray of float
ENU North coordina... | python | def enu2aer(e: np.ndarray, n: np.ndarray, u: np.ndarray, deg: bool = True) -> Tuple[float, float, float]:
"""
ENU to Azimuth, Elevation, Range
Parameters
----------
e : float or np.ndarray of float
ENU East coordinate (meters)
n : float or np.ndarray of float
ENU North coordina... | [
"def",
"enu2aer",
"(",
"e",
":",
"np",
".",
"ndarray",
",",
"n",
":",
"np",
".",
"ndarray",
",",
"u",
":",
"np",
".",
"ndarray",
",",
"deg",
":",
"bool",
"=",
"True",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
"]",
":",
"e"... | ENU to Azimuth, Elevation, Range
Parameters
----------
e : float or np.ndarray of float
ENU East coordinate (meters)
n : float or np.ndarray of float
ENU North coordinate (meters)
u : float or np.ndarray of float
ENU Up coordinate (meters)
deg : bool, optional
d... | [
"ENU",
"to",
"Azimuth",
"Elevation",
"Range"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/enu.py#L16-L62 | train |
scivision/pymap3d | pymap3d/enu.py | aer2enu | def aer2enu(az: float, el: float, srange: float, deg: bool = True) -> Tuple[float, float, float]:
"""
Azimuth, Elevation, Slant range to target to East, north, Up
Parameters
----------
azimuth : float or np.ndarray of float
azimuth clockwise from north (degrees)
elevation : float or... | python | def aer2enu(az: float, el: float, srange: float, deg: bool = True) -> Tuple[float, float, float]:
"""
Azimuth, Elevation, Slant range to target to East, north, Up
Parameters
----------
azimuth : float or np.ndarray of float
azimuth clockwise from north (degrees)
elevation : float or... | [
"def",
"aer2enu",
"(",
"az",
":",
"float",
",",
"el",
":",
"float",
",",
"srange",
":",
"float",
",",
"deg",
":",
"bool",
"=",
"True",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
"]",
":",
"if",
"deg",
":",
"el",
"=",
"radians... | Azimuth, Elevation, Slant range to target to East, north, Up
Parameters
----------
azimuth : float or np.ndarray of float
azimuth clockwise from north (degrees)
elevation : float or np.ndarray of float
elevation angle above horizon, neglecting aberattions (degrees)
srange : floa... | [
"Azimuth",
"Elevation",
"Slant",
"range",
"to",
"target",
"to",
"East",
"north",
"Up"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/enu.py#L65-L99 | train |
scivision/pymap3d | pymap3d/enu.py | enu2geodetic | def enu2geodetic(e: float, n: float, u: float,
lat0: float, lon0: float, h0: float,
ell=None, deg: bool = True) -> Tuple[float, float, float]:
"""
East, North, Up to target to geodetic coordinates
Parameters
----------
e : float or np.ndarray of float
East ... | python | def enu2geodetic(e: float, n: float, u: float,
lat0: float, lon0: float, h0: float,
ell=None, deg: bool = True) -> Tuple[float, float, float]:
"""
East, North, Up to target to geodetic coordinates
Parameters
----------
e : float or np.ndarray of float
East ... | [
"def",
"enu2geodetic",
"(",
"e",
":",
"float",
",",
"n",
":",
"float",
",",
"u",
":",
"float",
",",
"lat0",
":",
"float",
",",
"lon0",
":",
"float",
",",
"h0",
":",
"float",
",",
"ell",
"=",
"None",
",",
"deg",
":",
"bool",
"=",
"True",
")",
... | East, North, Up to target to geodetic coordinates
Parameters
----------
e : float or np.ndarray of float
East ENU coordinate (meters)
n : float or np.ndarray of float
North ENU coordinate (meters)
u : float or np.ndarray of float
Up ENU coordinate (meters)
lat0 : float
... | [
"East",
"North",
"Up",
"to",
"target",
"to",
"geodetic",
"coordinates"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/enu.py#L102-L140 | train |
scivision/pymap3d | pymap3d/vincenty.py | track2 | def track2(lat1: float, lon1: float, lat2: float, lon2: float,
ell: Ellipsoid = None, npts: int = 100, deg: bool = True):
"""
computes great circle tracks starting at the point lat1, lon1 and ending at lat2, lon2
Parameters
----------
Lat1 : float or numpy.ndarray of float
Geode... | python | def track2(lat1: float, lon1: float, lat2: float, lon2: float,
ell: Ellipsoid = None, npts: int = 100, deg: bool = True):
"""
computes great circle tracks starting at the point lat1, lon1 and ending at lat2, lon2
Parameters
----------
Lat1 : float or numpy.ndarray of float
Geode... | [
"def",
"track2",
"(",
"lat1",
":",
"float",
",",
"lon1",
":",
"float",
",",
"lat2",
":",
"float",
",",
"lon2",
":",
"float",
",",
"ell",
":",
"Ellipsoid",
"=",
"None",
",",
"npts",
":",
"int",
"=",
"100",
",",
"deg",
":",
"bool",
"=",
"True",
"... | computes great circle tracks starting at the point lat1, lon1 and ending at lat2, lon2
Parameters
----------
Lat1 : float or numpy.ndarray of float
Geodetic latitude of first point (degrees)
Lon1 : float or numpy.ndarray of float
Geodetic longitude of first point (degrees)
Lat2 : f... | [
"computes",
"great",
"circle",
"tracks",
"starting",
"at",
"the",
"point",
"lat1",
"lon1",
"and",
"ending",
"at",
"lat2",
"lon2"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/vincenty.py#L416-L491 | train |
scivision/pymap3d | pymap3d/sidereal.py | datetime2sidereal | def datetime2sidereal(time: datetime,
lon_radians: float,
usevallado: bool = True) -> float:
"""
Convert ``datetime`` to sidereal time
from D. Vallado "Fundamentals of Astrodynamics and Applications"
time : datetime.datetime
time to convert
lon_... | python | def datetime2sidereal(time: datetime,
lon_radians: float,
usevallado: bool = True) -> float:
"""
Convert ``datetime`` to sidereal time
from D. Vallado "Fundamentals of Astrodynamics and Applications"
time : datetime.datetime
time to convert
lon_... | [
"def",
"datetime2sidereal",
"(",
"time",
":",
"datetime",
",",
"lon_radians",
":",
"float",
",",
"usevallado",
":",
"bool",
"=",
"True",
")",
"->",
"float",
":",
"usevallado",
"=",
"usevallado",
"or",
"Time",
"is",
"None",
"if",
"usevallado",
":",
"jd",
... | Convert ``datetime`` to sidereal time
from D. Vallado "Fundamentals of Astrodynamics and Applications"
time : datetime.datetime
time to convert
lon_radians : float
longitude (radians)
usevallado : bool, optional
use vallado instead of AstroPy (default is Vallado)
Results
... | [
"Convert",
"datetime",
"to",
"sidereal",
"time"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/sidereal.py#L22-L55 | train |
scivision/pymap3d | pymap3d/sidereal.py | juliandate | def juliandate(time: datetime) -> float:
"""
Python datetime to Julian time
from D.Vallado Fundamentals of Astrodynamics and Applications p.187
and J. Meeus Astronomical Algorithms 1991 Eqn. 7.1 pg. 61
Parameters
----------
time : datetime.datetime
time to convert
Results
... | python | def juliandate(time: datetime) -> float:
"""
Python datetime to Julian time
from D.Vallado Fundamentals of Astrodynamics and Applications p.187
and J. Meeus Astronomical Algorithms 1991 Eqn. 7.1 pg. 61
Parameters
----------
time : datetime.datetime
time to convert
Results
... | [
"def",
"juliandate",
"(",
"time",
":",
"datetime",
")",
"->",
"float",
":",
"times",
"=",
"np",
".",
"atleast_1d",
"(",
"time",
")",
"assert",
"times",
".",
"ndim",
"==",
"1",
"jd",
"=",
"np",
".",
"empty",
"(",
"times",
".",
"size",
")",
"for",
... | Python datetime to Julian time
from D.Vallado Fundamentals of Astrodynamics and Applications p.187
and J. Meeus Astronomical Algorithms 1991 Eqn. 7.1 pg. 61
Parameters
----------
time : datetime.datetime
time to convert
Results
-------
jd : float
Julian date | [
"Python",
"datetime",
"to",
"Julian",
"time"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/sidereal.py#L58-L97 | train |
scivision/pymap3d | pymap3d/sidereal.py | julian2sidereal | def julian2sidereal(Jdate: float) -> float:
"""
Convert Julian time to sidereal time
D. Vallado Ed. 4
Parameters
----------
Jdate: float
Julian centuries from J2000.0
Results
-------
tsr : float
Sidereal time
"""
jdate = np.atleast_1d(Jdate)
assert ... | python | def julian2sidereal(Jdate: float) -> float:
"""
Convert Julian time to sidereal time
D. Vallado Ed. 4
Parameters
----------
Jdate: float
Julian centuries from J2000.0
Results
-------
tsr : float
Sidereal time
"""
jdate = np.atleast_1d(Jdate)
assert ... | [
"def",
"julian2sidereal",
"(",
"Jdate",
":",
"float",
")",
"->",
"float",
":",
"jdate",
"=",
"np",
".",
"atleast_1d",
"(",
"Jdate",
")",
"assert",
"jdate",
".",
"ndim",
"==",
"1",
"tsr",
"=",
"np",
".",
"empty",
"(",
"jdate",
".",
"size",
")",
"for... | Convert Julian time to sidereal time
D. Vallado Ed. 4
Parameters
----------
Jdate: float
Julian centuries from J2000.0
Results
-------
tsr : float
Sidereal time | [
"Convert",
"Julian",
"time",
"to",
"sidereal",
"time"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/sidereal.py#L100-L135 | train |
scivision/pymap3d | pymap3d/ecef.py | get_radius_normal | def get_radius_normal(lat_radians: float, ell: Ellipsoid = None) -> float:
"""
Compute normal radius of planetary body
Parameters
----------
lat_radians : float
latitude in radians
ell : Ellipsoid, optional
reference ellipsoid
Returns
-------
radius : float
... | python | def get_radius_normal(lat_radians: float, ell: Ellipsoid = None) -> float:
"""
Compute normal radius of planetary body
Parameters
----------
lat_radians : float
latitude in radians
ell : Ellipsoid, optional
reference ellipsoid
Returns
-------
radius : float
... | [
"def",
"get_radius_normal",
"(",
"lat_radians",
":",
"float",
",",
"ell",
":",
"Ellipsoid",
"=",
"None",
")",
"->",
"float",
":",
"if",
"ell",
"is",
"None",
":",
"ell",
"=",
"Ellipsoid",
"(",
")",
"a",
"=",
"ell",
".",
"a",
"b",
"=",
"ell",
".",
... | Compute normal radius of planetary body
Parameters
----------
lat_radians : float
latitude in radians
ell : Ellipsoid, optional
reference ellipsoid
Returns
-------
radius : float
normal radius (meters) | [
"Compute",
"normal",
"radius",
"of",
"planetary",
"body"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ecef.py#L70-L94 | train |
scivision/pymap3d | pymap3d/ecef.py | ecef2enuv | def ecef2enuv(u: float, v: float, w: float,
lat0: float, lon0: float, deg: bool = True) -> Tuple[float, float, float]:
"""
VECTOR from observer to target ECEF => ENU
Parameters
----------
u : float or numpy.ndarray of float
target x ECEF coordinate (meters)
v : float or n... | python | def ecef2enuv(u: float, v: float, w: float,
lat0: float, lon0: float, deg: bool = True) -> Tuple[float, float, float]:
"""
VECTOR from observer to target ECEF => ENU
Parameters
----------
u : float or numpy.ndarray of float
target x ECEF coordinate (meters)
v : float or n... | [
"def",
"ecef2enuv",
"(",
"u",
":",
"float",
",",
"v",
":",
"float",
",",
"w",
":",
"float",
",",
"lat0",
":",
"float",
",",
"lon0",
":",
"float",
",",
"deg",
":",
"bool",
"=",
"True",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
",",
"float"... | VECTOR from observer to target ECEF => ENU
Parameters
----------
u : float or numpy.ndarray of float
target x ECEF coordinate (meters)
v : float or numpy.ndarray of float
target y ECEF coordinate (meters)
w : float or numpy.ndarray of float
target z ECEF coordinate (meters)... | [
"VECTOR",
"from",
"observer",
"to",
"target",
"ECEF",
"=",
">",
"ENU"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ecef.py#L233-L274 | train |
scivision/pymap3d | pymap3d/ecef.py | ecef2enu | def ecef2enu(x: float, y: float, z: float,
lat0: float, lon0: float, h0: float,
ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]:
"""
from observer to target, ECEF => ENU
Parameters
----------
x : float or numpy.ndarray of float
target x ECEF ... | python | def ecef2enu(x: float, y: float, z: float,
lat0: float, lon0: float, h0: float,
ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]:
"""
from observer to target, ECEF => ENU
Parameters
----------
x : float or numpy.ndarray of float
target x ECEF ... | [
"def",
"ecef2enu",
"(",
"x",
":",
"float",
",",
"y",
":",
"float",
",",
"z",
":",
"float",
",",
"lat0",
":",
"float",
",",
"lon0",
":",
"float",
",",
"h0",
":",
"float",
",",
"ell",
":",
"Ellipsoid",
"=",
"None",
",",
"deg",
":",
"bool",
"=",
... | from observer to target, ECEF => ENU
Parameters
----------
x : float or numpy.ndarray of float
target x ECEF coordinate (meters)
y : float or numpy.ndarray of float
target y ECEF coordinate (meters)
z : float or numpy.ndarray of float
target z ECEF coordinate (meters)
la... | [
"from",
"observer",
"to",
"target",
"ECEF",
"=",
">",
"ENU"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ecef.py#L277-L314 | train |
scivision/pymap3d | pymap3d/ecef.py | eci2geodetic | def eci2geodetic(eci: np.ndarray, t: datetime,
useastropy: bool = True) -> Tuple[float, float, float]:
"""
convert ECI to geodetic coordinates
Parameters
----------
eci : tuple of float
[meters] Nx3 target ECI location (x,y,z)
t : datetime.datetime, float
le... | python | def eci2geodetic(eci: np.ndarray, t: datetime,
useastropy: bool = True) -> Tuple[float, float, float]:
"""
convert ECI to geodetic coordinates
Parameters
----------
eci : tuple of float
[meters] Nx3 target ECI location (x,y,z)
t : datetime.datetime, float
le... | [
"def",
"eci2geodetic",
"(",
"eci",
":",
"np",
".",
"ndarray",
",",
"t",
":",
"datetime",
",",
"useastropy",
":",
"bool",
"=",
"True",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
"]",
":",
"ecef",
"=",
"np",
".",
"atleast_2d",
"(",... | convert ECI to geodetic coordinates
Parameters
----------
eci : tuple of float
[meters] Nx3 target ECI location (x,y,z)
t : datetime.datetime, float
length N vector of datetime OR greenwich sidereal time angle [radians].
Results
-------
lat : float
geodetic la... | [
"convert",
"ECI",
"to",
"geodetic",
"coordinates"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ecef.py#L384-L416 | train |
scivision/pymap3d | pymap3d/ecef.py | enu2ecef | def enu2ecef(e1: float, n1: float, u1: float,
lat0: float, lon0: float, h0: float,
ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]:
"""
ENU to ECEF
Parameters
----------
e1 : float or numpy.ndarray of float
target east ENU coordinate (meters... | python | def enu2ecef(e1: float, n1: float, u1: float,
lat0: float, lon0: float, h0: float,
ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]:
"""
ENU to ECEF
Parameters
----------
e1 : float or numpy.ndarray of float
target east ENU coordinate (meters... | [
"def",
"enu2ecef",
"(",
"e1",
":",
"float",
",",
"n1",
":",
"float",
",",
"u1",
":",
"float",
",",
"lat0",
":",
"float",
",",
"lon0",
":",
"float",
",",
"h0",
":",
"float",
",",
"ell",
":",
"Ellipsoid",
"=",
"None",
",",
"deg",
":",
"bool",
"="... | ENU to ECEF
Parameters
----------
e1 : float or numpy.ndarray of float
target east ENU coordinate (meters)
n1 : float or numpy.ndarray of float
target north ENU coordinate (meters)
u1 : float or numpy.ndarray of float
target up ENU coordinate (meters)
lat0 : float
... | [
"ENU",
"to",
"ECEF"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ecef.py#L419-L458 | train |
scivision/pymap3d | pymap3d/ned.py | aer2ned | def aer2ned(az: float, elev: float, slantRange: float,
deg: bool = True) -> Tuple[float, float, float]:
"""
converts azimuth, elevation, range to target from observer to North, East, Down
Parameters
-----------
az : float or numpy.ndarray of float
azimuth
elev : float or n... | python | def aer2ned(az: float, elev: float, slantRange: float,
deg: bool = True) -> Tuple[float, float, float]:
"""
converts azimuth, elevation, range to target from observer to North, East, Down
Parameters
-----------
az : float or numpy.ndarray of float
azimuth
elev : float or n... | [
"def",
"aer2ned",
"(",
"az",
":",
"float",
",",
"elev",
":",
"float",
",",
"slantRange",
":",
"float",
",",
"deg",
":",
"bool",
"=",
"True",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
"]",
":",
"e",
",",
"n",
",",
"u",
"=",
... | converts azimuth, elevation, range to target from observer to North, East, Down
Parameters
-----------
az : float or numpy.ndarray of float
azimuth
elev : float or numpy.ndarray of float
elevation
slantRange : float or numpy.ndarray of float
slant range [meters]
deg ... | [
"converts",
"azimuth",
"elevation",
"range",
"to",
"target",
"from",
"observer",
"to",
"North",
"East",
"Down"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ned.py#L7-L35 | train |
scivision/pymap3d | pymap3d/ned.py | ned2aer | def ned2aer(n: float, e: float, d: float,
deg: bool = True) -> Tuple[float, float, float]:
"""
converts North, East, Down to azimuth, elevation, range
Parameters
----------
n : float or numpy.ndarray of float
North NED coordinate (meters)
e : float or numpy.ndarray of float... | python | def ned2aer(n: float, e: float, d: float,
deg: bool = True) -> Tuple[float, float, float]:
"""
converts North, East, Down to azimuth, elevation, range
Parameters
----------
n : float or numpy.ndarray of float
North NED coordinate (meters)
e : float or numpy.ndarray of float... | [
"def",
"ned2aer",
"(",
"n",
":",
"float",
",",
"e",
":",
"float",
",",
"d",
":",
"float",
",",
"deg",
":",
"bool",
"=",
"True",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
"]",
":",
"return",
"enu2aer",
"(",
"e",
",",
"n",
"... | converts North, East, Down to azimuth, elevation, range
Parameters
----------
n : float or numpy.ndarray of float
North NED coordinate (meters)
e : float or numpy.ndarray of float
East NED coordinate (meters)
d : float or numpy.ndarray of float
Down NED coordinate (meters)
... | [
"converts",
"North",
"East",
"Down",
"to",
"azimuth",
"elevation",
"range"
] | c9cf676594611cdb52ff7e0eca6388c80ed4f63f | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ned.py#L38-L65 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.