query stringlengths 9 3.4k | document stringlengths 9 87.4k | metadata dict | negatives listlengths 4 101 | negative_scores listlengths 4 101 | document_score stringlengths 3 10 | document_rank stringclasses 102 values |
|---|---|---|---|---|---|---|
return dictionary with extra keys used in model.__init__ | def _get_init_kwds(self):
kwds = dict(((key, getattr(self, key, None))
for key in self._init_keys))
return kwds | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, **kwds ):\n super(Model, self).__init__()\n self.__key = None \n for name, value in kwds.items():\n self[name] = value",
"def to_dict_model(self) -> dict:\n return dict((key, getattr(self, key)) for key in self.__mapper__.c.keys())",
"def extra_from_record(... | [
"0.68339634",
"0.6825465",
"0.6760999",
"0.67576766",
"0.67556274",
"0.67232966",
"0.6719624",
"0.6663634",
"0.6663634",
"0.6660793",
"0.66108835",
"0.65923446",
"0.657657",
"0.65584314",
"0.64814067",
"0.6439023",
"0.6415135",
"0.6399043",
"0.638495",
"0.6370132",
"0.6367242... | 0.0 | -1 |
Create a Model from a formula and dataframe. | def from_formula(cls, formula, data, subset=None,
drop_cols=None, *args, **kwargs):
# TODO: provide a docs template for args/kwargs from child models
# TODO: subset could use syntax. GH#469.
if subset is not None:
data = data.loc[subset]
eval_env = kwargs.pop('eval_env', None)
if eval_env is None:
eval_env = 2
elif eval_env == -1:
from patsy import EvalEnvironment
eval_env = EvalEnvironment({})
else:
eval_env += 1 # we're going down the stack again
missing = kwargs.get('missing', 'drop')
if missing == 'none': # with patsy it's drop or raise. let's raise.
missing = 'raise'
tmp = handle_formula_data(data, None, formula, depth=eval_env,
missing=missing)
((endog, exog), missing_idx, design_info) = tmp
if drop_cols is not None and len(drop_cols) > 0:
# TODO: not hit in tests
cols = [x for x in exog.columns if x not in drop_cols]
if len(cols) < len(exog.columns):
exog = exog[cols]
cols = list(design_info.term_names)
for col in drop_cols:
try:
cols.remove(col)
except ValueError:
pass # OK if not present
design_info = design_info.subset(cols)
kwargs.update({'missing_idx': missing_idx,
'missing': missing,
'formula': formula, # attach formula for unpckling
'design_info': design_info})
mod = cls(endog, exog, *args, **kwargs)
mod.formula = formula
# since we got a dataframe, attach the original
mod.data.frame = data
return mod | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_formula():\n config = {\"samples\": {\"x1\": onp.ones((2, 10)), \"x2\": onp.ones((2, 10))}}\n\n class Model(Poisson):\n dv = \"y\"\n features = dict(\n x1=dict(transformer=1, prior=dist.Normal(0, 1)),\n x2=dict(transformer=2, prior=dist.Normal(0, 1)),\n )\n... | [
"0.64051425",
"0.6352155",
"0.6185541",
"0.5942793",
"0.58994234",
"0.5815461",
"0.5793945",
"0.565781",
"0.5657534",
"0.56343275",
"0.5602399",
"0.5592737",
"0.55794835",
"0.5542218",
"0.5530604",
"0.5495615",
"0.54892266",
"0.54615164",
"0.5460569",
"0.54572856",
"0.5424416... | 0.6909729 | 0 |
Fit a model to data. | def fit(self):
raise NotImplementedError # pragma: no cover | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit_from_model_data(self, model_data: np.ndarray) -> f.FitDataset:\r\n return f.FitDataset(dataset=self.dataset, model_data=model_data)",
"def fit_training_data(self):\n self.model.fit(self.X_train)",
"def fit_model(self):\n logger.info('Fitting model')\n if self.traj_dict is No... | [
"0.81083125",
"0.78165245",
"0.76790136",
"0.74471337",
"0.73553294",
"0.72820145",
"0.7271266",
"0.72706705",
"0.72706705",
"0.72706705",
"0.72706705",
"0.72706705",
"0.72706705",
"0.72706705",
"0.72706705",
"0.72706705",
"0.72706705",
"0.72503513",
"0.7200485",
"0.7165293",
... | 0.6884465 | 42 |
After a model has been fit predict returns the fitted values. This is a placeholder intended to be overwritten by individual models. | def predict(self, params, exog=None, *args, **kwargs):
raise NotImplementedError # pragma: no cover | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fittedvalues(self):\n return self.model.predict(self.params)\n # TODO: GH#5255 is this necessarily equivalent to self.predict()?",
"def fit_predict(self):\n raise AttributeError",
"def fit_predict(self, X, y=None):\n return super().fit_predict(X, y)",
"def predict_only(self):"... | [
"0.763376",
"0.7340481",
"0.7176646",
"0.70071083",
"0.69615495",
"0.6811762",
"0.6780039",
"0.67395735",
"0.67003053",
"0.66701806",
"0.6623872",
"0.65716237",
"0.65716237",
"0.65679145",
"0.6562471",
"0.6515628",
"0.6515343",
"0.6505706",
"0.6497324",
"0.64924717",
"0.64544... | 0.6104935 | 76 |
Initialize (possibly reinitialize) a Model instance. For instance, the design matrix of a linear model may change and some things must be recomputed. | def initialize(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_model(self):\n pass",
"def init_model(self):\n pass",
"def initialize(self, model):\n pass",
"def __init__(self, model: Model1D):\n self._model = model",
"def re_init(self):\n self.latent.re_init()\n if 're_init' in dir(self.inference_model):\n ... | [
"0.7124921",
"0.6987733",
"0.6885349",
"0.6875176",
"0.68088514",
"0.67898726",
"0.6724793",
"0.6722912",
"0.66522413",
"0.6631922",
"0.6631922",
"0.66145754",
"0.66093516",
"0.66029775",
"0.65747577",
"0.65733886",
"0.65632457",
"0.6534131",
"0.6534131",
"0.6534131",
"0.6534... | 0.0 | -1 |
Loglikelihood of model evaluated pointwise | def loglikeobs(self, params, *args, **kwargs):
raise NotImplementedError # pragma: no cover | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_likelihood(self, data, reward_model, bias_params):",
"def log_likelihood(self):\r\n return (-0.5 * self.num_data * self.output_dim * np.log(2.*np.pi) -\r\n 0.5 * self.output_dim * self.K_logdet + self._model_fit_term() + self.likelihood.Z)",
"def loglikelihood(self, y):\n raise... | [
"0.8078789",
"0.8046145",
"0.78648543",
"0.782446",
"0.77342033",
"0.77272224",
"0.77194923",
"0.7687198",
"0.7685602",
"0.7643445",
"0.7605884",
"0.7569359",
"0.75504184",
"0.74748665",
"0.74734956",
"0.74657774",
"0.7450817",
"0.74382687",
"0.7420948",
"0.738504",
"0.736787... | 0.0 | -1 |
Loglikelihood of model. Default implementation sums loglikeobs. | def loglike(self, params, *args, **kwargs):
return np.sum(self.loglikeobs(params, *args, **kwargs)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loglikelihood(self):\n raise NotImplementedError(\"To be implemented\")",
"def log_likelihood(self, data, reward_model, bias_params):",
"def log_likelihood(self):\r\n return (-0.5 * self.num_data * self.output_dim * np.log(2.*np.pi) -\r\n 0.5 * self.output_dim * self.K_logdet + sel... | [
"0.81072646",
"0.7853458",
"0.77865106",
"0.7597883",
"0.7591351",
"0.75211746",
"0.7505817",
"0.75030684",
"0.7466109",
"0.7463448",
"0.74243414",
"0.74091846",
"0.740693",
"0.73675585",
"0.7324371",
"0.7308806",
"0.7306328",
"0.7265567",
"0.7232976",
"0.7188578",
"0.715438"... | 0.75402844 | 5 |
Score vector of model evaluated pointwise. The gradient of loglikeobs with respect to each parameter. | def score_obs(self, params, *args, **kwargs):
if self._use_approx_cs:
return approx_fprime_cs(params, self.loglikeobs,
args=args, kwargs=kwargs)
else:
return approx_fprime(params, self.loglikeobs,
args=args, kwargs=kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss_fun(model: GPModel, params: dict) -> float:\n py = model.module.call(params, train_ds['index_points'])\n return -py.log_prob(train_ds['y'])",
"def objective(self,w):\n l = 0\n for i in range(len(self.x)):\n # Each example contributes log(sigma(y_i * x_i . w))\n l -= log(sig... | [
"0.6731809",
"0.6511133",
"0.6408616",
"0.6373088",
"0.6353184",
"0.6333015",
"0.6306042",
"0.6281399",
"0.627509",
"0.6274971",
"0.62635344",
"0.62288404",
"0.6224662",
"0.6214824",
"0.6204803",
"0.62040687",
"0.61912745",
"0.6183201",
"0.617974",
"0.61708385",
"0.61646855",... | 0.5764669 | 89 |
Score vector of model. Default implementation sums score_obs. The gradient of loglike with respect to each parameter. | def score(self, params, *args, **kwargs):
try:
# If an analytic score_obs is available, try this first before
# falling back to numerical differentiation below
return self.score_obs(params, *args, **kwargs).sum(0)
except NotImplementedError:
# Fallback in case a `loglike` is implemented but `loglikeobs`
# is not.
approx_func = (approx_fprime_cs
if self._use_approx_cs else approx_fprime)
return approx_func(params, self.loglike, args=args, kwargs=kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score(self, s):\n fv = s.feature_vector\n product = fv.dot(self.params.T)[0, 0]\n return s.score(lmwt=self.lmwt) + product",
"def svm_loss(scores, y):\r\n\r\n N = scores.shape[0]\r\n\r\n # Compute svm data loss\r\n correct_class_scores = scores[range(N), y]\r\n margins = np.m... | [
"0.6385058",
"0.6369366",
"0.6337341",
"0.62241894",
"0.6202223",
"0.6085212",
"0.6069365",
"0.5963406",
"0.59437096",
"0.59082556",
"0.5902111",
"0.58229357",
"0.5803482",
"0.57961464",
"0.5775284",
"0.5754475",
"0.5751942",
"0.5720772",
"0.5715828",
"0.57079184",
"0.5697270... | 0.6393054 | 0 |
Fisher information matrix of model Returns Hessian of loglike evaluated at params. | def information(self, params):
# TODO: If the docstring is right, then why not just implement this?
raise NotImplementedError # pragma: no cover | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hessian(self, params, transformed=True):\n params = np.array(params, ndmin=1)\n\n return approx_hess_cs(params, self.loglike)",
"def _hessian(self):\n log_g = np.log(self._gv())\n log_f = np.log(self._fv())\n h_inf = np.mean((1 - log_g + log_f) / (self.y - self.err_inf) ** 2)\n retu... | [
"0.693216",
"0.68775684",
"0.6742063",
"0.6737252",
"0.64117485",
"0.6381536",
"0.6330648",
"0.6237004",
"0.61958313",
"0.6183961",
"0.61752",
"0.61537415",
"0.61301404",
"0.61163014",
"0.6060606",
"0.6042777",
"0.59978664",
"0.5942022",
"0.58947915",
"0.5877783",
"0.5867141"... | 0.0 | -1 |
The Hessian matrix of the model The default implementation uses a numerical derivative. | def hessian(self, params, *args, **kwargs):
if self._use_approx_cs:
return approx_hess_cs(params, self.loglike,
args=args, kwargs=kwargs)
else:
return approx_hess(params, self.loglike,
args=args, kwargs=kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_hessian(self):\n if not self.sparse:\n hess = numpy.dot(self.jacobian_T, self.jacobian)\n else:\n hess = self.jacobian_T*self.jacobian\n return hess",
"def get_hessian(self):\n return self.tc.hessian_func(\n self.pf.XS[:, :, 0].transpose(),\n ... | [
"0.81279826",
"0.80043125",
"0.72955406",
"0.7269672",
"0.7233574",
"0.7195273",
"0.7130439",
"0.70821714",
"0.7045756",
"0.6984545",
"0.68845636",
"0.6882204",
"0.68040764",
"0.6759905",
"0.6717752",
"0.6695646",
"0.6690471",
"0.66878116",
"0.65491647",
"0.6513133",
"0.65000... | 0.6848153 | 12 |
Weights for calculating Hessian | def hessian_factor(self, params, scale=None, observed=True):
raise NotImplementedError # pragma: no cover | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_hessian(y, tx, w):\n txw = tx.dot(w)\n diag = sigmoid(txw)*(np.ones(txw.shape)-sigmoid(txw))\n return np.matmul(np.multiply(tx,diag).T,tx)",
"def hessian(self, params):\n\n if self.use_sqrt:\n return self.hessian_sqrt(params)\n else:\n return self.hessia... | [
"0.7432778",
"0.72551763",
"0.7211145",
"0.7205693",
"0.71838",
"0.70502096",
"0.69169587",
"0.6911036",
"0.68722624",
"0.6833038",
"0.6738732",
"0.6719632",
"0.6706449",
"0.6674543",
"0.6654394",
"0.663828",
"0.65999717",
"0.65776294",
"0.65616745",
"0.65462524",
"0.6495858"... | 0.6014805 | 80 |
If no start_params are given, use reasonable defaults. | def _get_start_params(self, start_params=None):
if start_params is None:
if hasattr(self, 'start_params'):
start_params = self.start_params
elif self.exog is not None:
# fails for shape (K,)?
start_params = [0] * self.exog.shape[1]
else: # pragma: no cover
raise ValueError("If exog is None, then start_params should "
"be specified")
return start_params | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _apply_params(self):\n config = self.get_startup_config()\n # Pass true to _set_params so we know these are startup values\n self._set_params(config, True)",
"def start( *args, **kwargs ):",
"def ReviewServiceArgs(cls, start = False):\n return (start,)",
"def prep_streamin... | [
"0.6189463",
"0.596062",
"0.5936523",
"0.5922948",
"0.5908743",
"0.5905468",
"0.58663934",
"0.5828694",
"0.5814522",
"0.5814522",
"0.5756695",
"0.5748159",
"0.5678698",
"0.5660043",
"0.5645459",
"0.56087685",
"0.56059563",
"0.5576346",
"0.5533934",
"0.5510091",
"0.55027384",
... | 0.73069286 | 0 |
Fit method for likelihood based models | def fit(self, start_params=None, method='newton', maxiter=100,
full_output=True, disp=True, fargs=(), callback=None, retall=False,
skip_hessian=False, **kwargs):
Hinv = None # JP error if full_output=0, Hinv not defined
start_params = self._get_start_params(start_params)
# TODO: separate args from nonarg taking score and hessian, ie.,
# user-supplied and numerically evaluated estimate frprime doesn't take
# args in most (any?) of the optimize function
nobs = self.endog.shape[0]
# f = lambda params, *args: -self.loglike(params, *args) / nobs
def f(params, *args):
return -self.loglike(params, *args) / nobs
if method == 'newton':
# TODO: why are score and hess positive?
def score(params, *args):
return self.score(params, *args) / nobs
def hess(params, *args):
return self.hessian(params, *args) / nobs
else:
def score(params, *args):
return -self.score(params, *args) / nobs
def hess(params, *args):
return -self.hessian(params, *args) / nobs
warn_convergence = kwargs.pop('warn_convergence', True)
optimizer = Optimizer()
xopt, retvals, optim_settings = optimizer._fit(f, score, start_params,
fargs, kwargs,
hessian=hess,
method=method,
disp=disp,
maxiter=maxiter,
callback=callback,
retall=retall,
full_output=full_output)
# NOTE: this is for fit_regularized and should be generalized
cov_params_func = kwargs.setdefault('cov_params_func', None)
if cov_params_func:
Hinv = cov_params_func(self, xopt, retvals)
elif method == 'newton' and full_output:
Hinv = np.linalg.inv(-retvals['Hessian']) / nobs
# TODO: try/except for non-invertible hessian?
elif not skip_hessian:
H = -1 * self.hessian(xopt)
invertible = False
if np.all(np.isfinite(H)):
eigvals, eigvecs = np.linalg.eigh(H)
if np.min(eigvals) > 0:
invertible = True
if invertible:
Hinv = eigvecs.dot(np.diag(1.0 / eigvals)).dot(eigvecs.T)
Hinv = np.asfortranarray((Hinv + Hinv.T) / 2.0)
else:
warnings.warn('Inverting hessian failed, no bse or cov_params '
'available', HessianInversionWarning)
Hinv = None
if 'cov_type' in kwargs:
cov_kwds = kwargs.get('cov_kwds', {})
kwds = {'cov_type': kwargs['cov_type'], 'cov_kwds': cov_kwds}
else:
kwds = {}
if 'use_t' in kwargs:
kwds['use_t'] = kwargs['use_t']
# TODO: add Hessian approximation and change the above if needed
mlefit = LikelihoodModelResults(self, xopt, Hinv, scale=1., **kwds)
# TODO: hardcode scale?
if isinstance(retvals, dict):
mlefit.mle_retvals = retvals
if warn_convergence and not retvals['converged']:
warnings.warn("Maximum Likelihood optimization failed to "
"converge. Check mle_retvals",
ConvergenceWarning)
mlefit.mle_settings = optim_settings
return mlefit | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit(self, X):",
"def fit(self, X, y=...):\n ...",
"def fit(self, X, y=...):\n ...",
"def fit(self, X, y=...):\n ...",
"def fit(self, X, y=...):\n ...",
"def fit(self, X, y=...):\n ...",
"def fit(self, X, y=...):\n ...",
"def fit(self, X, y=...):\n ... | [
"0.7537152",
"0.7372642",
"0.7372642",
"0.7372642",
"0.7372642",
"0.7372642",
"0.7372642",
"0.7372642",
"0.7372642",
"0.7372642",
"0.7372642",
"0.7346237",
"0.7229979",
"0.7154896",
"0.7139961",
"0.71326166",
"0.71136487",
"0.71136487",
"0.7056964",
"0.7034442",
"0.7034442",
... | 0.0 | -1 |
(array) The predicted values of the model. An (nobs x k_endog) array. | def fittedvalues(self):
return self.model.predict(self.params)
# TODO: GH#5255 is this necessarily equivalent to self.predict()? | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predicted(self):\n return np.squeeze(self._predicted)",
"def predictions(self):\n return self._pred",
"def predict(self):\n self.kf.predict()\n self.nb_kf_pred += 1\n if self.time_since_update > 0:\n self.hit_streak = 0\n self.time_since_update += 1\n ... | [
"0.7712333",
"0.7250647",
"0.71565753",
"0.7084843",
"0.7081569",
"0.69067216",
"0.68599117",
"0.68599117",
"0.6858041",
"0.6837202",
"0.6804691",
"0.6788451",
"0.67536706",
"0.6731195",
"0.67286116",
"0.6702297",
"0.6701598",
"0.67001456",
"0.66936904",
"0.66884923",
"0.6678... | 0.64621586 | 50 |
(array) The model residuals. An (nobs x k_endog) array. | def resid(self):
# GH#5255
return self.model.endog - self.fittedvalues | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def residuals(self):\r\n return self.__residuals",
"def residuals_(self):\n return self._residuals",
"def residuals(self) -> npt.NDArray[np.float64]:\n return self.data - self.theory",
"def _get_residuals(self, model: Model) -> np.ndarray:\n try:\n # pyre-fixme[16]: `Mo... | [
"0.7572452",
"0.7444132",
"0.72688514",
"0.7094661",
"0.7090032",
"0.68978417",
"0.6875627",
"0.68409854",
"0.6705539",
"0.66076",
"0.6558537",
"0.65114504",
"0.65114504",
"0.65114504",
"0.6500384",
"0.64960504",
"0.6495944",
"0.6441256",
"0.6383142",
"0.63715947",
"0.6365249... | 0.5674281 | 44 |
Call self.model.predict with self.params as the first argument. | def predict(self, exog=None, transform=True, *args, **kwargs):
is_pandas = _is_using_pandas(exog, None)
exog_index = exog.index if is_pandas else None
if transform and hasattr(self.model, 'formula') and (exog is not None):
design_info = self.model.data.design_info
from patsy import dmatrix
if isinstance(exog, pd.Series):
# we are guessing whether it should be column or row
if (hasattr(exog, 'name') and
isinstance(exog.name, str) and
exog.name in design_info.describe()):
# assume we need one column
exog = pd.DataFrame(exog)
else:
# assume we need a row
exog = pd.DataFrame(exog).T
orig_exog_len = len(exog)
is_dict = isinstance(exog, dict)
exog = dmatrix(design_info, exog, return_type="dataframe")
if orig_exog_len > len(exog) and not is_dict:
if exog_index is None:
warnings.warn("nan values have been dropped", ValueWarning)
else:
exog = exog.reindex(exog_index)
exog_index = exog.index
if exog is not None:
exog = np.asarray(exog)
if exog.ndim == 1 and (self.model.exog.ndim == 1 or
self.model.exog.shape[1] == 1):
exog = exog[:, None]
exog = np.atleast_2d(exog) # needed in count model shape[1]
predict_results = self.model.predict(self.params, exog,
*args, **kwargs)
# TODO: Shouldn't this be done by wrapping?
if exog_index is not None and not hasattr(predict_results,
'predicted_values'):
if predict_results.ndim == 1:
return pd.Series(predict_results, index=exog_index)
else:
# FIXME: columns-->neq_names for e.g. MNLogit, VAR
ynames = self.model.data.ynames
return pd.DataFrame(predict_results, index=exog_index,
columns=ynames)
else:
return predict_results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, params, exog=None, *args, **kwargs):\n raise NotImplementedError # pragma: no cover",
"def predict(self, **kwargs):\n raise NotImplementedError",
"def predict(self, *args, **kwargs):\n return self(*args, **kwargs)",
"def _predict(self, x):\n pass",
"def predic... | [
"0.818373",
"0.78223795",
"0.7495833",
"0.7317303",
"0.73074985",
"0.72913486",
"0.72899944",
"0.7286579",
"0.7285986",
"0.72676605",
"0.7258348",
"0.7226006",
"0.72209585",
"0.7216009",
"0.720618",
"0.72039515",
"0.7197023",
"0.7196392",
"0.71649635",
"0.7164158",
"0.7131129... | 0.0 | -1 |
Summarize the Regression Results | def summary(self, yname=None, xname=None, title=None, alpha=.05):
# TODO: Make this raise upstream instead of just "pass"
raise NotImplementedError # pragma: no cover
# TODO: move the GenericLikelihoodModelResults implementation here? | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_stats_model(x, y):\n Xx = sm.add_constant(x)\n sm_logit = sm.Logit(y, Xx)\n result = sm_logit.fit()\n print result.summary()\n result.pred_table()\n # linear model\n print \"linear regression model:\\n\"\n sm_linear = sm.OLS(y, Xx)\n result = sm_linear.fit()\n print result.summ... | [
"0.6406348",
"0.63713837",
"0.6356689",
"0.63342285",
"0.6287831",
"0.6285578",
"0.6261427",
"0.62577116",
"0.62223923",
"0.6219097",
"0.61927754",
"0.6186985",
"0.61651766",
"0.6127877",
"0.6116654",
"0.60860497",
"0.6075616",
"0.60577536",
"0.6052378",
"0.6042831",
"0.60402... | 0.56184536 | 61 |
(float) The value of the loglikelihood function evaluated at `params`. | def llf(self):
return self.model.loglike(self.params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_log_likelihood(self,params: ndarray) -> float:\n \n pred_mag = self._pred_mag(params,self.times)\n sigma_2 = self.sd_mags**2 \n ln_likelihood = -0.5*np.sum((pred_mag - self.mags)**2 / sigma_2+ np.log(sigma_2))\n\n return ln_likelihood",
"def compute_log_pro... | [
"0.7583201",
"0.75121284",
"0.7457546",
"0.7209427",
"0.7124011",
"0.70207",
"0.6955007",
"0.69263536",
"0.68272287",
"0.6826398",
"0.6725675",
"0.66759413",
"0.66617227",
"0.66419446",
"0.6640716",
"0.661356",
"0.65459085",
"0.65014017",
"0.64994335",
"0.64519876",
"0.643485... | 0.0 | -1 |
(float) The value of the loglikelihood function evaluated at `params`. | def llf_obs(self):
return self.model.loglikeobs(self.params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_log_likelihood(self,params: ndarray) -> float:\n \n pred_mag = self._pred_mag(params,self.times)\n sigma_2 = self.sd_mags**2 \n ln_likelihood = -0.5*np.sum((pred_mag - self.mags)**2 / sigma_2+ np.log(sigma_2))\n\n return ln_likelihood",
"def compute_log_pro... | [
"0.7583201",
"0.75121284",
"0.7457546",
"0.7209427",
"0.7124011",
"0.70207",
"0.6955007",
"0.69263536",
"0.68272287",
"0.6826398",
"0.6725675",
"0.66759413",
"0.66617227",
"0.66419446",
"0.6640716",
"0.661356",
"0.65459085",
"0.65014017",
"0.64994335",
"0.64519876",
"0.643485... | 0.0 | -1 |
Return the tstatistic for a given parameter estimate. | def tvalues(self):
return self.params / self.bse | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_t_params(mu, kappa, alpha, beta):\r\n mu_, sigma2_, dof_ = mu, beta*(kappa + 1)/(alpha*kappa), 2*alpha\r\n return mu_, sigma2_, dof_",
"def t_measure_estimate(self):\n ho = self.humidity_oversampling\n to = self.temperature_oversampling\n po = self.pressure_oversampling\n ... | [
"0.572344",
"0.5572131",
"0.55429137",
"0.54679704",
"0.54327816",
"0.53799844",
"0.536686",
"0.5357605",
"0.53125864",
"0.5266699",
"0.52574205",
"0.5219881",
"0.52093285",
"0.5167227",
"0.51620823",
"0.5152715",
"0.51152396",
"0.51094764",
"0.5073365",
"0.5017591",
"0.50017... | 0.5572323 | 2 |
Returns the variance/covariance matrix. The variance/covariance matrix can be of a linear contrast of the estimates of params or all params multiplied by scale which will usually be an estimate of sigma^2. Scale is assumed to be a scalar. | def cov_params(self, r_matrix=None, column=None, scale=None, cov_p=None,
other=None):
if (hasattr(self, 'mle_settings') and
self.mle_settings['optimizer'] in ['l1', 'l1_cvxopt_cp']):
dot_fun = nan_dot
else:
dot_fun = np.dot
if (cov_p is None and self.normalized_cov_params is None and
not hasattr(self, 'cov_params_default')): # pragma: no cover
raise ValueError('need covariance of parameters for computing '
'(unnormalized) covariances')
if column is not None and (r_matrix is not None or other is not None):
raise ValueError('Column should be specified without other '
'arguments.') # pragma: no cover
if other is not None and r_matrix is None: # pragma: no cover
raise ValueError('other can only be specified with r_matrix')
if cov_p is None:
if hasattr(self, 'cov_params_default'):
cov_p = self.cov_params_default
else:
if scale is None:
scale = self.scale
cov_p = self.normalized_cov_params * scale
if column is not None:
column = np.asarray(column)
if column.shape == ():
return cov_p[column, column]
else:
return cov_p[column[:, None], column]
elif r_matrix is not None:
r_matrix = np.asarray(r_matrix)
if r_matrix.shape == (): # pragma: no cover
raise ValueError("r_matrix should be 1d or 2d")
if other is None:
other = r_matrix
else:
other = np.asarray(other)
tmp = dot_fun(r_matrix, dot_fun(cov_p, np.transpose(other)))
return tmp
else: # if r_matrix is None and column is None:
return cov_p | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params_to_scale_mean_cov(params_):\n # Extract scale and mean\n #scale_sqrt_ = params_[0]\n #scale_ = scale_sqrt_ * scale_sqrt_\n scale_ = params_[0]\n\n mean_ = params_[1:n + 1]\n\n # Get eigenvalues\n evals_sqrt_ = numpy.array(params_[n + 1:n2 + 1])\n e... | [
"0.5861856",
"0.577266",
"0.56941545",
"0.5600745",
"0.55539244",
"0.5537247",
"0.55147076",
"0.5510998",
"0.5503762",
"0.5450632",
"0.5436815",
"0.54117376",
"0.53925276",
"0.5346251",
"0.5309275",
"0.5307099",
"0.5306794",
"0.530079",
"0.5273775",
"0.5265709",
"0.5201272",
... | 0.0 | -1 |
Compute a ttest for a each linear hypothesis of the form Rb = q | def t_test(self, r_matrix, cov_p=None, scale=None, use_t=None): # noqa:E501
from patsy import DesignInfo
names = self.model.data.param_names
LC = DesignInfo(names).linear_constraint(r_matrix)
r_matrix, q_matrix = LC.coefs, LC.constants
num_ttests = r_matrix.shape[0]
num_params = r_matrix.shape[1]
if (cov_p is None and self.normalized_cov_params is None and
not hasattr(self, 'cov_params_default')):
raise ValueError('Need covariance of parameters for computing '
'T statistics') # pragma: no cover
if num_params != self.params.shape[0]: # pragma: no cover
raise ValueError('r_matrix and params are not aligned')
if q_matrix is None:
q_matrix = np.zeros(num_ttests)
else:
q_matrix = np.asarray(q_matrix)
q_matrix = q_matrix.squeeze()
if q_matrix.size > 1:
if q_matrix.shape[0] != num_ttests: # pragma: no cover
raise ValueError("r_matrix and q_matrix must have the same "
"number of rows")
if use_t is None:
# switch to use_t false if undefined
use_t = (hasattr(self, 'use_t') and self.use_t)
tstat = _sd = None
_effect = np.dot(r_matrix, self.params)
# nan_dot multiplies with the convention nan * 0 = 0
cparams = self.cov_params(r_matrix=r_matrix, cov_p=cov_p)
# Perform the test
if num_ttests > 1:
_sd = np.sqrt(np.diag(cparams))
else:
_sd = np.sqrt(cparams)
tstat = (_effect - q_matrix) * recipr(_sd)
df_resid = getattr(self, 'df_resid_inference', self.df_resid)
if use_t:
return ContrastResults(effect=_effect, t=tstat, sd=_sd,
df_denom=df_resid)
else:
return ContrastResults(effect=_effect, statistic=tstat, sd=_sd,
df_denom=df_resid,
distribution='norm') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def t_tests(self):\n se = self.se()\n t = self._coef / se\n p = 2 * stats.distributions.t.sf(np.abs(t), self._rdf)\n return (t, p)",
"def _t_test(_sample_a, _sample_b):\n res = stats.ttest_ind(_sample_a, _sample_b, axis=0, equal_var=equal_var, nan_policy='propagate')\n p... | [
"0.6740125",
"0.64186555",
"0.6367431",
"0.6359604",
"0.6324414",
"0.62921345",
"0.6085627",
"0.60754967",
"0.59786165",
"0.59353685",
"0.5921201",
"0.58064675",
"0.58024555",
"0.5798893",
"0.5790756",
"0.5783054",
"0.5782556",
"0.57736266",
"0.57735896",
"0.5765224",
"0.5756... | 0.6122987 | 6 |
Compute the Ftest for a joint linear hypothesis. This is a special case of `wald_test` that always uses the F distribution. | def f_test(self, r_matrix, cov_p=None, scale=1.0, invcov=None):
res = self.wald_test(r_matrix, cov_p=cov_p, scale=scale,
invcov=invcov, use_f=True)
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_joint_fitter(self):\n p1 = [14.9, 0.3]\n p2 = [13, 0.4]\n A = 9.8\n p = np.r_[A, p1, p2]\n\n def model(A, p, x):\n return A * np.exp(-0.5 / p[1] ** 2 * (x - p[0]) ** 2)\n\n def errfunc(p, x1, y1, x2, y2):\n return np.ravel(\n n... | [
"0.62175006",
"0.59313136",
"0.57992893",
"0.5789409",
"0.5753273",
"0.56032485",
"0.55942744",
"0.5555011",
"0.5532248",
"0.5489704",
"0.5489704",
"0.5489704",
"0.5489704",
"0.54816693",
"0.54639775",
"0.5443622",
"0.54368186",
"0.5426024",
"0.542323",
"0.54194605",
"0.54110... | 0.59112656 | 2 |
Compute a Waldtest for a joint linear hypothesis. | def wald_test(self, r_matrix, cov_p=None, scale=1.0, invcov=None,
use_f=None):
if use_f is None:
# switch to use_t false if undefined
use_f = (hasattr(self, 'use_t') and self.use_t)
from patsy import DesignInfo
names = self.model.data.param_names
LC = DesignInfo(names).linear_constraint(r_matrix)
r_matrix, q_matrix = LC.coefs, LC.constants
if (self.normalized_cov_params is None and cov_p is None and
invcov is None and not hasattr(self, 'cov_params_default')):
raise ValueError('need covariance of parameters for computing '
'F statistics') # pragma: no cover
cparams = np.dot(r_matrix, self.params[:, None])
J = float(r_matrix.shape[0]) # number of restrictions
if q_matrix is None:
q_matrix = np.zeros(J)
else:
q_matrix = np.asarray(q_matrix)
if q_matrix.ndim == 1:
q_matrix = q_matrix[:, None]
if q_matrix.shape[0] != J:
raise ValueError("r_matrix and q_matrix must have the same "
"number of rows")
Rbq = cparams - q_matrix
if invcov is None:
cov_p = self.cov_params(r_matrix=r_matrix, cov_p=cov_p)
if np.isnan(cov_p).max():
raise ValueError("r_matrix performs f_test for using "
"dimensions that are asymptotically "
"non-normal")
invcov = np.linalg.pinv(cov_p)
J_ = np.linalg.matrix_rank(cov_p)
if J_ < J:
warnings.warn('covariance of constraints does not have full '
'rank. The number of constraints is %d, but '
'rank is %d' % (J, J_), ValueWarning)
J = J_
if (hasattr(self, 'mle_settings') and
self.mle_settings['optimizer'] in ['l1', 'l1_cvxopt_cp']):
F = nan_dot(nan_dot(Rbq.T, invcov), Rbq)
else:
F = np.dot(np.dot(Rbq.T, invcov), Rbq)
df_resid = getattr(self, 'df_resid_inference', self.df_resid)
if use_f:
F /= J
return ContrastResults(F=F, df_denom=df_resid,
df_num=J)
else:
return ContrastResults(chi2=F, df_denom=J, statistic=F,
distribution='chi2', distargs=(J,)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_null_distribution_wald(self, n_cells: int = 2000, n_genes: int = 100):\n logging.getLogger(\"tensorflow\").setLevel(logging.ERROR)\n logging.getLogger(\"batchglm\").setLevel(logging.WARNING)\n logging.getLogger(\"diffxpy\").setLevel(logging.WARNING)\n\n sim = Simulator(num_obse... | [
"0.5814578",
"0.55685",
"0.55546004",
"0.54914194",
"0.54667383",
"0.54667383",
"0.54367995",
"0.5427969",
"0.5383164",
"0.53804135",
"0.5377707",
"0.5370084",
"0.53386796",
"0.52805245",
"0.5276071",
"0.527296",
"0.52697283",
"0.52659935",
"0.52651185",
"0.52339625",
"0.5233... | 0.0 | -1 |
Compute a sequence of Wald tests for terms over multiple columns This computes joined Wald tests for the hypothesis that all coefficients corresponding to a `term` are zero. `Terms` are defined by the underlying formula or by string matching. | def wald_test_terms(self, skip_single=False, extra_constraints=None,
combine_terms=None): # noqa:E501
result = self
if extra_constraints is None:
extra_constraints = []
if combine_terms is None:
combine_terms = []
design_info = getattr(result.model.data, 'design_info', None)
if design_info is None and extra_constraints is None:
raise ValueError('no constraints, nothing to do')
identity = np.eye(len(result.params))
constraints = []
combined = defaultdict(list)
if design_info is not None:
for term in design_info.terms:
cols = design_info.slice(term)
name = term.name()
constraint_matrix = identity[cols]
# check if in combined
for cname in combine_terms:
if cname in name:
combined[cname].append(constraint_matrix)
k_constraint = constraint_matrix.shape[0]
if skip_single:
if k_constraint == 1:
continue
constraints.append((name, constraint_matrix))
combined_constraints = []
for cname in combine_terms:
combined_constraints.append((cname,
np.vstack(combined[cname])))
else:
# check by exog/params names if there is no formula info
for col, name in enumerate(result.model.exog_names):
constraint_matrix = identity[col]
# check if in combined
for cname in combine_terms:
if cname in name:
combined[cname].append(constraint_matrix)
if skip_single:
continue
constraints.append((name, constraint_matrix))
combined_constraints = []
for cname in combine_terms:
combined_constraints.append((cname,
np.vstack(combined[cname])))
use_t = result.use_t
distribution = ['chi2', 'F'][use_t]
res_wald = []
index = []
for pair in constraints + combined_constraints + extra_constraints:
name, constraint = pair
wt = result.wald_test(constraint)
row = [wt.statistic.item(), wt.pvalue, constraint.shape[0]]
if use_t:
row.append(wt.df_denom)
res_wald.append(row)
index.append(name)
# distribution neutral names
col_names = ['statistic', 'pvalue', 'df_constraint']
if use_t:
col_names.append('df_denom')
# TODO: maybe move DataFrame creation to results class
table = pd.DataFrame(res_wald, index=index, columns=col_names)
res = WaldTestResults(None, distribution, None, table=table)
# TODO: remove temp again, added for testing
res.temp = constraints + combined_constraints + extra_constraints
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all(any, shard, shard_term_features, qterms):\n tmp = 1\n for t in qterms:\n if t in shard_term_features[shard]:\n cdf = shard_term_features[shard][t].df\n else:\n cdf = 0\n tmp *= cdf/any\n all = tmp * any\n return all",
"def evaluate_terms(terms):\... | [
"0.5098105",
"0.49435574",
"0.49396107",
"0.4900988",
"0.4857589",
"0.4845605",
"0.46524802",
"0.4648548",
"0.4620158",
"0.46167716",
"0.46052644",
"0.45635396",
"0.45390478",
"0.45198467",
"0.45163706",
"0.4515403",
"0.4504055",
"0.45020077",
"0.44826326",
"0.44797707",
"0.4... | 0.61136484 | 0 |
Returns the confidence interval of the fitted parameters. | def conf_int(self, alpha=.05, cols=None, method=None):
if method is not None: # pragma: no cover
raise NotImplementedError("`method` argument is not actually "
"supported. Upstream silently ignores "
"it.")
bse = self.bse
if self.use_t:
dist = stats.t
df_resid = getattr(self, 'df_resid_inference', self.df_resid)
q = dist.ppf(1 - alpha / 2, df_resid)
else:
dist = stats.norm
q = dist.ppf(1 - alpha / 2)
if cols is None:
lower = self.params - q * bse
upper = self.params + q * bse
else:
cols = np.asarray(cols)
lower = self.params[cols] - q * bse[cols]
upper = self.params[cols] + q * bse[cols]
return np.asarray(list(zip(lower, upper))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confidence(self) -> float:\n return self._confidence",
"def confidence(self):\n return self._confidence",
"def confidence(self):\n return self._confidence",
"def confidence(self) -> float:\n return float(self.class_scores[self.class_num])",
"def calculate_confidence_interval... | [
"0.68219185",
"0.6498113",
"0.6498113",
"0.64727414",
"0.6388635",
"0.6311576",
"0.62752163",
"0.6229275",
"0.6110395",
"0.60803914",
"0.60660297",
"0.60526866",
"0.6051802",
"0.6024401",
"0.60003996",
"0.590071",
"0.5890141",
"0.58519065",
"0.5841124",
"0.58395547",
"0.57960... | 0.51247424 | 73 |
Configure app object blueprints and global variables. | def create_app(config='dev'):
if config == 'dev':
from .conf.config import DevelopmentConfig as dev_config
app = configure_app(Flask(__name__), dev_config)
else:
from .conf.config import ProdConfig
app = configure_app(Flask(__name__), ProdConfig)
# setup flask blueprints
configure_blueprints(app)
return app | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_app(flask_app):\n flask_app.config['RESTPLUS_SWAGGER_UI_DOC_EXPANSION'] = \\\n settings.RESTPLUS_SWAGGER_UI_DOC_EXPANSION\n flask_app.config['RESTPLUS_VALIDATE'] = \\\n settings.RESTPLUS_VALIDATE\n\n flask_app.config['SQLALCHEMY_DATABASE_URI'] = \\\n settings.SQLALCHEMY_... | [
"0.6912322",
"0.6909037",
"0.6776755",
"0.6729488",
"0.67033446",
"0.6680665",
"0.6629941",
"0.6628452",
"0.661505",
"0.65740204",
"0.6563665",
"0.65455115",
"0.6527511",
"0.6517811",
"0.650456",
"0.64928526",
"0.6415426",
"0.6414632",
"0.6411077",
"0.64020663",
"0.6355862",
... | 0.0 | -1 |
Formats dictated text to camel case. | def camel_case_text(text):
newText = format_camel_case(text)
Text("%(text)s").execute({"text": newText}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_camel(text):\r\n\toutput = \"\"\r\n\tfor i,w in enumerate(text.split(\" \")):\r\n\t\tif i > 0:\r\n\t\t\toutput += w[0].upper() + w[1:]\r\n\t\telse:\r\n\t\t\toutput += w\r\n\treturn output",
"def _to_camel_case(text: str) -> str:\n return \"\".join(word.title() for word in text.split(\"_\"))",
"de... | [
"0.7785462",
"0.7445175",
"0.72581625",
"0.7184089",
"0.71070236",
"0.70822126",
"0.6964225",
"0.69159365",
"0.6845309",
"0.68369484",
"0.683591",
"0.67920893",
"0.6758114",
"0.6714242",
"0.66896963",
"0.6676171",
"0.6648838",
"0.6558678",
"0.6504255",
"0.6491712",
"0.6463216... | 0.77859265 | 0 |
Formats n words to the left of the cursor to camel case. Note that word count differs between editors and programming languages. The examples are all from Eclipse/Python. | def camel_case_count(n):
saveText = _get_clipboard_text()
cutText = _select_and_cut_text(n)
if cutText:
endSpace = cutText.endswith(' ')
text = _cleanup_text(cutText)
newText = _camelify(text.split(' '))
if endSpace:
newText = newText + ' '
newText = newText.replace("%", "%%") # Escape any format chars.
Text(newText).execute()
else: # Failed to get text from clipboard.
Key('c-v').execute() # Restore cut out text.
_set_clipboard_text(saveText) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pascal_case_count(n):\n saveText = _get_clipboard_text()\n cutText = _select_and_cut_text(n)\n if cutText:\n endSpace = cutText.endswith(' ')\n text = _cleanup_text(cutText)\n newText = text.title().replace(' ', '')\n if endSpace:\n newText = newText + ' '\n ... | [
"0.73462373",
"0.6970347",
"0.6930063",
"0.69166636",
"0.66168064",
"0.6470583",
"0.6462862",
"0.6323668",
"0.6291367",
"0.6219177",
"0.61823606",
"0.61714643",
"0.6143847",
"0.6097175",
"0.60751027",
"0.60740274",
"0.60687244",
"0.6060768",
"0.6060067",
"0.6053927",
"0.59890... | 0.7841125 | 0 |
Takes a list of words and returns a string formatted to camel case. | def _camelify(words):
newText = ''
for word in words:
if newText == '':
newText = word[:1].lower() + word[1:]
else:
newText = '%s%s' % (newText, word.capitalize())
return newText | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_camel(var_words):\n return ''.join([word.capitalize() for word in var_words])",
"def format_camel(text):\r\n\toutput = \"\"\r\n\tfor i,w in enumerate(text.split(\" \")):\r\n\t\tif i > 0:\r\n\t\t\toutput += w[0].upper() + w[1:]\r\n\t\telse:\r\n\t\t\toutput += w\r\n\treturn output",
"def camel_case... | [
"0.8251883",
"0.7825327",
"0.7563968",
"0.7526195",
"0.7506611",
"0.7506611",
"0.7482835",
"0.72373885",
"0.7220596",
"0.7182877",
"0.7105976",
"0.7050961",
"0.70338947",
"0.7015833",
"0.70085067",
"0.6960694",
"0.6957555",
"0.6947957",
"0.69223166",
"0.69102275",
"0.6900598"... | 0.8511594 | 0 |
Formats dictated text to pascal case. | def pascal_case_text(text):
newText = format_pascal_case(text)
Text("%(text)s").execute({"text": newText}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_pascal_case_to_readable_format(text):\n return \"\".join(list(map(lambda x : \" \" + x.lower() if x.isupper() else x, list(text))))",
"def pascal_case(value: str, **kwargs: Any) -> str:\n return \"\".join(map(str.title, split_words(value)))",
"def mixed_pascal_case(value: str, **kwargs: A... | [
"0.8325709",
"0.7577789",
"0.7054179",
"0.6948193",
"0.67188567",
"0.66129065",
"0.64995056",
"0.64025515",
"0.6349463",
"0.633064",
"0.6246584",
"0.6222095",
"0.6209781",
"0.6185109",
"0.61772996",
"0.6169017",
"0.6150109",
"0.6128363",
"0.6115912",
"0.6075849",
"0.60635227"... | 0.8074431 | 1 |
Formats n words to the left of the cursor to pascal case. Note that word count differs between editors and programming languages. The examples are all from Eclipse/Python. | def pascal_case_count(n):
saveText = _get_clipboard_text()
cutText = _select_and_cut_text(n)
if cutText:
endSpace = cutText.endswith(' ')
text = _cleanup_text(cutText)
newText = text.title().replace(' ', '')
if endSpace:
newText = newText + ' '
newText = newText.replace("%", "%%") # Escape any format chars.
Text(newText).execute()
else: # Failed to get text from clipboard.
Key('c-v').execute() # Restore cut out text.
_set_clipboard_text(saveText) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pascal_case_text(text):\n newText = format_pascal_case(text)\n Text(\"%(text)s\").execute({\"text\": newText})",
"def convert_pascal_case_to_readable_format(text):\n return \"\".join(list(map(lambda x : \" \" + x.lower() if x.isupper() else x, list(text))))",
"def pascal_case(value: str, **kwa... | [
"0.6748049",
"0.668678",
"0.66685766",
"0.65173775",
"0.6507821",
"0.64246476",
"0.62588936",
"0.5990105",
"0.5817989",
"0.5803157",
"0.5715056",
"0.5696685",
"0.5679296",
"0.5647844",
"0.56197363",
"0.56024784",
"0.5598668",
"0.5587423",
"0.5575231",
"0.5562862",
"0.5554474"... | 0.7799282 | 0 |
Formats dictated text to snake case. | def snake_case_text(text):
newText = format_snake_case(text)
Text("%(text)s").execute({"text": newText}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CamelCase_to_snake_case(text):\n s1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', text)\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', s1).lower()",
"def _camel_case_to_snake_case(text: str) -> str:\n return re.sub(r\"(?<!^)(?=[A-Z])\", \"_\", text).lower()",
"def snake_case(value: str, **kwargs: Any... | [
"0.70693374",
"0.7003121",
"0.69320387",
"0.6745865",
"0.67148775",
"0.6688143",
"0.66141355",
"0.65758014",
"0.65488815",
"0.64430827",
"0.6417229",
"0.6416612",
"0.63867706",
"0.63755894",
"0.6365438",
"0.63618255",
"0.6327051",
"0.6304511",
"0.6293115",
"0.62793934",
"0.62... | 0.7620087 | 0 |
Formats n words to the left of the cursor to snake case. Note that word count differs between editors and programming languages. The examples are all from Eclipse/Python. | def snake_case_count(n):
saveText = _get_clipboard_text()
cutText = _select_and_cut_text(n)
if cutText:
endSpace = cutText.endswith(' ')
text = _cleanup_text(cutText.lower())
newText = '_'.join(text.split(' '))
if endSpace:
newText = newText + ' '
newText = newText.replace("%", "%%") # Escape any format chars.
Text(newText).execute()
else: # Failed to get text from clipboard.
Key('c-v').execute() # Restore cut out text.
_set_clipboard_text(saveText) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pascal_case_count(n):\n saveText = _get_clipboard_text()\n cutText = _select_and_cut_text(n)\n if cutText:\n endSpace = cutText.endswith(' ')\n text = _cleanup_text(cutText)\n newText = text.title().replace(' ', '')\n if endSpace:\n newText = newText + ' '\n ... | [
"0.7383346",
"0.7166221",
"0.6926944",
"0.6357526",
"0.62876",
"0.6222895",
"0.5993043",
"0.5974094",
"0.5933266",
"0.5884368",
"0.5855512",
"0.58387643",
"0.57972294",
"0.57646835",
"0.574676",
"0.57403195",
"0.57358956",
"0.5729549",
"0.5655932",
"0.5653761",
"0.56503767",
... | 0.7747876 | 0 |
Formats dictated text with whitespace removed. | def squash_text(text):
newText = format_squash(text)
Text("%(text)s").execute({"text": newText}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reformat_text(self, text):\n xml = BeautifulSoup(text)\n self.remove_header_and_footer(xml)\n self.process_superscripts(xml)\n self.remove_footnotes(xml)\n text = xml.get_text() # Strip XML tags.\n text = self.join_hyphenated_words(text)\n text = self.remove_lin... | [
"0.6537464",
"0.64203817",
"0.63955766",
"0.638702",
"0.63303804",
"0.61618394",
"0.60671043",
"0.5989454",
"0.59656113",
"0.5920744",
"0.5918541",
"0.59150285",
"0.58982563",
"0.5888299",
"0.5853104",
"0.58076817",
"0.5796348",
"0.5772249",
"0.57603693",
"0.5750695",
"0.5728... | 0.0 | -1 |
Formats n words to the left of the cursor with whitespace removed. Excepting spaces immediately after comma, colon and percent chars. | def squash_count(n):
saveText = _get_clipboard_text()
cutText = _select_and_cut_text(n)
if cutText:
endSpace = cutText.endswith(' ')
text = _cleanup_text(cutText)
newText = ''.join(text.split(' '))
if endSpace:
newText = newText + ' '
newText = _expand_after_special_chars(newText)
newText = newText.replace("%", "%%") # Escape any format chars.
Text(newText).execute()
else: # Failed to get text from clipboard.
Key('c-v').execute() # Restore cut out text.
_set_clipboard_text(saveText) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_words(word_list,specifier):\n \n if specifier.lower() == 'score':\n print(\"{:>6s} - {:s}\".format(\"Score\", \"Word\"))\n if len(word_list) < 5:\n for tup in word_list:\n print(\"{:>6d} - {:s}\".format(tup[1], tup[0]))\n else:\n \n ... | [
"0.5716477",
"0.56824267",
"0.56137496",
"0.5555356",
"0.5551132",
"0.54461175",
"0.5431609",
"0.54211974",
"0.54129255",
"0.54071826",
"0.5400933",
"0.53925633",
"0.53710663",
"0.5361933",
"0.5333949",
"0.5318006",
"0.5300602",
"0.5297923",
"0.5276843",
"0.5260407",
"0.52588... | 0.5585617 | 3 |
Formats n words to the left of the cursor by adding whitespace in certain positions. Note that word count differs between editors and programming languages. The examples are all from Eclipse/Python. | def expand_count(n):
saveText = _get_clipboard_text()
cutText = _select_and_cut_text(n)
if cutText:
endSpace = cutText.endswith(' ')
cutText = _expand_after_special_chars(cutText)
reg = re.compile(
r'([a-zA-Z0-9_\"\'\)][=\+\-\*/\%]|[=\+\-\*/\%][a-zA-Z0-9_\"\'\(])')
hit = reg.search(cutText)
count = 0
while hit and count < 10:
cutText = cutText[:hit.start() + 1] + ' ' + \
cutText[hit.end() - 1:]
hit = reg.search(cutText)
count += 1
newText = cutText
if endSpace:
newText = newText + ' '
newText = newText.replace("%", "%%") # Escape any format chars.
Text(newText).execute()
else: # Failed to get text from clipboard.
Key('c-v').execute() # Restore cut out text.
_set_clipboard_text(saveText) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_by_word(s, n):\n\ta = s.split()\n\tret = ''\n\tfor i in range(0, len(a), n):\n\t\tret += ' '.join(a[i:i+n]) + '\\n'\n\treturn ret",
"def _set_number_of_words(self, N):\n self.N_words_to_display = N",
"def wrap(text, width):\n retstr = \"\"\n for word in text.split(' '):\n if len(re... | [
"0.662828",
"0.62945515",
"0.6190352",
"0.6139892",
"0.6126422",
"0.6030799",
"0.6020674",
"0.59485686",
"0.59349114",
"0.5918667",
"0.59178454",
"0.5900272",
"0.5900229",
"0.5873123",
"0.58688444",
"0.58219737",
"0.579922",
"0.579865",
"0.57816565",
"0.5758057",
"0.5754745",... | 0.6068492 | 5 |
Formats dictated text to upper case. | def uppercase_text(text):
newText = format_upper_case(text)
Text("%(text)s").execute({"text": newText}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_upper(self, text):\n\t\treturn text.upper()",
"def UPPER(text):\n return text.upper()",
"def convert_to_uppercase(text):\n return text.upper()",
"def UCase(text):\n return text.upper()",
"def _transliterate_text(self, _text):\n return _text.upper()",
"def upperCase(self,phrase):\n ... | [
"0.7926861",
"0.781187",
"0.7696189",
"0.75935656",
"0.7231077",
"0.7210327",
"0.70803845",
"0.6985208",
"0.6815186",
"0.67244554",
"0.6724301",
"0.66712606",
"0.66581935",
"0.6649381",
"0.664162",
"0.6625295",
"0.66139257",
"0.65889776",
"0.65846056",
"0.6550878",
"0.652874"... | 0.7757802 | 2 |
Formats n words to the left of the cursor to upper case. Note that word count differs between editors and programming languages. The examples are all from Eclipse/Python. | def uppercase_count(n):
saveText = _get_clipboard_text()
cutText = _select_and_cut_text(n)
if cutText:
newText = cutText.upper()
newText = newText.replace("%", "%%") # Escape any format chars.
Text(newText).execute()
else: # Failed to get text from clipboard.
Key('c-v').execute() # Restore cut out text.
_set_clipboard_text(saveText) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pascal_case_count(n):\n saveText = _get_clipboard_text()\n cutText = _select_and_cut_text(n)\n if cutText:\n endSpace = cutText.endswith(' ')\n text = _cleanup_text(cutText)\n newText = text.title().replace(' ', '')\n if endSpace:\n newText = newText + ' '\n ... | [
"0.7106559",
"0.6925886",
"0.6874002",
"0.66543984",
"0.64259547",
"0.60723484",
"0.6036499",
"0.6025138",
"0.59689647",
"0.5953917",
"0.58584684",
"0.5850111",
"0.58310604",
"0.58229566",
"0.5809339",
"0.57956696",
"0.5791785",
"0.5782367",
"0.57508373",
"0.5699419",
"0.5694... | 0.6954752 | 1 |
Formats dictated text to lower case. | def lowercase_text(text):
newText = format_lower_case(text)
Text("%(text)s").execute({"text": newText}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_lower(self, text):\n return text.lower()",
"def LOWER(text):\n return text.lower()",
"def LCase(text):\n return text.lower()",
"def lower(text):\n text = text.lower()\n return text",
"def toLowerCase(self) -> None:\n self.text = self.text.lower()",
"def normalize_case(text)... | [
"0.7950047",
"0.7778725",
"0.76062495",
"0.757439",
"0.7487152",
"0.7474553",
"0.744533",
"0.73600155",
"0.7350697",
"0.7326691",
"0.72125846",
"0.7002865",
"0.6945686",
"0.6917932",
"0.68785036",
"0.68477106",
"0.68410075",
"0.670077",
"0.6686607",
"0.66477966",
"0.6613953",... | 0.7870158 | 1 |
Formats n words to the left of the cursor to lower case. Note that word count differs between editors and programming languages. The examples are all from Eclipse/Python. | def lowercase_count(n):
saveText = _get_clipboard_text()
cutText = _select_and_cut_text(n)
if cutText:
newText = cutText.lower()
newText = newText.replace("%", "%%") # Escape any format chars.
Text(newText).execute()
else: # Failed to get text from clipboard.
Key('c-v').execute() # Restore cut out text.
_set_clipboard_text(saveText) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pascal_case_count(n):\n saveText = _get_clipboard_text()\n cutText = _select_and_cut_text(n)\n if cutText:\n endSpace = cutText.endswith(' ')\n text = _cleanup_text(cutText)\n newText = text.title().replace(' ', '')\n if endSpace:\n newText = newText + ' '\n ... | [
"0.68059164",
"0.67174524",
"0.6428881",
"0.612785",
"0.60862404",
"0.60718983",
"0.6050795",
"0.59884626",
"0.59352654",
"0.59344274",
"0.5890492",
"0.58382356",
"0.5795074",
"0.5784348",
"0.5748356",
"0.5746969",
"0.5746722",
"0.57407844",
"0.57185817",
"0.5685551",
"0.5658... | 0.73799914 | 0 |
Cleans up the text before formatting to camel, pascal or snake case. Removes dashes, underscores, single quotes (apostrophes) and replaces them with a space character. Multiple spaces, tabs or new line characters are collapsed to one space character. Returns the result as a string. | def _cleanup_text(text):
prefixChars = ""
suffixChars = ""
if text.startswith("-"):
prefixChars += "-"
if text.startswith("_"):
prefixChars += "_"
if text.endswith("-"):
suffixChars += "-"
if text.endswith("_"):
suffixChars += "_"
text = text.strip()
text = text.replace('-', ' ')
text = text.replace('_', ' ')
text = text.replace("'", ' ')
text = re.sub('[ \t\r\n]+', ' ', text) # Any whitespaces to one space.
text = prefixChars + text + suffixChars
return text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_review(self, text):\n text = text.lower() # lowercase capital letters\n\n if self.remove_stopwords:\n text = self.remove_stopwords_f(text, keep_neg_words=True)\n\n text = re.sub('[^a-zA-Z]+', ' ', text) # select only alphabet characters (letters only)\n # text = r... | [
"0.6987627",
"0.69115055",
"0.68299866",
"0.68170524",
"0.6792189",
"0.6779221",
"0.6683785",
"0.6663541",
"0.66497254",
"0.661544",
"0.66122067",
"0.6598049",
"0.65703285",
"0.6562379",
"0.6545204",
"0.6541442",
"0.6536878",
"0.6534535",
"0.6511388",
"0.64796376",
"0.6465856... | 0.7590578 | 0 |
Returns the text contents of the system clip board. | def _get_clipboard_text():
clipboard = Clipboard()
return clipboard.get_system_text() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTextFromClipboard(self) -> str:\n cb = self.qtApp.clipboard()\n if cb:\n QtWidgets.QApplication.processEvents()\n return cb.text()\n g.trace('no clipboard!')\n return ''",
"def read_all_screen(self):\n full_text = \"\"\n for ypos in range(sel... | [
"0.65942186",
"0.6435534",
"0.63300586",
"0.61199254",
"0.6119129",
"0.61073905",
"0.6069073",
"0.5950574",
"0.5950574",
"0.5950574",
"0.5950574",
"0.5950574",
"0.58960754",
"0.58941376",
"0.588573",
"0.5876206",
"0.5874571",
"0.5853478",
"0.58394194",
"0.58292186",
"0.581609... | 0.68701446 | 0 |
Selects wordCount number of words to the left of the cursor and cuts them out of the text. Returns the text from the system clip board. | def _select_and_cut_text(wordCount):
clipboard = Clipboard()
clipboard.set_system_text('')
Key('cs-left/3:%s/10, c-x/10' % wordCount).execute()
return clipboard.get_system_text() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cut_in_words(self,linea):\n length = 0\n res = ''\n limit_screen = 30\n for word in linea.split(' '):\n if length + len(word) <= limit_screen:\n new_word = word + ' '\n length += len(new_word)\n else:\n new_word = '\... | [
"0.5991796",
"0.5976473",
"0.5937633",
"0.59360015",
"0.5921066",
"0.56286114",
"0.5511649",
"0.54804397",
"0.54544324",
"0.53912175",
"0.53642124",
"0.5343262",
"0.5335321",
"0.53241056",
"0.5289842",
"0.52851576",
"0.52594143",
"0.5233265",
"0.52057403",
"0.5187018",
"0.516... | 0.808763 | 0 |
Sets the system clip board content. | def _set_clipboard_text(text):
clipboard = Clipboard()
clipboard.set_text(text) # Restore previous clipboard text.
clipboard.copy_to_system() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_board(board):",
"def set_clipboard_contents(contents):\n pboard = NSPasteboard.generalPasteboard()\n pboard.clearContents()\n for uti in contents:\n data = nsdata(contents[uti])\n pboard.setData_forType_(data, uti.encode('utf-8'))",
"def set_clipboard(content, *args, **kwargs):\n... | [
"0.5636461",
"0.56241775",
"0.56007797",
"0.55882066",
"0.5579036",
"0.5543145",
"0.5503222",
"0.54816544",
"0.54584825",
"0.5431708",
"0.5427628",
"0.53481144",
"0.5347229",
"0.53063387",
"0.5292606",
"0.5292606",
"0.52838135",
"0.52283597",
"0.519499",
"0.51938814",
"0.5122... | 0.46337497 | 53 |
Builds the wx Panel | def init_ui(self):
self.panel_sizer = wx.BoxSizer(wx.VERTICAL)
self.figure_bmp = wx.StaticBitmap(self, wx.ID_ANY,
bitmap=self.controller.empty_bitmap(self.bitmap_width,
self.bitmap_height),
pos=wx.DefaultPosition, size=wx.DefaultSize)
self.panel_sizer.Add(self.figure_bmp, ui_defaults.ctrl_pct, wx.CENTER,
ui_defaults.widget_margin)
self.SetSizerAndFit(self.panel_sizer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_main_panel(self):\n self.panel = wx.Panel(self)\n\n self.init_plot()\n self.canvas = FigCanvas(self.panel, -1, self.fig)\n\n self.control_box = VSControlBox(self.panel, -1, 'Information board')\n\n self.vbox = wx.BoxSizer(wx.VERTICAL)\n self.vbox.Add(self.canvas... | [
"0.7385788",
"0.6923711",
"0.6813496",
"0.66688484",
"0.66683596",
"0.66556764",
"0.65513384",
"0.652836",
"0.645381",
"0.64036214",
"0.6377987",
"0.6332031",
"0.63203603",
"0.6313604",
"0.63063955",
"0.63021123",
"0.6299205",
"0.6261179",
"0.6248059",
"0.6245965",
"0.6225458... | 0.6124254 | 25 |
Generates a plot of the specified data file and sets the ThumbnailPanel's bitmap accordingly | def plot_thumb(self, data_fname):
thumbnail = self.controller.plot_thumb(data_fname, self.bitmap_width, self.bitmap_height)
if thumbnail is not None:
self.figure_bmp.SetBitmap(thumbnail)
else:
self.plot_blank() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_plot(ax, power_data, title, min_db, max_db):\n # only generate plots for the transducers that have data\n if power_data.size <= 0:\n return\n\n ax.set_title(title, fontsize=ZPLSCCPlot.font_size_large)\n return imshow(ax, power_data, interpolation='none', aspect=... | [
"0.6426788",
"0.63435924",
"0.6265439",
"0.62604624",
"0.62195396",
"0.62031156",
"0.6172043",
"0.613385",
"0.61045796",
"0.60914683",
"0.60585433",
"0.6013517",
"0.5999623",
"0.5993755",
"0.5926441",
"0.5907435",
"0.58943826",
"0.58767754",
"0.5841144",
"0.5835282",
"0.58277... | 0.7840498 | 0 |
Sets the ThumbnailPanel's bitmap to a placeholder bitmap when thumbnails are disabled | def plot_blank(self):
self.figure_bmp.SetBitmap(self.controller.plot_blank()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MakeDisabledBitmap(original):\r\n \r\n img = original.ConvertToImage()\r\n return wx.BitmapFromImage(img.ConvertToGreyscale())",
"def SetDisabledBitmap(self, bmp):\r\n \r\n self.disabled_bitmap = bmp",
"def RefreshThumbnail(self):\n if not self.property:\n self.bmp ... | [
"0.659299",
"0.65669173",
"0.6550721",
"0.6123886",
"0.6098775",
"0.6092194",
"0.60567355",
"0.6041891",
"0.5903169",
"0.5866036",
"0.5741572",
"0.57384914",
"0.5658414",
"0.5480358",
"0.5475113",
"0.5414041",
"0.54001987",
"0.53946155",
"0.5358883",
"0.5336738",
"0.5332489",... | 0.56492853 | 13 |
Given the u, v parameters, return a point on the crosssection u is the angle around the cross section curve. For example, for a circle, theta = 2 pi u v is the parameter along the extrusion path. It is used for varying the crosssection at different parts of the path. Return a Vector where the x and y coordinates are in the plane of the cross section. the z coordinate should normally be 0.0, but it doesn't have to be ;) | def position(self, u, v):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def angle_between_vectors(self, u, v):\n vec1_unit = self.get_unit_vector(u)\n vec2_unit = self.get_unit_vector(v)\n return np.arccos(np.clip(np.dot(vec1_unit, vec2_unit), -1.0, 1.0)) * (180/math.pi)",
"def angle_between_vectors_degrees(u, v):\n a = np.dot(u, v)\n b = np.linalg.norm(u)... | [
"0.7025404",
"0.68344337",
"0.6752673",
"0.66578203",
"0.64704037",
"0.646253",
"0.6455052",
"0.63939893",
"0.6362043",
"0.6336837",
"0.6326872",
"0.6326872",
"0.63046926",
"0.62465835",
"0.62256324",
"0.62221944",
"0.6217011",
"0.61493486",
"0.6130122",
"0.61051524",
"0.6081... | 0.0 | -1 |
a is the frequency in the x direction, b is the frequency in the y direction | def __init__(self, a, b):
self.a = a
self.b = b | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def freq_response(b, a=1., n_freqs=1024, sides='onesided'):\r\n # transitioning to scipy freqz\r\n real_n = n_freqs // 2 + 1 if sides == 'onesided' else n_freqs\r\n return sig.freqz(b, a=a, worN=real_n, whole=sides != 'onesided')",
"def freqz(b, a=1, worN=None):\n if worN is None or isinstance(worN, ... | [
"0.6110915",
"0.5992405",
"0.59816706",
"0.5890807",
"0.5879636",
"0.57552236",
"0.57190615",
"0.56921566",
"0.56823105",
"0.56598777",
"0.56512135",
"0.5644057",
"0.5637544",
"0.5629808",
"0.5591739",
"0.5586866",
"0.55634403",
"0.5552246",
"0.5550721",
"0.55504066",
"0.5549... | 0.0 | -1 |
Uploads a new transaction to Rex (Click to see more) | def get(self):
args = single_parser.parse_args()
n1 = args.n
m1 = args.m
r = summation(n1, m1)
print(r)
return {"add": r} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_transaction():\n tx_dict = encode_transaction(\"gautham=awesome\") \n print(tx_dict)\n\n tendermint_host = 'localhost'\n tendermint_port = 26657\n endpoint = 'http://{}:{}/'.format(tendermint_host, tendermint_port)\n\n payload = {\n 'method': 'broadcast_tx_commit',\n 'jsonr... | [
"0.61232543",
"0.6110544",
"0.608616",
"0.6082285",
"0.607676",
"0.6025124",
"0.59454113",
"0.5938837",
"0.5938707",
"0.5918176",
"0.58792144",
"0.5847983",
"0.5846506",
"0.5797633",
"0.57951856",
"0.5787983",
"0.57702297",
"0.5753735",
"0.5752439",
"0.5735202",
"0.5712338",
... | 0.0 | -1 |
Check Whether this command is allowed to be run in current device state. | def check_allowed(self):
if self.state_model.op_state in [
DevState.FAULT,
DevState.UNKNOWN,
DevState.ON,
]:
tango.Except.throw_exception(
f"Disable() is not allowed in current state {self.state_model.op_state}",
"Failed to invoke Disable command on SdpMasterLeafNode.",
"SdpMasterLeafNode.Disable() ",
tango.ErrSeverity.ERR,
)
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_allowed(self):\n if self.state_model.op_state in [\n DevState.FAULT,\n DevState.UNKNOWN,\n DevState.DISABLE,\n ]:\n return False\n\n return True",
"def check_device_state(self):",
"def check_subsystem_commands(self):\n self.commu... | [
"0.7648626",
"0.7175639",
"0.6919901",
"0.69176394",
"0.68736464",
"0.68403673",
"0.682443",
"0.6819756",
"0.6730472",
"0.6730472",
"0.6730472",
"0.66860986",
"0.66518617",
"0.6585563",
"0.6568026",
"0.6549128",
"0.6543349",
"0.65116644",
"0.6509165",
"0.6509131",
"0.65001637... | 0.69579506 | 2 |
Callback function immediately executed when the asynchronous invoked command returns. Checks whether the disable command has been successfully invoked on SDP Master. | def disable_cmd_ended_cb(self, event):
this_server = TangoServerHelper.get_instance()
if event.err:
log_msg = (
f"{const.ERR_INVOKING_CMD}{event.cmd_name}\n{event.errors}"
)
self.logger.error(log_msg)
this_server.write_attr("activityMessage", log_msg, False)
else:
log_msg = f"{const.STR_COMMAND}{event.cmd_name}{const.STR_INVOKE_SUCCESS}"
self.logger.info(log_msg)
this_server.write_attr("activityMessage", log_msg, False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do(self):\n this_server = TangoServerHelper.get_instance()\n try:\n sdp_master_ln_fqdn = \"\"\n property_val = this_server.read_property(\"SdpMasterFQDN\")[0]\n sdp_master_ln_fqdn = sdp_master_ln_fqdn.join(property_val)\n sdp_mln_client_obj = TangoClien... | [
"0.7076065",
"0.6165494",
"0.60460854",
"0.6037636",
"0.5963541",
"0.59550655",
"0.5929981",
"0.58966804",
"0.5892812",
"0.5856831",
"0.5800519",
"0.5799643",
"0.57865214",
"0.5756381",
"0.57319176",
"0.5654577",
"0.5590112",
"0.5557854",
"0.5550717",
"0.5546746",
"0.55359083... | 0.5901317 | 7 |
Method to invoke Disable command on SDP Master. | def do(self):
this_server = TangoServerHelper.get_instance()
try:
sdp_master_ln_fqdn = ""
property_val = this_server.read_property("SdpMasterFQDN")[0]
sdp_master_ln_fqdn = sdp_master_ln_fqdn.join(property_val)
sdp_mln_client_obj = TangoClient(sdp_master_ln_fqdn)
sdp_mln_client_obj.send_command_async(
const.CMD_Disable, None, self.disable_cmd_ended_cb
)
self.logger.debug(const.STR_DISABLE_CMS_SUCCESS)
this_server.write_attr(
"activityMessage", const.STR_DISABLE_CMS_SUCCESS, False
)
except DevFailed as dev_failed:
self.logger.exception(dev_failed)
log_msg = f"{const.ERR_DISABLE_CMD_FAIL}{dev_failed}"
tango.Except.re_throw_exception(
dev_failed,
const.ERR_INVOKING_CMD,
log_msg,
"SdpMasterLeafNode.DisableCommand()",
tango.ErrSeverity.ERR,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Disable(self):\n handler = self.get_command_object(\"Disable\")\n handler()",
"def cmd_disable(self, app_name=None):\n rc = self.socket_command_with_project('disable', app_name)\n return rc",
"def disable(self, sid):\n return",
"def disable(self):\n logging.debug... | [
"0.72543144",
"0.682667",
"0.6537114",
"0.6527344",
"0.6507283",
"0.6505277",
"0.64890575",
"0.64763004",
"0.6459875",
"0.6419226",
"0.63770306",
"0.637017",
"0.6363984",
"0.63474035",
"0.62944055",
"0.6292118",
"0.6276801",
"0.627648",
"0.627209",
"0.62699884",
"0.62642103",... | 0.795008 | 0 |
Creates a named tuple from a dictionary. | def namedtuple_from_dict(obj):
if isinstance(obj, dict):
fields = sorted(obj.keys())
namedtuple_type = namedtuple(typename='Config',
field_names=fields,
rename=True)
field_value_pairs = OrderedDict(
(str(field), Config.namedtuple_from_dict(obj[field]))
for field in fields)
try:
return namedtuple_type(**field_value_pairs)
except TypeError:
# Cannot create namedtuple instance so fallback to dict (invalid attribute names)
return dict(**field_value_pairs)
elif isinstance(obj, (list, set, tuple, frozenset)):
return [Config.namedtuple_from_dict(item) for item in obj]
else:
return obj | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_tuple(in_dict,tupname='values'):\n the_tup = namedtuple(tupname, in_dict.keys())\n the_tup = the_tup(**in_dict)\n return the_tup",
"def ntuple_from_dict(d):\n return namedtuple('TupleFromDict', d.keys())(**d)",
"def make_tuple(name, **kwargs):\n tuple_class = collections.namedtuple(type... | [
"0.8427131",
"0.79982275",
"0.69924045",
"0.6788516",
"0.66534394",
"0.64902914",
"0.64544564",
"0.63769853",
"0.63622445",
"0.63100547",
"0.6171877",
"0.6161274",
"0.60242426",
"0.6023281",
"0.59786564",
"0.59320253",
"0.5883411",
"0.5876747",
"0.5843632",
"0.58232385",
"0.5... | 0.5780806 | 22 |
Returns whether the current instance is an edge server in crosssilo FL. | def is_edge_server() -> bool:
return Config().args.port is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_edge_site(self) -> bool:\n return self.config.edge",
"def is_connected_to(self, receiver: SkupperSite) -> bool:\n return receiver in self.connected_sites",
"def isEdge(self,x,y):\n\t\treturn y in self._dictOut[x]",
"def isEdge(self,x,y):\n\t\treturn y in self._dict[x]",
"def isEdge(sel... | [
"0.7256668",
"0.65036786",
"0.6496777",
"0.6456621",
"0.64283705",
"0.63906115",
"0.6335268",
"0.63215107",
"0.6301984",
"0.6286371",
"0.62700874",
"0.6203978",
"0.61531115",
"0.6063415",
"0.60367393",
"0.60330695",
"0.5981147",
"0.5979535",
"0.5975428",
"0.5965382",
"0.59630... | 0.7117317 | 1 |
Returns whether the current instance is a central server in crosssilo FL. | def is_central_server() -> bool:
return hasattr(Config().algorithm,
'cross_silo') and Config().args.port is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_remote(self):\n if socket.gethostbyname(socket.gethostname()).startswith('10.7'):\n return False\n else:\n return True",
"def is_on(self) -> bool:\n val = bool(self._cluster_handler.cluster.get(self._zcl_attribute))\n return (not val) if self.inverted else... | [
"0.66080767",
"0.65418833",
"0.6524869",
"0.6519794",
"0.6491021",
"0.64296925",
"0.639115",
"0.63826996",
"0.6380103",
"0.6369597",
"0.63640034",
"0.6328281",
"0.6286668",
"0.62676233",
"0.6239149",
"0.6202125",
"0.61955136",
"0.61894524",
"0.61597776",
"0.6134595",
"0.61243... | 0.83141166 | 0 |
Returns the device to be used for training. | def device() -> str:
import torch
if torch.cuda.is_available() and torch.cuda.device_count() > 0:
if hasattr(Config().trainer,
'parallelized') and Config().trainer.parallelized:
device = 'cuda'
else:
device = 'cuda:' + str(
random.randint(0,
torch.cuda.device_count() - 1))
else:
device = 'cpu'
return device | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device(self) -> torch.device:\n for param in self.parameters():\n return param.device\n return get_device(\"cpu\")",
"def get_device():\n import torch\n\n if torch.cuda.is_available():\n return torch.device('cuda')\n return torch.device('cpu')",
"def... | [
"0.8276948",
"0.8204713",
"0.81753296",
"0.80565923",
"0.79779685",
"0.79452527",
"0.79452527",
"0.79452527",
"0.79452527",
"0.79452527",
"0.78916585",
"0.78675044",
"0.7835675",
"0.77565765",
"0.77542937",
"0.77542937",
"0.77542937",
"0.77542937",
"0.7713507",
"0.7709037",
"... | 0.8220512 | 1 |
Check if the hardware and OS support data parallelism. | def is_parallel() -> bool:
import torch
return hasattr(Config().trainer, 'parallelized') and Config(
).trainer.parallelized and torch.cuda.is_available(
) and torch.distributed.is_available(
) and torch.cuda.device_count() > 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parallel_safe(self):\n return True",
"def is_multiprocessing_problematic():\n # Handling numpy linked against accelerate.\n config_info = str([value for key, value in\n np.__config__.__dict__.items()\n if key.endswith(\"_info\")]).lower()\n\n if \"a... | [
"0.63122064",
"0.6217546",
"0.6193051",
"0.61780185",
"0.61725044",
"0.61503655",
"0.6127145",
"0.6078269",
"0.6058447",
"0.603029",
"0.6027548",
"0.59874004",
"0.5955343",
"0.5927671",
"0.58607745",
"0.58542687",
"0.58361876",
"0.58319396",
"0.58313346",
"0.58165216",
"0.580... | 0.66771305 | 0 |
Responsible for converting a LogRecord to a string. | def format(self, record):
return '[{}] {}'.format(QBShFormatter.LEVEL_DICT[record.levelname], record.getMessage()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format(self, record: LogRecord) -> str:\n json_record: Dict = self.json_record(record.getMessage(), record)\n mutated_record: Dict = self.mutate_json_record(json_record)\n mutated_record = mutated_record if mutated_record is not None else json_record\n\n return self.to_json(mutated_... | [
"0.7008044",
"0.69639575",
"0.69169354",
"0.6403992",
"0.6396035",
"0.63660896",
"0.6323886",
"0.61869884",
"0.6149548",
"0.6103099",
"0.6052202",
"0.60219127",
"0.5971884",
"0.5971298",
"0.59584796",
"0.59510505",
"0.59124696",
"0.58543694",
"0.5848523",
"0.584811",
"0.58463... | 0.57463837 | 24 |
Return a command that starts an skvbc replica when passed to subprocess.Popen. The replica is started with a short view change timeout. Note each arguments is an element in a list. | def start_replica_cmd_prefix(builddir, replica_id, config):
statusTimerMilli = "500"
path_to_s3_config = os.path.join(builddir, "test_s3_config_prefix.txt")
if replica_id >= config.n and replica_id < config.n + config.num_ro_replicas:
bucket = "blockchain-" + ''.join(random.choice('0123456789abcdefghijklmnopqrstuvwxyz') for i in range(6))
with open(path_to_s3_config, "w") as f:
f.write("# test configuration for S3-compatible storage\n"
"s3-bucket-name:" + bucket + "\n"
"s3-access-key: concordbft\n"
"s3-protocol: HTTP\n"
"s3-url: 127.0.0.1:9000\n"
"s3-secret-key: concordbft\n"
"s3-path-prefix: concord")
os.makedirs(os.path.join(MINIO_DATA_DIR, "data", bucket)) # create new bucket for this run
ro_params = [ "--s3-config-file",
path_to_s3_config
]
path = os.path.join(builddir, "tests", "simpleKVBC", "TesterReplica", "skvbc_replica")
ret = [path,
"-k", KEY_FILE_PREFIX,
"-i", str(replica_id),
"-s", statusTimerMilli,
"-V", os.getenv('BLOCK_CHAIN_VERSION', default="1"),
"-l", os.path.join(builddir, "tests", "simpleKVBC", "scripts", "logging.properties")
]
if replica_id < config.n:
ret += ["--key-exchange-on-start", "--publish-master-key-on-startup"]
if replica_id >= config.n and replica_id < config.n + config.num_ro_replicas:
ret.extend(ro_params)
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_replica_cmd(builddir, replica_id):\n statusTimerMilli = \"500\"\n viewChangeTimeoutMilli = \"10000\"\n path = os.path.join(builddir, \"tests\", \"simpleKVBC\", \"TesterReplica\", \"skvbc_replica\")\n return [path,\n \"-k\", KEY_FILE_PREFIX,\n \"-i\", str(replica_id),\n ... | [
"0.78137475",
"0.7717148",
"0.5588287",
"0.54520285",
"0.543603",
"0.5400916",
"0.5332327",
"0.52927345",
"0.51990217",
"0.515756",
"0.50810075",
"0.5065432",
"0.5031213",
"0.50212044",
"0.50108457",
"0.5000161",
"0.4948063",
"0.4895872",
"0.48936856",
"0.48688263",
"0.485722... | 0.5777458 | 2 |
generator for primes below threshold | def primes_below_thresh(thresh):
primes_lookup = {n: True for n in range(2, thresh)}
for n in range(2, thresh):
if primes_lookup[n]:
for tick_off in range(n+n, thresh, n):
primes_lookup[tick_off] = False
return sorted((n for n, is_prime in primes_lookup.items() if is_prime)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_primes():\n\n n = 1\n while True:\n while not isPrime(n):\n n += 1\n\n yield n\n n += 1",
"def primes():\n yield 2\n found_primes = [2]\n a = 3\n while True:\n for p in found_primes:\n if p**2 > a:\n found_primes.append(a)... | [
"0.74480325",
"0.7377035",
"0.73052454",
"0.72586906",
"0.7133222",
"0.7117662",
"0.7117662",
"0.71107304",
"0.7063913",
"0.70566493",
"0.70468926",
"0.70215964",
"0.697506",
"0.69364065",
"0.69047195",
"0.6880698",
"0.68761224",
"0.6849385",
"0.68255585",
"0.68095154",
"0.68... | 0.6985148 | 12 |
return True if the number_str can be truncated from both left and right and always be prime, e.g. 3797 | def is_left_right_truncatable(number_str, prime_str_set):
l = len(number_str)
#left truncatable?
for i in range(l):
if number_str[i:] not in prime_str_set or number_str[:l-i] not in prime_str_set:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_truncatable(number: int):\n\n str_number = str(number)\n index = 0\n\n # Left shift:\n while index < len(str_number):\n if not is_prime(int(str_number[index:])):\n return False\n\n index += 1\n\n # Right shift:\n index = len(str_number)\n while index > 0:\n ... | [
"0.8172049",
"0.72789836",
"0.69700235",
"0.6308689",
"0.61999017",
"0.6155211",
"0.6115153",
"0.6111989",
"0.6109884",
"0.6073659",
"0.6044184",
"0.6039048",
"0.60375977",
"0.60341597",
"0.60208774",
"0.6020748",
"0.601937",
"0.60004914",
"0.5998233",
"0.5982962",
"0.5968794... | 0.7736553 | 1 |
Determine fixed modifications in case the reference shift is not at zero. Needs localization. | def determine_fixed_mods_nonzero(reference, locmod_df, data):
utils.internal('Localizations for %s: %s', reference, locmod_df.at[reference, 'localization'])
loc = get_fix_mod_from_l10n(reference, locmod_df)
label = reference
data_dict = data.ms_stats().copy()
while loc is None:
del data_dict[label]
label = max(data_dict, key=lambda k: data_dict[k][1])
loc = get_fix_mod_from_l10n(label, locmod_df)
logger.debug('No luck. Trying %s. Got %s', label, loc)
if not data_dict:
break
return loc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_fixed_mods_zero(aastat_result, data, params_dict):\n fix_mod_zero_thresh = params_dict['fix_mod_zero_thresh']\n min_fix_mod_pep_count_factor = params_dict['min_fix_mod_pep_count_factor']\n\n fix_mod_dict = {}\n reference = utils.mass_format(0)\n aa_rel = aastat_result[reference][2]\n ... | [
"0.61892533",
"0.6004834",
"0.5786946",
"0.5511628",
"0.54182035",
"0.5341413",
"0.52645195",
"0.5253012",
"0.5237",
"0.5225602",
"0.52148324",
"0.5205912",
"0.5189934",
"0.5129188",
"0.51038384",
"0.51002914",
"0.5086002",
"0.50812876",
"0.49967453",
"0.4983229",
"0.49150836... | 0.59622836 | 2 |
Determine fixed modifications in case the reference shift is at zero. Does not need localization. | def determine_fixed_mods_zero(aastat_result, data, params_dict):
fix_mod_zero_thresh = params_dict['fix_mod_zero_thresh']
min_fix_mod_pep_count_factor = params_dict['min_fix_mod_pep_count_factor']
fix_mod_dict = {}
reference = utils.mass_format(0)
aa_rel = aastat_result[reference][2]
utils.internal('aa_rel:\n%s', aa_rel)
candidates = aa_rel[aa_rel < fix_mod_zero_thresh].index
logger.debug('Fixed mod candidates: %s', candidates)
for i in candidates:
candidate_label = get_fixed_mod_raw(i, data, params_dict)
if candidate_label != reference:
# number of peptides with `i` at shift `candidate label` must be higher than ...
count_cand = data.peptides(candidate_label).str.contains(i).sum()
# number of peptides with `i` at shift `reference` by a factor of `min_fix_mod_pep_count_factor`
count_ref = data.peptides(reference).str.contains(i).sum()
# peptide count at candidate shift over # of peptides at reference
est_ratio = count_cand / data.ms_stats()[reference][1]
logger.debug('Peptides with %s: ~%d at %s, ~%d at %s. Estimated pct: %f',
i, count_ref, reference, count_cand, candidate_label, est_ratio)
if aastat_result[candidate_label][2][i] > fix_mod_zero_thresh and (
est_ratio * 100 > fix_mod_zero_thresh * min_fix_mod_pep_count_factor):
fix_mod_dict[i] = candidate_label
else:
logger.debug('Could not find %s anywhere. Can\'t fix.', i)
else:
logger.debug('Reference shift is the best for %s.', i)
return fix_mod_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_fixed_mods_nonzero(reference, locmod_df, data):\n utils.internal('Localizations for %s: %s', reference, locmod_df.at[reference, 'localization'])\n loc = get_fix_mod_from_l10n(reference, locmod_df)\n label = reference\n data_dict = data.ms_stats().copy()\n while loc is None:\n de... | [
"0.6245811",
"0.5993922",
"0.58981633",
"0.54384756",
"0.5420952",
"0.5370132",
"0.5319682",
"0.52733696",
"0.52633834",
"0.5207875",
"0.5174516",
"0.5168301",
"0.5162118",
"0.5160096",
"0.5155298",
"0.5127173",
"0.5121005",
"0.50911295",
"0.49932376",
"0.4955329",
"0.4909749... | 0.63415945 | 0 |
Generates points used as input to a hotspot detection algorithm. With probability hotspot_weight (20%), a point is drawn from the hotspot; otherwise, it is drawn from the base field. The location of the hotspot changes for every 1000 points generated. | def generate(
stream_name, field, hotspot_size, hotspot_weight, batch_size, kinesis_client):
points_generated = 0
hotspot = None
while True:
if points_generated % 1000 == 0:
hotspot = get_hotspot(field, hotspot_size)
records = [
get_record(field, hotspot, hotspot_weight) for _ in range(batch_size)]
points_generated += len(records)
pprint(records)
kinesis_client.put_records(StreamName=stream_name, Records=records)
time.sleep(0.1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_points(num_points):\n for i in xrange(0, num_points):\n pass",
"def __get_random_hotspot(self):\n x_min = self.occupancy_map.info.origin.position.x\n x_max = x_min + self.occupancy_map.info.width * self.occupancy_map.info.resolution\n y_min = self.occupancy_map.info.or... | [
"0.5980552",
"0.5892994",
"0.5780709",
"0.5760391",
"0.5661503",
"0.56367826",
"0.5512635",
"0.5436439",
"0.5356636",
"0.53310627",
"0.53305316",
"0.53082323",
"0.52768755",
"0.5271147",
"0.52537584",
"0.52499676",
"0.5233892",
"0.5219804",
"0.5211902",
"0.52063584",
"0.52026... | 0.5625842 | 6 |
r"""Compute the Einstein radius for a given isotropic velocity dispersion assuming a singular isothermal sphere (SIS) mass profile | def approximate_theta_E_for_SIS(vel_disp_iso, z_lens, z_src, cosmo):
lens_cosmo = LensCosmo(z_lens, z_src, cosmo=cosmo)
theta_E_SIS = lens_cosmo.sis_sigma_v2theta_E(vel_disp_iso)
return theta_E_SIS | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calculate_residual_sphere(parameters, x_values, y_values, z_values):\n #extract the parameters\n x_centre, y_centre, z_centre, radius = parameters\n\n #use numpy's sqrt function here, which works by element on arrays\n distance_from_centre = numpy.sqrt((x_values - x_centre)**2 +\n ... | [
"0.59292984",
"0.5824991",
"0.5817226",
"0.58086616",
"0.57849306",
"0.57736725",
"0.5735249",
"0.57111436",
"0.5704036",
"0.56862265",
"0.5664737",
"0.5664737",
"0.56512725",
"0.5550405",
"0.5496292",
"0.5456463",
"0.5426158",
"0.54168355",
"0.53976965",
"0.5365244",
"0.5362... | 0.6008606 | 0 |
Evaluate the Vband luminosity L_V expected from the FJ relation for a given velocity dispersion | def get_luminosity(self, vel_disp):
log_L_V = self.slope*np.log10(vel_disp) + self.intercept
return log_L_V | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_vcond(lambdam, taum):\n return 2 * lambdam / taum",
"def V_hipass(V, R_S, C, L, R_L, f):\n # current in circuit\n I = V/(R_S + Z_hipass(C, L, R_L, f))\n # voltage across circuit\n V_out = V - I*R_S\n I_L = V_out/Z_high(C, R_L, f) # current through load branch\n V_L = I_L*R_L # voltage across loa... | [
"0.63736004",
"0.5998151",
"0.5983169",
"0.5946282",
"0.58367145",
"0.5795854",
"0.5793172",
"0.57542485",
"0.571141",
"0.57062334",
"0.56781685",
"0.5638643",
"0.5626958",
"0.5622531",
"0.56085986",
"0.5567615",
"0.5557632",
"0.5544373",
"0.55408514",
"0.5531132",
"0.553042"... | 0.64296955 | 0 |
Set the parameters fit on SDSS DR4 Note The values of slope and intercept are taken from the rband orthogonal fit on SDSS DR4. See Table 2 of [1]_. References .. [1] Hyde, Joseph B., and Mariangela Bernardi. "The luminosity and stellar mass Fundamental Plane of earlytype galaxies." | def _define_SDSS_fit_params(self):
self.a = 1.4335
self.b = 0.3150
self.c = -8.8979
self.intrinsic_scatter = 0.0578
#self.delta_a = 0.02
#self.delta_b = 0.01 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _define_SLACS_fit_params(self):\n\t\t# Fit params from R_eff\n\t\tself.a = -0.41\n\t\tself.b = 0.39\n\t\t#self.delta_a = 0.12\n\t\t#self.delta_b = 0.10\n\t\tself.intrinsic_scatter = 0.14\n\t\t# Fit params from vel_disp\n\t\tself.a_v = 0.07\n\t\tself.b_v = -0.12\n\t\tself.int_v = 0.17",
"def doParametersOfInt... | [
"0.6524372",
"0.5828944",
"0.5815241",
"0.5792441",
"0.5774732",
"0.5649416",
"0.560434",
"0.5591655",
"0.55806255",
"0.5562633",
"0.5548635",
"0.5524629",
"0.5523357",
"0.5509879",
"0.5508611",
"0.5453511",
"0.544221",
"0.54013795",
"0.54003555",
"0.53875685",
"0.5369344",
... | 0.6969803 | 0 |
Evaluate the size expected from the FP relation for a given velocity dispersion and Vband apparent magnitude | def get_effective_radius(self, vel_disp, m_V):
log_vel_disp = np.log10(vel_disp)
log_R_eff = self.a*log_vel_disp + self.b*m_V + self.c + np.random.randn()*self.intrinsic_scatter
R_eff = 10**log_R_eff
return R_eff | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fluxRatio_fromVmag(Vmag):\n fluxRatio = 10.**(-0.4*Vmag)\n return fluxRatio",
"def width_v_a(model: SingleRhNeutrinoModel) -> float:\n u = 0.5 * np.tan(2 * model.theta)\n return 9 * ALPHA_EM * GF**2 / (256 * np.pi**4) * model.mx**5 * u**2",
"def testCalspecMags(self):\n std = MKIDStd.MKI... | [
"0.6291265",
"0.5848869",
"0.5809261",
"0.5802869",
"0.57336414",
"0.5729062",
"0.569543",
"0.56734866",
"0.5662906",
"0.56628376",
"0.56435436",
"0.56359833",
"0.5614053",
"0.5611046",
"0.55810857",
"0.55808634",
"0.5556087",
"0.55491066",
"0.55242413",
"0.5521659",
"0.55142... | 0.0 | -1 |
Set the parameters fit on the Sloan Lens Arcs Survey (SLACS) sample of 73 ETGs Note See Table 4 of [1]_ for the fit values, taken from the empirical correlation derived from the SLACS lens galaxy sample. References | def _define_SLACS_fit_params(self):
# Fit params from R_eff
self.a = -0.41
self.b = 0.39
#self.delta_a = 0.12
#self.delta_b = 0.10
self.intrinsic_scatter = 0.14
# Fit params from vel_disp
self.a_v = 0.07
self.b_v = -0.12
self.int_v = 0.17 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _define_SDSS_fit_params(self):\n\t\tself.a = 1.4335\n\t\tself.b = 0.3150 \n\t\tself.c = -8.8979\n\t\tself.intrinsic_scatter = 0.0578\n\t\t#self.delta_a = 0.02\n\t\t#self.delta_b = 0.01",
"def set_fit_params(self):\n\n self.p0 = np.array([self.A_arr, self.T_a])\n # initial guess at A_arr and T_a\n\n ... | [
"0.66335446",
"0.6191415",
"0.59800696",
"0.58964324",
"0.5816966",
"0.5668345",
"0.56514496",
"0.5646242",
"0.5645791",
"0.561993",
"0.56091666",
"0.55902165",
"0.55819917",
"0.55689085",
"0.5561756",
"0.5520965",
"0.5512555",
"0.5506377",
"0.550578",
"0.549302",
"0.54860383... | 0.750283 | 0 |
Evaluate the powerlaw slope of the mass profile from its powerlaw relation with effective radius | def get_gamma_from_R_eff(self, R_eff):
log_R_eff = np.log10(R_eff)
gam_minus_2 = log_R_eff*self.a + self.b + np.random.randn()*self.intrinsic_scatter
return gam_minus_2 + 2.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def power(self):\n return irradiance_on_plane(self.vnorm, self.h,\n self.date, self.lat) * self.s * self.eff",
"def _powerlaw(self, x: np.ndarray, y: np.ndarray) -> float:\n\n # regress\n def _regress(x, y):\n slope, intercept, rval, pval, err = l... | [
"0.6757806",
"0.6462289",
"0.6391217",
"0.6186872",
"0.61128086",
"0.5965611",
"0.59109455",
"0.58782387",
"0.5849429",
"0.5842808",
"0.5838932",
"0.58238125",
"0.5823275",
"0.5812738",
"0.5809786",
"0.5801164",
"0.57895917",
"0.5785309",
"0.57821614",
"0.5743392",
"0.5738444... | 0.0 | -1 |
Evaluate the powerlaw slope of the mass profile from its powerlaw relation with effective radius | def get_gamma_from_vel_disp(self, vel_disp):
gam_minus_2 = vel_disp*self.a_v + self.b_v + np.random.randn()*self.int_v
return gam_minus_2 + 2.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def power(self):\n return irradiance_on_plane(self.vnorm, self.h,\n self.date, self.lat) * self.s * self.eff",
"def _powerlaw(self, x: np.ndarray, y: np.ndarray) -> float:\n\n # regress\n def _regress(x, y):\n slope, intercept, rval, pval, err = l... | [
"0.6757806",
"0.6462289",
"0.6391217",
"0.6186872",
"0.61128086",
"0.5965611",
"0.59109455",
"0.58782387",
"0.5849429",
"0.5842808",
"0.5838932",
"0.58238125",
"0.5823275",
"0.5812738",
"0.5809786",
"0.5801164",
"0.57895917",
"0.5785309",
"0.57821614",
"0.5743392",
"0.5738444... | 0.0 | -1 |
Sample (one minus) the axis ratio of the lens galaxy from the Rayleigh distribution with scale that depends on velocity dispersion | def get_axis_ratio(self, vel_disp):
scale = self.a*vel_disp + self.b
q = 0.0
while q < self.lower:
q = 1.0 - np.random.rayleigh(scale, size=None)
return q | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRatio(probe_num, position_vector, shot_range, dir, day ='050119r'):\n ratio_x = 0\n ratio_y = 0\n ratio_z = 0\n # helm_B = [0,0,0]\n divideby = 0\n for shot in range(shot_range[0], shot_range[1]+1):\n print( 'On shot ', day+str(shot), ' for probe ',probe_num)\n x,y,z, currma... | [
"0.5984484",
"0.5951197",
"0.5821933",
"0.5732663",
"0.57284033",
"0.567641",
"0.56427747",
"0.56382126",
"0.5614669",
"0.56115395",
"0.5601904",
"0.5573603",
"0.5534662",
"0.55199206",
"0.54970366",
"0.54887855",
"0.5470825",
"0.5469452",
"0.5453029",
"0.54443336",
"0.543773... | 0.7055274 | 0 |
Evaluate the double power law at the given grid of absolute magnitudes | def get_double_power_law(self, alpha, beta, M_star):
denom = 10.0**(0.4*(alpha + 1.0)*(self.M_grid - M_star))
denom += 10.0**(0.4*(beta + 1.0)*(self.M_grid - M_star))
dn = 1.0/denom
dn /= np.sum(dn)
return dn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_powers(self):\n l = np.array([0, 1, 2])\n r = np.linspace(0, 1, 11) # rho coordinates\n\n correct_vals = np.array([np.ones_like(r), r, r**2]).T\n correct_ders = np.array([np.zeros_like(r), np.ones_like(r), 2 * r]).T\n\n values = powers(r, l, dr=0)\n derivs = powe... | [
"0.59356666",
"0.5698591",
"0.5668886",
"0.5603993",
"0.5581548",
"0.5566813",
"0.5537873",
"0.5494465",
"0.5466236",
"0.5465886",
"0.5446438",
"0.53736854",
"0.5353577",
"0.53370494",
"0.5319311",
"0.5316912",
"0.53169",
"0.5298397",
"0.5294312",
"0.52837807",
"0.5272999",
... | 0.536298 | 12 |
Sample the AGN luminosity from the redshiftbinned luminosity function | def sample_agn_luminosity(self, z):
# Assign redshift bin
is_less_than_right_edge = (z < self.z_bins)
alpha = self.alphas[is_less_than_right_edge][0]
beta = self.betas[is_less_than_right_edge][0]
M_star = self.M_stars[is_less_than_right_edge][0]
# Evaluate function
pmf = self.get_double_power_law(alpha, beta, M_star)
# Sample luminosity
sampled_M = np.random.choice(self.M_grid, None, replace=True, p=pmf)
return sampled_M | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_luminosity(red, green, blue):\r\n return (0.299 * red) + (0.587 * green) + (0.114 * blue)",
"def luminance(self):\n \n return (self.r + self.g + self.b) // 3",
"def compute_radiocore_luminosity(MBH, L_AGN):\n\tL_X = bolcorr_hardX(L_AGN)\n\tm = log10(MBH / u.Msun)\n\t# Merloni, Hein... | [
"0.6417541",
"0.63884014",
"0.6198883",
"0.5988071",
"0.58689255",
"0.5791698",
"0.5777783",
"0.57607454",
"0.5741125",
"0.5704976",
"0.5666426",
"0.56387365",
"0.56344163",
"0.5579416",
"0.5577653",
"0.55769515",
"0.5561606",
"0.5552182",
"0.55497104",
"0.554356",
"0.5517453... | 0.7363408 | 0 |
expects 2 arrays of shape (3, N) rigid transform algorithm from | def rigid_transform_3d(xs,ys):
assert xs.shape == ys.shape
assert xs.shape[0] == 3, 'The points must be of dimmensionality 3'
# find centroids and H
x_centroid = np.mean(xs, axis=1)[:, np.newaxis]
y_centroid = np.mean(ys, axis=1)[:, np.newaxis]
H = (xs - x_centroid)@(ys - y_centroid).T
# find rotation
U, S, Vt = np.linalg.svd(H)
rotation = Vt.T@U.T
# handling reflection
if np.linalg.det(rotation) < 0:
Vt[2, :] *= -1
rotation = np.dot(Vt.T, U.T)
# find translation
translation = y_centroid - rotation@x_centroid
return translation, rotation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compose_transform(T1, T2):\n aux_vec = np.array([0, 0, 1]).reshape(1, 3)\n\n T1 = np.concatenate((T1, aux_vec), axis=0)\n T2 = np.concatenate((T2, aux_vec), axis=0)\n\n T1_inv = np.linalg.inv(T1)\n T = T1_inv@T2\n\n return T[0:2]",
"def transform(tvec1, rvec1, tvec2, rvec2):\n op = local... | [
"0.64119685",
"0.6391706",
"0.637345",
"0.63456833",
"0.6247986",
"0.61719114",
"0.6155749",
"0.6147075",
"0.60972595",
"0.60801315",
"0.607085",
"0.607085",
"0.6059854",
"0.6050465",
"0.6016514",
"0.59902495",
"0.59778076",
"0.59692",
"0.59610087",
"0.5923086",
"0.5920455",
... | 0.6508242 | 0 |
Update used dataset No copy is made. | def _updateData(self, data, range_):
self._data = None if data is None else numpy.array(data, copy=False)
self._getPlane().setData(self._data, copy=False)
# Store data range info as 3-tuple of values
self._dataRange = range_
if range_ is None:
range_ = None, None, None
self._setColormappedData(self._data, copy=False,
min_=range_[0],
minPositive=range_[1],
max_=range_[2])
self._updated(ItemChangedType.DATA) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_data(self, selected):\n if selected.row() != self.datasets.index:\n self.datasets.index = selected.row()\n self.datasets.update_current()\n self._update_main()",
"def _UpdateDataSetValues( self ):\n pass",
"def update_data(self, newData):\r\n self.A... | [
"0.72957367",
"0.6916875",
"0.68677783",
"0.6687427",
"0.6636599",
"0.64887625",
"0.64763397",
"0.6363844",
"0.63379943",
"0.6290157",
"0.6272427",
"0.6256088",
"0.6151666",
"0.61373025",
"0.61060303",
"0.6089082",
"0.6079945",
"0.6057681",
"0.6042186",
"0.60393506",
"0.60347... | 0.5581601 | 73 |
Synchronize this instance data with that of its parent | def _syncDataWithParent(self):
parent = self.parent()
if parent is None:
data, range_ = None, None
else:
data = parent.getData(copy=False)
range_ = parent.getDataRange()
self._updateData(data, range_) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _syncDataWithParent(self):\n parent = self.parent()\n if parent is None:\n self._data = None\n else:\n self._data = parent.getData(copy=False)\n self._updateScenePrimitive()",
"def _syncDataWithParent(self):\n parent = self.parent()\n if parent ... | [
"0.8105605",
"0.7977319",
"0.7733652",
"0.71153784",
"0.71153784",
"0.70563495",
"0.7043718",
"0.674526",
"0.65729344",
"0.6530828",
"0.64562",
"0.6451494",
"0.6362502",
"0.6362502",
"0.6325555",
"0.63112843",
"0.6255493",
"0.6245364",
"0.6242624",
"0.619789",
"0.61851496",
... | 0.80830806 | 1 |
Handle data change in the parent this plane belongs to | def _parentChanged(self, event):
if event == ItemChangedType.DATA:
self._syncDataWithParent() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _updated(self, event=None):\n if event == ItemChangedType.COMPLEX_MODE:\n self._syncDataWithParent()\n super(ComplexCutPlane, self)._updated(event)",
"def _parentChanged(self, event):\n if event == ItemChangedType.COMPLEX_MODE:\n self._syncDataWithParent()\n ... | [
"0.6953876",
"0.68844354",
"0.67612237",
"0.6697958",
"0.65322846",
"0.6528624",
"0.6475116",
"0.6469735",
"0.6335095",
"0.63126916",
"0.6303943",
"0.6144572",
"0.6131545",
"0.6011931",
"0.5992628",
"0.59669846",
"0.5949945",
"0.59455943",
"0.5932121",
"0.59244823",
"0.586596... | 0.6928027 | 2 |
Return whether values <= colormap min are displayed or not. | def getDisplayValuesBelowMin(self):
return self._getPlane().colormap.displayValuesBelowMin | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setDisplayValuesBelowMin(self, display):\n display = bool(display)\n if display != self.getDisplayValuesBelowMin():\n self._getPlane().colormap.displayValuesBelowMin = display\n self._updated(ItemChangedType.ALPHA)",
"def visible(self):\n return -PipePair.WIDTH < se... | [
"0.6101894",
"0.606636",
"0.5966878",
"0.59301066",
"0.5888018",
"0.58112633",
"0.58078593",
"0.5752245",
"0.5747372",
"0.57274777",
"0.57218593",
"0.5695929",
"0.55961335",
"0.5590847",
"0.5554003",
"0.5551317",
"0.55380684",
"0.5532524",
"0.55230325",
"0.5503854",
"0.550056... | 0.7410294 | 0 |
Set whether to display values <= colormap min. | def setDisplayValuesBelowMin(self, display):
display = bool(display)
if display != self.getDisplayValuesBelowMin():
self._getPlane().colormap.displayValuesBelowMin = display
self._updated(ItemChangedType.ALPHA) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_colormap_full_range(self):\n if(self.plot.image is None):\n return\n \n cmin = self.settingsWidget.ui.colormap_min\n cmax = self.settingsWidget.ui.colormap_max\n data_min = numpy.min(self.plot.image)\n data_max = numpy.max(self.plot.image)\n cmin.... | [
"0.6897544",
"0.68503755",
"0.6472414",
"0.64165556",
"0.6364885",
"0.6256008",
"0.6017445",
"0.6017445",
"0.5980322",
"0.5958103",
"0.59348243",
"0.58880955",
"0.58671427",
"0.5842141",
"0.580647",
"0.57340556",
"0.57123756",
"0.56508297",
"0.56315273",
"0.5560471",
"0.55498... | 0.77897596 | 0 |
Return the range of the data as a 3tuple of values. positive min is NaN if no data is positive. | def getDataRange(self):
return None if self._dataRange is None else tuple(self._dataRange) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _computeRangeFromData(data):\n if data is None:\n return None\n\n dataRange = min_max(data, min_positive=True, finite=True)\n if dataRange.minimum is None: # Only non-finite data\n return None\n\n if dataRange is not None:\n min_positive = dataRange... | [
"0.80794895",
"0.7623016",
"0.7399985",
"0.7339498",
"0.7240076",
"0.7086574",
"0.7079901",
"0.70793736",
"0.6944895",
"0.6782193",
"0.6766099",
"0.6677474",
"0.66592604",
"0.6654025",
"0.6621791",
"0.6613688",
"0.6587012",
"0.6554875",
"0.6525205",
"0.6514943",
"0.64271283",... | 0.7169807 | 5 |
Perform picking in this item at given widget position. | def _pickFull(self, context):
rayObject = context.getPickingSegment(frame=self._getScenePrimitive())
if rayObject is None:
return None
points = utils.segmentPlaneIntersect(
rayObject[0, :3],
rayObject[1, :3],
planeNorm=self.getNormal(),
planePt=self.getPoint())
if len(points) == 1: # Single intersection
if numpy.any(points[0] < 0.):
return None # Outside volume
z, y, x = int(points[0][2]), int(points[0][1]), int(points[0][0])
data = self.getData(copy=False)
if data is None:
return None # No dataset
depth, height, width = data.shape
if z < depth and y < height and x < width:
return PickingResult(self,
positions=[points[0]],
indices=([z], [y], [x]))
else:
return None # Outside image
else: # Either no intersection or segment and image are coplanar
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Point_Pick(self):\n self.vtkWidget.iren.AddObserver('RightButtonPressEvent', self.pick_loc)\n self.renWin.Render()",
"def pick_loc(self, event, x):\n #print(event, x)\n self.vtkWidget.iren.RemoveObservers('RightButtonPressEvent')\n loc = event.GetEventPosition()\n\n ... | [
"0.66232896",
"0.58813524",
"0.5879792",
"0.5860174",
"0.5787622",
"0.57383424",
"0.570975",
"0.56717336",
"0.564384",
"0.5572894",
"0.55690295",
"0.5561806",
"0.55518645",
"0.5547201",
"0.55388415",
"0.5531264",
"0.5512377",
"0.5507659",
"0.54962397",
"0.5493375",
"0.5490328... | 0.0 | -1 |
Synchronize this instance data with that of its parent | def _syncDataWithParent(self):
parent = self.parent()
if parent is None:
self._data = None
else:
self._data = parent.getData(copy=False)
self._updateScenePrimitive() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _syncDataWithParent(self):\n parent = self.parent()\n if parent is None:\n data, range_ = None, None\n else:\n data = parent.getData(copy=False)\n range_ = parent.getDataRange()\n self._updateData(data, range_)",
"def _syncDataWithParent(self):\n ... | [
"0.80830806",
"0.7977319",
"0.7733652",
"0.71153784",
"0.71153784",
"0.70563495",
"0.7043718",
"0.674526",
"0.65729344",
"0.6530828",
"0.64562",
"0.6451494",
"0.6362502",
"0.6362502",
"0.6325555",
"0.63112843",
"0.6255493",
"0.6245364",
"0.6242624",
"0.619789",
"0.61851496",
... | 0.8105605 | 0 |
Handle data change in the parent this isosurface belongs to | def _parentChanged(self, event):
if event == ItemChangedType.DATA:
self._syncDataWithParent() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parentChanged(self, event):\n if event == ItemChangedType.COMPLEX_MODE:\n self._syncDataWithParent()\n super(ComplexIsosurface, self)._parentChanged(event)",
"def _updated(self, event=None):\n if event == ItemChangedType.COMPLEX_MODE:\n self._syncDataWithParent()\n... | [
"0.78250813",
"0.7281809",
"0.6798219",
"0.663362",
"0.6617056",
"0.6495038",
"0.63203007",
"0.6309291",
"0.62671393",
"0.6239306",
"0.6219209",
"0.6177352",
"0.6040155",
"0.59989554",
"0.5994137",
"0.59767103",
"0.5967239",
"0.5934066",
"0.5895432",
"0.58403164",
"0.5837722"... | 0.63887423 | 6 |
Return the level of this isosurface (float) | def getLevel(self):
return self._level | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level(self):\n return self.game_data['player stats']['Level']",
"def level(self):\n return self.init_v[2]",
"def getLevel(self):\n return _libsbml.SBasePlugin_getLevel(self)",
"def level(self):\n return self._level",
"def level(self):\n return self._level",
"def lev... | [
"0.692961",
"0.68555295",
"0.68304414",
"0.67786837",
"0.67786837",
"0.67786837",
"0.67786837",
"0.67447656",
"0.67447656",
"0.673165",
"0.6729187",
"0.67290646",
"0.67083573",
"0.6660453",
"0.66239667",
"0.66239667",
"0.65987796",
"0.6588329",
"0.65245295",
"0.65243083",
"0.... | 0.68635625 | 1 |
Set the value at which to build the isosurface. Setting this value reset autolevel function | def setLevel(self, level):
self._autoLevelFunction = None
level = float(level)
if level != self._level:
self._level = level
self._updateScenePrimitive()
self._updated(Item3DChangedType.ISO_LEVEL) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetLevelSetValue(self, _arg: 'double const') -> \"void\":\n return _itkReinitializeLevelSetImageFilterPython.itkReinitializeLevelSetImageFilterIF3_SetLevelSetValue(self, _arg)",
"def SetLevelSetValue(self, _arg: 'double const') -> \"void\":\n return _itkReinitializeLevelSetImageFilterPython.itk... | [
"0.59382164",
"0.58852255",
"0.5742166",
"0.5726637",
"0.57214034",
"0.571938",
"0.5709026",
"0.56838727",
"0.56748176",
"0.5579223",
"0.55515665",
"0.55400157",
"0.55338275",
"0.5522072",
"0.54870933",
"0.5481656",
"0.5459882",
"0.5447825",
"0.54363453",
"0.5433698",
"0.5425... | 0.6042807 | 0 |
True if isolevel is rebuild for each data set. | def isAutoLevel(self):
return self.getAutoLevelFunction() is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_flat(self):\n if self.master:\n return self.master.is_flat\n\n return len(self.levels) == 1",
"def is_dirty(self):\n return True in [n.is_dirty for n in self.nodes]",
"def is_populated(self) -> bool:\n return 0 < self.count_compounds()",
"def expand(self) -> bool... | [
"0.5513903",
"0.53375137",
"0.53244",
"0.5214366",
"0.52118033",
"0.51006144",
"0.509896",
"0.5054429",
"0.50461084",
"0.504185",
"0.5018518",
"0.5013366",
"0.4990533",
"0.49454755",
"0.49356946",
"0.4934179",
"0.49291185",
"0.49103767",
"0.49099454",
"0.49048275",
"0.4894874... | 0.46711308 | 68 |
Return the function computing the isolevel (callable or None) | def getAutoLevelFunction(self):
return self._autoLevelFunction | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _func(self):\n return self._get_flint_func(self.domain)",
"def _get_isis_level(self):\n return self.__isis_level",
"def poly_level(f):\n if poly_univariate_p(f):\n return 1\n else:\n return 1 + poly_level(poly_LC(f))",
"def getFunction(self) -> ghidra.program.model.listing.F... | [
"0.6047651",
"0.5671476",
"0.5463008",
"0.54624134",
"0.5348979",
"0.53289545",
"0.5268753",
"0.5257093",
"0.52481455",
"0.5203101",
"0.5194863",
"0.51774395",
"0.51627976",
"0.5157307",
"0.51524407",
"0.5147835",
"0.513994",
"0.51247656",
"0.5106995",
"0.5046533",
"0.5028735... | 0.5753576 | 1 |
Set the function used to compute the isolevel. | def setAutoLevelFunction(self, autoLevel):
assert callable(autoLevel)
self._autoLevelFunction = autoLevel
self._updateScenePrimitive() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_func(self, function):\n self.get(COMMAND_UIC, 'SetFunc', [('function', function)])",
"def setLevel(self, level):\n self._autoLevelFunction = None\n level = float(level)\n if level != self._level:\n self._level = level\n self._updateScenePrimitive()\n ... | [
"0.6181312",
"0.6165592",
"0.6127846",
"0.5975614",
"0.59404004",
"0.588994",
"0.5565282",
"0.54807913",
"0.546307",
"0.54172516",
"0.5397693",
"0.5396863",
"0.539358",
"0.5385595",
"0.5355135",
"0.53504646",
"0.5310676",
"0.5305245",
"0.5295712",
"0.5280084",
"0.52643174",
... | 0.612693 | 3 |
Return the color of this isosurface (QColor) | def getColor(self):
return qt.QColor.fromRgbF(*self._color) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getColor(self):\n return self.color",
"def getColor(self):\r\n return self.color",
"def get_color(self):\r\n return self._color",
"def getColor(self):\n return self.__color",
"def getColor(self):\n return self.__color",
"def getColor(self):\n return self.__co... | [
"0.70161194",
"0.6997709",
"0.69830304",
"0.6970522",
"0.6970522",
"0.6970522",
"0.69664246",
"0.6958327",
"0.69552636",
"0.69552636",
"0.69544834",
"0.6918692",
"0.6895953",
"0.68916535",
"0.68916535",
"0.68693244",
"0.68693244",
"0.68580174",
"0.680577",
"0.67948073",
"0.67... | 0.77090704 | 0 |
Handle update of color | def _updateColor(self, color):
primitive = self._getScenePrimitive()
if len(primitive.children) != 0:
primitive.children[0].setAttribute('color', color) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_color(self, color):\n self.color = color",
"def _update_color(self, *args):\n\n if self._variable and 'w' in self._mode and not self._dnd_started:\n self._internal_color_change = True\n self.color_var.set(self._variable)",
"def update_color(self):\r\n \r\n ... | [
"0.792751",
"0.7712366",
"0.77086216",
"0.7582702",
"0.72797334",
"0.7251339",
"0.72495466",
"0.7238376",
"0.72019273",
"0.7178436",
"0.7135327",
"0.69967073",
"0.69614214",
"0.69462603",
"0.6907712",
"0.68813443",
"0.6823944",
"0.6733206",
"0.67252445",
"0.6687395",
"0.66537... | 0.6820552 | 17 |
Set the color of the isosurface | def setColor(self, color):
color = rgba(color)
if color != self._color:
self._color = color
self._updateColor(self._color)
self._updated(ItemChangedType.COLOR) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _updateColor(self, color):\n primitive = self._getScenePrimitive()\n if (len(primitive.children) != 0 and\n isinstance(primitive.children[0], primitives.ColormapMesh3D)):\n primitive.children[0].alpha = self._color[3]\n else:\n super(ComplexIsosurface, ... | [
"0.6811779",
"0.67965776",
"0.6700545",
"0.6639459",
"0.66203904",
"0.6502433",
"0.647672",
"0.645605",
"0.64526445",
"0.64462304",
"0.64165473",
"0.627027",
"0.624905",
"0.623961",
"0.62221557",
"0.6202853",
"0.62005407",
"0.61851376",
"0.61728835",
"0.6150435",
"0.61454993"... | 0.6050741 | 30 |
Compute isosurface for current state. | def _computeIsosurface(self):
data = self.getData(copy=False)
if data is None:
if self.isAutoLevel():
self._level = float('nan')
else:
if self.isAutoLevel():
st = time.time()
try:
level = float(self.getAutoLevelFunction()(data))
except Exception:
module_ = self.getAutoLevelFunction().__module__
name = self.getAutoLevelFunction().__name__
_logger.error(
"Error while executing iso level function %s.%s",
module_,
name,
exc_info=True)
level = float('nan')
else:
_logger.info(
'Computed iso-level in %f s.', time.time() - st)
if level != self._level:
self._level = level
self._updated(Item3DChangedType.ISO_LEVEL)
if numpy.isfinite(self._level):
st = time.time()
vertices, normals, indices = MarchingCubes(
data,
isolevel=self._level)
_logger.info('Computed iso-surface in %f s.', time.time() - st)
if len(vertices) != 0:
return vertices, normals, indices
return None, None, None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isosurface(self):\n return self._isosurface()",
"def get_fsurface(self, path):\n raise NotImplementedError",
"def _isosurfaceItemChanged(self, event):\n if event == Item3DChangedType.ISO_LEVEL:\n self._updateIsosurfaces()",
"def isosurface(grd_name, isosurface_name, level,... | [
"0.7749475",
"0.64308286",
"0.6121801",
"0.6089994",
"0.5459395",
"0.5374221",
"0.49754205",
"0.49631813",
"0.494308",
"0.49310347",
"0.49100575",
"0.48892054",
"0.4882994",
"0.48674196",
"0.4839715",
"0.47886744",
"0.4778599",
"0.476231",
"0.47320402",
"0.47290966",
"0.47155... | 0.71063083 | 1 |
Perform picking in this item at given widget position. | def _pickFull(self, context):
rayObject = context.getPickingSegment(frame=self._getScenePrimitive())
if rayObject is None:
return None
rayObject = rayObject[:, :3]
data = self.getData(copy=False)
bins = utils.segmentVolumeIntersect(
rayObject, numpy.array(data.shape) - 1)
if bins is None:
return None
# gather bin data
offsets = [(i, j, k) for i in (0, 1) for j in (0, 1) for k in (0, 1)]
indices = bins[:, numpy.newaxis, :] + offsets
binsData = data[indices[:, :, 0], indices[:, :, 1], indices[:, :, 2]]
# binsData.shape = nbins, 8
# TODO up-to this point everything can be done once for all isosurfaces
# check bin candidates
level = self.getLevel()
mask = numpy.logical_and(numpy.nanmin(binsData, axis=1) <= level,
level <= numpy.nanmax(binsData, axis=1))
bins = bins[mask]
binsData = binsData[mask]
if len(bins) == 0:
return None # No bin candidate
# do picking on candidates
intersections = []
depths = []
for currentBin, data in zip(bins, binsData):
mc = MarchingCubes(data.reshape(2, 2, 2), isolevel=level)
points = mc.get_vertices() + currentBin
triangles = points[mc.get_indices()]
t = glu.segmentTrianglesIntersection(rayObject, triangles)[1]
t = numpy.unique(t) # Duplicates happen on triangle edges
if len(t) != 0:
# Compute intersection points and get closest data point
points = t.reshape(-1, 1) * (rayObject[1] - rayObject[0]) + rayObject[0]
# Get closest data points by rounding to int
intersections.extend(points)
depths.extend(t)
if len(intersections) == 0:
return None # No intersected triangles
intersections = numpy.array(intersections)[numpy.argsort(depths)]
indices = numpy.transpose(numpy.round(intersections).astype(numpy.int64))
return PickingResult(self, positions=intersections, indices=indices) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Point_Pick(self):\n self.vtkWidget.iren.AddObserver('RightButtonPressEvent', self.pick_loc)\n self.renWin.Render()",
"def pick_loc(self, event, x):\n #print(event, x)\n self.vtkWidget.iren.RemoveObservers('RightButtonPressEvent')\n loc = event.GetEventPosition()\n\n ... | [
"0.66232896",
"0.58813524",
"0.5879792",
"0.5860174",
"0.5787622",
"0.57383424",
"0.570975",
"0.56717336",
"0.564384",
"0.5572894",
"0.55690295",
"0.5561806",
"0.55518645",
"0.5547201",
"0.55388415",
"0.5531264",
"0.5512377",
"0.5507659",
"0.54962397",
"0.5493375",
"0.5490328... | 0.0 | -1 |
Compute range info (min, min positive, max) from data | def _computeRangeFromData(data):
if data is None:
return None
dataRange = min_max(data, min_positive=True, finite=True)
if dataRange.minimum is None: # Only non-finite data
return None
if dataRange is not None:
min_positive = dataRange.min_positive
if min_positive is None:
min_positive = float('nan')
return dataRange.minimum, min_positive, dataRange.maximum | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_range(cls, data: tuple or list) -> float:\n cls._data_validation(data)\n max_ = cls.get_max(data)\n min_ = cls.get_min(data)\n return float(max_ - min_)",
"def data_range(x):\n return max(x)-min(x)",
"def m_to_range(self, data):\n return (data - self._min_range_m) / se... | [
"0.74131215",
"0.7375797",
"0.7371305",
"0.73698366",
"0.7079913",
"0.69400847",
"0.6933809",
"0.68565273",
"0.6837749",
"0.6828716",
"0.68116766",
"0.677769",
"0.6730659",
"0.66858673",
"0.6631129",
"0.661481",
"0.66129404",
"0.6605451",
"0.65986764",
"0.65552515",
"0.654875... | 0.80179286 | 0 |
Set the 3D scalar data represented by this item. Dataset order is zyx (i.e., first dimension is z). | def setData(self, data, copy=True):
if data is None:
self._data = None
self._boundedGroup.shape = None
else:
data = numpy.array(data, copy=copy, dtype=numpy.float32, order='C')
assert data.ndim == 3
assert min(data.shape) >= 2
self._data = data
self._boundedGroup.shape = self._data.shape
self._dataRange = self._computeRangeFromData(self._data)
self._updated(ItemChangedType.DATA) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _setitem3d(self, index, value):\n ix = index[0]\n iy = index[1]\n iz = index[2]\n\n lovects = self._getlovects()\n hivects = self._gethivects()\n fields = self._getfields()\n\n if len(index) > self.dim:\n if ncomps > 1:\n ic = index[-1]... | [
"0.6446806",
"0.611566",
"0.59838897",
"0.5964819",
"0.59601384",
"0.59502226",
"0.58907306",
"0.58347994",
"0.58287907",
"0.5692124",
"0.5668796",
"0.5661337",
"0.5661213",
"0.5655243",
"0.56467724",
"0.5642596",
"0.56412905",
"0.56365776",
"0.5629091",
"0.5627743",
"0.56241... | 0.5278795 | 46 |
Return the range of the data as a 3tuple of values. positive min is NaN if no data is positive. | def getDataRange(self):
return self._dataRange | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _computeRangeFromData(data):\n if data is None:\n return None\n\n dataRange = min_max(data, min_positive=True, finite=True)\n if dataRange.minimum is None: # Only non-finite data\n return None\n\n if dataRange is not None:\n min_positive = dataRange... | [
"0.80794895",
"0.7623016",
"0.7399985",
"0.7339498",
"0.7240076",
"0.7169807",
"0.7086574",
"0.7079901",
"0.70793736",
"0.6944895",
"0.6782193",
"0.6766099",
"0.6677474",
"0.66592604",
"0.6654025",
"0.6621791",
"0.6613688",
"0.6587012",
"0.6554875",
"0.6525205",
"0.6514943",
... | 0.587778 | 75 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.