repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
dellis23/ansible-toolkit | ansible_toolkit/git_diff.py | get_new_filename | def get_new_filename(diff_part):
"""
Returns the filename for the updated file in a diff part.
"""
regexps = (
# e.g. "+++ b/foo/bar"
r'^\+\+\+ b/(.*)',
# e.g. "+++ /dev/null"
r'^\+\+\+ (.*)',
)
for regexp in regexps:
r = re.compile(regexp, re.MULTILINE)
... | python | def get_new_filename(diff_part):
"""
Returns the filename for the updated file in a diff part.
"""
regexps = (
# e.g. "+++ b/foo/bar"
r'^\+\+\+ b/(.*)',
# e.g. "+++ /dev/null"
r'^\+\+\+ (.*)',
)
for regexp in regexps:
r = re.compile(regexp, re.MULTILINE)
... | [
"def",
"get_new_filename",
"(",
"diff_part",
")",
":",
"regexps",
"=",
"(",
"# e.g. \"+++ b/foo/bar\"",
"r'^\\+\\+\\+ b/(.*)'",
",",
"# e.g. \"+++ /dev/null\"",
"r'^\\+\\+\\+ (.*)'",
",",
")",
"for",
"regexp",
"in",
"regexps",
":",
"r",
"=",
"re",
".",
"compile",
... | Returns the filename for the updated file in a diff part. | [
"Returns",
"the",
"filename",
"for",
"the",
"updated",
"file",
"in",
"a",
"diff",
"part",
"."
] | 7eb5198e1f68c9a3ca1d129d9e2a52fb3f0e65c5 | https://github.com/dellis23/ansible-toolkit/blob/7eb5198e1f68c9a3ca1d129d9e2a52fb3f0e65c5/ansible_toolkit/git_diff.py#L58-L74 | train | 64,300 |
dellis23/ansible-toolkit | ansible_toolkit/git_diff.py | get_contents | def get_contents(diff_part):
"""
Returns a tuple of old content and new content.
"""
old_sha = get_old_sha(diff_part)
old_filename = get_old_filename(diff_part)
old_contents = get_old_contents(old_sha, old_filename)
new_filename = get_new_filename(diff_part)
new_contents = get_new_conten... | python | def get_contents(diff_part):
"""
Returns a tuple of old content and new content.
"""
old_sha = get_old_sha(diff_part)
old_filename = get_old_filename(diff_part)
old_contents = get_old_contents(old_sha, old_filename)
new_filename = get_new_filename(diff_part)
new_contents = get_new_conten... | [
"def",
"get_contents",
"(",
"diff_part",
")",
":",
"old_sha",
"=",
"get_old_sha",
"(",
"diff_part",
")",
"old_filename",
"=",
"get_old_filename",
"(",
"diff_part",
")",
"old_contents",
"=",
"get_old_contents",
"(",
"old_sha",
",",
"old_filename",
")",
"new_filenam... | Returns a tuple of old content and new content. | [
"Returns",
"a",
"tuple",
"of",
"old",
"content",
"and",
"new",
"content",
"."
] | 7eb5198e1f68c9a3ca1d129d9e2a52fb3f0e65c5 | https://github.com/dellis23/ansible-toolkit/blob/7eb5198e1f68c9a3ca1d129d9e2a52fb3f0e65c5/ansible_toolkit/git_diff.py#L96-L105 | train | 64,301 |
timothydmorton/VESPA | vespa/populations.py | _loadcache | def _loadcache(cachefile):
""" Returns a dictionary resulting from reading a likelihood cachefile
"""
cache = {}
if os.path.exists(cachefile):
with open(cachefile) as f:
for line in f:
line = line.split()
if len(line) == 2:
try:
... | python | def _loadcache(cachefile):
""" Returns a dictionary resulting from reading a likelihood cachefile
"""
cache = {}
if os.path.exists(cachefile):
with open(cachefile) as f:
for line in f:
line = line.split()
if len(line) == 2:
try:
... | [
"def",
"_loadcache",
"(",
"cachefile",
")",
":",
"cache",
"=",
"{",
"}",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"cachefile",
")",
":",
"with",
"open",
"(",
"cachefile",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"line",
"=",
"line"... | Returns a dictionary resulting from reading a likelihood cachefile | [
"Returns",
"a",
"dictionary",
"resulting",
"from",
"reading",
"a",
"likelihood",
"cachefile"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2953-L2966 | train | 64,302 |
timothydmorton/VESPA | vespa/populations.py | EclipsePopulation.fit_trapezoids | def fit_trapezoids(self, MAfn=None, msg=None, use_pbar=True, **kwargs):
"""
Fit trapezoid shape to each eclipse in population
For each instance in the population, first the correct,
physical Mandel-Agol transit shape is simulated,
and then this curve is fit with a trapezoid mode... | python | def fit_trapezoids(self, MAfn=None, msg=None, use_pbar=True, **kwargs):
"""
Fit trapezoid shape to each eclipse in population
For each instance in the population, first the correct,
physical Mandel-Agol transit shape is simulated,
and then this curve is fit with a trapezoid mode... | [
"def",
"fit_trapezoids",
"(",
"self",
",",
"MAfn",
"=",
"None",
",",
"msg",
"=",
"None",
",",
"use_pbar",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"'Fitting trapezoid models for {}...'",
".",
"format",
"(",
"self",
"."... | Fit trapezoid shape to each eclipse in population
For each instance in the population, first the correct,
physical Mandel-Agol transit shape is simulated,
and then this curve is fit with a trapezoid model
:param MAfn:
:class:`transit_basic.MAInterpolationFunction` object.
... | [
"Fit",
"trapezoid",
"shape",
"to",
"each",
"eclipse",
"in",
"population"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L200-L274 | train | 64,303 |
timothydmorton/VESPA | vespa/populations.py | EclipsePopulation.eclipseprob | def eclipseprob(self):
"""
Array of eclipse probabilities.
"""
#TODO: incorporate eccentricity/omega for exact calculation?
s = self.stars
return ((s['radius_1'] + s['radius_2'])*RSUN /
(semimajor(s['P'],s['mass_1'] + s['mass_2'])*AU)) | python | def eclipseprob(self):
"""
Array of eclipse probabilities.
"""
#TODO: incorporate eccentricity/omega for exact calculation?
s = self.stars
return ((s['radius_1'] + s['radius_2'])*RSUN /
(semimajor(s['P'],s['mass_1'] + s['mass_2'])*AU)) | [
"def",
"eclipseprob",
"(",
"self",
")",
":",
"#TODO: incorporate eccentricity/omega for exact calculation?",
"s",
"=",
"self",
".",
"stars",
"return",
"(",
"(",
"s",
"[",
"'radius_1'",
"]",
"+",
"s",
"[",
"'radius_2'",
"]",
")",
"*",
"RSUN",
"/",
"(",
"semim... | Array of eclipse probabilities. | [
"Array",
"of",
"eclipse",
"probabilities",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L317-L324 | train | 64,304 |
timothydmorton/VESPA | vespa/populations.py | EclipsePopulation.modelshort | def modelshort(self):
"""
Short version of model name
Dictionary defined in ``populations.py``::
SHORT_MODELNAMES = {'Planets':'pl',
'EBs':'eb',
'HEBs':'heb',
'BEBs':'beb',
'Blended Planets':'bpl',
... | python | def modelshort(self):
"""
Short version of model name
Dictionary defined in ``populations.py``::
SHORT_MODELNAMES = {'Planets':'pl',
'EBs':'eb',
'HEBs':'heb',
'BEBs':'beb',
'Blended Planets':'bpl',
... | [
"def",
"modelshort",
"(",
"self",
")",
":",
"try",
":",
"name",
"=",
"SHORT_MODELNAMES",
"[",
"self",
".",
"model",
"]",
"#add index if specific model is indexed",
"if",
"hasattr",
"(",
"self",
",",
"'index'",
")",
":",
"name",
"+=",
"'-{}'",
".",
"format",
... | Short version of model name
Dictionary defined in ``populations.py``::
SHORT_MODELNAMES = {'Planets':'pl',
'EBs':'eb',
'HEBs':'heb',
'BEBs':'beb',
'Blended Planets':'bpl',
'Specific BEB':'sbeb',
... | [
"Short",
"version",
"of",
"model",
"name"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L333-L359 | train | 64,305 |
timothydmorton/VESPA | vespa/populations.py | EclipsePopulation.constrain_secdepth | def constrain_secdepth(self, thresh):
"""
Constrain the observed secondary depth to be less than a given value
:param thresh:
Maximum allowed fractional depth for diluted secondary
eclipse depth
"""
self.apply_constraint(UpperLimit(self.secondary_depth, ... | python | def constrain_secdepth(self, thresh):
"""
Constrain the observed secondary depth to be less than a given value
:param thresh:
Maximum allowed fractional depth for diluted secondary
eclipse depth
"""
self.apply_constraint(UpperLimit(self.secondary_depth, ... | [
"def",
"constrain_secdepth",
"(",
"self",
",",
"thresh",
")",
":",
"self",
".",
"apply_constraint",
"(",
"UpperLimit",
"(",
"self",
".",
"secondary_depth",
",",
"thresh",
",",
"name",
"=",
"'secondary depth'",
")",
")"
] | Constrain the observed secondary depth to be less than a given value
:param thresh:
Maximum allowed fractional depth for diluted secondary
eclipse depth | [
"Constrain",
"the",
"observed",
"secondary",
"depth",
"to",
"be",
"less",
"than",
"a",
"given",
"value"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L382-L391 | train | 64,306 |
timothydmorton/VESPA | vespa/populations.py | EclipsePopulation.prior | def prior(self):
"""
Model prior for particular model.
Product of eclipse probability (``self.prob``),
the fraction of scenario that is allowed by the various
constraints (``self.selectfrac``), and all additional
factors in ``self.priorfactors``.
"""
pri... | python | def prior(self):
"""
Model prior for particular model.
Product of eclipse probability (``self.prob``),
the fraction of scenario that is allowed by the various
constraints (``self.selectfrac``), and all additional
factors in ``self.priorfactors``.
"""
pri... | [
"def",
"prior",
"(",
"self",
")",
":",
"prior",
"=",
"self",
".",
"prob",
"*",
"self",
".",
"selectfrac",
"for",
"f",
"in",
"self",
".",
"priorfactors",
":",
"prior",
"*=",
"self",
".",
"priorfactors",
"[",
"f",
"]",
"return",
"prior"
] | Model prior for particular model.
Product of eclipse probability (``self.prob``),
the fraction of scenario that is allowed by the various
constraints (``self.selectfrac``), and all additional
factors in ``self.priorfactors``. | [
"Model",
"prior",
"for",
"particular",
"model",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L409-L422 | train | 64,307 |
timothydmorton/VESPA | vespa/populations.py | EclipsePopulation.add_priorfactor | def add_priorfactor(self,**kwargs):
"""Adds given values to priorfactors
If given keyword exists already, error will be raised
to use :func:`EclipsePopulation.change_prior` instead.
"""
for kw in kwargs:
if kw in self.priorfactors:
logging.error('%s a... | python | def add_priorfactor(self,**kwargs):
"""Adds given values to priorfactors
If given keyword exists already, error will be raised
to use :func:`EclipsePopulation.change_prior` instead.
"""
for kw in kwargs:
if kw in self.priorfactors:
logging.error('%s a... | [
"def",
"add_priorfactor",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"kw",
"in",
"kwargs",
":",
"if",
"kw",
"in",
"self",
".",
"priorfactors",
":",
"logging",
".",
"error",
"(",
"'%s already in prior factors for %s. use change_prior function instead.'... | Adds given values to priorfactors
If given keyword exists already, error will be raised
to use :func:`EclipsePopulation.change_prior` instead. | [
"Adds",
"given",
"values",
"to",
"priorfactors"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L424-L436 | train | 64,308 |
timothydmorton/VESPA | vespa/populations.py | EclipsePopulation.change_prior | def change_prior(self, **kwargs):
"""
Changes existing priorfactors.
If given keyword isn't already in priorfactors,
then will be ignored.
"""
for kw in kwargs:
if kw in self.priorfactors:
self.priorfactors[kw] = kwargs[kw]
log... | python | def change_prior(self, **kwargs):
"""
Changes existing priorfactors.
If given keyword isn't already in priorfactors,
then will be ignored.
"""
for kw in kwargs:
if kw in self.priorfactors:
self.priorfactors[kw] = kwargs[kw]
log... | [
"def",
"change_prior",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"kw",
"in",
"kwargs",
":",
"if",
"kw",
"in",
"self",
".",
"priorfactors",
":",
"self",
".",
"priorfactors",
"[",
"kw",
"]",
"=",
"kwargs",
"[",
"kw",
"]",
"logging",
".",... | Changes existing priorfactors.
If given keyword isn't already in priorfactors,
then will be ignored. | [
"Changes",
"existing",
"priorfactors",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L438-L449 | train | 64,309 |
timothydmorton/VESPA | vespa/populations.py | EclipsePopulation._density | def _density(self, logd, dur, slope):
"""
Evaluate KDE at given points.
Prepares data according to whether sklearn or scipy
KDE in use.
:param log, dur, slope:
Trapezoidal shape parameters.
"""
if self.sklearn_kde:
#TODO: fix preprocessin... | python | def _density(self, logd, dur, slope):
"""
Evaluate KDE at given points.
Prepares data according to whether sklearn or scipy
KDE in use.
:param log, dur, slope:
Trapezoidal shape parameters.
"""
if self.sklearn_kde:
#TODO: fix preprocessin... | [
"def",
"_density",
"(",
"self",
",",
"logd",
",",
"dur",
",",
"slope",
")",
":",
"if",
"self",
".",
"sklearn_kde",
":",
"#TODO: fix preprocessing",
"pts",
"=",
"np",
".",
"array",
"(",
"[",
"(",
"logd",
"-",
"self",
".",
"mean_logdepth",
")",
"/",
"s... | Evaluate KDE at given points.
Prepares data according to whether sklearn or scipy
KDE in use.
:param log, dur, slope:
Trapezoidal shape parameters. | [
"Evaluate",
"KDE",
"at",
"given",
"points",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L569-L586 | train | 64,310 |
timothydmorton/VESPA | vespa/populations.py | EclipsePopulation.lhood | def lhood(self, trsig, recalc=False, cachefile=None):
"""Returns likelihood of transit signal
Returns sum of ``trsig`` MCMC samples evaluated
at ``self.kde``.
:param trsig:
:class:`vespa.TransitSignal` object.
:param recalc: (optional)
Whether to recalc... | python | def lhood(self, trsig, recalc=False, cachefile=None):
"""Returns likelihood of transit signal
Returns sum of ``trsig`` MCMC samples evaluated
at ``self.kde``.
:param trsig:
:class:`vespa.TransitSignal` object.
:param recalc: (optional)
Whether to recalc... | [
"def",
"lhood",
"(",
"self",
",",
"trsig",
",",
"recalc",
"=",
"False",
",",
"cachefile",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'kde'",
")",
":",
"self",
".",
"_make_kde",
"(",
")",
"if",
"cachefile",
"is",
"None",
":",
... | Returns likelihood of transit signal
Returns sum of ``trsig`` MCMC samples evaluated
at ``self.kde``.
:param trsig:
:class:`vespa.TransitSignal` object.
:param recalc: (optional)
Whether to recalculate likelihood (if calculation
is cached).
... | [
"Returns",
"likelihood",
"of",
"transit",
"signal"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L588-L627 | train | 64,311 |
timothydmorton/VESPA | vespa/populations.py | EclipsePopulation.load_hdf | def load_hdf(cls, filename, path=''): #perhaps this doesn't need to be written?
"""
Loads EclipsePopulation from HDF file
Also runs :func:`EclipsePopulation._make_kde` if it can.
:param filename:
HDF file
:param path: (optional)
Path within HDF file
... | python | def load_hdf(cls, filename, path=''): #perhaps this doesn't need to be written?
"""
Loads EclipsePopulation from HDF file
Also runs :func:`EclipsePopulation._make_kde` if it can.
:param filename:
HDF file
:param path: (optional)
Path within HDF file
... | [
"def",
"load_hdf",
"(",
"cls",
",",
"filename",
",",
"path",
"=",
"''",
")",
":",
"#perhaps this doesn't need to be written?",
"new",
"=",
"StarPopulation",
".",
"load_hdf",
"(",
"filename",
",",
"path",
"=",
"path",
")",
"#setup lazy loading of starmodel if present... | Loads EclipsePopulation from HDF file
Also runs :func:`EclipsePopulation._make_kde` if it can.
:param filename:
HDF file
:param path: (optional)
Path within HDF file | [
"Loads",
"EclipsePopulation",
"from",
"HDF",
"file"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L928-L958 | train | 64,312 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.constraints | def constraints(self):
"""
Unique list of constraints among all populations in set.
"""
cs = []
for pop in self.poplist:
cs += [c for c in pop.constraints]
return list(set(cs)) | python | def constraints(self):
"""
Unique list of constraints among all populations in set.
"""
cs = []
for pop in self.poplist:
cs += [c for c in pop.constraints]
return list(set(cs)) | [
"def",
"constraints",
"(",
"self",
")",
":",
"cs",
"=",
"[",
"]",
"for",
"pop",
"in",
"self",
".",
"poplist",
":",
"cs",
"+=",
"[",
"c",
"for",
"c",
"in",
"pop",
".",
"constraints",
"]",
"return",
"list",
"(",
"set",
"(",
"cs",
")",
")"
] | Unique list of constraints among all populations in set. | [
"Unique",
"list",
"of",
"constraints",
"among",
"all",
"populations",
"in",
"set",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2206-L2213 | train | 64,313 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.save_hdf | def save_hdf(self, filename, path='', overwrite=False):
"""
Saves PopulationSet to HDF file.
"""
if os.path.exists(filename) and overwrite:
os.remove(filename)
for pop in self.poplist:
name = pop.modelshort
pop.save_hdf(filename, path='{}/{}'.... | python | def save_hdf(self, filename, path='', overwrite=False):
"""
Saves PopulationSet to HDF file.
"""
if os.path.exists(filename) and overwrite:
os.remove(filename)
for pop in self.poplist:
name = pop.modelshort
pop.save_hdf(filename, path='{}/{}'.... | [
"def",
"save_hdf",
"(",
"self",
",",
"filename",
",",
"path",
"=",
"''",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
"and",
"overwrite",
":",
"os",
".",
"remove",
"(",
"filename",
")",
"fo... | Saves PopulationSet to HDF file. | [
"Saves",
"PopulationSet",
"to",
"HDF",
"file",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2229-L2238 | train | 64,314 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.load_hdf | def load_hdf(cls, filename, path=''):
"""
Loads PopulationSet from file
"""
with pd.HDFStore(filename) as store:
models = []
types = []
for k in store.keys():
m = re.search('/(\S+)/stars', k)
if m:
mo... | python | def load_hdf(cls, filename, path=''):
"""
Loads PopulationSet from file
"""
with pd.HDFStore(filename) as store:
models = []
types = []
for k in store.keys():
m = re.search('/(\S+)/stars', k)
if m:
mo... | [
"def",
"load_hdf",
"(",
"cls",
",",
"filename",
",",
"path",
"=",
"''",
")",
":",
"with",
"pd",
".",
"HDFStore",
"(",
"filename",
")",
"as",
"store",
":",
"models",
"=",
"[",
"]",
"types",
"=",
"[",
"]",
"for",
"k",
"in",
"store",
".",
"keys",
... | Loads PopulationSet from file | [
"Loads",
"PopulationSet",
"from",
"file"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2241-L2257 | train | 64,315 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.add_population | def add_population(self,pop):
"""Adds population to PopulationSet
"""
if pop.model in self.modelnames:
raise ValueError('%s model already in PopulationSet.' % pop.model)
self.modelnames.append(pop.model)
self.shortmodelnames.append(pop.modelshort)
self.poplist... | python | def add_population(self,pop):
"""Adds population to PopulationSet
"""
if pop.model in self.modelnames:
raise ValueError('%s model already in PopulationSet.' % pop.model)
self.modelnames.append(pop.model)
self.shortmodelnames.append(pop.modelshort)
self.poplist... | [
"def",
"add_population",
"(",
"self",
",",
"pop",
")",
":",
"if",
"pop",
".",
"model",
"in",
"self",
".",
"modelnames",
":",
"raise",
"ValueError",
"(",
"'%s model already in PopulationSet.'",
"%",
"pop",
".",
"model",
")",
"self",
".",
"modelnames",
".",
... | Adds population to PopulationSet | [
"Adds",
"population",
"to",
"PopulationSet"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2261-L2268 | train | 64,316 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.remove_population | def remove_population(self,pop):
"""Removes population from PopulationSet
"""
iremove=None
for i in range(len(self.poplist)):
if self.modelnames[i]==self.poplist[i].model:
iremove=i
if iremove is not None:
self.modelnames.pop(i)
... | python | def remove_population(self,pop):
"""Removes population from PopulationSet
"""
iremove=None
for i in range(len(self.poplist)):
if self.modelnames[i]==self.poplist[i].model:
iremove=i
if iremove is not None:
self.modelnames.pop(i)
... | [
"def",
"remove_population",
"(",
"self",
",",
"pop",
")",
":",
"iremove",
"=",
"None",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"poplist",
")",
")",
":",
"if",
"self",
".",
"modelnames",
"[",
"i",
"]",
"==",
"self",
".",
"poplist",
... | Removes population from PopulationSet | [
"Removes",
"population",
"from",
"PopulationSet"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2271-L2281 | train | 64,317 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.colordict | def colordict(self):
"""
Dictionary holding colors that correspond to constraints.
"""
d = {}
i=0
n = len(self.constraints)
for c in self.constraints:
#self.colordict[c] = colors[i % 6]
d[c] = cm.jet(1.*i/n)
i+=1
return ... | python | def colordict(self):
"""
Dictionary holding colors that correspond to constraints.
"""
d = {}
i=0
n = len(self.constraints)
for c in self.constraints:
#self.colordict[c] = colors[i % 6]
d[c] = cm.jet(1.*i/n)
i+=1
return ... | [
"def",
"colordict",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"i",
"=",
"0",
"n",
"=",
"len",
"(",
"self",
".",
"constraints",
")",
"for",
"c",
"in",
"self",
".",
"constraints",
":",
"#self.colordict[c] = colors[i % 6]",
"d",
"[",
"c",
"]",
"=",
"... | Dictionary holding colors that correspond to constraints. | [
"Dictionary",
"holding",
"colors",
"that",
"correspond",
"to",
"constraints",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2317-L2328 | train | 64,318 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.priorfactors | def priorfactors(self):
"""Combinartion of priorfactors from all populations
"""
priorfactors = {}
for pop in self.poplist:
for f in pop.priorfactors:
if f in priorfactors:
if pop.priorfactors[f] != priorfactors[f]:
... | python | def priorfactors(self):
"""Combinartion of priorfactors from all populations
"""
priorfactors = {}
for pop in self.poplist:
for f in pop.priorfactors:
if f in priorfactors:
if pop.priorfactors[f] != priorfactors[f]:
... | [
"def",
"priorfactors",
"(",
"self",
")",
":",
"priorfactors",
"=",
"{",
"}",
"for",
"pop",
"in",
"self",
".",
"poplist",
":",
"for",
"f",
"in",
"pop",
".",
"priorfactors",
":",
"if",
"f",
"in",
"priorfactors",
":",
"if",
"pop",
".",
"priorfactors",
"... | Combinartion of priorfactors from all populations | [
"Combinartion",
"of",
"priorfactors",
"from",
"all",
"populations"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2331-L2342 | train | 64,319 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.apply_multicolor_transit | def apply_multicolor_transit(self,band,depth):
"""
Applies constraint corresponding to measuring transit in different band
This is not implemented yet.
"""
if '{} band transit'.format(band) not in self.constraints:
self.constraints.append('{} band transit'.format(ban... | python | def apply_multicolor_transit(self,band,depth):
"""
Applies constraint corresponding to measuring transit in different band
This is not implemented yet.
"""
if '{} band transit'.format(band) not in self.constraints:
self.constraints.append('{} band transit'.format(ban... | [
"def",
"apply_multicolor_transit",
"(",
"self",
",",
"band",
",",
"depth",
")",
":",
"if",
"'{} band transit'",
".",
"format",
"(",
"band",
")",
"not",
"in",
"self",
".",
"constraints",
":",
"self",
".",
"constraints",
".",
"append",
"(",
"'{} band transit'"... | Applies constraint corresponding to measuring transit in different band
This is not implemented yet. | [
"Applies",
"constraint",
"corresponding",
"to",
"measuring",
"transit",
"in",
"different",
"band"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2356-L2365 | train | 64,320 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.set_maxrad | def set_maxrad(self,newrad):
"""
Sets max allowed radius in populations.
Doesn't operate via the :class:`stars.Constraint`
protocol; rather just rescales the sky positions
for the background objects and recalculates
sky area, etc.
"""
if not isinstance(n... | python | def set_maxrad(self,newrad):
"""
Sets max allowed radius in populations.
Doesn't operate via the :class:`stars.Constraint`
protocol; rather just rescales the sky positions
for the background objects and recalculates
sky area, etc.
"""
if not isinstance(n... | [
"def",
"set_maxrad",
"(",
"self",
",",
"newrad",
")",
":",
"if",
"not",
"isinstance",
"(",
"newrad",
",",
"Quantity",
")",
":",
"newrad",
"=",
"newrad",
"*",
"u",
".",
"arcsec",
"#if 'Rsky' not in self.constraints:",
"# self.constraints.append('Rsky')",
"for",
... | Sets max allowed radius in populations.
Doesn't operate via the :class:`stars.Constraint`
protocol; rather just rescales the sky positions
for the background objects and recalculates
sky area, etc. | [
"Sets",
"max",
"allowed",
"radius",
"in",
"populations",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2367-L2386 | train | 64,321 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.apply_dmaglim | def apply_dmaglim(self,dmaglim=None):
"""
Applies a constraint that sets the maximum brightness for non-target star
:func:`stars.StarPopulation.set_dmaglim` not yet implemented.
"""
raise NotImplementedError
if 'bright blend limit' not in self.constraints:
s... | python | def apply_dmaglim(self,dmaglim=None):
"""
Applies a constraint that sets the maximum brightness for non-target star
:func:`stars.StarPopulation.set_dmaglim` not yet implemented.
"""
raise NotImplementedError
if 'bright blend limit' not in self.constraints:
s... | [
"def",
"apply_dmaglim",
"(",
"self",
",",
"dmaglim",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"if",
"'bright blend limit'",
"not",
"in",
"self",
".",
"constraints",
":",
"self",
".",
"constraints",
".",
"append",
"(",
"'bright blend limit'",
")",
... | Applies a constraint that sets the maximum brightness for non-target star
:func:`stars.StarPopulation.set_dmaglim` not yet implemented. | [
"Applies",
"a",
"constraint",
"that",
"sets",
"the",
"maximum",
"brightness",
"for",
"non",
"-",
"target",
"star"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2388-L2406 | train | 64,322 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.apply_trend_constraint | def apply_trend_constraint(self, limit, dt, **kwargs):
"""
Applies constraint corresponding to RV trend non-detection to each population
See :func:`stars.StarPopulation.apply_trend_constraint`;
all arguments passed to that function for each population.
"""
if 'RV monito... | python | def apply_trend_constraint(self, limit, dt, **kwargs):
"""
Applies constraint corresponding to RV trend non-detection to each population
See :func:`stars.StarPopulation.apply_trend_constraint`;
all arguments passed to that function for each population.
"""
if 'RV monito... | [
"def",
"apply_trend_constraint",
"(",
"self",
",",
"limit",
",",
"dt",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'RV monitoring'",
"not",
"in",
"self",
".",
"constraints",
":",
"self",
".",
"constraints",
".",
"append",
"(",
"'RV monitoring'",
")",
"for",
... | Applies constraint corresponding to RV trend non-detection to each population
See :func:`stars.StarPopulation.apply_trend_constraint`;
all arguments passed to that function for each population. | [
"Applies",
"constraint",
"corresponding",
"to",
"RV",
"trend",
"non",
"-",
"detection",
"to",
"each",
"population"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2408-L2423 | train | 64,323 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.apply_secthresh | def apply_secthresh(self, secthresh, **kwargs):
"""Applies secondary depth constraint to each population
See :func:`EclipsePopulation.apply_secthresh`;
all arguments passed to that function for each population.
"""
if 'secondary depth' not in self.constraints:
self... | python | def apply_secthresh(self, secthresh, **kwargs):
"""Applies secondary depth constraint to each population
See :func:`EclipsePopulation.apply_secthresh`;
all arguments passed to that function for each population.
"""
if 'secondary depth' not in self.constraints:
self... | [
"def",
"apply_secthresh",
"(",
"self",
",",
"secthresh",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'secondary depth'",
"not",
"in",
"self",
".",
"constraints",
":",
"self",
".",
"constraints",
".",
"append",
"(",
"'secondary depth'",
")",
"for",
"pop",
"in... | Applies secondary depth constraint to each population
See :func:`EclipsePopulation.apply_secthresh`;
all arguments passed to that function for each population. | [
"Applies",
"secondary",
"depth",
"constraint",
"to",
"each",
"population"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2425-L2438 | train | 64,324 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.constrain_property | def constrain_property(self,prop,**kwargs):
"""
Constrains property for each population
See :func:`vespa.stars.StarPopulation.constrain_property`;
all arguments passed to that function for each population.
"""
if prop not in self.constraints:
self.constraint... | python | def constrain_property(self,prop,**kwargs):
"""
Constrains property for each population
See :func:`vespa.stars.StarPopulation.constrain_property`;
all arguments passed to that function for each population.
"""
if prop not in self.constraints:
self.constraint... | [
"def",
"constrain_property",
"(",
"self",
",",
"prop",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"prop",
"not",
"in",
"self",
".",
"constraints",
":",
"self",
".",
"constraints",
".",
"append",
"(",
"prop",
")",
"for",
"pop",
"in",
"self",
".",
"popli... | Constrains property for each population
See :func:`vespa.stars.StarPopulation.constrain_property`;
all arguments passed to that function for each population. | [
"Constrains",
"property",
"for",
"each",
"population"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2452-L2466 | train | 64,325 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.replace_constraint | def replace_constraint(self,name,**kwargs):
"""
Replaces removed constraint in each population.
See :func:`vespa.stars.StarPopulation.replace_constraint`
"""
for pop in self.poplist:
pop.replace_constraint(name,**kwargs)
if name not in self.constraints:
... | python | def replace_constraint(self,name,**kwargs):
"""
Replaces removed constraint in each population.
See :func:`vespa.stars.StarPopulation.replace_constraint`
"""
for pop in self.poplist:
pop.replace_constraint(name,**kwargs)
if name not in self.constraints:
... | [
"def",
"replace_constraint",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"pop",
"in",
"self",
".",
"poplist",
":",
"pop",
".",
"replace_constraint",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"if",
"name",
"not",
"in",
"self",... | Replaces removed constraint in each population.
See :func:`vespa.stars.StarPopulation.replace_constraint` | [
"Replaces",
"removed",
"constraint",
"in",
"each",
"population",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2468-L2479 | train | 64,326 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.remove_constraint | def remove_constraint(self,*names):
"""
Removes constraint from each population
See :func:`vespa.stars.StarPopulation.remove_constraint
"""
for name in names:
for pop in self.poplist:
if name in pop.constraints:
pop.remove_constra... | python | def remove_constraint(self,*names):
"""
Removes constraint from each population
See :func:`vespa.stars.StarPopulation.remove_constraint
"""
for name in names:
for pop in self.poplist:
if name in pop.constraints:
pop.remove_constra... | [
"def",
"remove_constraint",
"(",
"self",
",",
"*",
"names",
")",
":",
"for",
"name",
"in",
"names",
":",
"for",
"pop",
"in",
"self",
".",
"poplist",
":",
"if",
"name",
"in",
"pop",
".",
"constraints",
":",
"pop",
".",
"remove_constraint",
"(",
"name",
... | Removes constraint from each population
See :func:`vespa.stars.StarPopulation.remove_constraint | [
"Removes",
"constraint",
"from",
"each",
"population"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2481-L2495 | train | 64,327 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.apply_cc | def apply_cc(self, cc, **kwargs):
"""
Applies contrast curve constraint to each population
See :func:`vespa.stars.StarPopulation.apply_cc`;
all arguments passed to that function for each population.
"""
if type(cc)==type(''):
pass
if cc.name not in s... | python | def apply_cc(self, cc, **kwargs):
"""
Applies contrast curve constraint to each population
See :func:`vespa.stars.StarPopulation.apply_cc`;
all arguments passed to that function for each population.
"""
if type(cc)==type(''):
pass
if cc.name not in s... | [
"def",
"apply_cc",
"(",
"self",
",",
"cc",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"type",
"(",
"cc",
")",
"==",
"type",
"(",
"''",
")",
":",
"pass",
"if",
"cc",
".",
"name",
"not",
"in",
"self",
".",
"constraints",
":",
"self",
".",
"constrai... | Applies contrast curve constraint to each population
See :func:`vespa.stars.StarPopulation.apply_cc`;
all arguments passed to that function for each population. | [
"Applies",
"contrast",
"curve",
"constraint",
"to",
"each",
"population"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2497-L2514 | train | 64,328 |
timothydmorton/VESPA | vespa/populations.py | PopulationSet.apply_vcc | def apply_vcc(self,vcc):
"""
Applies velocity contrast curve constraint to each population
See :func:`vespa.stars.StarPopulation.apply_vcc`;
all arguments passed to that function for each population.
"""
if 'secondary spectrum' not in self.constraints:
self.... | python | def apply_vcc(self,vcc):
"""
Applies velocity contrast curve constraint to each population
See :func:`vespa.stars.StarPopulation.apply_vcc`;
all arguments passed to that function for each population.
"""
if 'secondary spectrum' not in self.constraints:
self.... | [
"def",
"apply_vcc",
"(",
"self",
",",
"vcc",
")",
":",
"if",
"'secondary spectrum'",
"not",
"in",
"self",
".",
"constraints",
":",
"self",
".",
"constraints",
".",
"append",
"(",
"'secondary spectrum'",
")",
"for",
"pop",
"in",
"self",
".",
"poplist",
":",... | Applies velocity contrast curve constraint to each population
See :func:`vespa.stars.StarPopulation.apply_vcc`;
all arguments passed to that function for each population. | [
"Applies",
"velocity",
"contrast",
"curve",
"constraint",
"to",
"each",
"population"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2516-L2531 | train | 64,329 |
timothydmorton/VESPA | vespa/stars/trilegal.py | get_trilegal | def get_trilegal(filename,ra,dec,folder='.', galactic=False,
filterset='kepler_2mass',area=1,maglim=27,binaries=False,
trilegal_version='1.6',sigma_AV=0.1,convert_h5=True):
"""Runs get_trilegal perl script; optionally saves output into .h5 file
Depends on a perl script provide... | python | def get_trilegal(filename,ra,dec,folder='.', galactic=False,
filterset='kepler_2mass',area=1,maglim=27,binaries=False,
trilegal_version='1.6',sigma_AV=0.1,convert_h5=True):
"""Runs get_trilegal perl script; optionally saves output into .h5 file
Depends on a perl script provide... | [
"def",
"get_trilegal",
"(",
"filename",
",",
"ra",
",",
"dec",
",",
"folder",
"=",
"'.'",
",",
"galactic",
"=",
"False",
",",
"filterset",
"=",
"'kepler_2mass'",
",",
"area",
"=",
"1",
",",
"maglim",
"=",
"27",
",",
"binaries",
"=",
"False",
",",
"tr... | Runs get_trilegal perl script; optionally saves output into .h5 file
Depends on a perl script provided by L. Girardi; calls the
web form simulation, downloads the file, and (optionally) converts
to HDF format.
Uses A_V at infinity from :func:`utils.get_AV_infinity`.
.. note::
Would be de... | [
"Runs",
"get_trilegal",
"perl",
"script",
";",
"optionally",
"saves",
"output",
"into",
".",
"h5",
"file"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/stars/trilegal.py#L23-L118 | train | 64,330 |
dmsimard/python-cephclient | cephclient/client.py | CephClient.log_wrapper | def log_wrapper(self):
"""
Wrapper to set logging parameters for output
"""
log = logging.getLogger('client.py')
# Set the log format and log level
try:
debug = self.params["debug"]
log.setLevel(logging.DEBUG)
except KeyError:
... | python | def log_wrapper(self):
"""
Wrapper to set logging parameters for output
"""
log = logging.getLogger('client.py')
# Set the log format and log level
try:
debug = self.params["debug"]
log.setLevel(logging.DEBUG)
except KeyError:
... | [
"def",
"log_wrapper",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'client.py'",
")",
"# Set the log format and log level",
"try",
":",
"debug",
"=",
"self",
".",
"params",
"[",
"\"debug\"",
"]",
"log",
".",
"setLevel",
"(",
"logging... | Wrapper to set logging parameters for output | [
"Wrapper",
"to",
"set",
"logging",
"parameters",
"for",
"output"
] | 44aea09d8c512b3bbd3bc12dfd185205ac8b551b | https://github.com/dmsimard/python-cephclient/blob/44aea09d8c512b3bbd3bc12dfd185205ac8b551b/cephclient/client.py#L135-L156 | train | 64,331 |
ternaris/marv | marv_node/setid.py | decode_setid | def decode_setid(encoded):
"""Decode setid as uint128"""
try:
lo, hi = struct.unpack('<QQ', b32decode(encoded.upper() + '======'))
except struct.error:
raise ValueError('Cannot decode {!r}'.format(encoded))
return (hi << 64) + lo | python | def decode_setid(encoded):
"""Decode setid as uint128"""
try:
lo, hi = struct.unpack('<QQ', b32decode(encoded.upper() + '======'))
except struct.error:
raise ValueError('Cannot decode {!r}'.format(encoded))
return (hi << 64) + lo | [
"def",
"decode_setid",
"(",
"encoded",
")",
":",
"try",
":",
"lo",
",",
"hi",
"=",
"struct",
".",
"unpack",
"(",
"'<QQ'",
",",
"b32decode",
"(",
"encoded",
".",
"upper",
"(",
")",
"+",
"'======'",
")",
")",
"except",
"struct",
".",
"error",
":",
"r... | Decode setid as uint128 | [
"Decode",
"setid",
"as",
"uint128"
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv_node/setid.py#L28-L34 | train | 64,332 |
ternaris/marv | marv_node/setid.py | encode_setid | def encode_setid(uint128):
"""Encode uint128 setid as stripped b32encoded string"""
hi, lo = divmod(uint128, 2**64)
return b32encode(struct.pack('<QQ', lo, hi))[:-6].lower() | python | def encode_setid(uint128):
"""Encode uint128 setid as stripped b32encoded string"""
hi, lo = divmod(uint128, 2**64)
return b32encode(struct.pack('<QQ', lo, hi))[:-6].lower() | [
"def",
"encode_setid",
"(",
"uint128",
")",
":",
"hi",
",",
"lo",
"=",
"divmod",
"(",
"uint128",
",",
"2",
"**",
"64",
")",
"return",
"b32encode",
"(",
"struct",
".",
"pack",
"(",
"'<QQ'",
",",
"lo",
",",
"hi",
")",
")",
"[",
":",
"-",
"6",
"]"... | Encode uint128 setid as stripped b32encoded string | [
"Encode",
"uint128",
"setid",
"as",
"stripped",
"b32encoded",
"string"
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv_node/setid.py#L37-L40 | train | 64,333 |
originell/sorl-watermark | sorl_watermarker/engines/pgmagick_engine.py | Engine._reduce_opacity | def _reduce_opacity(self, watermark, opacity):
"""
Returns an image with reduced opacity. Converts image to RGBA if needs.
Simple watermark.opacity(65535 - int(65535 * opacity) would not work for
images with the Opacity channel (RGBA images). So we have to convert RGB or any
oth... | python | def _reduce_opacity(self, watermark, opacity):
"""
Returns an image with reduced opacity. Converts image to RGBA if needs.
Simple watermark.opacity(65535 - int(65535 * opacity) would not work for
images with the Opacity channel (RGBA images). So we have to convert RGB or any
oth... | [
"def",
"_reduce_opacity",
"(",
"self",
",",
"watermark",
",",
"opacity",
")",
":",
"if",
"watermark",
".",
"type",
"(",
")",
"!=",
"ImageType",
".",
"TrueColorMatteType",
":",
"watermark",
".",
"type",
"(",
"ImageType",
".",
"TrueColorMatteType",
")",
"depth... | Returns an image with reduced opacity. Converts image to RGBA if needs.
Simple watermark.opacity(65535 - int(65535 * opacity) would not work for
images with the Opacity channel (RGBA images). So we have to convert RGB or any
other type to RGBA in this case | [
"Returns",
"an",
"image",
"with",
"reduced",
"opacity",
".",
"Converts",
"image",
"to",
"RGBA",
"if",
"needs",
"."
] | d9ce72a05477158520d70d70a99203b36fb66a30 | https://github.com/originell/sorl-watermark/blob/d9ce72a05477158520d70d70a99203b36fb66a30/sorl_watermarker/engines/pgmagick_engine.py#L48-L60 | train | 64,334 |
ternaris/marv | marv/site.py | Site.cleanup_relations | def cleanup_relations(self):
"""Cleanup listing relations"""
collections = self.collections
for relation in [x for col in collections.values()
for x in col.model.relations.values()]:
db.session.query(relation)\
.filter(~relation.listing... | python | def cleanup_relations(self):
"""Cleanup listing relations"""
collections = self.collections
for relation in [x for col in collections.values()
for x in col.model.relations.values()]:
db.session.query(relation)\
.filter(~relation.listing... | [
"def",
"cleanup_relations",
"(",
"self",
")",
":",
"collections",
"=",
"self",
".",
"collections",
"for",
"relation",
"in",
"[",
"x",
"for",
"col",
"in",
"collections",
".",
"values",
"(",
")",
"for",
"x",
"in",
"col",
".",
"model",
".",
"relations",
"... | Cleanup listing relations | [
"Cleanup",
"listing",
"relations"
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/site.py#L261-L269 | train | 64,335 |
ternaris/marv | marv/cli.py | marvcli_cleanup | def marvcli_cleanup(ctx, discarded, unused_tags):
"""Cleanup unused tags and discarded datasets."""
if not any([discarded, unused_tags]):
click.echo(ctx.get_help())
ctx.exit(1)
site = create_app().site
if discarded:
site.cleanup_discarded()
if unused_tags:
site.cle... | python | def marvcli_cleanup(ctx, discarded, unused_tags):
"""Cleanup unused tags and discarded datasets."""
if not any([discarded, unused_tags]):
click.echo(ctx.get_help())
ctx.exit(1)
site = create_app().site
if discarded:
site.cleanup_discarded()
if unused_tags:
site.cle... | [
"def",
"marvcli_cleanup",
"(",
"ctx",
",",
"discarded",
",",
"unused_tags",
")",
":",
"if",
"not",
"any",
"(",
"[",
"discarded",
",",
"unused_tags",
"]",
")",
":",
"click",
".",
"echo",
"(",
"ctx",
".",
"get_help",
"(",
")",
")",
"ctx",
".",
"exit",
... | Cleanup unused tags and discarded datasets. | [
"Cleanup",
"unused",
"tags",
"and",
"discarded",
"datasets",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L108-L121 | train | 64,336 |
ternaris/marv | marv/cli.py | marvcli_develop_server | def marvcli_develop_server(port, public):
"""Run development webserver.
ATTENTION: By default it is only served on localhost. To run it
within a container and access it from the outside, you need to
forward the port and tell it to listen on all IPs instead of only
localhost.
"""
from flask_... | python | def marvcli_develop_server(port, public):
"""Run development webserver.
ATTENTION: By default it is only served on localhost. To run it
within a container and access it from the outside, you need to
forward the port and tell it to listen on all IPs instead of only
localhost.
"""
from flask_... | [
"def",
"marvcli_develop_server",
"(",
"port",
",",
"public",
")",
":",
"from",
"flask_cors",
"import",
"CORS",
"app",
"=",
"create_app",
"(",
"push",
"=",
"False",
")",
"app",
".",
"site",
".",
"load_for_web",
"(",
")",
"CORS",
"(",
"app",
")",
"class",
... | Run development webserver.
ATTENTION: By default it is only served on localhost. To run it
within a container and access it from the outside, you need to
forward the port and tell it to listen on all IPs instead of only
localhost. | [
"Run",
"development",
"webserver",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L135-L171 | train | 64,337 |
ternaris/marv | marv/cli.py | marvcli_discard | def marvcli_discard(datasets, all_nodes, nodes, tags, comments, confirm):
"""Mark DATASETS to be discarded or discard associated data.
Without any options the specified datasets are marked to be
discarded via `marv cleanup --discarded`. Use `marv undiscard` to
undo this operation.
Otherwise, selec... | python | def marvcli_discard(datasets, all_nodes, nodes, tags, comments, confirm):
"""Mark DATASETS to be discarded or discard associated data.
Without any options the specified datasets are marked to be
discarded via `marv cleanup --discarded`. Use `marv undiscard` to
undo this operation.
Otherwise, selec... | [
"def",
"marvcli_discard",
"(",
"datasets",
",",
"all_nodes",
",",
"nodes",
",",
"tags",
",",
"comments",
",",
"confirm",
")",
":",
"mark_discarded",
"=",
"not",
"any",
"(",
"[",
"all_nodes",
",",
"nodes",
",",
"tags",
",",
"comments",
"]",
")",
"site",
... | Mark DATASETS to be discarded or discard associated data.
Without any options the specified datasets are marked to be
discarded via `marv cleanup --discarded`. Use `marv undiscard` to
undo this operation.
Otherwise, selected data associated with the specified datasets is
discarded right away. | [
"Mark",
"DATASETS",
"to",
"be",
"discarded",
"or",
"discard",
"associated",
"data",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L182-L229 | train | 64,338 |
ternaris/marv | marv/cli.py | marvcli_undiscard | def marvcli_undiscard(datasets):
"""Undiscard DATASETS previously discarded."""
create_app()
setids = parse_setids(datasets, discarded=True)
dataset = Dataset.__table__
stmt = dataset.update()\
.where(dataset.c.setid.in_(setids))\
.values(discarded=False)
db.... | python | def marvcli_undiscard(datasets):
"""Undiscard DATASETS previously discarded."""
create_app()
setids = parse_setids(datasets, discarded=True)
dataset = Dataset.__table__
stmt = dataset.update()\
.where(dataset.c.setid.in_(setids))\
.values(discarded=False)
db.... | [
"def",
"marvcli_undiscard",
"(",
"datasets",
")",
":",
"create_app",
"(",
")",
"setids",
"=",
"parse_setids",
"(",
"datasets",
",",
"discarded",
"=",
"True",
")",
"dataset",
"=",
"Dataset",
".",
"__table__",
"stmt",
"=",
"dataset",
".",
"update",
"(",
")",... | Undiscard DATASETS previously discarded. | [
"Undiscard",
"DATASETS",
"previously",
"discarded",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L234-L244 | train | 64,339 |
ternaris/marv | marv/cli.py | marvcli_restore | def marvcli_restore(file):
"""Restore previously dumped database"""
data = json.load(file)
site = create_app().site
site.restore_database(**data) | python | def marvcli_restore(file):
"""Restore previously dumped database"""
data = json.load(file)
site = create_app().site
site.restore_database(**data) | [
"def",
"marvcli_restore",
"(",
"file",
")",
":",
"data",
"=",
"json",
".",
"load",
"(",
"file",
")",
"site",
"=",
"create_app",
"(",
")",
".",
"site",
"site",
".",
"restore_database",
"(",
"*",
"*",
"data",
")"
] | Restore previously dumped database | [
"Restore",
"previously",
"dumped",
"database"
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L249-L253 | train | 64,340 |
ternaris/marv | marv/cli.py | marvcli_query | def marvcli_query(ctx, list_tags, collections, discarded, outdated, path, tags, null):
"""Query datasets.
Use --collection=* to list all datasets across all collections.
"""
if not any([collections, discarded, list_tags, outdated, path, tags]):
click.echo(ctx.get_help())
ctx.exit(1)
... | python | def marvcli_query(ctx, list_tags, collections, discarded, outdated, path, tags, null):
"""Query datasets.
Use --collection=* to list all datasets across all collections.
"""
if not any([collections, discarded, list_tags, outdated, path, tags]):
click.echo(ctx.get_help())
ctx.exit(1)
... | [
"def",
"marvcli_query",
"(",
"ctx",
",",
"list_tags",
",",
"collections",
",",
"discarded",
",",
"outdated",
",",
"path",
",",
"tags",
",",
"null",
")",
":",
"if",
"not",
"any",
"(",
"[",
"collections",
",",
"discarded",
",",
"list_tags",
",",
"outdated"... | Query datasets.
Use --collection=* to list all datasets across all collections. | [
"Query",
"datasets",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L273-L304 | train | 64,341 |
ternaris/marv | marv/cli.py | marvcli_tag | def marvcli_tag(ctx, add, remove, datasets):
"""Add or remove tags to datasets"""
if not any([add, remove]) or not datasets:
click.echo(ctx.get_help())
ctx.exit(1)
app = create_app()
setids = parse_setids(datasets)
app.site.tag(setids, add, remove) | python | def marvcli_tag(ctx, add, remove, datasets):
"""Add or remove tags to datasets"""
if not any([add, remove]) or not datasets:
click.echo(ctx.get_help())
ctx.exit(1)
app = create_app()
setids = parse_setids(datasets)
app.site.tag(setids, add, remove) | [
"def",
"marvcli_tag",
"(",
"ctx",
",",
"add",
",",
"remove",
",",
"datasets",
")",
":",
"if",
"not",
"any",
"(",
"[",
"add",
",",
"remove",
"]",
")",
"or",
"not",
"datasets",
":",
"click",
".",
"echo",
"(",
"ctx",
".",
"get_help",
"(",
")",
")",
... | Add or remove tags to datasets | [
"Add",
"or",
"remove",
"tags",
"to",
"datasets"
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L463-L471 | train | 64,342 |
ternaris/marv | marv/cli.py | marvcli_comment_add | def marvcli_comment_add(user, message, datasets):
"""Add comment as user for one or more datasets"""
app = create_app()
try:
db.session.query(User).filter(User.name==user).one()
except NoResultFound:
click.echo("ERROR: No such user '{}'".format(user), err=True)
sys.exit(1)
id... | python | def marvcli_comment_add(user, message, datasets):
"""Add comment as user for one or more datasets"""
app = create_app()
try:
db.session.query(User).filter(User.name==user).one()
except NoResultFound:
click.echo("ERROR: No such user '{}'".format(user), err=True)
sys.exit(1)
id... | [
"def",
"marvcli_comment_add",
"(",
"user",
",",
"message",
",",
"datasets",
")",
":",
"app",
"=",
"create_app",
"(",
")",
"try",
":",
"db",
".",
"session",
".",
"query",
"(",
"User",
")",
".",
"filter",
"(",
"User",
".",
"name",
"==",
"user",
")",
... | Add comment as user for one or more datasets | [
"Add",
"comment",
"as",
"user",
"for",
"one",
"or",
"more",
"datasets"
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L483-L492 | train | 64,343 |
ternaris/marv | marv/cli.py | marvcli_comment_list | def marvcli_comment_list(datasets):
"""Lists comments for datasets.
Output: setid comment_id date time author message
"""
app = create_app()
ids = parse_setids(datasets, dbids=True)
comments = db.session.query(Comment)\
.options(db.joinedload(Comment.dataset))\
... | python | def marvcli_comment_list(datasets):
"""Lists comments for datasets.
Output: setid comment_id date time author message
"""
app = create_app()
ids = parse_setids(datasets, dbids=True)
comments = db.session.query(Comment)\
.options(db.joinedload(Comment.dataset))\
... | [
"def",
"marvcli_comment_list",
"(",
"datasets",
")",
":",
"app",
"=",
"create_app",
"(",
")",
"ids",
"=",
"parse_setids",
"(",
"datasets",
",",
"dbids",
"=",
"True",
")",
"comments",
"=",
"db",
".",
"session",
".",
"query",
"(",
"Comment",
")",
".",
"o... | Lists comments for datasets.
Output: setid comment_id date time author message | [
"Lists",
"comments",
"for",
"datasets",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L497-L510 | train | 64,344 |
ternaris/marv | marv/cli.py | marvcli_comment_rm | def marvcli_comment_rm(ids):
"""Remove comments.
Remove comments by id as given in second column of: marv comment list
"""
app = create_app()
db.session.query(Comment)\
.filter(Comment.id.in_(ids))\
.delete(synchronize_session=False)
db.session.commit() | python | def marvcli_comment_rm(ids):
"""Remove comments.
Remove comments by id as given in second column of: marv comment list
"""
app = create_app()
db.session.query(Comment)\
.filter(Comment.id.in_(ids))\
.delete(synchronize_session=False)
db.session.commit() | [
"def",
"marvcli_comment_rm",
"(",
"ids",
")",
":",
"app",
"=",
"create_app",
"(",
")",
"db",
".",
"session",
".",
"query",
"(",
"Comment",
")",
".",
"filter",
"(",
"Comment",
".",
"id",
".",
"in_",
"(",
"ids",
")",
")",
".",
"delete",
"(",
"synchro... | Remove comments.
Remove comments by id as given in second column of: marv comment list | [
"Remove",
"comments",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L515-L524 | train | 64,345 |
ternaris/marv | marv/cli.py | marvcli_user_list | def marvcli_user_list():
"""List existing users"""
app = create_app()
for name in db.session.query(User.name).order_by(User.name):
click.echo(name[0]) | python | def marvcli_user_list():
"""List existing users"""
app = create_app()
for name in db.session.query(User.name).order_by(User.name):
click.echo(name[0]) | [
"def",
"marvcli_user_list",
"(",
")",
":",
"app",
"=",
"create_app",
"(",
")",
"for",
"name",
"in",
"db",
".",
"session",
".",
"query",
"(",
"User",
".",
"name",
")",
".",
"order_by",
"(",
"User",
".",
"name",
")",
":",
"click",
".",
"echo",
"(",
... | List existing users | [
"List",
"existing",
"users"
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L554-L558 | train | 64,346 |
ternaris/marv | marv/cli.py | marvcli_user_rm | def marvcli_user_rm(ctx, username):
"""Remove a user"""
app = create_app()
try:
app.um.user_rm(username)
except ValueError as e:
ctx.fail(e.args[0]) | python | def marvcli_user_rm(ctx, username):
"""Remove a user"""
app = create_app()
try:
app.um.user_rm(username)
except ValueError as e:
ctx.fail(e.args[0]) | [
"def",
"marvcli_user_rm",
"(",
"ctx",
",",
"username",
")",
":",
"app",
"=",
"create_app",
"(",
")",
"try",
":",
"app",
".",
"um",
".",
"user_rm",
"(",
"username",
")",
"except",
"ValueError",
"as",
"e",
":",
"ctx",
".",
"fail",
"(",
"e",
".",
"arg... | Remove a user | [
"Remove",
"a",
"user"
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L578-L584 | train | 64,347 |
originell/sorl-watermark | sorl_watermarker/engines/base.py | WatermarkEngineBase.watermark | def watermark(self, image, options):
"""
Wrapper for ``_watermark``
Takes care of all the options handling.
"""
watermark_img = options.get("watermark", settings.THUMBNAIL_WATERMARK)
if not watermark_img:
raise AttributeError("No THUMBNAIL_WATERMARK defined o... | python | def watermark(self, image, options):
"""
Wrapper for ``_watermark``
Takes care of all the options handling.
"""
watermark_img = options.get("watermark", settings.THUMBNAIL_WATERMARK)
if not watermark_img:
raise AttributeError("No THUMBNAIL_WATERMARK defined o... | [
"def",
"watermark",
"(",
"self",
",",
"image",
",",
"options",
")",
":",
"watermark_img",
"=",
"options",
".",
"get",
"(",
"\"watermark\"",
",",
"settings",
".",
"THUMBNAIL_WATERMARK",
")",
"if",
"not",
"watermark_img",
":",
"raise",
"AttributeError",
"(",
"... | Wrapper for ``_watermark``
Takes care of all the options handling. | [
"Wrapper",
"for",
"_watermark"
] | d9ce72a05477158520d70d70a99203b36fb66a30 | https://github.com/originell/sorl-watermark/blob/d9ce72a05477158520d70d70a99203b36fb66a30/sorl_watermarker/engines/base.py#L65-L108 | train | 64,348 |
ternaris/marv | marv/config.py | make_funcs | def make_funcs(dataset, setdir, store):
"""Functions available for listing columns and filters."""
return {
'cat': lambda *lists: [x for lst in lists for x in lst],
'comments': lambda: None,
'detail_route': detail_route,
'format': lambda fmt, *args: fmt.format(*args),
'ge... | python | def make_funcs(dataset, setdir, store):
"""Functions available for listing columns and filters."""
return {
'cat': lambda *lists: [x for lst in lists for x in lst],
'comments': lambda: None,
'detail_route': detail_route,
'format': lambda fmt, *args: fmt.format(*args),
'ge... | [
"def",
"make_funcs",
"(",
"dataset",
",",
"setdir",
",",
"store",
")",
":",
"return",
"{",
"'cat'",
":",
"lambda",
"*",
"lists",
":",
"[",
"x",
"for",
"lst",
"in",
"lists",
"for",
"x",
"in",
"lst",
"]",
",",
"'comments'",
":",
"lambda",
":",
"None"... | Functions available for listing columns and filters. | [
"Functions",
"available",
"for",
"listing",
"columns",
"and",
"filters",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/config.py#L48-L69 | train | 64,349 |
ternaris/marv | marv/config.py | make_summary_funcs | def make_summary_funcs(rows, ids):
"""Functions available for listing summary fields."""
return {
'len': len,
'list': lambda *x: filter(None, list(x)),
'max': max,
'min': min,
'rows': partial(summary_rows, rows, ids),
'sum': sum,
'trace': print_trace
} | python | def make_summary_funcs(rows, ids):
"""Functions available for listing summary fields."""
return {
'len': len,
'list': lambda *x: filter(None, list(x)),
'max': max,
'min': min,
'rows': partial(summary_rows, rows, ids),
'sum': sum,
'trace': print_trace
} | [
"def",
"make_summary_funcs",
"(",
"rows",
",",
"ids",
")",
":",
"return",
"{",
"'len'",
":",
"len",
",",
"'list'",
":",
"lambda",
"*",
"x",
":",
"filter",
"(",
"None",
",",
"list",
"(",
"x",
")",
")",
",",
"'max'",
":",
"max",
",",
"'min'",
":",
... | Functions available for listing summary fields. | [
"Functions",
"available",
"for",
"listing",
"summary",
"fields",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/config.py#L72-L82 | train | 64,350 |
ternaris/marv | marv/collection.py | cached_property | def cached_property(func):
"""Create read-only property that caches its function's value"""
@functools.wraps(func)
def cached_func(self):
cacheattr = '_{}'.format(func.func_name)
try:
return getattr(self, cacheattr)
except AttributeError:
value = func(self)
... | python | def cached_property(func):
"""Create read-only property that caches its function's value"""
@functools.wraps(func)
def cached_func(self):
cacheattr = '_{}'.format(func.func_name)
try:
return getattr(self, cacheattr)
except AttributeError:
value = func(self)
... | [
"def",
"cached_property",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"cached_func",
"(",
"self",
")",
":",
"cacheattr",
"=",
"'_{}'",
".",
"format",
"(",
"func",
".",
"func_name",
")",
"try",
":",
"return",
"getattr... | Create read-only property that caches its function's value | [
"Create",
"read",
"-",
"only",
"property",
"that",
"caches",
"its",
"function",
"s",
"value"
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/collection.py#L169-L180 | train | 64,351 |
ternaris/marv | marv_node/io.py | create_stream | def create_stream(name, **header):
"""Create a stream for publishing messages.
All keyword arguments will be used to form the header.
"""
assert isinstance(name, basestring), name
return CreateStream(parent=None, name=name, group=False, header=header) | python | def create_stream(name, **header):
"""Create a stream for publishing messages.
All keyword arguments will be used to form the header.
"""
assert isinstance(name, basestring), name
return CreateStream(parent=None, name=name, group=False, header=header) | [
"def",
"create_stream",
"(",
"name",
",",
"*",
"*",
"header",
")",
":",
"assert",
"isinstance",
"(",
"name",
",",
"basestring",
")",
",",
"name",
"return",
"CreateStream",
"(",
"parent",
"=",
"None",
",",
"name",
"=",
"name",
",",
"group",
"=",
"False"... | Create a stream for publishing messages.
All keyword arguments will be used to form the header. | [
"Create",
"a",
"stream",
"for",
"publishing",
"messages",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv_node/io.py#L34-L40 | train | 64,352 |
ternaris/marv | marv_node/io.py | pull | def pull(handle, enumerate=False):
"""Pulls next message for handle.
Args:
handle: A :class:`.stream.Handle` or GroupHandle.
enumerate (bool): boolean to indicate whether a tuple ``(idx, msg)``
should be returned, not unlike Python's enumerate().
Returns:
A :class:`Pull... | python | def pull(handle, enumerate=False):
"""Pulls next message for handle.
Args:
handle: A :class:`.stream.Handle` or GroupHandle.
enumerate (bool): boolean to indicate whether a tuple ``(idx, msg)``
should be returned, not unlike Python's enumerate().
Returns:
A :class:`Pull... | [
"def",
"pull",
"(",
"handle",
",",
"enumerate",
"=",
"False",
")",
":",
"assert",
"isinstance",
"(",
"handle",
",",
"Handle",
")",
",",
"handle",
"return",
"Pull",
"(",
"handle",
",",
"enumerate",
")"
] | Pulls next message for handle.
Args:
handle: A :class:`.stream.Handle` or GroupHandle.
enumerate (bool): boolean to indicate whether a tuple ``(idx, msg)``
should be returned, not unlike Python's enumerate().
Returns:
A :class:`Pull` task to be yielded. Marv will send the
... | [
"Pulls",
"next",
"message",
"for",
"handle",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv_node/io.py#L71-L98 | train | 64,353 |
originell/sorl-watermark | sorl_watermarker/parsers.py | parse_geometry | def parse_geometry(geometry, ratio=None):
"""
Enhanced parse_geometry parser with percentage support.
"""
if "%" not in geometry:
# fall back to old parser
return xy_geometry_parser(geometry, ratio)
# parse with float so geometry strings like "42.11%" are possible
return float(ge... | python | def parse_geometry(geometry, ratio=None):
"""
Enhanced parse_geometry parser with percentage support.
"""
if "%" not in geometry:
# fall back to old parser
return xy_geometry_parser(geometry, ratio)
# parse with float so geometry strings like "42.11%" are possible
return float(ge... | [
"def",
"parse_geometry",
"(",
"geometry",
",",
"ratio",
"=",
"None",
")",
":",
"if",
"\"%\"",
"not",
"in",
"geometry",
":",
"# fall back to old parser",
"return",
"xy_geometry_parser",
"(",
"geometry",
",",
"ratio",
")",
"# parse with float so geometry strings like \"... | Enhanced parse_geometry parser with percentage support. | [
"Enhanced",
"parse_geometry",
"parser",
"with",
"percentage",
"support",
"."
] | d9ce72a05477158520d70d70a99203b36fb66a30 | https://github.com/originell/sorl-watermark/blob/d9ce72a05477158520d70d70a99203b36fb66a30/sorl_watermarker/parsers.py#L4-L12 | train | 64,354 |
ternaris/marv | docs/tutorial/code/marv_tutorial/__init__.py | image | def image(cam):
"""Extract first image of input stream to jpg file.
Args:
cam: Input stream of raw rosbag messages.
Returns:
File instance for first image of input stream.
"""
# Set output stream title and pull first message
yield marv.set_header(title=cam.topic)
msg = yiel... | python | def image(cam):
"""Extract first image of input stream to jpg file.
Args:
cam: Input stream of raw rosbag messages.
Returns:
File instance for first image of input stream.
"""
# Set output stream title and pull first message
yield marv.set_header(title=cam.topic)
msg = yiel... | [
"def",
"image",
"(",
"cam",
")",
":",
"# Set output stream title and pull first message",
"yield",
"marv",
".",
"set_header",
"(",
"title",
"=",
"cam",
".",
"topic",
")",
"msg",
"=",
"yield",
"marv",
".",
"pull",
"(",
"cam",
")",
"if",
"msg",
"is",
"None",... | Extract first image of input stream to jpg file.
Args:
cam: Input stream of raw rosbag messages.
Returns:
File instance for first image of input stream. | [
"Extract",
"first",
"image",
"of",
"input",
"stream",
"to",
"jpg",
"file",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/docs/tutorial/code/marv_tutorial/__init__.py#L35-L60 | train | 64,355 |
ternaris/marv | docs/tutorial/code/marv_tutorial/__init__.py | image_section | def image_section(image, title):
"""Create detail section with one image.
Args:
title (str): Title to be displayed for detail section.
image: marv image file.
Returns
One detail section.
"""
# pull first image
img = yield marv.pull(image)
if img is None:
ret... | python | def image_section(image, title):
"""Create detail section with one image.
Args:
title (str): Title to be displayed for detail section.
image: marv image file.
Returns
One detail section.
"""
# pull first image
img = yield marv.pull(image)
if img is None:
ret... | [
"def",
"image_section",
"(",
"image",
",",
"title",
")",
":",
"# pull first image",
"img",
"=",
"yield",
"marv",
".",
"pull",
"(",
"image",
")",
"if",
"img",
"is",
"None",
":",
"return",
"# create image widget and section containing it",
"widget",
"=",
"{",
"'... | Create detail section with one image.
Args:
title (str): Title to be displayed for detail section.
image: marv image file.
Returns
One detail section. | [
"Create",
"detail",
"section",
"with",
"one",
"image",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/docs/tutorial/code/marv_tutorial/__init__.py#L66-L84 | train | 64,356 |
ternaris/marv | docs/tutorial/code/marv_tutorial/__init__.py | images | def images(cam):
"""Extract images from input stream to jpg files.
Args:
cam: Input stream of raw rosbag messages.
Returns:
File instances for images of input stream.
"""
# Set output stream title and pull first message
yield marv.set_header(title=cam.topic)
# Fetch and pr... | python | def images(cam):
"""Extract images from input stream to jpg files.
Args:
cam: Input stream of raw rosbag messages.
Returns:
File instances for images of input stream.
"""
# Set output stream title and pull first message
yield marv.set_header(title=cam.topic)
# Fetch and pr... | [
"def",
"images",
"(",
"cam",
")",
":",
"# Set output stream title and pull first message",
"yield",
"marv",
".",
"set_header",
"(",
"title",
"=",
"cam",
".",
"topic",
")",
"# Fetch and process first 20 image messages",
"name_template",
"=",
"'%s-{}.jpg'",
"%",
"cam",
... | Extract images from input stream to jpg files.
Args:
cam: Input stream of raw rosbag messages.
Returns:
File instances for images of input stream. | [
"Extract",
"images",
"from",
"input",
"stream",
"to",
"jpg",
"files",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/docs/tutorial/code/marv_tutorial/__init__.py#L89-L118 | train | 64,357 |
ternaris/marv | docs/tutorial/code/marv_tutorial/__init__.py | gallery_section | def gallery_section(images, title):
"""Create detail section with gallery.
Args:
title (str): Title to be displayed for detail section.
images: stream of marv image files
Returns
One detail section.
"""
# pull all images
imgs = []
while True:
img = yield mar... | python | def gallery_section(images, title):
"""Create detail section with gallery.
Args:
title (str): Title to be displayed for detail section.
images: stream of marv image files
Returns
One detail section.
"""
# pull all images
imgs = []
while True:
img = yield mar... | [
"def",
"gallery_section",
"(",
"images",
",",
"title",
")",
":",
"# pull all images",
"imgs",
"=",
"[",
"]",
"while",
"True",
":",
"img",
"=",
"yield",
"marv",
".",
"pull",
"(",
"images",
")",
"if",
"img",
"is",
"None",
":",
"break",
"imgs",
".",
"ap... | Create detail section with gallery.
Args:
title (str): Title to be displayed for detail section.
images: stream of marv image files
Returns
One detail section. | [
"Create",
"detail",
"section",
"with",
"gallery",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/docs/tutorial/code/marv_tutorial/__init__.py#L124-L147 | train | 64,358 |
ternaris/marv | docs/tutorial/code/marv_tutorial/__init__.py | filesizes | def filesizes(images):
"""Stat filesize of files.
Args:
images: stream of marv image files
Returns:
Stream of filesizes
"""
# Pull each image and push its filesize
while True:
img = yield marv.pull(images)
if img is None:
break
yield marv.pus... | python | def filesizes(images):
"""Stat filesize of files.
Args:
images: stream of marv image files
Returns:
Stream of filesizes
"""
# Pull each image and push its filesize
while True:
img = yield marv.pull(images)
if img is None:
break
yield marv.pus... | [
"def",
"filesizes",
"(",
"images",
")",
":",
"# Pull each image and push its filesize",
"while",
"True",
":",
"img",
"=",
"yield",
"marv",
".",
"pull",
"(",
"images",
")",
"if",
"img",
"is",
"None",
":",
"break",
"yield",
"marv",
".",
"push",
"(",
"img",
... | Stat filesize of files.
Args:
images: stream of marv image files
Returns:
Stream of filesizes | [
"Stat",
"filesize",
"of",
"files",
"."
] | c221354d912ff869bbdb4f714a86a70be30d823e | https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/docs/tutorial/code/marv_tutorial/__init__.py#L152-L166 | train | 64,359 |
kolypto/py-good | good/helpers.py | name | def name(name, validator=None):
""" Set a name on a validator callable.
Useful for user-friendly reporting when using lambdas to populate the [`Invalid.expected`](#invalid) field:
```python
from good import Schema, name
Schema(lambda x: int(x))('a')
#-> Invalid: invalid literal for int(): exp... | python | def name(name, validator=None):
""" Set a name on a validator callable.
Useful for user-friendly reporting when using lambdas to populate the [`Invalid.expected`](#invalid) field:
```python
from good import Schema, name
Schema(lambda x: int(x))('a')
#-> Invalid: invalid literal for int(): exp... | [
"def",
"name",
"(",
"name",
",",
"validator",
"=",
"None",
")",
":",
"# Decorator mode",
"if",
"validator",
"is",
"None",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"f",
".",
"name",
"=",
"name",
"return",
"f",
"return",
"decorator",
"# Direct mode",
... | Set a name on a validator callable.
Useful for user-friendly reporting when using lambdas to populate the [`Invalid.expected`](#invalid) field:
```python
from good import Schema, name
Schema(lambda x: int(x))('a')
#-> Invalid: invalid literal for int(): expected <lambda>(), got
Schema(name('i... | [
"Set",
"a",
"name",
"on",
"a",
"validator",
"callable",
"."
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/helpers.py#L255-L297 | train | 64,360 |
kolypto/py-good | good/validators/strings.py | stringmethod | def stringmethod(func):
""" Validator factory which call a single method on the string. """
method_name = func()
@wraps(func)
def factory():
def validator(v):
if not isinstance(v, six.string_types):
raise Invalid(_(u'Not a string'), get_type_name(six.text_type), get_... | python | def stringmethod(func):
""" Validator factory which call a single method on the string. """
method_name = func()
@wraps(func)
def factory():
def validator(v):
if not isinstance(v, six.string_types):
raise Invalid(_(u'Not a string'), get_type_name(six.text_type), get_... | [
"def",
"stringmethod",
"(",
"func",
")",
":",
"method_name",
"=",
"func",
"(",
")",
"@",
"wraps",
"(",
"func",
")",
"def",
"factory",
"(",
")",
":",
"def",
"validator",
"(",
"v",
")",
":",
"if",
"not",
"isinstance",
"(",
"v",
",",
"six",
".",
"st... | Validator factory which call a single method on the string. | [
"Validator",
"factory",
"which",
"call",
"a",
"single",
"method",
"on",
"the",
"string",
"."
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/validators/strings.py#L10-L21 | train | 64,361 |
kolypto/py-good | good/validators/dates.py | FixedOffset.parse_z | def parse_z(cls, offset):
""" Parse %z offset into `timedelta` """
assert len(offset) == 5, 'Invalid offset string format, must be "+HHMM"'
return timedelta(hours=int(offset[:3]), minutes=int(offset[0] + offset[3:])) | python | def parse_z(cls, offset):
""" Parse %z offset into `timedelta` """
assert len(offset) == 5, 'Invalid offset string format, must be "+HHMM"'
return timedelta(hours=int(offset[:3]), minutes=int(offset[0] + offset[3:])) | [
"def",
"parse_z",
"(",
"cls",
",",
"offset",
")",
":",
"assert",
"len",
"(",
"offset",
")",
"==",
"5",
",",
"'Invalid offset string format, must be \"+HHMM\"'",
"return",
"timedelta",
"(",
"hours",
"=",
"int",
"(",
"offset",
"[",
":",
"3",
"]",
")",
",",
... | Parse %z offset into `timedelta` | [
"Parse",
"%z",
"offset",
"into",
"timedelta"
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/validators/dates.py#L25-L28 | train | 64,362 |
kolypto/py-good | good/validators/dates.py | FixedOffset.format_z | def format_z(cls, offset):
""" Format `timedelta` into %z """
sec = offset.total_seconds()
return '{s}{h:02d}{m:02d}'.format(s='-' if sec<0 else '+', h=abs(int(sec/3600)), m=int((sec%3600)/60)) | python | def format_z(cls, offset):
""" Format `timedelta` into %z """
sec = offset.total_seconds()
return '{s}{h:02d}{m:02d}'.format(s='-' if sec<0 else '+', h=abs(int(sec/3600)), m=int((sec%3600)/60)) | [
"def",
"format_z",
"(",
"cls",
",",
"offset",
")",
":",
"sec",
"=",
"offset",
".",
"total_seconds",
"(",
")",
"return",
"'{s}{h:02d}{m:02d}'",
".",
"format",
"(",
"s",
"=",
"'-'",
"if",
"sec",
"<",
"0",
"else",
"'+'",
",",
"h",
"=",
"abs",
"(",
"in... | Format `timedelta` into %z | [
"Format",
"timedelta",
"into",
"%z"
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/validators/dates.py#L31-L34 | train | 64,363 |
kolypto/py-good | good/validators/dates.py | DateTime.strptime | def strptime(cls, value, format):
""" Parse a datetime string using the provided format.
This also emulates `%z` support on Python 2.
:param value: Datetime string
:type value: str
:param format: Format to use for parsing
:type format: str
:rtype: datetime
... | python | def strptime(cls, value, format):
""" Parse a datetime string using the provided format.
This also emulates `%z` support on Python 2.
:param value: Datetime string
:type value: str
:param format: Format to use for parsing
:type format: str
:rtype: datetime
... | [
"def",
"strptime",
"(",
"cls",
",",
"value",
",",
"format",
")",
":",
"# Simplest case: direct parsing",
"if",
"cls",
".",
"python_supports_z",
"or",
"'%z'",
"not",
"in",
"format",
":",
"return",
"datetime",
".",
"strptime",
"(",
"value",
",",
"format",
")",... | Parse a datetime string using the provided format.
This also emulates `%z` support on Python 2.
:param value: Datetime string
:type value: str
:param format: Format to use for parsing
:type format: str
:rtype: datetime
:raises ValueError: Invalid format
... | [
"Parse",
"a",
"datetime",
"string",
"using",
"the",
"provided",
"format",
"."
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/validators/dates.py#L235-L260 | train | 64,364 |
kolypto/py-good | misc/performance/performance.py | generate_random_type | def generate_random_type(valid):
""" Generate a random type and samples for it.
:param valid: Generate valid samples?
:type valid: bool
:return: type, sample-generator
:rtype: type, generator
"""
type = choice(['int', 'str'])
r = lambda: randrange(-1000000000, 1000000000)
if type ... | python | def generate_random_type(valid):
""" Generate a random type and samples for it.
:param valid: Generate valid samples?
:type valid: bool
:return: type, sample-generator
:rtype: type, generator
"""
type = choice(['int', 'str'])
r = lambda: randrange(-1000000000, 1000000000)
if type ... | [
"def",
"generate_random_type",
"(",
"valid",
")",
":",
"type",
"=",
"choice",
"(",
"[",
"'int'",
",",
"'str'",
"]",
")",
"r",
"=",
"lambda",
":",
"randrange",
"(",
"-",
"1000000000",
",",
"1000000000",
")",
"if",
"type",
"==",
"'int'",
":",
"return",
... | Generate a random type and samples for it.
:param valid: Generate valid samples?
:type valid: bool
:return: type, sample-generator
:rtype: type, generator | [
"Generate",
"a",
"random",
"type",
"and",
"samples",
"for",
"it",
"."
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/misc/performance/performance.py#L13-L30 | train | 64,365 |
kolypto/py-good | misc/performance/performance.py | generate_random_schema | def generate_random_schema(valid):
""" Generate a random plain schema, and a sample generation function.
:param valid: Generate valid samples?
:type valid: bool
:returns: schema, sample-generator
:rtype: *, generator
"""
schema_type = choice(['literal', 'type'])
if schema_type == 'lite... | python | def generate_random_schema(valid):
""" Generate a random plain schema, and a sample generation function.
:param valid: Generate valid samples?
:type valid: bool
:returns: schema, sample-generator
:rtype: *, generator
"""
schema_type = choice(['literal', 'type'])
if schema_type == 'lite... | [
"def",
"generate_random_schema",
"(",
"valid",
")",
":",
"schema_type",
"=",
"choice",
"(",
"[",
"'literal'",
",",
"'type'",
"]",
")",
"if",
"schema_type",
"==",
"'literal'",
":",
"type",
",",
"gen",
"=",
"generate_random_type",
"(",
"valid",
")",
"value",
... | Generate a random plain schema, and a sample generation function.
:param valid: Generate valid samples?
:type valid: bool
:returns: schema, sample-generator
:rtype: *, generator | [
"Generate",
"a",
"random",
"plain",
"schema",
"and",
"a",
"sample",
"generation",
"function",
"."
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/misc/performance/performance.py#L33-L50 | train | 64,366 |
kolypto/py-good | misc/performance/performance.py | generate_dict_schema | def generate_dict_schema(size, valid):
""" Generate a schema dict of size `size` using library `lib`.
In addition, it returns samples generator
:param size: Schema size
:type size: int
:param samples: The number of samples to generate
:type samples: int
:param valid: Generate valid samples... | python | def generate_dict_schema(size, valid):
""" Generate a schema dict of size `size` using library `lib`.
In addition, it returns samples generator
:param size: Schema size
:type size: int
:param samples: The number of samples to generate
:type samples: int
:param valid: Generate valid samples... | [
"def",
"generate_dict_schema",
"(",
"size",
",",
"valid",
")",
":",
"schema",
"=",
"{",
"}",
"generator_items",
"=",
"[",
"]",
"# Generate schema",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"size",
")",
":",
"while",
"True",
":",
"key_schema",
",",
"ke... | Generate a schema dict of size `size` using library `lib`.
In addition, it returns samples generator
:param size: Schema size
:type size: int
:param samples: The number of samples to generate
:type samples: int
:param valid: Generate valid samples?
:type valid: bool
:returns | [
"Generate",
"a",
"schema",
"dict",
"of",
"size",
"size",
"using",
"library",
"lib",
"."
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/misc/performance/performance.py#L53-L85 | train | 64,367 |
scot-dev/scot | scot/varbase.py | _calc_q_statistic | def _calc_q_statistic(x, h, nt):
"""Calculate Portmanteau statistics up to a lag of h.
"""
t, m, n = x.shape
# covariance matrix of x
c0 = acm(x, 0)
# LU factorization of covariance matrix
c0f = sp.linalg.lu_factor(c0, overwrite_a=False, check_finite=True)
q = np.zeros((3, h + 1))
... | python | def _calc_q_statistic(x, h, nt):
"""Calculate Portmanteau statistics up to a lag of h.
"""
t, m, n = x.shape
# covariance matrix of x
c0 = acm(x, 0)
# LU factorization of covariance matrix
c0f = sp.linalg.lu_factor(c0, overwrite_a=False, check_finite=True)
q = np.zeros((3, h + 1))
... | [
"def",
"_calc_q_statistic",
"(",
"x",
",",
"h",
",",
"nt",
")",
":",
"t",
",",
"m",
",",
"n",
"=",
"x",
".",
"shape",
"# covariance matrix of x",
"c0",
"=",
"acm",
"(",
"x",
",",
"0",
")",
"# LU factorization of covariance matrix",
"c0f",
"=",
"sp",
".... | Calculate Portmanteau statistics up to a lag of h. | [
"Calculate",
"Portmanteau",
"statistics",
"up",
"to",
"a",
"lag",
"of",
"h",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/varbase.py#L437-L474 | train | 64,368 |
scot-dev/scot | scot/varbase.py | _calc_q_h0 | def _calc_q_h0(n, x, h, nt, n_jobs=1, verbose=0, random_state=None):
"""Calculate q under the null hypothesis of whiteness.
"""
rng = check_random_state(random_state)
par, func = parallel_loop(_calc_q_statistic, n_jobs, verbose)
q = par(func(rng.permutation(x.T).T, h, nt) for _ in range(n))
... | python | def _calc_q_h0(n, x, h, nt, n_jobs=1, verbose=0, random_state=None):
"""Calculate q under the null hypothesis of whiteness.
"""
rng = check_random_state(random_state)
par, func = parallel_loop(_calc_q_statistic, n_jobs, verbose)
q = par(func(rng.permutation(x.T).T, h, nt) for _ in range(n))
... | [
"def",
"_calc_q_h0",
"(",
"n",
",",
"x",
",",
"h",
",",
"nt",
",",
"n_jobs",
"=",
"1",
",",
"verbose",
"=",
"0",
",",
"random_state",
"=",
"None",
")",
":",
"rng",
"=",
"check_random_state",
"(",
"random_state",
")",
"par",
",",
"func",
"=",
"paral... | Calculate q under the null hypothesis of whiteness. | [
"Calculate",
"q",
"under",
"the",
"null",
"hypothesis",
"of",
"whiteness",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/varbase.py#L477-L484 | train | 64,369 |
scot-dev/scot | scot/varbase.py | VARBase.copy | def copy(self):
"""Create a copy of the VAR model."""
other = self.__class__(self.p)
other.coef = self.coef.copy()
other.residuals = self.residuals.copy()
other.rescov = self.rescov.copy()
return other | python | def copy(self):
"""Create a copy of the VAR model."""
other = self.__class__(self.p)
other.coef = self.coef.copy()
other.residuals = self.residuals.copy()
other.rescov = self.rescov.copy()
return other | [
"def",
"copy",
"(",
"self",
")",
":",
"other",
"=",
"self",
".",
"__class__",
"(",
"self",
".",
"p",
")",
"other",
".",
"coef",
"=",
"self",
".",
"coef",
".",
"copy",
"(",
")",
"other",
".",
"residuals",
"=",
"self",
".",
"residuals",
".",
"copy"... | Create a copy of the VAR model. | [
"Create",
"a",
"copy",
"of",
"the",
"VAR",
"model",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/varbase.py#L74-L80 | train | 64,370 |
scot-dev/scot | scot/varbase.py | VARBase.from_yw | def from_yw(self, acms):
"""Determine VAR model from autocorrelation matrices by solving the
Yule-Walker equations.
Parameters
----------
acms : array, shape (n_lags, n_channels, n_channels)
acms[l] contains the autocorrelation matrix at lag l. The highest
... | python | def from_yw(self, acms):
"""Determine VAR model from autocorrelation matrices by solving the
Yule-Walker equations.
Parameters
----------
acms : array, shape (n_lags, n_channels, n_channels)
acms[l] contains the autocorrelation matrix at lag l. The highest
... | [
"def",
"from_yw",
"(",
"self",
",",
"acms",
")",
":",
"if",
"len",
"(",
"acms",
")",
"!=",
"self",
".",
"p",
"+",
"1",
":",
"raise",
"ValueError",
"(",
"\"Number of autocorrelation matrices ({}) does not\"",
"\" match model order ({}) + 1.\"",
".",
"format",
"("... | Determine VAR model from autocorrelation matrices by solving the
Yule-Walker equations.
Parameters
----------
acms : array, shape (n_lags, n_channels, n_channels)
acms[l] contains the autocorrelation matrix at lag l. The highest
lag must equal the model order.
... | [
"Determine",
"VAR",
"model",
"from",
"autocorrelation",
"matrices",
"by",
"solving",
"the",
"Yule",
"-",
"Walker",
"equations",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/varbase.py#L114-L156 | train | 64,371 |
scot-dev/scot | scot/varbase.py | VARBase.predict | def predict(self, data):
"""Predict samples on actual data.
The result of this function is used for calculating the residuals.
Parameters
----------
data : array, shape (trials, channels, samples) or (channels, samples)
Epoched or continuous data set.
Retur... | python | def predict(self, data):
"""Predict samples on actual data.
The result of this function is used for calculating the residuals.
Parameters
----------
data : array, shape (trials, channels, samples) or (channels, samples)
Epoched or continuous data set.
Retur... | [
"def",
"predict",
"(",
"self",
",",
"data",
")",
":",
"data",
"=",
"atleast_3d",
"(",
"data",
")",
"t",
",",
"m",
",",
"l",
"=",
"data",
".",
"shape",
"p",
"=",
"int",
"(",
"np",
".",
"shape",
"(",
"self",
".",
"coef",
")",
"[",
"1",
"]",
"... | Predict samples on actual data.
The result of this function is used for calculating the residuals.
Parameters
----------
data : array, shape (trials, channels, samples) or (channels, samples)
Epoched or continuous data set.
Returns
-------
predicted... | [
"Predict",
"samples",
"on",
"actual",
"data",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/varbase.py#L212-L248 | train | 64,372 |
scot-dev/scot | scot/varbase.py | VARBase.is_stable | def is_stable(self):
"""Test if VAR model is stable.
This function tests stability of the VAR model as described in [1]_.
Returns
-------
out : bool
True if the model is stable.
References
----------
.. [1] H. Lütkepohl, "New Introduction to... | python | def is_stable(self):
"""Test if VAR model is stable.
This function tests stability of the VAR model as described in [1]_.
Returns
-------
out : bool
True if the model is stable.
References
----------
.. [1] H. Lütkepohl, "New Introduction to... | [
"def",
"is_stable",
"(",
"self",
")",
":",
"m",
",",
"mp",
"=",
"self",
".",
"coef",
".",
"shape",
"p",
"=",
"mp",
"//",
"m",
"assert",
"(",
"mp",
"==",
"m",
"*",
"p",
")",
"# TODO: replace with raise?",
"top_block",
"=",
"[",
"]",
"for",
"i",
"i... | Test if VAR model is stable.
This function tests stability of the VAR model as described in [1]_.
Returns
-------
out : bool
True if the model is stable.
References
----------
.. [1] H. Lütkepohl, "New Introduction to Multiple Time Series
... | [
"Test",
"if",
"VAR",
"model",
"is",
"stable",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/varbase.py#L250-L282 | train | 64,373 |
scot-dev/scot | scot/datasets.py | fetch | def fetch(dataset="mi", datadir=datadir):
"""Fetch example dataset.
If the requested dataset is not found in the location specified by
`datadir`, the function attempts to download it.
Parameters
----------
dataset : str
Which dataset to load. Currently only 'mi' is supported.
datad... | python | def fetch(dataset="mi", datadir=datadir):
"""Fetch example dataset.
If the requested dataset is not found in the location specified by
`datadir`, the function attempts to download it.
Parameters
----------
dataset : str
Which dataset to load. Currently only 'mi' is supported.
datad... | [
"def",
"fetch",
"(",
"dataset",
"=",
"\"mi\"",
",",
"datadir",
"=",
"datadir",
")",
":",
"if",
"dataset",
"not",
"in",
"datasets",
":",
"raise",
"ValueError",
"(",
"\"Example data '{}' not available.\"",
".",
"format",
"(",
"dataset",
")",
")",
"else",
":",
... | Fetch example dataset.
If the requested dataset is not found in the location specified by
`datadir`, the function attempts to download it.
Parameters
----------
dataset : str
Which dataset to load. Currently only 'mi' is supported.
datadir : str
Path to the storage location of ... | [
"Fetch",
"example",
"dataset",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/datasets.py#L21-L71 | train | 64,374 |
kolypto/py-good | good/schema/compiler.py | CompiledSchema.supports_undefined | def supports_undefined(self):
""" Test whether this schema supports Undefined.
A Schema that supports `Undefined`, when given `Undefined`, should return some value (other than `Undefined`)
without raising errors.
This is designed to support a very special case like that:
```py... | python | def supports_undefined(self):
""" Test whether this schema supports Undefined.
A Schema that supports `Undefined`, when given `Undefined`, should return some value (other than `Undefined`)
without raising errors.
This is designed to support a very special case like that:
```py... | [
"def",
"supports_undefined",
"(",
"self",
")",
":",
"# Test",
"try",
":",
"yes",
"=",
"self",
"(",
"const",
".",
"UNDEFINED",
")",
"is",
"not",
"const",
".",
"UNDEFINED",
"except",
"(",
"Invalid",
",",
"SchemaError",
")",
":",
"yes",
"=",
"False",
"# R... | Test whether this schema supports Undefined.
A Schema that supports `Undefined`, when given `Undefined`, should return some value (other than `Undefined`)
without raising errors.
This is designed to support a very special case like that:
```python
Schema(Default(0)).supports_u... | [
"Test",
"whether",
"this",
"schema",
"supports",
"Undefined",
"."
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L85-L113 | train | 64,375 |
kolypto/py-good | good/schema/compiler.py | CompiledSchema.get_schema_type | def get_schema_type(cls, schema):
""" Get schema type for the argument
:param schema: Schema to analyze
:return: COMPILED_TYPE constant
:rtype: str|None
"""
schema_type = type(schema)
# Marker
if issubclass(schema_type, markers.Marker):
retur... | python | def get_schema_type(cls, schema):
""" Get schema type for the argument
:param schema: Schema to analyze
:return: COMPILED_TYPE constant
:rtype: str|None
"""
schema_type = type(schema)
# Marker
if issubclass(schema_type, markers.Marker):
retur... | [
"def",
"get_schema_type",
"(",
"cls",
",",
"schema",
")",
":",
"schema_type",
"=",
"type",
"(",
"schema",
")",
"# Marker",
"if",
"issubclass",
"(",
"schema_type",
",",
"markers",
".",
"Marker",
")",
":",
"return",
"const",
".",
"COMPILED_TYPE",
".",
"MARKE... | Get schema type for the argument
:param schema: Schema to analyze
:return: COMPILED_TYPE constant
:rtype: str|None | [
"Get",
"schema",
"type",
"for",
"the",
"argument"
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L118-L137 | train | 64,376 |
kolypto/py-good | good/schema/compiler.py | CompiledSchema.priority | def priority(self):
""" Get priority for this Schema.
Used to sort mapping keys
:rtype: int
"""
# Markers have priority set on the class
if self.compiled_type == const.COMPILED_TYPE.MARKER:
return self.compiled.priority
# Other types have static pri... | python | def priority(self):
""" Get priority for this Schema.
Used to sort mapping keys
:rtype: int
"""
# Markers have priority set on the class
if self.compiled_type == const.COMPILED_TYPE.MARKER:
return self.compiled.priority
# Other types have static pri... | [
"def",
"priority",
"(",
"self",
")",
":",
"# Markers have priority set on the class",
"if",
"self",
".",
"compiled_type",
"==",
"const",
".",
"COMPILED_TYPE",
".",
"MARKER",
":",
"return",
"self",
".",
"compiled",
".",
"priority",
"# Other types have static priority",... | Get priority for this Schema.
Used to sort mapping keys
:rtype: int | [
"Get",
"priority",
"for",
"this",
"Schema",
"."
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L140-L152 | train | 64,377 |
kolypto/py-good | good/schema/compiler.py | CompiledSchema.sort_schemas | def sort_schemas(cls, schemas_list):
""" Sort the provided list of schemas according to their priority.
This also supports markers, and markers of a single type are also sorted according to the priority of the wrapped schema.
:type schemas_list: list[CompiledSchema]
:rtype: list[Compil... | python | def sort_schemas(cls, schemas_list):
""" Sort the provided list of schemas according to their priority.
This also supports markers, and markers of a single type are also sorted according to the priority of the wrapped schema.
:type schemas_list: list[CompiledSchema]
:rtype: list[Compil... | [
"def",
"sort_schemas",
"(",
"cls",
",",
"schemas_list",
")",
":",
"return",
"sorted",
"(",
"schemas_list",
",",
"key",
"=",
"lambda",
"x",
":",
"(",
"# Top-level priority:",
"# priority of the schema itself",
"x",
".",
"priority",
",",
"# Second-level priority (for ... | Sort the provided list of schemas according to their priority.
This also supports markers, and markers of a single type are also sorted according to the priority of the wrapped schema.
:type schemas_list: list[CompiledSchema]
:rtype: list[CompiledSchema] | [
"Sort",
"the",
"provided",
"list",
"of",
"schemas",
"according",
"to",
"their",
"priority",
"."
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L155-L171 | train | 64,378 |
kolypto/py-good | good/schema/compiler.py | CompiledSchema.sub_compile | def sub_compile(self, schema, path=None, matcher=False):
""" Compile a sub-schema
:param schema: Validation schema
:type schema: *
:param path: Path to this schema, if any
:type path: list|None
:param matcher: Compile a matcher?
:type matcher: bool
:rtype... | python | def sub_compile(self, schema, path=None, matcher=False):
""" Compile a sub-schema
:param schema: Validation schema
:type schema: *
:param path: Path to this schema, if any
:type path: list|None
:param matcher: Compile a matcher?
:type matcher: bool
:rtype... | [
"def",
"sub_compile",
"(",
"self",
",",
"schema",
",",
"path",
"=",
"None",
",",
"matcher",
"=",
"False",
")",
":",
"return",
"type",
"(",
"self",
")",
"(",
"schema",
",",
"self",
".",
"path",
"+",
"(",
"path",
"or",
"[",
"]",
")",
",",
"None",
... | Compile a sub-schema
:param schema: Validation schema
:type schema: *
:param path: Path to this schema, if any
:type path: list|None
:param matcher: Compile a matcher?
:type matcher: bool
:rtype: CompiledSchema | [
"Compile",
"a",
"sub",
"-",
"schema"
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L173-L190 | train | 64,379 |
kolypto/py-good | good/schema/compiler.py | CompiledSchema.Invalid | def Invalid(self, message, expected):
""" Helper for Invalid errors.
Typical use:
err_type = self.Invalid(_(u'Message'), self.name)
raise err_type(<provided-value>)
Note: `provided` and `expected` are unicode-typecasted automatically
:type message: unicode
:ty... | python | def Invalid(self, message, expected):
""" Helper for Invalid errors.
Typical use:
err_type = self.Invalid(_(u'Message'), self.name)
raise err_type(<provided-value>)
Note: `provided` and `expected` are unicode-typecasted automatically
:type message: unicode
:ty... | [
"def",
"Invalid",
"(",
"self",
",",
"message",
",",
"expected",
")",
":",
"def",
"InvalidPartial",
"(",
"provided",
",",
"path",
"=",
"None",
",",
"*",
"*",
"info",
")",
":",
"\"\"\" Create an Invalid exception\n\n :type provided: unicode\n :type... | Helper for Invalid errors.
Typical use:
err_type = self.Invalid(_(u'Message'), self.name)
raise err_type(<provided-value>)
Note: `provided` and `expected` are unicode-typecasted automatically
:type message: unicode
:type expected: unicode | [
"Helper",
"for",
"Invalid",
"errors",
"."
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L192-L220 | train | 64,380 |
kolypto/py-good | good/schema/compiler.py | CompiledSchema.get_schema_compiler | def get_schema_compiler(self, schema):
""" Get compiler method for the provided schema
:param schema: Schema to analyze
:return: Callable compiled
:rtype: callable|None
"""
# Schema type
schema_type = self.get_schema_type(schema)
if schema_type is None:
... | python | def get_schema_compiler(self, schema):
""" Get compiler method for the provided schema
:param schema: Schema to analyze
:return: Callable compiled
:rtype: callable|None
"""
# Schema type
schema_type = self.get_schema_type(schema)
if schema_type is None:
... | [
"def",
"get_schema_compiler",
"(",
"self",
",",
"schema",
")",
":",
"# Schema type",
"schema_type",
"=",
"self",
".",
"get_schema_type",
"(",
"schema",
")",
"if",
"schema_type",
"is",
"None",
":",
"return",
"None",
"# Compiler",
"compilers",
"=",
"{",
"const",... | Get compiler method for the provided schema
:param schema: Schema to analyze
:return: Callable compiled
:rtype: callable|None | [
"Get",
"compiler",
"method",
"for",
"the",
"provided",
"schema"
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L226-L250 | train | 64,381 |
kolypto/py-good | good/schema/compiler.py | CompiledSchema.compile_schema | def compile_schema(self, schema):
""" Compile the current schema into a callable validator
:return: Callable validator
:rtype: callable
:raises SchemaError: Schema compilation error
"""
compiler = self.get_schema_compiler(schema)
if compiler is None:
... | python | def compile_schema(self, schema):
""" Compile the current schema into a callable validator
:return: Callable validator
:rtype: callable
:raises SchemaError: Schema compilation error
"""
compiler = self.get_schema_compiler(schema)
if compiler is None:
... | [
"def",
"compile_schema",
"(",
"self",
",",
"schema",
")",
":",
"compiler",
"=",
"self",
".",
"get_schema_compiler",
"(",
"schema",
")",
"if",
"compiler",
"is",
"None",
":",
"raise",
"SchemaError",
"(",
"_",
"(",
"u'Unsupported schema data type {!r}'",
")",
"."... | Compile the current schema into a callable validator
:return: Callable validator
:rtype: callable
:raises SchemaError: Schema compilation error | [
"Compile",
"the",
"current",
"schema",
"into",
"a",
"callable",
"validator"
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L252-L264 | train | 64,382 |
kolypto/py-good | good/schema/compiler.py | CompiledSchema._compile_schema | def _compile_schema(self, schema):
""" Compile another schema """
assert self.matcher == schema.matcher
self.name = schema.name
self.compiled_type = schema.compiled_type
return schema.compiled | python | def _compile_schema(self, schema):
""" Compile another schema """
assert self.matcher == schema.matcher
self.name = schema.name
self.compiled_type = schema.compiled_type
return schema.compiled | [
"def",
"_compile_schema",
"(",
"self",
",",
"schema",
")",
":",
"assert",
"self",
".",
"matcher",
"==",
"schema",
".",
"matcher",
"self",
".",
"name",
"=",
"schema",
".",
"name",
"self",
".",
"compiled_type",
"=",
"schema",
".",
"compiled_type",
"return",
... | Compile another schema | [
"Compile",
"another",
"schema"
] | 192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4 | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L331-L338 | train | 64,383 |
scot-dev/scot | scot/matfiles.py | loadmat | def loadmat(filename):
"""This function should be called instead of direct spio.loadmat
as it cures the problem of not properly recovering python dictionaries
from mat files. It calls the function check keys to cure all entries
which are still mat-objects
"""
data = sploadmat(filename, struct_as... | python | def loadmat(filename):
"""This function should be called instead of direct spio.loadmat
as it cures the problem of not properly recovering python dictionaries
from mat files. It calls the function check keys to cure all entries
which are still mat-objects
"""
data = sploadmat(filename, struct_as... | [
"def",
"loadmat",
"(",
"filename",
")",
":",
"data",
"=",
"sploadmat",
"(",
"filename",
",",
"struct_as_record",
"=",
"False",
",",
"squeeze_me",
"=",
"True",
")",
"return",
"_check_keys",
"(",
"data",
")"
] | This function should be called instead of direct spio.loadmat
as it cures the problem of not properly recovering python dictionaries
from mat files. It calls the function check keys to cure all entries
which are still mat-objects | [
"This",
"function",
"should",
"be",
"called",
"instead",
"of",
"direct",
"spio",
".",
"loadmat",
"as",
"it",
"cures",
"the",
"problem",
"of",
"not",
"properly",
"recovering",
"python",
"dictionaries",
"from",
"mat",
"files",
".",
"It",
"calls",
"the",
"funct... | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/matfiles.py#L12-L19 | train | 64,384 |
scot-dev/scot | scot/matfiles.py | _check_keys | def _check_keys(dictionary):
"""
checks if entries in dictionary are mat-objects. If yes
todict is called to change them to nested dictionaries
"""
for key in dictionary:
if isinstance(dictionary[key], matlab.mio5_params.mat_struct):
dictionary[key] = _todict(dictionary[key])
... | python | def _check_keys(dictionary):
"""
checks if entries in dictionary are mat-objects. If yes
todict is called to change them to nested dictionaries
"""
for key in dictionary:
if isinstance(dictionary[key], matlab.mio5_params.mat_struct):
dictionary[key] = _todict(dictionary[key])
... | [
"def",
"_check_keys",
"(",
"dictionary",
")",
":",
"for",
"key",
"in",
"dictionary",
":",
"if",
"isinstance",
"(",
"dictionary",
"[",
"key",
"]",
",",
"matlab",
".",
"mio5_params",
".",
"mat_struct",
")",
":",
"dictionary",
"[",
"key",
"]",
"=",
"_todict... | checks if entries in dictionary are mat-objects. If yes
todict is called to change them to nested dictionaries | [
"checks",
"if",
"entries",
"in",
"dictionary",
"are",
"mat",
"-",
"objects",
".",
"If",
"yes",
"todict",
"is",
"called",
"to",
"change",
"them",
"to",
"nested",
"dictionaries"
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/matfiles.py#L25-L33 | train | 64,385 |
scot-dev/scot | scot/matfiles.py | _todict | def _todict(matobj):
"""
a recursive function which constructs from matobjects nested dictionaries
"""
dictionary = {}
#noinspection PyProtectedMember
for strg in matobj._fieldnames:
elem = matobj.__dict__[strg]
if isinstance(elem, matlab.mio5_params.mat_struct):
dict... | python | def _todict(matobj):
"""
a recursive function which constructs from matobjects nested dictionaries
"""
dictionary = {}
#noinspection PyProtectedMember
for strg in matobj._fieldnames:
elem = matobj.__dict__[strg]
if isinstance(elem, matlab.mio5_params.mat_struct):
dict... | [
"def",
"_todict",
"(",
"matobj",
")",
":",
"dictionary",
"=",
"{",
"}",
"#noinspection PyProtectedMember",
"for",
"strg",
"in",
"matobj",
".",
"_fieldnames",
":",
"elem",
"=",
"matobj",
".",
"__dict__",
"[",
"strg",
"]",
"if",
"isinstance",
"(",
"elem",
",... | a recursive function which constructs from matobjects nested dictionaries | [
"a",
"recursive",
"function",
"which",
"constructs",
"from",
"matobjects",
"nested",
"dictionaries"
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/matfiles.py#L36-L48 | train | 64,386 |
scot-dev/scot | scot/plainica.py | plainica | def plainica(x, reducedim=0.99, backend=None, random_state=None):
""" Source decomposition with ICA.
Apply ICA to the data x, with optional PCA dimensionality reduction.
Parameters
----------
x : array, shape (n_trials, n_channels, n_samples) or (n_channels, n_samples)
data set
reduced... | python | def plainica(x, reducedim=0.99, backend=None, random_state=None):
""" Source decomposition with ICA.
Apply ICA to the data x, with optional PCA dimensionality reduction.
Parameters
----------
x : array, shape (n_trials, n_channels, n_samples) or (n_channels, n_samples)
data set
reduced... | [
"def",
"plainica",
"(",
"x",
",",
"reducedim",
"=",
"0.99",
",",
"backend",
"=",
"None",
",",
"random_state",
"=",
"None",
")",
":",
"x",
"=",
"atleast_3d",
"(",
"x",
")",
"t",
",",
"m",
",",
"l",
"=",
"np",
".",
"shape",
"(",
"x",
")",
"if",
... | Source decomposition with ICA.
Apply ICA to the data x, with optional PCA dimensionality reduction.
Parameters
----------
x : array, shape (n_trials, n_channels, n_samples) or (n_channels, n_samples)
data set
reducedim : {int, float, 'no_pca'}, optional
A number of less than 1 in i... | [
"Source",
"decomposition",
"with",
"ICA",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/plainica.py#L29-L77 | train | 64,387 |
scot-dev/scot | scot/var.py | _msge_with_gradient_underdetermined | def _msge_with_gradient_underdetermined(data, delta, xvschema, skipstep, p):
"""Calculate mean squared generalization error and its gradient for
underdetermined equation system.
"""
t, m, l = data.shape
d = None
j, k = 0, 0
nt = np.ceil(t / skipstep)
for trainset, testset in xvschema(t, ... | python | def _msge_with_gradient_underdetermined(data, delta, xvschema, skipstep, p):
"""Calculate mean squared generalization error and its gradient for
underdetermined equation system.
"""
t, m, l = data.shape
d = None
j, k = 0, 0
nt = np.ceil(t / skipstep)
for trainset, testset in xvschema(t, ... | [
"def",
"_msge_with_gradient_underdetermined",
"(",
"data",
",",
"delta",
",",
"xvschema",
",",
"skipstep",
",",
"p",
")",
":",
"t",
",",
"m",
",",
"l",
"=",
"data",
".",
"shape",
"d",
"=",
"None",
"j",
",",
"k",
"=",
"0",
",",
"0",
"nt",
"=",
"np... | Calculate mean squared generalization error and its gradient for
underdetermined equation system. | [
"Calculate",
"mean",
"squared",
"generalization",
"error",
"and",
"its",
"gradient",
"for",
"underdetermined",
"equation",
"system",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/var.py#L218-L245 | train | 64,388 |
scot-dev/scot | scot/var.py | _msge_with_gradient_overdetermined | def _msge_with_gradient_overdetermined(data, delta, xvschema, skipstep, p):
"""Calculate mean squared generalization error and its gradient for
overdetermined equation system.
"""
t, m, l = data.shape
d = None
l, k = 0, 0
nt = np.ceil(t / skipstep)
for trainset, testset in xvschema(t, sk... | python | def _msge_with_gradient_overdetermined(data, delta, xvschema, skipstep, p):
"""Calculate mean squared generalization error and its gradient for
overdetermined equation system.
"""
t, m, l = data.shape
d = None
l, k = 0, 0
nt = np.ceil(t / skipstep)
for trainset, testset in xvschema(t, sk... | [
"def",
"_msge_with_gradient_overdetermined",
"(",
"data",
",",
"delta",
",",
"xvschema",
",",
"skipstep",
",",
"p",
")",
":",
"t",
",",
"m",
",",
"l",
"=",
"data",
".",
"shape",
"d",
"=",
"None",
"l",
",",
"k",
"=",
"0",
",",
"0",
"nt",
"=",
"np"... | Calculate mean squared generalization error and its gradient for
overdetermined equation system. | [
"Calculate",
"mean",
"squared",
"generalization",
"error",
"and",
"its",
"gradient",
"for",
"overdetermined",
"equation",
"system",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/var.py#L248-L272 | train | 64,389 |
scot-dev/scot | scot/var.py | _get_msge_with_gradient | def _get_msge_with_gradient(data, delta, xvschema, skipstep, p):
"""Calculate mean squared generalization error and its gradient,
automatically selecting the best function.
"""
t, m, l = data.shape
n = (l - p) * t
underdetermined = n < m * p
if underdetermined:
return _msge_with_gr... | python | def _get_msge_with_gradient(data, delta, xvschema, skipstep, p):
"""Calculate mean squared generalization error and its gradient,
automatically selecting the best function.
"""
t, m, l = data.shape
n = (l - p) * t
underdetermined = n < m * p
if underdetermined:
return _msge_with_gr... | [
"def",
"_get_msge_with_gradient",
"(",
"data",
",",
"delta",
",",
"xvschema",
",",
"skipstep",
",",
"p",
")",
":",
"t",
",",
"m",
",",
"l",
"=",
"data",
".",
"shape",
"n",
"=",
"(",
"l",
"-",
"p",
")",
"*",
"t",
"underdetermined",
"=",
"n",
"<",
... | Calculate mean squared generalization error and its gradient,
automatically selecting the best function. | [
"Calculate",
"mean",
"squared",
"generalization",
"error",
"and",
"its",
"gradient",
"automatically",
"selecting",
"the",
"best",
"function",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/var.py#L290-L304 | train | 64,390 |
scot-dev/scot | scot/var.py | VAR.optimize_order | def optimize_order(self, data, min_p=1, max_p=None):
"""Determine optimal model order by minimizing the mean squared
generalization error.
Parameters
----------
data : array, shape (n_trials, n_channels, n_samples)
Epoched data set on which to optimize the model orde... | python | def optimize_order(self, data, min_p=1, max_p=None):
"""Determine optimal model order by minimizing the mean squared
generalization error.
Parameters
----------
data : array, shape (n_trials, n_channels, n_samples)
Epoched data set on which to optimize the model orde... | [
"def",
"optimize_order",
"(",
"self",
",",
"data",
",",
"min_p",
"=",
"1",
",",
"max_p",
"=",
"None",
")",
":",
"data",
"=",
"np",
".",
"asarray",
"(",
"data",
")",
"if",
"data",
".",
"shape",
"[",
"0",
"]",
"<",
"2",
":",
"raise",
"ValueError",
... | Determine optimal model order by minimizing the mean squared
generalization error.
Parameters
----------
data : array, shape (n_trials, n_channels, n_samples)
Epoched data set on which to optimize the model order. At least two
trials are required.
min_p :... | [
"Determine",
"optimal",
"model",
"order",
"by",
"minimizing",
"the",
"mean",
"squared",
"generalization",
"error",
"."
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/var.py#L84-L131 | train | 64,391 |
scot-dev/scot | scot/eegtopo/geo_spherical.py | Point.fromvector | def fromvector(cls, v):
"""Initialize from euclidean vector"""
w = v.normalized()
return cls(w.x, w.y, w.z) | python | def fromvector(cls, v):
"""Initialize from euclidean vector"""
w = v.normalized()
return cls(w.x, w.y, w.z) | [
"def",
"fromvector",
"(",
"cls",
",",
"v",
")",
":",
"w",
"=",
"v",
".",
"normalized",
"(",
")",
"return",
"cls",
"(",
"w",
".",
"x",
",",
"w",
".",
"y",
",",
"w",
".",
"z",
")"
] | Initialize from euclidean vector | [
"Initialize",
"from",
"euclidean",
"vector"
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/eegtopo/geo_spherical.py#L34-L37 | train | 64,392 |
scot-dev/scot | scot/eegtopo/geo_spherical.py | Point.list | def list(self):
"""position in 3d space"""
return [self._pos3d.x, self._pos3d.y, self._pos3d.z] | python | def list(self):
"""position in 3d space"""
return [self._pos3d.x, self._pos3d.y, self._pos3d.z] | [
"def",
"list",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"_pos3d",
".",
"x",
",",
"self",
".",
"_pos3d",
".",
"y",
",",
"self",
".",
"_pos3d",
".",
"z",
"]"
] | position in 3d space | [
"position",
"in",
"3d",
"space"
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/eegtopo/geo_spherical.py#L45-L47 | train | 64,393 |
scot-dev/scot | scot/eegtopo/geo_spherical.py | Point.distance | def distance(self, other):
"""Distance to another point on the sphere"""
return math.acos(self._pos3d.dot(other.vector)) | python | def distance(self, other):
"""Distance to another point on the sphere"""
return math.acos(self._pos3d.dot(other.vector)) | [
"def",
"distance",
"(",
"self",
",",
"other",
")",
":",
"return",
"math",
".",
"acos",
"(",
"self",
".",
"_pos3d",
".",
"dot",
"(",
"other",
".",
"vector",
")",
")"
] | Distance to another point on the sphere | [
"Distance",
"to",
"another",
"point",
"on",
"the",
"sphere"
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/eegtopo/geo_spherical.py#L59-L61 | train | 64,394 |
scot-dev/scot | scot/eegtopo/geo_spherical.py | Point.distances | def distances(self, points):
"""Distance to other points on the sphere"""
return [math.acos(self._pos3d.dot(p.vector)) for p in points] | python | def distances(self, points):
"""Distance to other points on the sphere"""
return [math.acos(self._pos3d.dot(p.vector)) for p in points] | [
"def",
"distances",
"(",
"self",
",",
"points",
")",
":",
"return",
"[",
"math",
".",
"acos",
"(",
"self",
".",
"_pos3d",
".",
"dot",
"(",
"p",
".",
"vector",
")",
")",
"for",
"p",
"in",
"points",
"]"
] | Distance to other points on the sphere | [
"Distance",
"to",
"other",
"points",
"on",
"the",
"sphere"
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/eegtopo/geo_spherical.py#L63-L65 | train | 64,395 |
scot-dev/scot | scot/eegtopo/geo_euclidean.py | Vector.fromiterable | def fromiterable(cls, itr):
"""Initialize from iterable"""
x, y, z = itr
return cls(x, y, z) | python | def fromiterable(cls, itr):
"""Initialize from iterable"""
x, y, z = itr
return cls(x, y, z) | [
"def",
"fromiterable",
"(",
"cls",
",",
"itr",
")",
":",
"x",
",",
"y",
",",
"z",
"=",
"itr",
"return",
"cls",
"(",
"x",
",",
"y",
",",
"z",
")"
] | Initialize from iterable | [
"Initialize",
"from",
"iterable"
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/eegtopo/geo_euclidean.py#L20-L23 | train | 64,396 |
scot-dev/scot | scot/eegtopo/geo_euclidean.py | Vector.fromvector | def fromvector(cls, v):
"""Copy another vector"""
return cls(v.x, v.y, v.z) | python | def fromvector(cls, v):
"""Copy another vector"""
return cls(v.x, v.y, v.z) | [
"def",
"fromvector",
"(",
"cls",
",",
"v",
")",
":",
"return",
"cls",
"(",
"v",
".",
"x",
",",
"v",
".",
"y",
",",
"v",
".",
"z",
")"
] | Copy another vector | [
"Copy",
"another",
"vector"
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/eegtopo/geo_euclidean.py#L26-L28 | train | 64,397 |
scot-dev/scot | scot/eegtopo/geo_euclidean.py | Vector.norm2 | def norm2(self):
"""Squared norm of the vector"""
return self.x * self.x + self.y * self.y + self.z * self.z | python | def norm2(self):
"""Squared norm of the vector"""
return self.x * self.x + self.y * self.y + self.z * self.z | [
"def",
"norm2",
"(",
"self",
")",
":",
"return",
"self",
".",
"x",
"*",
"self",
".",
"x",
"+",
"self",
".",
"y",
"*",
"self",
".",
"y",
"+",
"self",
".",
"z",
"*",
"self",
".",
"z"
] | Squared norm of the vector | [
"Squared",
"norm",
"of",
"the",
"vector"
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/eegtopo/geo_euclidean.py#L127-L129 | train | 64,398 |
scot-dev/scot | scot/eegtopo/geo_euclidean.py | Vector.rotate | def rotate(self, l, u):
"""rotate l radians around axis u"""
cl = math.cos(l)
sl = math.sin(l)
x = (cl + u.x * u.x * (1 - cl)) * self.x + (u.x * u.y * (1 - cl) - u.z * sl) * self.y + (
u.x * u.z * (1 - cl) + u.y * sl) * self.z
y = (u.y * u.x * (1 - cl) + u.z * sl) * self.... | python | def rotate(self, l, u):
"""rotate l radians around axis u"""
cl = math.cos(l)
sl = math.sin(l)
x = (cl + u.x * u.x * (1 - cl)) * self.x + (u.x * u.y * (1 - cl) - u.z * sl) * self.y + (
u.x * u.z * (1 - cl) + u.y * sl) * self.z
y = (u.y * u.x * (1 - cl) + u.z * sl) * self.... | [
"def",
"rotate",
"(",
"self",
",",
"l",
",",
"u",
")",
":",
"cl",
"=",
"math",
".",
"cos",
"(",
"l",
")",
"sl",
"=",
"math",
".",
"sin",
"(",
"l",
")",
"x",
"=",
"(",
"cl",
"+",
"u",
".",
"x",
"*",
"u",
".",
"x",
"*",
"(",
"1",
"-",
... | rotate l radians around axis u | [
"rotate",
"l",
"radians",
"around",
"axis",
"u"
] | 48598b79d4400dad893b134cd2194715511facda | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/eegtopo/geo_euclidean.py#L145-L156 | train | 64,399 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.