id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
232,800 | sebp/scikit-survival | sksurv/nonparametric.py | SurvivalFunctionEstimator.predict_proba | def predict_proba(self, time):
"""Return probability of an event after given time point.
:math:`\\hat{S}(t) = P(T > t)`
Parameters
----------
time : array, shape = (n_samples,)
Time to estimate probability at.
Returns
-------
prob : array, s... | python | def predict_proba(self, time):
"""Return probability of an event after given time point.
:math:`\\hat{S}(t) = P(T > t)`
Parameters
----------
time : array, shape = (n_samples,)
Time to estimate probability at.
Returns
-------
prob : array, s... | [
"def",
"predict_proba",
"(",
"self",
",",
"time",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"\"unique_time_\"",
")",
"time",
"=",
"check_array",
"(",
"time",
",",
"ensure_2d",
"=",
"False",
")",
"# K-M is undefined if estimate at last time point is non-zero",
"... | Return probability of an event after given time point.
:math:`\\hat{S}(t) = P(T > t)`
Parameters
----------
time : array, shape = (n_samples,)
Time to estimate probability at.
Returns
-------
prob : array, shape = (n_samples,)
Probabilit... | [
"Return",
"probability",
"of",
"an",
"event",
"after",
"given",
"time",
"point",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/nonparametric.py#L327-L364 |
232,801 | sebp/scikit-survival | sksurv/nonparametric.py | CensoringDistributionEstimator.fit | def fit(self, y):
"""Estimate censoring distribution from training data.
Parameters
----------
y : structured array, shape = (n_samples,)
A structured array containing the binary event indicator
as first field, and time of event or time of censoring as
... | python | def fit(self, y):
"""Estimate censoring distribution from training data.
Parameters
----------
y : structured array, shape = (n_samples,)
A structured array containing the binary event indicator
as first field, and time of event or time of censoring as
... | [
"def",
"fit",
"(",
"self",
",",
"y",
")",
":",
"event",
",",
"time",
"=",
"check_y_survival",
"(",
"y",
")",
"if",
"event",
".",
"all",
"(",
")",
":",
"self",
".",
"unique_time_",
"=",
"numpy",
".",
"unique",
"(",
"time",
")",
"self",
".",
"prob_... | Estimate censoring distribution from training data.
Parameters
----------
y : structured array, shape = (n_samples,)
A structured array containing the binary event indicator
as first field, and time of event or time of censoring as
second field.
Retu... | [
"Estimate",
"censoring",
"distribution",
"from",
"training",
"data",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/nonparametric.py#L370-L393 |
232,802 | sebp/scikit-survival | sksurv/nonparametric.py | CensoringDistributionEstimator.predict_ipcw | def predict_ipcw(self, y):
"""Return inverse probability of censoring weights at given time points.
:math:`\\omega_i = \\delta_i / \\hat{G}(y_i)`
Parameters
----------
y : structured array, shape = (n_samples,)
A structured array containing the binary event indicato... | python | def predict_ipcw(self, y):
"""Return inverse probability of censoring weights at given time points.
:math:`\\omega_i = \\delta_i / \\hat{G}(y_i)`
Parameters
----------
y : structured array, shape = (n_samples,)
A structured array containing the binary event indicato... | [
"def",
"predict_ipcw",
"(",
"self",
",",
"y",
")",
":",
"event",
",",
"time",
"=",
"check_y_survival",
"(",
"y",
")",
"Ghat",
"=",
"self",
".",
"predict_proba",
"(",
"time",
"[",
"event",
"]",
")",
"if",
"(",
"Ghat",
"==",
"0.0",
")",
".",
"any",
... | Return inverse probability of censoring weights at given time points.
:math:`\\omega_i = \\delta_i / \\hat{G}(y_i)`
Parameters
----------
y : structured array, shape = (n_samples,)
A structured array containing the binary event indicator
as first field, and time... | [
"Return",
"inverse",
"probability",
"of",
"censoring",
"weights",
"at",
"given",
"time",
"points",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/nonparametric.py#L395-L421 |
232,803 | sebp/scikit-survival | sksurv/metrics.py | concordance_index_censored | def concordance_index_censored(event_indicator, event_time, estimate, tied_tol=1e-8):
"""Concordance index for right-censored data
The concordance index is defined as the proportion of all comparable pairs
in which the predictions and outcomes are concordant.
Samples are comparable if for at least one... | python | def concordance_index_censored(event_indicator, event_time, estimate, tied_tol=1e-8):
"""Concordance index for right-censored data
The concordance index is defined as the proportion of all comparable pairs
in which the predictions and outcomes are concordant.
Samples are comparable if for at least one... | [
"def",
"concordance_index_censored",
"(",
"event_indicator",
",",
"event_time",
",",
"estimate",
",",
"tied_tol",
"=",
"1e-8",
")",
":",
"event_indicator",
",",
"event_time",
",",
"estimate",
"=",
"_check_inputs",
"(",
"event_indicator",
",",
"event_time",
",",
"e... | Concordance index for right-censored data
The concordance index is defined as the proportion of all comparable pairs
in which the predictions and outcomes are concordant.
Samples are comparable if for at least one of them an event occurred.
If the estimated risk is larger for the sample with a higher ... | [
"Concordance",
"index",
"for",
"right",
"-",
"censored",
"data"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/metrics.py#L111-L174 |
232,804 | sebp/scikit-survival | sksurv/metrics.py | concordance_index_ipcw | def concordance_index_ipcw(survival_train, survival_test, estimate, tau=None, tied_tol=1e-8):
"""Concordance index for right-censored data based on inverse probability of censoring weights.
This is an alternative to the estimator in :func:`concordance_index_censored`
that does not depend on the distributio... | python | def concordance_index_ipcw(survival_train, survival_test, estimate, tau=None, tied_tol=1e-8):
"""Concordance index for right-censored data based on inverse probability of censoring weights.
This is an alternative to the estimator in :func:`concordance_index_censored`
that does not depend on the distributio... | [
"def",
"concordance_index_ipcw",
"(",
"survival_train",
",",
"survival_test",
",",
"estimate",
",",
"tau",
"=",
"None",
",",
"tied_tol",
"=",
"1e-8",
")",
":",
"test_event",
",",
"test_time",
"=",
"check_y_survival",
"(",
"survival_test",
")",
"if",
"tau",
"is... | Concordance index for right-censored data based on inverse probability of censoring weights.
This is an alternative to the estimator in :func:`concordance_index_censored`
that does not depend on the distribution of censoring times in the test data.
Therefore, the estimate is unbiased and consistent for a p... | [
"Concordance",
"index",
"for",
"right",
"-",
"censored",
"data",
"based",
"on",
"inverse",
"probability",
"of",
"censoring",
"weights",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/metrics.py#L177-L266 |
232,805 | sebp/scikit-survival | sksurv/kernels/clinical.py | _nominal_kernel | def _nominal_kernel(x, y, out):
"""Number of features that match exactly"""
for i in range(x.shape[0]):
for j in range(y.shape[0]):
out[i, j] += (x[i, :] == y[j, :]).sum()
return out | python | def _nominal_kernel(x, y, out):
"""Number of features that match exactly"""
for i in range(x.shape[0]):
for j in range(y.shape[0]):
out[i, j] += (x[i, :] == y[j, :]).sum()
return out | [
"def",
"_nominal_kernel",
"(",
"x",
",",
"y",
",",
"out",
")",
":",
"for",
"i",
"in",
"range",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
")",
":",
"for",
"j",
"in",
"range",
"(",
"y",
".",
"shape",
"[",
"0",
"]",
")",
":",
"out",
"[",
"i",
"... | Number of features that match exactly | [
"Number",
"of",
"features",
"that",
"match",
"exactly"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/kernels/clinical.py#L26-L32 |
232,806 | sebp/scikit-survival | sksurv/kernels/clinical.py | _get_continuous_and_ordinal_array | def _get_continuous_and_ordinal_array(x):
"""Convert array from continuous and ordered categorical columns"""
nominal_columns = x.select_dtypes(include=['object', 'category']).columns
ordinal_columns = pandas.Index([v for v in nominal_columns if x[v].cat.ordered])
continuous_columns = x.select_dtypes(in... | python | def _get_continuous_and_ordinal_array(x):
"""Convert array from continuous and ordered categorical columns"""
nominal_columns = x.select_dtypes(include=['object', 'category']).columns
ordinal_columns = pandas.Index([v for v in nominal_columns if x[v].cat.ordered])
continuous_columns = x.select_dtypes(in... | [
"def",
"_get_continuous_and_ordinal_array",
"(",
"x",
")",
":",
"nominal_columns",
"=",
"x",
".",
"select_dtypes",
"(",
"include",
"=",
"[",
"'object'",
",",
"'category'",
"]",
")",
".",
"columns",
"ordinal_columns",
"=",
"pandas",
".",
"Index",
"(",
"[",
"v... | Convert array from continuous and ordered categorical columns | [
"Convert",
"array",
"from",
"continuous",
"and",
"ordered",
"categorical",
"columns"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/kernels/clinical.py#L35-L50 |
232,807 | sebp/scikit-survival | sksurv/kernels/clinical.py | clinical_kernel | def clinical_kernel(x, y=None):
"""Computes clinical kernel
The clinical kernel distinguishes between continuous
ordinal,and nominal variables.
Parameters
----------
x : pandas.DataFrame, shape = (n_samples_x, n_features)
Training data
y : pandas.DataFrame, shape = (n_samples_y, n... | python | def clinical_kernel(x, y=None):
"""Computes clinical kernel
The clinical kernel distinguishes between continuous
ordinal,and nominal variables.
Parameters
----------
x : pandas.DataFrame, shape = (n_samples_x, n_features)
Training data
y : pandas.DataFrame, shape = (n_samples_y, n... | [
"def",
"clinical_kernel",
"(",
"x",
",",
"y",
"=",
"None",
")",
":",
"if",
"y",
"is",
"not",
"None",
":",
"if",
"x",
".",
"shape",
"[",
"1",
"]",
"!=",
"y",
".",
"shape",
"[",
"1",
"]",
":",
"raise",
"ValueError",
"(",
"'x and y have different numb... | Computes clinical kernel
The clinical kernel distinguishes between continuous
ordinal,and nominal variables.
Parameters
----------
x : pandas.DataFrame, shape = (n_samples_x, n_features)
Training data
y : pandas.DataFrame, shape = (n_samples_y, n_features)
Testing data
Re... | [
"Computes",
"clinical",
"kernel"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/kernels/clinical.py#L61-L107 |
232,808 | sebp/scikit-survival | sksurv/kernels/clinical.py | ClinicalKernelTransform._prepare_by_column_dtype | def _prepare_by_column_dtype(self, X):
"""Get distance functions for each column's dtype"""
if not isinstance(X, pandas.DataFrame):
raise TypeError('X must be a pandas DataFrame')
numeric_columns = []
nominal_columns = []
numeric_ranges = []
fit_data = numpy... | python | def _prepare_by_column_dtype(self, X):
"""Get distance functions for each column's dtype"""
if not isinstance(X, pandas.DataFrame):
raise TypeError('X must be a pandas DataFrame')
numeric_columns = []
nominal_columns = []
numeric_ranges = []
fit_data = numpy... | [
"def",
"_prepare_by_column_dtype",
"(",
"self",
",",
"X",
")",
":",
"if",
"not",
"isinstance",
"(",
"X",
",",
"pandas",
".",
"DataFrame",
")",
":",
"raise",
"TypeError",
"(",
"'X must be a pandas DataFrame'",
")",
"numeric_columns",
"=",
"[",
"]",
"nominal_col... | Get distance functions for each column's dtype | [
"Get",
"distance",
"functions",
"for",
"each",
"column",
"s",
"dtype"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/kernels/clinical.py#L153-L185 |
232,809 | sebp/scikit-survival | sksurv/kernels/clinical.py | ClinicalKernelTransform.fit | def fit(self, X, y=None, **kwargs):
"""Determine transformation parameters from data in X.
Subsequent calls to `transform(Y)` compute the pairwise
distance to `X`.
Parameters of the clinical kernel are only updated
if `fit_once` is `False`, otherwise you have to
explicit... | python | def fit(self, X, y=None, **kwargs):
"""Determine transformation parameters from data in X.
Subsequent calls to `transform(Y)` compute the pairwise
distance to `X`.
Parameters of the clinical kernel are only updated
if `fit_once` is `False`, otherwise you have to
explicit... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"X",
".",
"ndim",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"\"expected 2d array, but got %d\"",
"%",
"X",
".",
"ndim",
")",
"if",
"self",
".",
... | Determine transformation parameters from data in X.
Subsequent calls to `transform(Y)` compute the pairwise
distance to `X`.
Parameters of the clinical kernel are only updated
if `fit_once` is `False`, otherwise you have to
explicitly call `prepare()` once.
Parameters
... | [
"Determine",
"transformation",
"parameters",
"from",
"data",
"in",
"X",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/kernels/clinical.py#L187-L220 |
232,810 | sebp/scikit-survival | sksurv/kernels/clinical.py | ClinicalKernelTransform.transform | def transform(self, Y):
r"""Compute all pairwise distances between `self.X_fit_` and `Y`.
Parameters
----------
y : array-like, shape = (n_samples_y, n_features)
Returns
-------
kernel : ndarray, shape = (n_samples_y, n_samples_X_fit\_)
Kernel matrix... | python | def transform(self, Y):
r"""Compute all pairwise distances between `self.X_fit_` and `Y`.
Parameters
----------
y : array-like, shape = (n_samples_y, n_features)
Returns
-------
kernel : ndarray, shape = (n_samples_y, n_samples_X_fit\_)
Kernel matrix... | [
"def",
"transform",
"(",
"self",
",",
"Y",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"'X_fit_'",
")",
"n_samples_x",
",",
"n_features",
"=",
"self",
".",
"X_fit_",
".",
"shape",
"Y",
"=",
"numpy",
".",
"asarray",
"(",
"Y",
")",
"if",
"Y",
".",
... | r"""Compute all pairwise distances between `self.X_fit_` and `Y`.
Parameters
----------
y : array-like, shape = (n_samples_y, n_features)
Returns
-------
kernel : ndarray, shape = (n_samples_y, n_samples_X_fit\_)
Kernel matrix. Values are normalized to lie w... | [
"r",
"Compute",
"all",
"pairwise",
"distances",
"between",
"self",
".",
"X_fit_",
"and",
"Y",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/kernels/clinical.py#L222-L257 |
232,811 | sebp/scikit-survival | sksurv/ensemble/boosting.py | _fit_stage_componentwise | def _fit_stage_componentwise(X, residuals, sample_weight, **fit_params):
"""Fit component-wise weighted least squares model"""
n_features = X.shape[1]
base_learners = []
error = numpy.empty(n_features)
for component in range(n_features):
learner = ComponentwiseLeastSquares(component).fit(X,... | python | def _fit_stage_componentwise(X, residuals, sample_weight, **fit_params):
"""Fit component-wise weighted least squares model"""
n_features = X.shape[1]
base_learners = []
error = numpy.empty(n_features)
for component in range(n_features):
learner = ComponentwiseLeastSquares(component).fit(X,... | [
"def",
"_fit_stage_componentwise",
"(",
"X",
",",
"residuals",
",",
"sample_weight",
",",
"*",
"*",
"fit_params",
")",
":",
"n_features",
"=",
"X",
".",
"shape",
"[",
"1",
"]",
"base_learners",
"=",
"[",
"]",
"error",
"=",
"numpy",
".",
"empty",
"(",
"... | Fit component-wise weighted least squares model | [
"Fit",
"component",
"-",
"wise",
"weighted",
"least",
"squares",
"model"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/ensemble/boosting.py#L72-L87 |
232,812 | sebp/scikit-survival | sksurv/ensemble/boosting.py | ComponentwiseGradientBoostingSurvivalAnalysis.coef_ | def coef_(self):
"""Return the aggregated coefficients.
Returns
-------
coef_ : ndarray, shape = (n_features + 1,)
Coefficients of features. The first element denotes the intercept.
"""
coef = numpy.zeros(self.n_features_ + 1, dtype=float)
for estima... | python | def coef_(self):
"""Return the aggregated coefficients.
Returns
-------
coef_ : ndarray, shape = (n_features + 1,)
Coefficients of features. The first element denotes the intercept.
"""
coef = numpy.zeros(self.n_features_ + 1, dtype=float)
for estima... | [
"def",
"coef_",
"(",
"self",
")",
":",
"coef",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"n_features_",
"+",
"1",
",",
"dtype",
"=",
"float",
")",
"for",
"estimator",
"in",
"self",
".",
"estimators_",
":",
"coef",
"[",
"estimator",
".",
"componen... | Return the aggregated coefficients.
Returns
-------
coef_ : ndarray, shape = (n_features + 1,)
Coefficients of features. The first element denotes the intercept. | [
"Return",
"the",
"aggregated",
"coefficients",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/ensemble/boosting.py#L338-L351 |
232,813 | sebp/scikit-survival | sksurv/ensemble/boosting.py | GradientBoostingSurvivalAnalysis._fit_stage | def _fit_stage(self, i, X, y, y_pred, sample_weight, sample_mask,
random_state, scale, X_idx_sorted, X_csc=None, X_csr=None):
"""Fit another stage of ``n_classes_`` trees to the boosting model. """
assert sample_mask.dtype == numpy.bool
loss = self.loss_
# whether to... | python | def _fit_stage(self, i, X, y, y_pred, sample_weight, sample_mask,
random_state, scale, X_idx_sorted, X_csc=None, X_csr=None):
"""Fit another stage of ``n_classes_`` trees to the boosting model. """
assert sample_mask.dtype == numpy.bool
loss = self.loss_
# whether to... | [
"def",
"_fit_stage",
"(",
"self",
",",
"i",
",",
"X",
",",
"y",
",",
"y_pred",
",",
"sample_weight",
",",
"sample_mask",
",",
"random_state",
",",
"scale",
",",
"X_idx_sorted",
",",
"X_csc",
"=",
"None",
",",
"X_csr",
"=",
"None",
")",
":",
"assert",
... | Fit another stage of ``n_classes_`` trees to the boosting model. | [
"Fit",
"another",
"stage",
"of",
"n_classes_",
"trees",
"to",
"the",
"boosting",
"model",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/ensemble/boosting.py#L609-L671 |
232,814 | sebp/scikit-survival | sksurv/ensemble/boosting.py | GradientBoostingSurvivalAnalysis._fit_stages | def _fit_stages(self, X, y, y_pred, sample_weight, random_state,
begin_at_stage=0, monitor=None, X_idx_sorted=None):
"""Iteratively fits the stages.
For each stage it computes the progress (OOB, train score)
and delegates to ``_fit_stage``.
Returns the number of stag... | python | def _fit_stages(self, X, y, y_pred, sample_weight, random_state,
begin_at_stage=0, monitor=None, X_idx_sorted=None):
"""Iteratively fits the stages.
For each stage it computes the progress (OOB, train score)
and delegates to ``_fit_stage``.
Returns the number of stag... | [
"def",
"_fit_stages",
"(",
"self",
",",
"X",
",",
"y",
",",
"y_pred",
",",
"sample_weight",
",",
"random_state",
",",
"begin_at_stage",
"=",
"0",
",",
"monitor",
"=",
"None",
",",
"X_idx_sorted",
"=",
"None",
")",
":",
"n_samples",
"=",
"X",
".",
"shap... | Iteratively fits the stages.
For each stage it computes the progress (OOB, train score)
and delegates to ``_fit_stage``.
Returns the number of stages fit; might differ from ``n_estimators``
due to early stopping. | [
"Iteratively",
"fits",
"the",
"stages",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/ensemble/boosting.py#L673-L741 |
232,815 | sebp/scikit-survival | sksurv/ensemble/boosting.py | GradientBoostingSurvivalAnalysis.fit | def fit(self, X, y, sample_weight=None, monitor=None):
"""Fit the gradient boosting model.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Data matrix
y : structured array, shape = (n_samples,)
A structured array containing the bina... | python | def fit(self, X, y, sample_weight=None, monitor=None):
"""Fit the gradient boosting model.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Data matrix
y : structured array, shape = (n_samples,)
A structured array containing the bina... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
",",
"sample_weight",
"=",
"None",
",",
"monitor",
"=",
"None",
")",
":",
"random_state",
"=",
"check_random_state",
"(",
"self",
".",
"random_state",
")",
"X",
",",
"event",
",",
"time",
"=",
"check_array... | Fit the gradient boosting model.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Data matrix
y : structured array, shape = (n_samples,)
A structured array containing the binary event indicator
as first field, and time of event o... | [
"Fit",
"the",
"gradient",
"boosting",
"model",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/ensemble/boosting.py#L743-L823 |
232,816 | sebp/scikit-survival | sksurv/ensemble/boosting.py | GradientBoostingSurvivalAnalysis.staged_predict | def staged_predict(self, X):
"""Predict hazard at each stage for X.
This method allows monitoring (i.e. determine error on testing set)
after each stage.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
The input samples.
Return... | python | def staged_predict(self, X):
"""Predict hazard at each stage for X.
This method allows monitoring (i.e. determine error on testing set)
after each stage.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
The input samples.
Return... | [
"def",
"staged_predict",
"(",
"self",
",",
"X",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"'estimators_'",
")",
"# if dropout wasn't used during training, proceed as usual,",
"# otherwise consider scaling factor of individual trees",
"if",
"not",
"hasattr",
"(",
"self",
... | Predict hazard at each stage for X.
This method allows monitoring (i.e. determine error on testing set)
after each stage.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
The input samples.
Returns
-------
y : generator ... | [
"Predict",
"hazard",
"at",
"each",
"stage",
"for",
"X",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/ensemble/boosting.py#L886-L911 |
232,817 | sebp/scikit-survival | sksurv/svm/minlip.py | MinlipSurvivalAnalysis.fit | def fit(self, X, y):
"""Build a MINLIP survival model from training data.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Data matrix.
y : structured array, shape = (n_samples,)
A structured array containing the binary event indicat... | python | def fit(self, X, y):
"""Build a MINLIP survival model from training data.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Data matrix.
y : structured array, shape = (n_samples,)
A structured array containing the binary event indicat... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
")",
":",
"X",
",",
"event",
",",
"time",
"=",
"check_arrays_survival",
"(",
"X",
",",
"y",
")",
"self",
".",
"_fit",
"(",
"X",
",",
"event",
",",
"time",
")",
"return",
"self"
] | Build a MINLIP survival model from training data.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Data matrix.
y : structured array, shape = (n_samples,)
A structured array containing the binary event indicator
as first field, a... | [
"Build",
"a",
"MINLIP",
"survival",
"model",
"from",
"training",
"data",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/svm/minlip.py#L227-L247 |
232,818 | sebp/scikit-survival | sksurv/svm/minlip.py | MinlipSurvivalAnalysis.predict | def predict(self, X):
"""Predict risk score of experiencing an event.
Higher scores indicate shorter survival (high risk),
lower scores longer survival (low risk).
Parameters
----------
X : array-like, shape = (n_samples, n_features)
The input samples.
... | python | def predict(self, X):
"""Predict risk score of experiencing an event.
Higher scores indicate shorter survival (high risk),
lower scores longer survival (low risk).
Parameters
----------
X : array-like, shape = (n_samples, n_features)
The input samples.
... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"K",
"=",
"self",
".",
"_get_kernel",
"(",
"X",
",",
"self",
".",
"X_fit_",
")",
"pred",
"=",
"-",
"numpy",
".",
"dot",
"(",
"self",
".",
"coef_",
",",
"K",
".",
"T",
")",
"return",
"pred",
"... | Predict risk score of experiencing an event.
Higher scores indicate shorter survival (high risk),
lower scores longer survival (low risk).
Parameters
----------
X : array-like, shape = (n_samples, n_features)
The input samples.
Returns
-------
... | [
"Predict",
"risk",
"score",
"of",
"experiencing",
"an",
"event",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/svm/minlip.py#L249-L267 |
232,819 | sebp/scikit-survival | sksurv/datasets/base.py | get_x_y | def get_x_y(data_frame, attr_labels, pos_label=None, survival=True):
"""Split data frame into features and labels.
Parameters
----------
data_frame : pandas.DataFrame, shape = (n_samples, n_columns)
A data frame.
attr_labels : sequence of str or None
A list of one or more columns t... | python | def get_x_y(data_frame, attr_labels, pos_label=None, survival=True):
"""Split data frame into features and labels.
Parameters
----------
data_frame : pandas.DataFrame, shape = (n_samples, n_columns)
A data frame.
attr_labels : sequence of str or None
A list of one or more columns t... | [
"def",
"get_x_y",
"(",
"data_frame",
",",
"attr_labels",
",",
"pos_label",
"=",
"None",
",",
"survival",
"=",
"True",
")",
":",
"if",
"survival",
":",
"if",
"len",
"(",
"attr_labels",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"\"expected sequence of... | Split data frame into features and labels.
Parameters
----------
data_frame : pandas.DataFrame, shape = (n_samples, n_columns)
A data frame.
attr_labels : sequence of str or None
A list of one or more columns that are considered the label.
If `survival` is `True`, then attr_lab... | [
"Split",
"data",
"frame",
"into",
"features",
"and",
"labels",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/datasets/base.py#L46-L88 |
232,820 | sebp/scikit-survival | sksurv/datasets/base.py | load_arff_files_standardized | def load_arff_files_standardized(path_training, attr_labels, pos_label=None, path_testing=None, survival=True,
standardize_numeric=True, to_numeric=True):
"""Load dataset in ARFF format.
Parameters
----------
path_training : str
Path to ARFF file containing data... | python | def load_arff_files_standardized(path_training, attr_labels, pos_label=None, path_testing=None, survival=True,
standardize_numeric=True, to_numeric=True):
"""Load dataset in ARFF format.
Parameters
----------
path_training : str
Path to ARFF file containing data... | [
"def",
"load_arff_files_standardized",
"(",
"path_training",
",",
"attr_labels",
",",
"pos_label",
"=",
"None",
",",
"path_testing",
"=",
"None",
",",
"survival",
"=",
"True",
",",
"standardize_numeric",
"=",
"True",
",",
"to_numeric",
"=",
"True",
")",
":",
"... | Load dataset in ARFF format.
Parameters
----------
path_training : str
Path to ARFF file containing data.
attr_labels : sequence of str
Names of attributes denoting dependent variables.
If ``survival`` is set, it must be a sequence with two items:
the name of the event ... | [
"Load",
"dataset",
"in",
"ARFF",
"format",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/datasets/base.py#L91-L179 |
232,821 | sebp/scikit-survival | sksurv/datasets/base.py | load_aids | def load_aids(endpoint="aids"):
"""Load and return the AIDS Clinical Trial dataset
The dataset has 1,151 samples and 11 features.
The dataset has 2 endpoints:
1. AIDS defining event, which occurred for 96 patients (8.3%)
2. Death, which occurred for 26 patients (2.3%)
Parameters
---------... | python | def load_aids(endpoint="aids"):
"""Load and return the AIDS Clinical Trial dataset
The dataset has 1,151 samples and 11 features.
The dataset has 2 endpoints:
1. AIDS defining event, which occurred for 96 patients (8.3%)
2. Death, which occurred for 26 patients (2.3%)
Parameters
---------... | [
"def",
"load_aids",
"(",
"endpoint",
"=",
"\"aids\"",
")",
":",
"labels_aids",
"=",
"[",
"'censor'",
",",
"'time'",
"]",
"labels_death",
"=",
"[",
"'censor_d'",
",",
"'time_d'",
"]",
"if",
"endpoint",
"==",
"\"aids\"",
":",
"attr_labels",
"=",
"labels_aids",... | Load and return the AIDS Clinical Trial dataset
The dataset has 1,151 samples and 11 features.
The dataset has 2 endpoints:
1. AIDS defining event, which occurred for 96 patients (8.3%)
2. Death, which occurred for 26 patients (2.3%)
Parameters
----------
endpoint : aids|death
The... | [
"Load",
"and",
"return",
"the",
"AIDS",
"Clinical",
"Trial",
"dataset"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/datasets/base.py#L284-L333 |
232,822 | seemethere/nba_py | nba_py/__init__.py | _api_scrape | def _api_scrape(json_inp, ndx):
"""
Internal method to streamline the getting of data from the json
Args:
json_inp (json): json input from our caller
ndx (int): index where the data is located in the api
Returns:
If pandas is present:
DataFrame (pandas.DataFrame): d... | python | def _api_scrape(json_inp, ndx):
"""
Internal method to streamline the getting of data from the json
Args:
json_inp (json): json input from our caller
ndx (int): index where the data is located in the api
Returns:
If pandas is present:
DataFrame (pandas.DataFrame): d... | [
"def",
"_api_scrape",
"(",
"json_inp",
",",
"ndx",
")",
":",
"try",
":",
"headers",
"=",
"json_inp",
"[",
"'resultSets'",
"]",
"[",
"ndx",
"]",
"[",
"'headers'",
"]",
"values",
"=",
"json_inp",
"[",
"'resultSets'",
"]",
"[",
"ndx",
"]",
"[",
"'rowSet'"... | Internal method to streamline the getting of data from the json
Args:
json_inp (json): json input from our caller
ndx (int): index where the data is located in the api
Returns:
If pandas is present:
DataFrame (pandas.DataFrame): data set from ndx within the
API'... | [
"Internal",
"method",
"to",
"streamline",
"the",
"getting",
"of",
"data",
"from",
"the",
"json"
] | ffeaf4251d796ff9313367a752a45a0d7b16489e | https://github.com/seemethere/nba_py/blob/ffeaf4251d796ff9313367a752a45a0d7b16489e/nba_py/__init__.py#L34-L67 |
232,823 | seemethere/nba_py | nba_py/player.py | get_player | def get_player(first_name,
last_name=None,
season=constants.CURRENT_SEASON,
only_current=0,
just_id=True):
"""
Calls our PlayerList class to get a full list of players and then returns
just an id if specified or the full row of player information
... | python | def get_player(first_name,
last_name=None,
season=constants.CURRENT_SEASON,
only_current=0,
just_id=True):
"""
Calls our PlayerList class to get a full list of players and then returns
just an id if specified or the full row of player information
... | [
"def",
"get_player",
"(",
"first_name",
",",
"last_name",
"=",
"None",
",",
"season",
"=",
"constants",
".",
"CURRENT_SEASON",
",",
"only_current",
"=",
"0",
",",
"just_id",
"=",
"True",
")",
":",
"if",
"last_name",
"is",
"None",
":",
"name",
"=",
"first... | Calls our PlayerList class to get a full list of players and then returns
just an id if specified or the full row of player information
Args:
:first_name: First name of the player
:last_name: Last name of the player
(this is None if the player only has first name [Nene])
:only_c... | [
"Calls",
"our",
"PlayerList",
"class",
"to",
"get",
"a",
"full",
"list",
"of",
"players",
"and",
"then",
"returns",
"just",
"an",
"id",
"if",
"specified",
"or",
"the",
"full",
"row",
"of",
"player",
"information"
] | ffeaf4251d796ff9313367a752a45a0d7b16489e | https://github.com/seemethere/nba_py/blob/ffeaf4251d796ff9313367a752a45a0d7b16489e/nba_py/player.py#L9-L46 |
232,824 | ishikota/PyPokerEngine | pypokerengine/players.py | BasePokerPlayer.respond_to_ask | def respond_to_ask(self, message):
"""Called from Dealer when ask message received from RoundManager"""
valid_actions, hole_card, round_state = self.__parse_ask_message(message)
return self.declare_action(valid_actions, hole_card, round_state) | python | def respond_to_ask(self, message):
"""Called from Dealer when ask message received from RoundManager"""
valid_actions, hole_card, round_state = self.__parse_ask_message(message)
return self.declare_action(valid_actions, hole_card, round_state) | [
"def",
"respond_to_ask",
"(",
"self",
",",
"message",
")",
":",
"valid_actions",
",",
"hole_card",
",",
"round_state",
"=",
"self",
".",
"__parse_ask_message",
"(",
"message",
")",
"return",
"self",
".",
"declare_action",
"(",
"valid_actions",
",",
"hole_card",
... | Called from Dealer when ask message received from RoundManager | [
"Called",
"from",
"Dealer",
"when",
"ask",
"message",
"received",
"from",
"RoundManager"
] | a52a048a15da276005eca4acae96fb6eeb4dc034 | https://github.com/ishikota/PyPokerEngine/blob/a52a048a15da276005eca4acae96fb6eeb4dc034/pypokerengine/players.py#L45-L48 |
232,825 | ishikota/PyPokerEngine | pypokerengine/players.py | BasePokerPlayer.receive_notification | def receive_notification(self, message):
"""Called from Dealer when notification received from RoundManager"""
msg_type = message["message_type"]
if msg_type == "game_start_message":
info = self.__parse_game_start_message(message)
self.receive_game_start_message(info)
elif msg_type == "rou... | python | def receive_notification(self, message):
"""Called from Dealer when notification received from RoundManager"""
msg_type = message["message_type"]
if msg_type == "game_start_message":
info = self.__parse_game_start_message(message)
self.receive_game_start_message(info)
elif msg_type == "rou... | [
"def",
"receive_notification",
"(",
"self",
",",
"message",
")",
":",
"msg_type",
"=",
"message",
"[",
"\"message_type\"",
"]",
"if",
"msg_type",
"==",
"\"game_start_message\"",
":",
"info",
"=",
"self",
".",
"__parse_game_start_message",
"(",
"message",
")",
"s... | Called from Dealer when notification received from RoundManager | [
"Called",
"from",
"Dealer",
"when",
"notification",
"received",
"from",
"RoundManager"
] | a52a048a15da276005eca4acae96fb6eeb4dc034 | https://github.com/ishikota/PyPokerEngine/blob/a52a048a15da276005eca4acae96fb6eeb4dc034/pypokerengine/players.py#L50-L72 |
232,826 | alex-sherman/unsync | examples/mixing_methods.py | result_continuation | async def result_continuation(task):
"""A preliminary result processor we'll chain on to the original task
This will get executed wherever the source task was executed, in this
case one of the threads in the ThreadPoolExecutor"""
await asyncio.sleep(0.1)
num, res = task.result()
return num... | python | async def result_continuation(task):
"""A preliminary result processor we'll chain on to the original task
This will get executed wherever the source task was executed, in this
case one of the threads in the ThreadPoolExecutor"""
await asyncio.sleep(0.1)
num, res = task.result()
return num... | [
"async",
"def",
"result_continuation",
"(",
"task",
")",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"0.1",
")",
"num",
",",
"res",
"=",
"task",
".",
"result",
"(",
")",
"return",
"num",
",",
"res",
"*",
"2"
] | A preliminary result processor we'll chain on to the original task
This will get executed wherever the source task was executed, in this
case one of the threads in the ThreadPoolExecutor | [
"A",
"preliminary",
"result",
"processor",
"we",
"ll",
"chain",
"on",
"to",
"the",
"original",
"task",
"This",
"will",
"get",
"executed",
"wherever",
"the",
"source",
"task",
"was",
"executed",
"in",
"this",
"case",
"one",
"of",
"the",
"threads",
"in",
"th... | a52a0b04980dcaf6dc2fd734aa9d7be9d8960bbe | https://github.com/alex-sherman/unsync/blob/a52a0b04980dcaf6dc2fd734aa9d7be9d8960bbe/examples/mixing_methods.py#L16-L22 |
232,827 | alex-sherman/unsync | examples/mixing_methods.py | result_processor | async def result_processor(tasks):
"""An async result aggregator that combines all the results
This gets executed in unsync.loop and unsync.thread"""
output = {}
for task in tasks:
num, res = await task
output[num] = res
return output | python | async def result_processor(tasks):
"""An async result aggregator that combines all the results
This gets executed in unsync.loop and unsync.thread"""
output = {}
for task in tasks:
num, res = await task
output[num] = res
return output | [
"async",
"def",
"result_processor",
"(",
"tasks",
")",
":",
"output",
"=",
"{",
"}",
"for",
"task",
"in",
"tasks",
":",
"num",
",",
"res",
"=",
"await",
"task",
"output",
"[",
"num",
"]",
"=",
"res",
"return",
"output"
] | An async result aggregator that combines all the results
This gets executed in unsync.loop and unsync.thread | [
"An",
"async",
"result",
"aggregator",
"that",
"combines",
"all",
"the",
"results",
"This",
"gets",
"executed",
"in",
"unsync",
".",
"loop",
"and",
"unsync",
".",
"thread"
] | a52a0b04980dcaf6dc2fd734aa9d7be9d8960bbe | https://github.com/alex-sherman/unsync/blob/a52a0b04980dcaf6dc2fd734aa9d7be9d8960bbe/examples/mixing_methods.py#L25-L32 |
232,828 | fastavro/fastavro | fastavro/_read_py.py | read_union | def read_union(fo, writer_schema, reader_schema=None):
"""A union is encoded by first writing a long value indicating the
zero-based position within the union of the schema of its value.
The value is then encoded per the indicated schema within the union.
"""
# schema resolution
index = read_lo... | python | def read_union(fo, writer_schema, reader_schema=None):
"""A union is encoded by first writing a long value indicating the
zero-based position within the union of the schema of its value.
The value is then encoded per the indicated schema within the union.
"""
# schema resolution
index = read_lo... | [
"def",
"read_union",
"(",
"fo",
",",
"writer_schema",
",",
"reader_schema",
"=",
"None",
")",
":",
"# schema resolution",
"index",
"=",
"read_long",
"(",
"fo",
")",
"if",
"reader_schema",
":",
"# Handle case where the reader schema is just a single type (not union)",
"i... | A union is encoded by first writing a long value indicating the
zero-based position within the union of the schema of its value.
The value is then encoded per the indicated schema within the union. | [
"A",
"union",
"is",
"encoded",
"by",
"first",
"writing",
"a",
"long",
"value",
"indicating",
"the",
"zero",
"-",
"based",
"position",
"within",
"the",
"union",
"of",
"the",
"schema",
"of",
"its",
"value",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_read_py.py#L345-L366 |
232,829 | fastavro/fastavro | fastavro/_read_py.py | read_data | def read_data(fo, writer_schema, reader_schema=None):
"""Read data from file object according to schema."""
record_type = extract_record_type(writer_schema)
logical_type = extract_logical_type(writer_schema)
if reader_schema and record_type in AVRO_TYPES:
# If the schemas are the same, set the... | python | def read_data(fo, writer_schema, reader_schema=None):
"""Read data from file object according to schema."""
record_type = extract_record_type(writer_schema)
logical_type = extract_logical_type(writer_schema)
if reader_schema and record_type in AVRO_TYPES:
# If the schemas are the same, set the... | [
"def",
"read_data",
"(",
"fo",
",",
"writer_schema",
",",
"reader_schema",
"=",
"None",
")",
":",
"record_type",
"=",
"extract_record_type",
"(",
"writer_schema",
")",
"logical_type",
"=",
"extract_logical_type",
"(",
"writer_schema",
")",
"if",
"reader_schema",
"... | Read data from file object according to schema. | [
"Read",
"data",
"from",
"file",
"object",
"according",
"to",
"schema",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_read_py.py#L477-L516 |
232,830 | fastavro/fastavro | fastavro/_read_py.py | _iter_avro_records | def _iter_avro_records(fo, header, codec, writer_schema, reader_schema):
"""Return iterator over avro records."""
sync_marker = header['sync']
read_block = BLOCK_READERS.get(codec)
if not read_block:
raise ValueError('Unrecognized codec: %r' % codec)
block_count = 0
while True:
... | python | def _iter_avro_records(fo, header, codec, writer_schema, reader_schema):
"""Return iterator over avro records."""
sync_marker = header['sync']
read_block = BLOCK_READERS.get(codec)
if not read_block:
raise ValueError('Unrecognized codec: %r' % codec)
block_count = 0
while True:
... | [
"def",
"_iter_avro_records",
"(",
"fo",
",",
"header",
",",
"codec",
",",
"writer_schema",
",",
"reader_schema",
")",
":",
"sync_marker",
"=",
"header",
"[",
"'sync'",
"]",
"read_block",
"=",
"BLOCK_READERS",
".",
"get",
"(",
"codec",
")",
"if",
"not",
"re... | Return iterator over avro records. | [
"Return",
"iterator",
"over",
"avro",
"records",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_read_py.py#L559-L579 |
232,831 | fastavro/fastavro | fastavro/_read_py.py | _iter_avro_blocks | def _iter_avro_blocks(fo, header, codec, writer_schema, reader_schema):
"""Return iterator over avro blocks."""
sync_marker = header['sync']
read_block = BLOCK_READERS.get(codec)
if not read_block:
raise ValueError('Unrecognized codec: %r' % codec)
while True:
offset = fo.tell()
... | python | def _iter_avro_blocks(fo, header, codec, writer_schema, reader_schema):
"""Return iterator over avro blocks."""
sync_marker = header['sync']
read_block = BLOCK_READERS.get(codec)
if not read_block:
raise ValueError('Unrecognized codec: %r' % codec)
while True:
offset = fo.tell()
... | [
"def",
"_iter_avro_blocks",
"(",
"fo",
",",
"header",
",",
"codec",
",",
"writer_schema",
",",
"reader_schema",
")",
":",
"sync_marker",
"=",
"header",
"[",
"'sync'",
"]",
"read_block",
"=",
"BLOCK_READERS",
".",
"get",
"(",
"codec",
")",
"if",
"not",
"rea... | Return iterator over avro blocks. | [
"Return",
"iterator",
"over",
"avro",
"blocks",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_read_py.py#L582-L606 |
232,832 | fastavro/fastavro | fastavro/_write_py.py | prepare_timestamp_millis | def prepare_timestamp_millis(data, schema):
"""Converts datetime.datetime object to int timestamp with milliseconds
"""
if isinstance(data, datetime.datetime):
if data.tzinfo is not None:
delta = (data - epoch)
return int(delta.total_seconds() * MLS_PER_SECOND)
t = in... | python | def prepare_timestamp_millis(data, schema):
"""Converts datetime.datetime object to int timestamp with milliseconds
"""
if isinstance(data, datetime.datetime):
if data.tzinfo is not None:
delta = (data - epoch)
return int(delta.total_seconds() * MLS_PER_SECOND)
t = in... | [
"def",
"prepare_timestamp_millis",
"(",
"data",
",",
"schema",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"datetime",
".",
"datetime",
")",
":",
"if",
"data",
".",
"tzinfo",
"is",
"not",
"None",
":",
"delta",
"=",
"(",
"data",
"-",
"epoch",
")",
... | Converts datetime.datetime object to int timestamp with milliseconds | [
"Converts",
"datetime",
".",
"datetime",
"object",
"to",
"int",
"timestamp",
"with",
"milliseconds"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L43-L54 |
232,833 | fastavro/fastavro | fastavro/_write_py.py | prepare_timestamp_micros | def prepare_timestamp_micros(data, schema):
"""Converts datetime.datetime to int timestamp with microseconds"""
if isinstance(data, datetime.datetime):
if data.tzinfo is not None:
delta = (data - epoch)
return int(delta.total_seconds() * MCS_PER_SECOND)
t = int(time.mktim... | python | def prepare_timestamp_micros(data, schema):
"""Converts datetime.datetime to int timestamp with microseconds"""
if isinstance(data, datetime.datetime):
if data.tzinfo is not None:
delta = (data - epoch)
return int(delta.total_seconds() * MCS_PER_SECOND)
t = int(time.mktim... | [
"def",
"prepare_timestamp_micros",
"(",
"data",
",",
"schema",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"datetime",
".",
"datetime",
")",
":",
"if",
"data",
".",
"tzinfo",
"is",
"not",
"None",
":",
"delta",
"=",
"(",
"data",
"-",
"epoch",
")",
... | Converts datetime.datetime to int timestamp with microseconds | [
"Converts",
"datetime",
".",
"datetime",
"to",
"int",
"timestamp",
"with",
"microseconds"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L57-L67 |
232,834 | fastavro/fastavro | fastavro/_write_py.py | prepare_date | def prepare_date(data, schema):
"""Converts datetime.date to int timestamp"""
if isinstance(data, datetime.date):
return data.toordinal() - DAYS_SHIFT
else:
return data | python | def prepare_date(data, schema):
"""Converts datetime.date to int timestamp"""
if isinstance(data, datetime.date):
return data.toordinal() - DAYS_SHIFT
else:
return data | [
"def",
"prepare_date",
"(",
"data",
",",
"schema",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"datetime",
".",
"date",
")",
":",
"return",
"data",
".",
"toordinal",
"(",
")",
"-",
"DAYS_SHIFT",
"else",
":",
"return",
"data"
] | Converts datetime.date to int timestamp | [
"Converts",
"datetime",
".",
"date",
"to",
"int",
"timestamp"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L70-L75 |
232,835 | fastavro/fastavro | fastavro/_write_py.py | prepare_uuid | def prepare_uuid(data, schema):
"""Converts uuid.UUID to
string formatted UUID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
"""
if isinstance(data, uuid.UUID):
return str(data)
else:
return data | python | def prepare_uuid(data, schema):
"""Converts uuid.UUID to
string formatted UUID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
"""
if isinstance(data, uuid.UUID):
return str(data)
else:
return data | [
"def",
"prepare_uuid",
"(",
"data",
",",
"schema",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"uuid",
".",
"UUID",
")",
":",
"return",
"str",
"(",
"data",
")",
"else",
":",
"return",
"data"
] | Converts uuid.UUID to
string formatted UUID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | [
"Converts",
"uuid",
".",
"UUID",
"to",
"string",
"formatted",
"UUID",
"xxxxxxxx",
"-",
"xxxx",
"-",
"xxxx",
"-",
"xxxx",
"-",
"xxxxxxxxxxxx"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L78-L85 |
232,836 | fastavro/fastavro | fastavro/_write_py.py | prepare_time_millis | def prepare_time_millis(data, schema):
"""Convert datetime.time to int timestamp with milliseconds"""
if isinstance(data, datetime.time):
return int(
data.hour * MLS_PER_HOUR + data.minute * MLS_PER_MINUTE
+ data.second * MLS_PER_SECOND + int(data.microsecond / 1000))
else:
... | python | def prepare_time_millis(data, schema):
"""Convert datetime.time to int timestamp with milliseconds"""
if isinstance(data, datetime.time):
return int(
data.hour * MLS_PER_HOUR + data.minute * MLS_PER_MINUTE
+ data.second * MLS_PER_SECOND + int(data.microsecond / 1000))
else:
... | [
"def",
"prepare_time_millis",
"(",
"data",
",",
"schema",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"datetime",
".",
"time",
")",
":",
"return",
"int",
"(",
"data",
".",
"hour",
"*",
"MLS_PER_HOUR",
"+",
"data",
".",
"minute",
"*",
"MLS_PER_MINUTE"... | Convert datetime.time to int timestamp with milliseconds | [
"Convert",
"datetime",
".",
"time",
"to",
"int",
"timestamp",
"with",
"milliseconds"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L88-L95 |
232,837 | fastavro/fastavro | fastavro/_write_py.py | prepare_time_micros | def prepare_time_micros(data, schema):
"""Convert datetime.time to int timestamp with microseconds"""
if isinstance(data, datetime.time):
return long(data.hour * MCS_PER_HOUR + data.minute * MCS_PER_MINUTE
+ data.second * MCS_PER_SECOND + data.microsecond)
else:
return da... | python | def prepare_time_micros(data, schema):
"""Convert datetime.time to int timestamp with microseconds"""
if isinstance(data, datetime.time):
return long(data.hour * MCS_PER_HOUR + data.minute * MCS_PER_MINUTE
+ data.second * MCS_PER_SECOND + data.microsecond)
else:
return da... | [
"def",
"prepare_time_micros",
"(",
"data",
",",
"schema",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"datetime",
".",
"time",
")",
":",
"return",
"long",
"(",
"data",
".",
"hour",
"*",
"MCS_PER_HOUR",
"+",
"data",
".",
"minute",
"*",
"MCS_PER_MINUTE... | Convert datetime.time to int timestamp with microseconds | [
"Convert",
"datetime",
".",
"time",
"to",
"int",
"timestamp",
"with",
"microseconds"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L98-L104 |
232,838 | fastavro/fastavro | fastavro/_write_py.py | prepare_bytes_decimal | def prepare_bytes_decimal(data, schema):
"""Convert decimal.Decimal to bytes"""
if not isinstance(data, decimal.Decimal):
return data
scale = schema.get('scale', 0)
# based on https://github.com/apache/avro/pull/82/
sign, digits, exp = data.as_tuple()
if -exp > scale:
raise Va... | python | def prepare_bytes_decimal(data, schema):
"""Convert decimal.Decimal to bytes"""
if not isinstance(data, decimal.Decimal):
return data
scale = schema.get('scale', 0)
# based on https://github.com/apache/avro/pull/82/
sign, digits, exp = data.as_tuple()
if -exp > scale:
raise Va... | [
"def",
"prepare_bytes_decimal",
"(",
"data",
",",
"schema",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"decimal",
".",
"Decimal",
")",
":",
"return",
"data",
"scale",
"=",
"schema",
".",
"get",
"(",
"'scale'",
",",
"0",
")",
"# based on https... | Convert decimal.Decimal to bytes | [
"Convert",
"decimal",
".",
"Decimal",
"to",
"bytes"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L107-L145 |
232,839 | fastavro/fastavro | fastavro/_write_py.py | prepare_fixed_decimal | def prepare_fixed_decimal(data, schema):
"""Converts decimal.Decimal to fixed length bytes array"""
if not isinstance(data, decimal.Decimal):
return data
scale = schema.get('scale', 0)
size = schema['size']
# based on https://github.com/apache/avro/pull/82/
sign, digits, exp = data.as_... | python | def prepare_fixed_decimal(data, schema):
"""Converts decimal.Decimal to fixed length bytes array"""
if not isinstance(data, decimal.Decimal):
return data
scale = schema.get('scale', 0)
size = schema['size']
# based on https://github.com/apache/avro/pull/82/
sign, digits, exp = data.as_... | [
"def",
"prepare_fixed_decimal",
"(",
"data",
",",
"schema",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"decimal",
".",
"Decimal",
")",
":",
"return",
"data",
"scale",
"=",
"schema",
".",
"get",
"(",
"'scale'",
",",
"0",
")",
"size",
"=",
... | Converts decimal.Decimal to fixed length bytes array | [
"Converts",
"decimal",
".",
"Decimal",
"to",
"fixed",
"length",
"bytes",
"array"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L148-L203 |
232,840 | fastavro/fastavro | fastavro/_write_py.py | write_crc32 | def write_crc32(fo, bytes):
"""A 4-byte, big-endian CRC32 checksum"""
data = crc32(bytes) & 0xFFFFFFFF
fo.write(pack('>I', data)) | python | def write_crc32(fo, bytes):
"""A 4-byte, big-endian CRC32 checksum"""
data = crc32(bytes) & 0xFFFFFFFF
fo.write(pack('>I', data)) | [
"def",
"write_crc32",
"(",
"fo",
",",
"bytes",
")",
":",
"data",
"=",
"crc32",
"(",
"bytes",
")",
"&",
"0xFFFFFFFF",
"fo",
".",
"write",
"(",
"pack",
"(",
"'>I'",
",",
"data",
")",
")"
] | A 4-byte, big-endian CRC32 checksum | [
"A",
"4",
"-",
"byte",
"big",
"-",
"endian",
"CRC32",
"checksum"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L245-L248 |
232,841 | fastavro/fastavro | fastavro/_write_py.py | write_union | def write_union(fo, datum, schema):
"""A union is encoded by first writing a long value indicating the
zero-based position within the union of the schema of its value. The value
is then encoded per the indicated schema within the union."""
if isinstance(datum, tuple):
(name, datum) = datum
... | python | def write_union(fo, datum, schema):
"""A union is encoded by first writing a long value indicating the
zero-based position within the union of the schema of its value. The value
is then encoded per the indicated schema within the union."""
if isinstance(datum, tuple):
(name, datum) = datum
... | [
"def",
"write_union",
"(",
"fo",
",",
"datum",
",",
"schema",
")",
":",
"if",
"isinstance",
"(",
"datum",
",",
"tuple",
")",
":",
"(",
"name",
",",
"datum",
")",
"=",
"datum",
"for",
"index",
",",
"candidate",
"in",
"enumerate",
"(",
"schema",
")",
... | A union is encoded by first writing a long value indicating the
zero-based position within the union of the schema of its value. The value
is then encoded per the indicated schema within the union. | [
"A",
"union",
"is",
"encoded",
"by",
"first",
"writing",
"a",
"long",
"value",
"indicating",
"the",
"zero",
"-",
"based",
"position",
"within",
"the",
"union",
"of",
"the",
"schema",
"of",
"its",
"value",
".",
"The",
"value",
"is",
"then",
"encoded",
"pe... | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L302-L341 |
232,842 | fastavro/fastavro | fastavro/_write_py.py | write_data | def write_data(fo, datum, schema):
"""Write a datum of data to output stream.
Paramaters
----------
fo: file-like
Output file
datum: object
Data to write
schema: dict
Schemda to use
"""
record_type = extract_record_type(schema)
logical_type = extract_logical... | python | def write_data(fo, datum, schema):
"""Write a datum of data to output stream.
Paramaters
----------
fo: file-like
Output file
datum: object
Data to write
schema: dict
Schemda to use
"""
record_type = extract_record_type(schema)
logical_type = extract_logical... | [
"def",
"write_data",
"(",
"fo",
",",
"datum",
",",
"schema",
")",
":",
"record_type",
"=",
"extract_record_type",
"(",
"schema",
")",
"logical_type",
"=",
"extract_logical_type",
"(",
"schema",
")",
"fn",
"=",
"WRITERS",
".",
"get",
"(",
"record_type",
")",
... | Write a datum of data to output stream.
Paramaters
----------
fo: file-like
Output file
datum: object
Data to write
schema: dict
Schemda to use | [
"Write",
"a",
"datum",
"of",
"data",
"to",
"output",
"stream",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L390-L414 |
232,843 | fastavro/fastavro | fastavro/_write_py.py | null_write_block | def null_write_block(fo, block_bytes):
"""Write block in "null" codec."""
write_long(fo, len(block_bytes))
fo.write(block_bytes) | python | def null_write_block(fo, block_bytes):
"""Write block in "null" codec."""
write_long(fo, len(block_bytes))
fo.write(block_bytes) | [
"def",
"null_write_block",
"(",
"fo",
",",
"block_bytes",
")",
":",
"write_long",
"(",
"fo",
",",
"len",
"(",
"block_bytes",
")",
")",
"fo",
".",
"write",
"(",
"block_bytes",
")"
] | Write block in "null" codec. | [
"Write",
"block",
"in",
"null",
"codec",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L426-L429 |
232,844 | fastavro/fastavro | fastavro/_write_py.py | deflate_write_block | def deflate_write_block(fo, block_bytes):
"""Write block in "deflate" codec."""
# The first two characters and last character are zlib
# wrappers around deflate data.
data = compress(block_bytes)[2:-1]
write_long(fo, len(data))
fo.write(data) | python | def deflate_write_block(fo, block_bytes):
"""Write block in "deflate" codec."""
# The first two characters and last character are zlib
# wrappers around deflate data.
data = compress(block_bytes)[2:-1]
write_long(fo, len(data))
fo.write(data) | [
"def",
"deflate_write_block",
"(",
"fo",
",",
"block_bytes",
")",
":",
"# The first two characters and last character are zlib",
"# wrappers around deflate data.",
"data",
"=",
"compress",
"(",
"block_bytes",
")",
"[",
"2",
":",
"-",
"1",
"]",
"write_long",
"(",
"fo",... | Write block in "deflate" codec. | [
"Write",
"block",
"in",
"deflate",
"codec",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L432-L439 |
232,845 | fastavro/fastavro | fastavro/_write_py.py | schemaless_writer | def schemaless_writer(fo, schema, record):
"""Write a single record without the schema or header information
Parameters
----------
fo: file-like
Output file
schema: dict
Schema
record: dict
Record to write
Example::
parsed_schema = fastavro.parse_schema(sc... | python | def schemaless_writer(fo, schema, record):
"""Write a single record without the schema or header information
Parameters
----------
fo: file-like
Output file
schema: dict
Schema
record: dict
Record to write
Example::
parsed_schema = fastavro.parse_schema(sc... | [
"def",
"schemaless_writer",
"(",
"fo",
",",
"schema",
",",
"record",
")",
":",
"schema",
"=",
"parse_schema",
"(",
"schema",
")",
"write_data",
"(",
"fo",
",",
"record",
",",
"schema",
")"
] | Write a single record without the schema or header information
Parameters
----------
fo: file-like
Output file
schema: dict
Schema
record: dict
Record to write
Example::
parsed_schema = fastavro.parse_schema(schema)
with open('file.avro', 'rb') as fp:
... | [
"Write",
"a",
"single",
"record",
"without",
"the",
"schema",
"or",
"header",
"information"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L636-L658 |
232,846 | fastavro/fastavro | fastavro/_validation_py.py | validate_int | def validate_int(datum, **kwargs):
"""
Check that the data value is a non floating
point number with size less that Int32.
Also support for logicalType timestamp validation with datetime.
Int32 = -2147483648<=datum<=2147483647
conditional python types
(int, long, numbers.Integral,
date... | python | def validate_int(datum, **kwargs):
"""
Check that the data value is a non floating
point number with size less that Int32.
Also support for logicalType timestamp validation with datetime.
Int32 = -2147483648<=datum<=2147483647
conditional python types
(int, long, numbers.Integral,
date... | [
"def",
"validate_int",
"(",
"datum",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"(",
"(",
"isinstance",
"(",
"datum",
",",
"(",
"int",
",",
"long",
",",
"numbers",
".",
"Integral",
")",
")",
"and",
"INT_MIN_VALUE",
"<=",
"datum",
"<=",
"INT_MAX_VALUE... | Check that the data value is a non floating
point number with size less that Int32.
Also support for logicalType timestamp validation with datetime.
Int32 = -2147483648<=datum<=2147483647
conditional python types
(int, long, numbers.Integral,
datetime.time, datetime.datetime, datetime.date)
... | [
"Check",
"that",
"the",
"data",
"value",
"is",
"a",
"non",
"floating",
"point",
"number",
"with",
"size",
"less",
"that",
"Int32",
".",
"Also",
"support",
"for",
"logicalType",
"timestamp",
"validation",
"with",
"datetime",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L79-L105 |
232,847 | fastavro/fastavro | fastavro/_validation_py.py | validate_float | def validate_float(datum, **kwargs):
"""
Check that the data value is a floating
point number or double precision.
conditional python types
(int, long, float, numbers.Real)
Parameters
----------
datum: Any
Data being validated
kwargs: Any
Unused kwargs
"""
r... | python | def validate_float(datum, **kwargs):
"""
Check that the data value is a floating
point number or double precision.
conditional python types
(int, long, float, numbers.Real)
Parameters
----------
datum: Any
Data being validated
kwargs: Any
Unused kwargs
"""
r... | [
"def",
"validate_float",
"(",
"datum",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"(",
"isinstance",
"(",
"datum",
",",
"(",
"int",
",",
"long",
",",
"float",
",",
"numbers",
".",
"Real",
")",
")",
"and",
"not",
"isinstance",
"(",
"datum",
",",
"... | Check that the data value is a floating
point number or double precision.
conditional python types
(int, long, float, numbers.Real)
Parameters
----------
datum: Any
Data being validated
kwargs: Any
Unused kwargs | [
"Check",
"that",
"the",
"data",
"value",
"is",
"a",
"floating",
"point",
"number",
"or",
"double",
"precision",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L137-L155 |
232,848 | fastavro/fastavro | fastavro/_validation_py.py | validate_record | def validate_record(datum, schema, parent_ns=None, raise_errors=True):
"""
Check that the data is a Mapping type with all schema defined fields
validated as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent name... | python | def validate_record(datum, schema, parent_ns=None, raise_errors=True):
"""
Check that the data is a Mapping type with all schema defined fields
validated as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent name... | [
"def",
"validate_record",
"(",
"datum",
",",
"schema",
",",
"parent_ns",
"=",
"None",
",",
"raise_errors",
"=",
"True",
")",
":",
"_",
",",
"namespace",
"=",
"schema_name",
"(",
"schema",
",",
"parent_ns",
")",
"return",
"(",
"isinstance",
"(",
"datum",
... | Check that the data is a Mapping type with all schema defined fields
validated as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent namespace
raise_errors: bool
If true, raises ValidationError on invalid dat... | [
"Check",
"that",
"the",
"data",
"is",
"a",
"Mapping",
"type",
"with",
"all",
"schema",
"defined",
"fields",
"validated",
"as",
"True",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L245-L270 |
232,849 | fastavro/fastavro | fastavro/_validation_py.py | validate_union | def validate_union(datum, schema, parent_ns=None, raise_errors=True):
"""
Check that the data is a list type with possible options to
validate as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent namespace
r... | python | def validate_union(datum, schema, parent_ns=None, raise_errors=True):
"""
Check that the data is a list type with possible options to
validate as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent namespace
r... | [
"def",
"validate_union",
"(",
"datum",
",",
"schema",
",",
"parent_ns",
"=",
"None",
",",
"raise_errors",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"datum",
",",
"tuple",
")",
":",
"(",
"name",
",",
"datum",
")",
"=",
"datum",
"for",
"candidate",... | Check that the data is a list type with possible options to
validate as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent namespace
raise_errors: bool
If true, raises ValidationError on invalid data | [
"Check",
"that",
"the",
"data",
"is",
"a",
"list",
"type",
"with",
"possible",
"options",
"to",
"validate",
"as",
"True",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L273-L313 |
232,850 | fastavro/fastavro | fastavro/_validation_py.py | validate_many | def validate_many(records, schema, raise_errors=True):
"""
Validate a list of data!
Parameters
----------
records: iterable
List of records to validate
schema: dict
Schema
raise_errors: bool, optional
If true, errors are raised for invalid data. If false, a simple
... | python | def validate_many(records, schema, raise_errors=True):
"""
Validate a list of data!
Parameters
----------
records: iterable
List of records to validate
schema: dict
Schema
raise_errors: bool, optional
If true, errors are raised for invalid data. If false, a simple
... | [
"def",
"validate_many",
"(",
"records",
",",
"schema",
",",
"raise_errors",
"=",
"True",
")",
":",
"errors",
"=",
"[",
"]",
"results",
"=",
"[",
"]",
"for",
"record",
"in",
"records",
":",
"try",
":",
"results",
".",
"append",
"(",
"validate",
"(",
"... | Validate a list of data!
Parameters
----------
records: iterable
List of records to validate
schema: dict
Schema
raise_errors: bool, optional
If true, errors are raised for invalid data. If false, a simple
True (valid) or False (invalid) result is returned
Exam... | [
"Validate",
"a",
"list",
"of",
"data!"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L383-L414 |
232,851 | fastavro/fastavro | fastavro/_schema_py.py | parse_schema | def parse_schema(schema, _write_hint=True, _force=False):
"""Returns a parsed avro schema
It is not necessary to call parse_schema but doing so and saving the parsed
schema for use later will make future operations faster as the schema will
not need to be reparsed.
Parameters
----------
sc... | python | def parse_schema(schema, _write_hint=True, _force=False):
"""Returns a parsed avro schema
It is not necessary to call parse_schema but doing so and saving the parsed
schema for use later will make future operations faster as the schema will
not need to be reparsed.
Parameters
----------
sc... | [
"def",
"parse_schema",
"(",
"schema",
",",
"_write_hint",
"=",
"True",
",",
"_force",
"=",
"False",
")",
":",
"if",
"_force",
":",
"return",
"_parse_schema",
"(",
"schema",
",",
"\"\"",
",",
"_write_hint",
")",
"elif",
"isinstance",
"(",
"schema",
",",
"... | Returns a parsed avro schema
It is not necessary to call parse_schema but doing so and saving the parsed
schema for use later will make future operations faster as the schema will
not need to be reparsed.
Parameters
----------
schema: dict
Input schema
_write_hint: bool
Int... | [
"Returns",
"a",
"parsed",
"avro",
"schema"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_schema_py.py#L53-L86 |
232,852 | fastavro/fastavro | fastavro/_schema_py.py | load_schema | def load_schema(schema_path):
'''
Returns a schema loaded from the file at `schema_path`.
Will recursively load referenced schemas assuming they can be found in
files in the same directory and named with the convention
`<type_name>.avsc`.
'''
with open(schema_path) as fd:
schema = j... | python | def load_schema(schema_path):
'''
Returns a schema loaded from the file at `schema_path`.
Will recursively load referenced schemas assuming they can be found in
files in the same directory and named with the convention
`<type_name>.avsc`.
'''
with open(schema_path) as fd:
schema = j... | [
"def",
"load_schema",
"(",
"schema_path",
")",
":",
"with",
"open",
"(",
"schema_path",
")",
"as",
"fd",
":",
"schema",
"=",
"json",
".",
"load",
"(",
"fd",
")",
"schema_dir",
",",
"schema_file",
"=",
"path",
".",
"split",
"(",
"schema_path",
")",
"ret... | Returns a schema loaded from the file at `schema_path`.
Will recursively load referenced schemas assuming they can be found in
files in the same directory and named with the convention
`<type_name>.avsc`. | [
"Returns",
"a",
"schema",
"loaded",
"from",
"the",
"file",
"at",
"schema_path",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_schema_py.py#L212-L223 |
232,853 | alejandroautalan/pygubu | pygubu/widgets/simpletooltip.py | ToolTip.showtip | def showtip(self, text):
"Display text in tooltip window"
self.text = text
if self.tipwindow or not self.text:
return
x, y, cx, cy = self.widget.bbox("insert")
x = x + self.widget.winfo_rootx() + 27
y = y + cy + self.widget.winfo_rooty() +27
self.tipwi... | python | def showtip(self, text):
"Display text in tooltip window"
self.text = text
if self.tipwindow or not self.text:
return
x, y, cx, cy = self.widget.bbox("insert")
x = x + self.widget.winfo_rootx() + 27
y = y + cy + self.widget.winfo_rooty() +27
self.tipwi... | [
"def",
"showtip",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"text",
"=",
"text",
"if",
"self",
".",
"tipwindow",
"or",
"not",
"self",
".",
"text",
":",
"return",
"x",
",",
"y",
",",
"cx",
",",
"cy",
"=",
"self",
".",
"widget",
".",
"bbox... | Display text in tooltip window | [
"Display",
"text",
"in",
"tooltip",
"window"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/simpletooltip.py#L20-L42 |
232,854 | alejandroautalan/pygubu | pygubu/__init__.py | TkApplication.run | def run(self):
"""Ejecute the main loop."""
self.toplevel.protocol("WM_DELETE_WINDOW", self.__on_window_close)
self.toplevel.mainloop() | python | def run(self):
"""Ejecute the main loop."""
self.toplevel.protocol("WM_DELETE_WINDOW", self.__on_window_close)
self.toplevel.mainloop() | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"toplevel",
".",
"protocol",
"(",
"\"WM_DELETE_WINDOW\"",
",",
"self",
".",
"__on_window_close",
")",
"self",
".",
"toplevel",
".",
"mainloop",
"(",
")"
] | Ejecute the main loop. | [
"Ejecute",
"the",
"main",
"loop",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/__init__.py#L41-L45 |
232,855 | alejandroautalan/pygubu | examples/py2exe/myapp.py | MyApplication.create_regpoly | def create_regpoly(self, x0, y0, x1, y1, sides=0, start=90, extent=360, **kw):
"""Create a regular polygon"""
coords = self.__regpoly_coords(x0, y0, x1, y1, sides, start, extent)
return self.canvas.create_polygon(*coords, **kw) | python | def create_regpoly(self, x0, y0, x1, y1, sides=0, start=90, extent=360, **kw):
"""Create a regular polygon"""
coords = self.__regpoly_coords(x0, y0, x1, y1, sides, start, extent)
return self.canvas.create_polygon(*coords, **kw) | [
"def",
"create_regpoly",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"sides",
"=",
"0",
",",
"start",
"=",
"90",
",",
"extent",
"=",
"360",
",",
"*",
"*",
"kw",
")",
":",
"coords",
"=",
"self",
".",
"__regpoly_coords",
"(",
"x... | Create a regular polygon | [
"Create",
"a",
"regular",
"polygon"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/examples/py2exe/myapp.py#L131-L134 |
232,856 | alejandroautalan/pygubu | examples/py2exe/myapp.py | MyApplication.__regpoly_coords | def __regpoly_coords(self, x0, y0, x1, y1, sides, start, extent):
"""Create the coordinates of the regular polygon specified"""
coords = []
if extent == 0:
return coords
xm = (x0 + x1) / 2.
ym = (y0 + y1) / 2.
rx = xm - x0
ry = ym - y0
n = s... | python | def __regpoly_coords(self, x0, y0, x1, y1, sides, start, extent):
"""Create the coordinates of the regular polygon specified"""
coords = []
if extent == 0:
return coords
xm = (x0 + x1) / 2.
ym = (y0 + y1) / 2.
rx = xm - x0
ry = ym - y0
n = s... | [
"def",
"__regpoly_coords",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"sides",
",",
"start",
",",
"extent",
")",
":",
"coords",
"=",
"[",
"]",
"if",
"extent",
"==",
"0",
":",
"return",
"coords",
"xm",
"=",
"(",
"x0",
"+",
"x1... | Create the coordinates of the regular polygon specified | [
"Create",
"the",
"coordinates",
"of",
"the",
"regular",
"polygon",
"specified"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/examples/py2exe/myapp.py#L136-L189 |
232,857 | alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.get_image | def get_image(self, path):
"""Return tk image corresponding to name which is taken form path."""
image = ''
name = os.path.basename(path)
if not StockImage.is_registered(name):
ipath = self.__find_image(path)
if ipath is not None:
StockImage.regist... | python | def get_image(self, path):
"""Return tk image corresponding to name which is taken form path."""
image = ''
name = os.path.basename(path)
if not StockImage.is_registered(name):
ipath = self.__find_image(path)
if ipath is not None:
StockImage.regist... | [
"def",
"get_image",
"(",
"self",
",",
"path",
")",
":",
"image",
"=",
"''",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"if",
"not",
"StockImage",
".",
"is_registered",
"(",
"name",
")",
":",
"ipath",
"=",
"self",
".",
"__fin... | Return tk image corresponding to name which is taken form path. | [
"Return",
"tk",
"image",
"corresponding",
"to",
"name",
"which",
"is",
"taken",
"form",
"path",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L195-L211 |
232,858 | alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.import_variables | def import_variables(self, container, varnames=None):
"""Helper method to avoid call get_variable for every variable."""
if varnames is None:
for keyword in self.tkvariables:
setattr(container, keyword, self.tkvariables[keyword])
else:
for keyword in varna... | python | def import_variables(self, container, varnames=None):
"""Helper method to avoid call get_variable for every variable."""
if varnames is None:
for keyword in self.tkvariables:
setattr(container, keyword, self.tkvariables[keyword])
else:
for keyword in varna... | [
"def",
"import_variables",
"(",
"self",
",",
"container",
",",
"varnames",
"=",
"None",
")",
":",
"if",
"varnames",
"is",
"None",
":",
"for",
"keyword",
"in",
"self",
".",
"tkvariables",
":",
"setattr",
"(",
"container",
",",
"keyword",
",",
"self",
".",... | Helper method to avoid call get_variable for every variable. | [
"Helper",
"method",
"to",
"avoid",
"call",
"get_variable",
"for",
"every",
"variable",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L228-L236 |
232,859 | alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.create_variable | def create_variable(self, varname, vtype=None):
"""Create a tk variable.
If the variable was created previously return that instance.
"""
var_types = ('string', 'int', 'boolean', 'double')
vname = varname
var = None
type_from_name = 'string' # default type
... | python | def create_variable(self, varname, vtype=None):
"""Create a tk variable.
If the variable was created previously return that instance.
"""
var_types = ('string', 'int', 'boolean', 'double')
vname = varname
var = None
type_from_name = 'string' # default type
... | [
"def",
"create_variable",
"(",
"self",
",",
"varname",
",",
"vtype",
"=",
"None",
")",
":",
"var_types",
"=",
"(",
"'string'",
",",
"'int'",
",",
"'boolean'",
",",
"'double'",
")",
"vname",
"=",
"varname",
"var",
"=",
"None",
"type_from_name",
"=",
"'str... | Create a tk variable.
If the variable was created previously return that instance. | [
"Create",
"a",
"tk",
"variable",
".",
"If",
"the",
"variable",
"was",
"created",
"previously",
"return",
"that",
"instance",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L238-L273 |
232,860 | alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.add_from_file | def add_from_file(self, fpath):
"""Load ui definition from file."""
if self.tree is None:
base, name = os.path.split(fpath)
self.add_resource_path(base)
self.tree = tree = ET.parse(fpath)
self.root = tree.getroot()
self.objects = {}
els... | python | def add_from_file(self, fpath):
"""Load ui definition from file."""
if self.tree is None:
base, name = os.path.split(fpath)
self.add_resource_path(base)
self.tree = tree = ET.parse(fpath)
self.root = tree.getroot()
self.objects = {}
els... | [
"def",
"add_from_file",
"(",
"self",
",",
"fpath",
")",
":",
"if",
"self",
".",
"tree",
"is",
"None",
":",
"base",
",",
"name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fpath",
")",
"self",
".",
"add_resource_path",
"(",
"base",
")",
"self",
"."... | Load ui definition from file. | [
"Load",
"ui",
"definition",
"from",
"file",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L275-L285 |
232,861 | alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.add_from_string | def add_from_string(self, strdata):
"""Load ui definition from string."""
if self.tree is None:
self.tree = tree = ET.ElementTree(ET.fromstring(strdata))
self.root = tree.getroot()
self.objects = {}
else:
# TODO: append to current tree
... | python | def add_from_string(self, strdata):
"""Load ui definition from string."""
if self.tree is None:
self.tree = tree = ET.ElementTree(ET.fromstring(strdata))
self.root = tree.getroot()
self.objects = {}
else:
# TODO: append to current tree
... | [
"def",
"add_from_string",
"(",
"self",
",",
"strdata",
")",
":",
"if",
"self",
".",
"tree",
"is",
"None",
":",
"self",
".",
"tree",
"=",
"tree",
"=",
"ET",
".",
"ElementTree",
"(",
"ET",
".",
"fromstring",
"(",
"strdata",
")",
")",
"self",
".",
"ro... | Load ui definition from string. | [
"Load",
"ui",
"definition",
"from",
"string",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L287-L295 |
232,862 | alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.add_from_xmlnode | def add_from_xmlnode(self, element):
"""Load ui definition from xml.etree.Element node."""
if self.tree is None:
root = ET.Element('interface')
root.append(element)
self.tree = tree = ET.ElementTree(root)
self.root = tree.getroot()
self.objects... | python | def add_from_xmlnode(self, element):
"""Load ui definition from xml.etree.Element node."""
if self.tree is None:
root = ET.Element('interface')
root.append(element)
self.tree = tree = ET.ElementTree(root)
self.root = tree.getroot()
self.objects... | [
"def",
"add_from_xmlnode",
"(",
"self",
",",
"element",
")",
":",
"if",
"self",
".",
"tree",
"is",
"None",
":",
"root",
"=",
"ET",
".",
"Element",
"(",
"'interface'",
")",
"root",
".",
"append",
"(",
"element",
")",
"self",
".",
"tree",
"=",
"tree",
... | Load ui definition from xml.etree.Element node. | [
"Load",
"ui",
"definition",
"from",
"xml",
".",
"etree",
".",
"Element",
"node",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L297-L308 |
232,863 | alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.get_object | def get_object(self, name, master=None):
"""Find and create the widget named name.
Use master as parent. If widget was already created, return
that instance."""
widget = None
if name in self.objects:
widget = self.objects[name].widget
else:
xpath =... | python | def get_object(self, name, master=None):
"""Find and create the widget named name.
Use master as parent. If widget was already created, return
that instance."""
widget = None
if name in self.objects:
widget = self.objects[name].widget
else:
xpath =... | [
"def",
"get_object",
"(",
"self",
",",
"name",
",",
"master",
"=",
"None",
")",
":",
"widget",
"=",
"None",
"if",
"name",
"in",
"self",
".",
"objects",
":",
"widget",
"=",
"self",
".",
"objects",
"[",
"name",
"]",
".",
"widget",
"else",
":",
"xpath... | Find and create the widget named name.
Use master as parent. If widget was already created, return
that instance. | [
"Find",
"and",
"create",
"the",
"widget",
"named",
"name",
".",
"Use",
"master",
"as",
"parent",
".",
"If",
"widget",
"was",
"already",
"created",
"return",
"that",
"instance",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L310-L328 |
232,864 | alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder._realize | def _realize(self, master, element):
"""Builds a widget from xml element using master as parent."""
data = data_xmlnode_to_dict(element, self.translator)
cname = data['class']
uniqueid = data['id']
if cname not in CLASS_MAP:
self._import_class(cname)
if cna... | python | def _realize(self, master, element):
"""Builds a widget from xml element using master as parent."""
data = data_xmlnode_to_dict(element, self.translator)
cname = data['class']
uniqueid = data['id']
if cname not in CLASS_MAP:
self._import_class(cname)
if cna... | [
"def",
"_realize",
"(",
"self",
",",
"master",
",",
"element",
")",
":",
"data",
"=",
"data_xmlnode_to_dict",
"(",
"element",
",",
"self",
".",
"translator",
")",
"cname",
"=",
"data",
"[",
"'class'",
"]",
"uniqueid",
"=",
"data",
"[",
"'id'",
"]",
"if... | Builds a widget from xml element using master as parent. | [
"Builds",
"a",
"widget",
"from",
"xml",
"element",
"using",
"master",
"as",
"parent",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L349-L377 |
232,865 | alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.connect_callbacks | def connect_callbacks(self, callbacks_bag):
"""Connect callbacks specified in callbacks_bag with callbacks
defined in the ui definition.
Return a list with the name of the callbacks not connected.
"""
notconnected = []
for wname, builderobj in self.objects.items():
... | python | def connect_callbacks(self, callbacks_bag):
"""Connect callbacks specified in callbacks_bag with callbacks
defined in the ui definition.
Return a list with the name of the callbacks not connected.
"""
notconnected = []
for wname, builderobj in self.objects.items():
... | [
"def",
"connect_callbacks",
"(",
"self",
",",
"callbacks_bag",
")",
":",
"notconnected",
"=",
"[",
"]",
"for",
"wname",
",",
"builderobj",
"in",
"self",
".",
"objects",
".",
"items",
"(",
")",
":",
"missing",
"=",
"builderobj",
".",
"connect_commands",
"("... | Connect callbacks specified in callbacks_bag with callbacks
defined in the ui definition.
Return a list with the name of the callbacks not connected. | [
"Connect",
"callbacks",
"specified",
"in",
"callbacks_bag",
"with",
"callbacks",
"defined",
"in",
"the",
"ui",
"definition",
".",
"Return",
"a",
"list",
"with",
"the",
"name",
"of",
"the",
"callbacks",
"not",
"connected",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L388-L407 |
232,866 | alejandroautalan/pygubu | pygubudesigner/util/selecttool.py | SelectTool._start_selecting | def _start_selecting(self, event):
"""Comienza con el proceso de seleccion."""
self._selecting = True
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
self._sstart = (x, y)
if not self._sobject:
self._sobject = canvas.creat... | python | def _start_selecting(self, event):
"""Comienza con el proceso de seleccion."""
self._selecting = True
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
self._sstart = (x, y)
if not self._sobject:
self._sobject = canvas.creat... | [
"def",
"_start_selecting",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_selecting",
"=",
"True",
"canvas",
"=",
"self",
".",
"_canvas",
"x",
"=",
"canvas",
".",
"canvasx",
"(",
"event",
".",
"x",
")",
"y",
"=",
"canvas",
".",
"canvasy",
"(",
... | Comienza con el proceso de seleccion. | [
"Comienza",
"con",
"el",
"proceso",
"de",
"seleccion",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/util/selecttool.py#L51-L63 |
232,867 | alejandroautalan/pygubu | pygubudesigner/util/selecttool.py | SelectTool._keep_selecting | def _keep_selecting(self, event):
"""Continua con el proceso de seleccion.
Crea o redimensiona el cuadro de seleccion de acuerdo con
la posicion del raton."""
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
canvas.coords(self._sobject... | python | def _keep_selecting(self, event):
"""Continua con el proceso de seleccion.
Crea o redimensiona el cuadro de seleccion de acuerdo con
la posicion del raton."""
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
canvas.coords(self._sobject... | [
"def",
"_keep_selecting",
"(",
"self",
",",
"event",
")",
":",
"canvas",
"=",
"self",
".",
"_canvas",
"x",
"=",
"canvas",
".",
"canvasx",
"(",
"event",
".",
"x",
")",
"y",
"=",
"canvas",
".",
"canvasy",
"(",
"event",
".",
"y",
")",
"canvas",
".",
... | Continua con el proceso de seleccion.
Crea o redimensiona el cuadro de seleccion de acuerdo con
la posicion del raton. | [
"Continua",
"con",
"el",
"proceso",
"de",
"seleccion",
".",
"Crea",
"o",
"redimensiona",
"el",
"cuadro",
"de",
"seleccion",
"de",
"acuerdo",
"con",
"la",
"posicion",
"del",
"raton",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/util/selecttool.py#L65-L73 |
232,868 | alejandroautalan/pygubu | pygubudesigner/util/selecttool.py | SelectTool._finish_selecting | def _finish_selecting(self, event):
"""Finaliza la seleccion.
Marca como seleccionados todos los objetos que se encuentran
dentro del recuadro de seleccion."""
self._selecting = False
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
... | python | def _finish_selecting(self, event):
"""Finaliza la seleccion.
Marca como seleccionados todos los objetos que se encuentran
dentro del recuadro de seleccion."""
self._selecting = False
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
... | [
"def",
"_finish_selecting",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_selecting",
"=",
"False",
"canvas",
"=",
"self",
".",
"_canvas",
"x",
"=",
"canvas",
".",
"canvasx",
"(",
"event",
".",
"x",
")",
"y",
"=",
"canvas",
".",
"canvasy",
"(",... | Finaliza la seleccion.
Marca como seleccionados todos los objetos que se encuentran
dentro del recuadro de seleccion. | [
"Finaliza",
"la",
"seleccion",
".",
"Marca",
"como",
"seleccionados",
"todos",
"los",
"objetos",
"que",
"se",
"encuentran",
"dentro",
"del",
"recuadro",
"de",
"seleccion",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/util/selecttool.py#L75-L89 |
232,869 | alejandroautalan/pygubu | pygubu/widgets/calendarframe.py | matrix_coords | def matrix_coords(rows, cols, rowh, colw, ox=0, oy=0):
"Generate coords for a matrix of rects"
for i, f, c in rowmajor(rows, cols):
x = ox + c * colw
y = oy + f * rowh
x1 = x + colw
y1 = y + rowh
yield (i, x, y, x1, y1) | python | def matrix_coords(rows, cols, rowh, colw, ox=0, oy=0):
"Generate coords for a matrix of rects"
for i, f, c in rowmajor(rows, cols):
x = ox + c * colw
y = oy + f * rowh
x1 = x + colw
y1 = y + rowh
yield (i, x, y, x1, y1) | [
"def",
"matrix_coords",
"(",
"rows",
",",
"cols",
",",
"rowh",
",",
"colw",
",",
"ox",
"=",
"0",
",",
"oy",
"=",
"0",
")",
":",
"for",
"i",
",",
"f",
",",
"c",
"in",
"rowmajor",
"(",
"rows",
",",
"cols",
")",
":",
"x",
"=",
"ox",
"+",
"c",
... | Generate coords for a matrix of rects | [
"Generate",
"coords",
"for",
"a",
"matrix",
"of",
"rects"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/calendarframe.py#L40-L47 |
232,870 | alejandroautalan/pygubu | pygubudesigner/util/__init__.py | ArrayVar.get | def get(self):
'''Return a dictionary that represents the Tcl array'''
value = {}
for (elementname, elementvar) in self._elementvars.items():
value[elementname] = elementvar.get()
return value | python | def get(self):
'''Return a dictionary that represents the Tcl array'''
value = {}
for (elementname, elementvar) in self._elementvars.items():
value[elementname] = elementvar.get()
return value | [
"def",
"get",
"(",
"self",
")",
":",
"value",
"=",
"{",
"}",
"for",
"(",
"elementname",
",",
"elementvar",
")",
"in",
"self",
".",
"_elementvars",
".",
"items",
"(",
")",
":",
"value",
"[",
"elementname",
"]",
"=",
"elementvar",
".",
"get",
"(",
")... | Return a dictionary that represents the Tcl array | [
"Return",
"a",
"dictionary",
"that",
"represents",
"the",
"Tcl",
"array"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/util/__init__.py#L96-L101 |
232,871 | alejandroautalan/pygubu | pygubu/widgets/editabletreeview.py | EditableTreeview.yview | def yview(self, *args):
"""Update inplace widgets position when doing vertical scroll"""
self.after_idle(self.__updateWnds)
ttk.Treeview.yview(self, *args) | python | def yview(self, *args):
"""Update inplace widgets position when doing vertical scroll"""
self.after_idle(self.__updateWnds)
ttk.Treeview.yview(self, *args) | [
"def",
"yview",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"after_idle",
"(",
"self",
".",
"__updateWnds",
")",
"ttk",
".",
"Treeview",
".",
"yview",
"(",
"self",
",",
"*",
"args",
")"
] | Update inplace widgets position when doing vertical scroll | [
"Update",
"inplace",
"widgets",
"position",
"when",
"doing",
"vertical",
"scroll"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/editabletreeview.py#L106-L109 |
232,872 | alejandroautalan/pygubu | pygubu/widgets/editabletreeview.py | EditableTreeview.xview | def xview(self, *args):
"""Update inplace widgets position when doing horizontal scroll"""
self.after_idle(self.__updateWnds)
ttk.Treeview.xview(self, *args) | python | def xview(self, *args):
"""Update inplace widgets position when doing horizontal scroll"""
self.after_idle(self.__updateWnds)
ttk.Treeview.xview(self, *args) | [
"def",
"xview",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"after_idle",
"(",
"self",
".",
"__updateWnds",
")",
"ttk",
".",
"Treeview",
".",
"xview",
"(",
"self",
",",
"*",
"args",
")"
] | Update inplace widgets position when doing horizontal scroll | [
"Update",
"inplace",
"widgets",
"position",
"when",
"doing",
"horizontal",
"scroll"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/editabletreeview.py#L119-L122 |
232,873 | alejandroautalan/pygubu | pygubu/widgets/editabletreeview.py | EditableTreeview.__check_focus | def __check_focus(self, event):
"""Checks if the focus has changed"""
#print('Event:', event.type, event.x, event.y)
changed = False
if not self._curfocus:
changed = True
elif self._curfocus != self.focus():
self.__clear_inplace_widgets()
chang... | python | def __check_focus(self, event):
"""Checks if the focus has changed"""
#print('Event:', event.type, event.x, event.y)
changed = False
if not self._curfocus:
changed = True
elif self._curfocus != self.focus():
self.__clear_inplace_widgets()
chang... | [
"def",
"__check_focus",
"(",
"self",
",",
"event",
")",
":",
"#print('Event:', event.type, event.x, event.y)",
"changed",
"=",
"False",
"if",
"not",
"self",
".",
"_curfocus",
":",
"changed",
"=",
"True",
"elif",
"self",
".",
"_curfocus",
"!=",
"self",
".",
"fo... | Checks if the focus has changed | [
"Checks",
"if",
"the",
"focus",
"has",
"changed"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/editabletreeview.py#L132-L147 |
232,874 | alejandroautalan/pygubu | pygubu/widgets/editabletreeview.py | EditableTreeview.__focus | def __focus(self, item):
"""Called when focus item has changed"""
cols = self.__get_display_columns()
for col in cols:
self.__event_info =(col,item)
self.event_generate('<<TreeviewInplaceEdit>>')
if col in self._inplace_widgets:
w = self._inpla... | python | def __focus(self, item):
"""Called when focus item has changed"""
cols = self.__get_display_columns()
for col in cols:
self.__event_info =(col,item)
self.event_generate('<<TreeviewInplaceEdit>>')
if col in self._inplace_widgets:
w = self._inpla... | [
"def",
"__focus",
"(",
"self",
",",
"item",
")",
":",
"cols",
"=",
"self",
".",
"__get_display_columns",
"(",
")",
"for",
"col",
"in",
"cols",
":",
"self",
".",
"__event_info",
"=",
"(",
"col",
",",
"item",
")",
"self",
".",
"event_generate",
"(",
"'... | Called when focus item has changed | [
"Called",
"when",
"focus",
"item",
"has",
"changed"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/editabletreeview.py#L149-L160 |
232,875 | alejandroautalan/pygubu | pygubu/widgets/editabletreeview.py | EditableTreeview.__clear_inplace_widgets | def __clear_inplace_widgets(self):
"""Remove all inplace edit widgets."""
cols = self.__get_display_columns()
#print('Clear:', cols)
for c in cols:
if c in self._inplace_widgets:
widget = self._inplace_widgets[c]
widget.place_forget()
... | python | def __clear_inplace_widgets(self):
"""Remove all inplace edit widgets."""
cols = self.__get_display_columns()
#print('Clear:', cols)
for c in cols:
if c in self._inplace_widgets:
widget = self._inplace_widgets[c]
widget.place_forget()
... | [
"def",
"__clear_inplace_widgets",
"(",
"self",
")",
":",
"cols",
"=",
"self",
".",
"__get_display_columns",
"(",
")",
"#print('Clear:', cols)",
"for",
"c",
"in",
"cols",
":",
"if",
"c",
"in",
"self",
".",
"_inplace_widgets",
":",
"widget",
"=",
"self",
".",
... | Remove all inplace edit widgets. | [
"Remove",
"all",
"inplace",
"edit",
"widgets",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/editabletreeview.py#L179-L187 |
232,876 | alejandroautalan/pygubu | setup.py | CustomInstall.run | def run(self):
"""Run parent install, and then save the install dir in the script."""
install.run(self)
#
# Remove old pygubu.py from scripts path if exists
spath = os.path.join(self.install_scripts, 'pygubu')
for ext in ('.py', '.pyw'):
filename = spath + ex... | python | def run(self):
"""Run parent install, and then save the install dir in the script."""
install.run(self)
#
# Remove old pygubu.py from scripts path if exists
spath = os.path.join(self.install_scripts, 'pygubu')
for ext in ('.py', '.pyw'):
filename = spath + ex... | [
"def",
"run",
"(",
"self",
")",
":",
"install",
".",
"run",
"(",
"self",
")",
"#",
"# Remove old pygubu.py from scripts path if exists",
"spath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"install_scripts",
",",
"'pygubu'",
")",
"for",
"ext",
... | Run parent install, and then save the install dir in the script. | [
"Run",
"parent",
"install",
"and",
"then",
"save",
"the",
"install",
"dir",
"in",
"the",
"script",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/setup.py#L30-L46 |
232,877 | alejandroautalan/pygubu | pygubudesigner/propertieseditor.py | PropertiesEditor.hide_all | def hide_all(self):
"""Hide all properties from property editor."""
self.current = None
for _v, (label, widget) in self._propbag.items():
label.grid_remove()
widget.grid_remove() | python | def hide_all(self):
"""Hide all properties from property editor."""
self.current = None
for _v, (label, widget) in self._propbag.items():
label.grid_remove()
widget.grid_remove() | [
"def",
"hide_all",
"(",
"self",
")",
":",
"self",
".",
"current",
"=",
"None",
"for",
"_v",
",",
"(",
"label",
",",
"widget",
")",
"in",
"self",
".",
"_propbag",
".",
"items",
"(",
")",
":",
"label",
".",
"grid_remove",
"(",
")",
"widget",
".",
"... | Hide all properties from property editor. | [
"Hide",
"all",
"properties",
"from",
"property",
"editor",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/propertieseditor.py#L150-L156 |
232,878 | alejandroautalan/pygubu | pygubu/builder/builderobject.py | BuilderObject._get_init_args | def _get_init_args(self):
"""Creates dict with properties marked as readonly"""
args = {}
for rop in self.ro_properties:
if rop in self.properties:
args[rop] = self.properties[rop]
return args | python | def _get_init_args(self):
"""Creates dict with properties marked as readonly"""
args = {}
for rop in self.ro_properties:
if rop in self.properties:
args[rop] = self.properties[rop]
return args | [
"def",
"_get_init_args",
"(",
"self",
")",
":",
"args",
"=",
"{",
"}",
"for",
"rop",
"in",
"self",
".",
"ro_properties",
":",
"if",
"rop",
"in",
"self",
".",
"properties",
":",
"args",
"[",
"rop",
"]",
"=",
"self",
".",
"properties",
"[",
"rop",
"]... | Creates dict with properties marked as readonly | [
"Creates",
"dict",
"with",
"properties",
"marked",
"as",
"readonly"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/builderobject.py#L86-L93 |
232,879 | alejandroautalan/pygubu | pygubudesigner/previewer.py | OnCanvasMenuPreview._calculate_menu_wh | def _calculate_menu_wh(self):
""" Calculate menu widht and height."""
w = iw = 50
h = ih = 0
# menu.index returns None if there are no choices
index = self._menu.index(tk.END)
index = index if index is not None else 0
count = index + 1
# First calculate u... | python | def _calculate_menu_wh(self):
""" Calculate menu widht and height."""
w = iw = 50
h = ih = 0
# menu.index returns None if there are no choices
index = self._menu.index(tk.END)
index = index if index is not None else 0
count = index + 1
# First calculate u... | [
"def",
"_calculate_menu_wh",
"(",
"self",
")",
":",
"w",
"=",
"iw",
"=",
"50",
"h",
"=",
"ih",
"=",
"0",
"# menu.index returns None if there are no choices",
"index",
"=",
"self",
".",
"_menu",
".",
"index",
"(",
"tk",
".",
"END",
")",
"index",
"=",
"ind... | Calculate menu widht and height. | [
"Calculate",
"menu",
"widht",
"and",
"height",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L283-L320 |
232,880 | alejandroautalan/pygubu | pygubudesigner/previewer.py | PreviewHelper._over_resizer | def _over_resizer(self, x, y):
"Returns True if mouse is over a resizer"
over_resizer = False
c = self.canvas
ids = c.find_overlapping(x, y, x, y)
if ids:
o = ids[0]
tags = c.gettags(o)
if 'resizer' in tags:
over_resizer = True... | python | def _over_resizer(self, x, y):
"Returns True if mouse is over a resizer"
over_resizer = False
c = self.canvas
ids = c.find_overlapping(x, y, x, y)
if ids:
o = ids[0]
tags = c.gettags(o)
if 'resizer' in tags:
over_resizer = True... | [
"def",
"_over_resizer",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"over_resizer",
"=",
"False",
"c",
"=",
"self",
".",
"canvas",
"ids",
"=",
"c",
".",
"find_overlapping",
"(",
"x",
",",
"y",
",",
"x",
",",
"y",
")",
"if",
"ids",
":",
"o",
"=",... | Returns True if mouse is over a resizer | [
"Returns",
"True",
"if",
"mouse",
"is",
"over",
"a",
"resizer"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L453-L464 |
232,881 | alejandroautalan/pygubu | pygubudesigner/previewer.py | PreviewHelper.resize_preview | def resize_preview(self, dw, dh):
"Resizes preview that is currently dragged"
# identify preview
if self._objects_moving:
id_ = self._objects_moving[0]
tags = self.canvas.gettags(id_)
for tag in tags:
if tag.startswith('preview_'):
... | python | def resize_preview(self, dw, dh):
"Resizes preview that is currently dragged"
# identify preview
if self._objects_moving:
id_ = self._objects_moving[0]
tags = self.canvas.gettags(id_)
for tag in tags:
if tag.startswith('preview_'):
... | [
"def",
"resize_preview",
"(",
"self",
",",
"dw",
",",
"dh",
")",
":",
"# identify preview",
"if",
"self",
".",
"_objects_moving",
":",
"id_",
"=",
"self",
".",
"_objects_moving",
"[",
"0",
"]",
"tags",
"=",
"self",
".",
"canvas",
".",
"gettags",
"(",
"... | Resizes preview that is currently dragged | [
"Resizes",
"preview",
"that",
"is",
"currently",
"dragged"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L466-L480 |
232,882 | alejandroautalan/pygubu | pygubudesigner/previewer.py | PreviewHelper.move_previews | def move_previews(self):
"Move previews after a resize event"
# calculate new positions
min_y = self._calc_preview_ypos()
for idx, (key, p) in enumerate(self.previews.items()):
new_dy = min_y[idx] - p.y
self.previews[key].move_by(0, new_dy)
self._update_c... | python | def move_previews(self):
"Move previews after a resize event"
# calculate new positions
min_y = self._calc_preview_ypos()
for idx, (key, p) in enumerate(self.previews.items()):
new_dy = min_y[idx] - p.y
self.previews[key].move_by(0, new_dy)
self._update_c... | [
"def",
"move_previews",
"(",
"self",
")",
":",
"# calculate new positions",
"min_y",
"=",
"self",
".",
"_calc_preview_ypos",
"(",
")",
"for",
"idx",
",",
"(",
"key",
",",
"p",
")",
"in",
"enumerate",
"(",
"self",
".",
"previews",
".",
"items",
"(",
")",
... | Move previews after a resize event | [
"Move",
"previews",
"after",
"a",
"resize",
"event"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L490-L499 |
232,883 | alejandroautalan/pygubu | pygubudesigner/previewer.py | PreviewHelper._calc_preview_ypos | def _calc_preview_ypos(self):
"Calculates the previews positions on canvas"
y = 10
min_y = [y]
for k, p in self.previews.items():
y += p.height() + self.padding
min_y.append(y)
return min_y | python | def _calc_preview_ypos(self):
"Calculates the previews positions on canvas"
y = 10
min_y = [y]
for k, p in self.previews.items():
y += p.height() + self.padding
min_y.append(y)
return min_y | [
"def",
"_calc_preview_ypos",
"(",
"self",
")",
":",
"y",
"=",
"10",
"min_y",
"=",
"[",
"y",
"]",
"for",
"k",
",",
"p",
"in",
"self",
".",
"previews",
".",
"items",
"(",
")",
":",
"y",
"+=",
"p",
".",
"height",
"(",
")",
"+",
"self",
".",
"pad... | Calculates the previews positions on canvas | [
"Calculates",
"the",
"previews",
"positions",
"on",
"canvas"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L501-L509 |
232,884 | alejandroautalan/pygubu | pygubudesigner/previewer.py | PreviewHelper._get_slot | def _get_slot(self):
"Returns the next coordinates for a preview"
x = y = 10
for k, p in self.previews.items():
y += p.height() + self.padding
return x, y | python | def _get_slot(self):
"Returns the next coordinates for a preview"
x = y = 10
for k, p in self.previews.items():
y += p.height() + self.padding
return x, y | [
"def",
"_get_slot",
"(",
"self",
")",
":",
"x",
"=",
"y",
"=",
"10",
"for",
"k",
",",
"p",
"in",
"self",
".",
"previews",
".",
"items",
"(",
")",
":",
"y",
"+=",
"p",
".",
"height",
"(",
")",
"+",
"self",
".",
"padding",
"return",
"x",
",",
... | Returns the next coordinates for a preview | [
"Returns",
"the",
"next",
"coordinates",
"for",
"a",
"preview"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L511-L517 |
232,885 | alejandroautalan/pygubu | pygubu/stockimage.py | StockImage.clear_cache | def clear_cache(cls):
"""Call this before closing tk root"""
#Prevent tkinter errors on python 2 ??
for key in cls._cached:
cls._cached[key] = None
cls._cached = {} | python | def clear_cache(cls):
"""Call this before closing tk root"""
#Prevent tkinter errors on python 2 ??
for key in cls._cached:
cls._cached[key] = None
cls._cached = {} | [
"def",
"clear_cache",
"(",
"cls",
")",
":",
"#Prevent tkinter errors on python 2 ??",
"for",
"key",
"in",
"cls",
".",
"_cached",
":",
"cls",
".",
"_cached",
"[",
"key",
"]",
"=",
"None",
"cls",
".",
"_cached",
"=",
"{",
"}"
] | Call this before closing tk root | [
"Call",
"this",
"before",
"closing",
"tk",
"root"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L54-L59 |
232,886 | alejandroautalan/pygubu | pygubu/stockimage.py | StockImage.register | def register(cls, key, filename):
"""Register a image file using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'custom', 'filename': filename}
logger.info('%s registered as %s' % (filename, key)) | python | def register(cls, key, filename):
"""Register a image file using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'custom', 'filename': filename}
logger.info('%s registered as %s' % (filename, key)) | [
"def",
"register",
"(",
"cls",
",",
"key",
",",
"filename",
")",
":",
"if",
"key",
"in",
"cls",
".",
"_stock",
":",
"logger",
".",
"info",
"(",
"'Warning, replacing resource '",
"+",
"str",
"(",
"key",
")",
")",
"cls",
".",
"_stock",
"[",
"key",
"]",... | Register a image file using key | [
"Register",
"a",
"image",
"file",
"using",
"key"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L62-L68 |
232,887 | alejandroautalan/pygubu | pygubu/stockimage.py | StockImage.register_from_data | def register_from_data(cls, key, format, data):
"""Register a image data using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'data', 'data': data, 'format': format }
logger.info('%s registered as %s' % ('data',... | python | def register_from_data(cls, key, format, data):
"""Register a image data using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'data', 'data': data, 'format': format }
logger.info('%s registered as %s' % ('data',... | [
"def",
"register_from_data",
"(",
"cls",
",",
"key",
",",
"format",
",",
"data",
")",
":",
"if",
"key",
"in",
"cls",
".",
"_stock",
":",
"logger",
".",
"info",
"(",
"'Warning, replacing resource '",
"+",
"str",
"(",
"key",
")",
")",
"cls",
".",
"_stock... | Register a image data using key | [
"Register",
"a",
"image",
"data",
"using",
"key"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L71-L77 |
232,888 | alejandroautalan/pygubu | pygubu/stockimage.py | StockImage.register_created | def register_created(cls, key, image):
"""Register an already created image using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'created', 'image': image}
logger.info('%s registered as %s' % ('data', key)) | python | def register_created(cls, key, image):
"""Register an already created image using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'created', 'image': image}
logger.info('%s registered as %s' % ('data', key)) | [
"def",
"register_created",
"(",
"cls",
",",
"key",
",",
"image",
")",
":",
"if",
"key",
"in",
"cls",
".",
"_stock",
":",
"logger",
".",
"info",
"(",
"'Warning, replacing resource '",
"+",
"str",
"(",
"key",
")",
")",
"cls",
".",
"_stock",
"[",
"key",
... | Register an already created image using key | [
"Register",
"an",
"already",
"created",
"image",
"using",
"key"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L80-L86 |
232,889 | alejandroautalan/pygubu | pygubu/stockimage.py | StockImage._load_image | def _load_image(cls, rkey):
"""Load image from file or return the cached instance."""
v = cls._stock[rkey]
img = None
itype = v['type']
if itype in ('stock', 'data'):
img = tk.PhotoImage(format=v['format'], data=v['data'])
elif itype == 'created':
... | python | def _load_image(cls, rkey):
"""Load image from file or return the cached instance."""
v = cls._stock[rkey]
img = None
itype = v['type']
if itype in ('stock', 'data'):
img = tk.PhotoImage(format=v['format'], data=v['data'])
elif itype == 'created':
... | [
"def",
"_load_image",
"(",
"cls",
",",
"rkey",
")",
":",
"v",
"=",
"cls",
".",
"_stock",
"[",
"rkey",
"]",
"img",
"=",
"None",
"itype",
"=",
"v",
"[",
"'type'",
"]",
"if",
"itype",
"in",
"(",
"'stock'",
",",
"'data'",
")",
":",
"img",
"=",
"tk"... | Load image from file or return the cached instance. | [
"Load",
"image",
"from",
"file",
"or",
"return",
"the",
"cached",
"instance",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L107-L121 |
232,890 | alejandroautalan/pygubu | pygubu/stockimage.py | StockImage.get | def get(cls, rkey):
"""Get image previously registered with key rkey.
If key not exist, raise StockImageException
"""
if rkey in cls._cached:
logger.info('Resource %s is in cache.' % rkey)
return cls._cached[rkey]
if rkey in cls._stock:
img = ... | python | def get(cls, rkey):
"""Get image previously registered with key rkey.
If key not exist, raise StockImageException
"""
if rkey in cls._cached:
logger.info('Resource %s is in cache.' % rkey)
return cls._cached[rkey]
if rkey in cls._stock:
img = ... | [
"def",
"get",
"(",
"cls",
",",
"rkey",
")",
":",
"if",
"rkey",
"in",
"cls",
".",
"_cached",
":",
"logger",
".",
"info",
"(",
"'Resource %s is in cache.'",
"%",
"rkey",
")",
"return",
"cls",
".",
"_cached",
"[",
"rkey",
"]",
"if",
"rkey",
"in",
"cls",... | Get image previously registered with key rkey.
If key not exist, raise StockImageException | [
"Get",
"image",
"previously",
"registered",
"with",
"key",
"rkey",
".",
"If",
"key",
"not",
"exist",
"raise",
"StockImageException"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L124-L136 |
232,891 | alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.config_treeview | def config_treeview(self):
"""Sets treeview columns and other params"""
tree = self.treeview
tree.bind('<Double-1>', self.on_treeview_double_click)
tree.bind('<<TreeviewSelect>>', self.on_treeview_select, add='+') | python | def config_treeview(self):
"""Sets treeview columns and other params"""
tree = self.treeview
tree.bind('<Double-1>', self.on_treeview_double_click)
tree.bind('<<TreeviewSelect>>', self.on_treeview_select, add='+') | [
"def",
"config_treeview",
"(",
"self",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"tree",
".",
"bind",
"(",
"'<Double-1>'",
",",
"self",
".",
"on_treeview_double_click",
")",
"tree",
".",
"bind",
"(",
"'<<TreeviewSelect>>'",
",",
"self",
".",
"on_treevi... | Sets treeview columns and other params | [
"Sets",
"treeview",
"columns",
"and",
"other",
"params"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L79-L83 |
232,892 | alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.get_toplevel_parent | def get_toplevel_parent(self, treeitem):
"""Returns the top level parent for treeitem."""
tv = self.treeview
toplevel_items = tv.get_children()
item = treeitem
while not (item in toplevel_items):
item = tv.parent(item)
return item | python | def get_toplevel_parent(self, treeitem):
"""Returns the top level parent for treeitem."""
tv = self.treeview
toplevel_items = tv.get_children()
item = treeitem
while not (item in toplevel_items):
item = tv.parent(item)
return item | [
"def",
"get_toplevel_parent",
"(",
"self",
",",
"treeitem",
")",
":",
"tv",
"=",
"self",
".",
"treeview",
"toplevel_items",
"=",
"tv",
".",
"get_children",
"(",
")",
"item",
"=",
"treeitem",
"while",
"not",
"(",
"item",
"in",
"toplevel_items",
")",
":",
... | Returns the top level parent for treeitem. | [
"Returns",
"the",
"top",
"level",
"parent",
"for",
"treeitem",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L85-L94 |
232,893 | alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.draw_widget | def draw_widget(self, item):
"""Create a preview of the selected treeview item"""
if item:
self.filter_remove(remember=True)
selected_id = self.treedata[item]['id']
item = self.get_toplevel_parent(item)
widget_id = self.treedata[item]['id']
wcl... | python | def draw_widget(self, item):
"""Create a preview of the selected treeview item"""
if item:
self.filter_remove(remember=True)
selected_id = self.treedata[item]['id']
item = self.get_toplevel_parent(item)
widget_id = self.treedata[item]['id']
wcl... | [
"def",
"draw_widget",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
":",
"self",
".",
"filter_remove",
"(",
"remember",
"=",
"True",
")",
"selected_id",
"=",
"self",
".",
"treedata",
"[",
"item",
"]",
"[",
"'id'",
"]",
"item",
"=",
"self",
".",
... | Create a preview of the selected treeview item | [
"Create",
"a",
"preview",
"of",
"the",
"selected",
"treeview",
"item"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L96-L107 |
232,894 | alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.on_treeview_delete_selection | def on_treeview_delete_selection(self, event=None):
"""Removes selected items from treeview"""
tv = self.treeview
selection = tv.selection()
# Need to remove filter
self.filter_remove(remember=True)
toplevel_items = tv.get_children()
parents_to_redraw = set()
... | python | def on_treeview_delete_selection(self, event=None):
"""Removes selected items from treeview"""
tv = self.treeview
selection = tv.selection()
# Need to remove filter
self.filter_remove(remember=True)
toplevel_items = tv.get_children()
parents_to_redraw = set()
... | [
"def",
"on_treeview_delete_selection",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"tv",
"=",
"self",
".",
"treeview",
"selection",
"=",
"tv",
".",
"selection",
"(",
")",
"# Need to remove filter",
"self",
".",
"filter_remove",
"(",
"remember",
"=",
"T... | Removes selected items from treeview | [
"Removes",
"selected",
"items",
"from",
"treeview"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L134-L167 |
232,895 | alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.tree_to_xml | def tree_to_xml(self):
"""Traverses treeview and generates a ElementTree object"""
# Need to remove filter or hidden items will not be saved.
self.filter_remove(remember=True)
tree = self.treeview
root = ET.Element('interface')
items = tree.get_children()
for it... | python | def tree_to_xml(self):
"""Traverses treeview and generates a ElementTree object"""
# Need to remove filter or hidden items will not be saved.
self.filter_remove(remember=True)
tree = self.treeview
root = ET.Element('interface')
items = tree.get_children()
for it... | [
"def",
"tree_to_xml",
"(",
"self",
")",
":",
"# Need to remove filter or hidden items will not be saved.",
"self",
".",
"filter_remove",
"(",
"remember",
"=",
"True",
")",
"tree",
"=",
"self",
".",
"treeview",
"root",
"=",
"ET",
".",
"Element",
"(",
"'interface'",... | Traverses treeview and generates a ElementTree object | [
"Traverses",
"treeview",
"and",
"generates",
"a",
"ElementTree",
"object"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L169-L185 |
232,896 | alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.tree_node_to_xml | def tree_node_to_xml(self, parent, item):
"""Converts a treeview item and children to xml nodes"""
tree = self.treeview
data = self.treedata[item]
node = data.to_xml_node()
children = tree.get_children(item)
for child in children:
cnode = ET.Element('child')... | python | def tree_node_to_xml(self, parent, item):
"""Converts a treeview item and children to xml nodes"""
tree = self.treeview
data = self.treedata[item]
node = data.to_xml_node()
children = tree.get_children(item)
for child in children:
cnode = ET.Element('child')... | [
"def",
"tree_node_to_xml",
"(",
"self",
",",
"parent",
",",
"item",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"data",
"=",
"self",
".",
"treedata",
"[",
"item",
"]",
"node",
"=",
"data",
".",
"to_xml_node",
"(",
")",
"children",
"=",
"tree",
".... | Converts a treeview item and children to xml nodes | [
"Converts",
"a",
"treeview",
"item",
"and",
"children",
"to",
"xml",
"nodes"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L187-L201 |
232,897 | alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor._insert_item | def _insert_item(self, root, data, from_file=False):
"""Insert a item on the treeview and fills columns from data"""
tree = self.treeview
treelabel = data.get_id()
row = col = ''
if root != '' and 'layout' in data:
row = data.get_layout_property('row')
co... | python | def _insert_item(self, root, data, from_file=False):
"""Insert a item on the treeview and fills columns from data"""
tree = self.treeview
treelabel = data.get_id()
row = col = ''
if root != '' and 'layout' in data:
row = data.get_layout_property('row')
co... | [
"def",
"_insert_item",
"(",
"self",
",",
"root",
",",
"data",
",",
"from_file",
"=",
"False",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"treelabel",
"=",
"data",
".",
"get_id",
"(",
")",
"row",
"=",
"col",
"=",
"''",
"if",
"root",
"!=",
"''",... | Insert a item on the treeview and fills columns from data | [
"Insert",
"a",
"item",
"on",
"the",
"treeview",
"and",
"fills",
"columns",
"from",
"data"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L203-L243 |
232,898 | alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.copy_to_clipboard | def copy_to_clipboard(self):
"""
Copies selected items to clipboard.
"""
tree = self.treeview
# get the selected item:
selection = tree.selection()
if selection:
self.filter_remove(remember=True)
root = ET.Element('selection')
f... | python | def copy_to_clipboard(self):
"""
Copies selected items to clipboard.
"""
tree = self.treeview
# get the selected item:
selection = tree.selection()
if selection:
self.filter_remove(remember=True)
root = ET.Element('selection')
f... | [
"def",
"copy_to_clipboard",
"(",
"self",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"# get the selected item:",
"selection",
"=",
"tree",
".",
"selection",
"(",
")",
"if",
"selection",
":",
"self",
".",
"filter_remove",
"(",
"remember",
"=",
"True",
")"... | Copies selected items to clipboard. | [
"Copies",
"selected",
"items",
"to",
"clipboard",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L255-L275 |
232,899 | alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.add_widget | def add_widget(self, wclass):
"""Adds a new item to the treeview."""
tree = self.treeview
# get the selected item:
selected_item = ''
tsel = tree.selection()
if tsel:
selected_item = tsel[0]
# Need to remove filter if set
self.filter_remove... | python | def add_widget(self, wclass):
"""Adds a new item to the treeview."""
tree = self.treeview
# get the selected item:
selected_item = ''
tsel = tree.selection()
if tsel:
selected_item = tsel[0]
# Need to remove filter if set
self.filter_remove... | [
"def",
"add_widget",
"(",
"self",
",",
"wclass",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"# get the selected item:",
"selected_item",
"=",
"''",
"tsel",
"=",
"tree",
".",
"selection",
"(",
")",
"if",
"tsel",
":",
"selected_item",
"=",
"tsel",
"[",... | Adds a new item to the treeview. | [
"Adds",
"a",
"new",
"item",
"to",
"the",
"treeview",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L422-L492 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.