repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
imbolc/mongo
mongo/__init__.py
Document.get_or_create
def get_or_create(cls, spec, defaults=None): '''Find or create single document. Return (doc, created_now).''' docs = list(cls.find(spec).limit(2)) assert len(docs) < 2, 'multiple docs returned' if docs: return docs[0], False else: kwargs = defaults or {} ...
python
def get_or_create(cls, spec, defaults=None): '''Find or create single document. Return (doc, created_now).''' docs = list(cls.find(spec).limit(2)) assert len(docs) < 2, 'multiple docs returned' if docs: return docs[0], False else: kwargs = defaults or {} ...
[ "def", "get_or_create", "(", "cls", ",", "spec", ",", "defaults", "=", "None", ")", ":", "docs", "=", "list", "(", "cls", ".", "find", "(", "spec", ")", ".", "limit", "(", "2", ")", ")", "assert", "len", "(", "docs", ")", "<", "2", ",", "'multi...
Find or create single document. Return (doc, created_now).
[ "Find", "or", "create", "single", "document", ".", "Return", "(", "doc", "created_now", ")", "." ]
ba86186c2c034a7cfb23ebe556a0cb65d48971d8
https://github.com/imbolc/mongo/blob/ba86186c2c034a7cfb23ebe556a0cb65d48971d8/mongo/__init__.py#L142-L153
train
Find or create single document. Return ( doc created_now.
guaix-ucm/numina
numina/modeling/sumofgauss.py
sum_of_gaussian_factory
def sum_of_gaussian_factory(N): """Return a model of the sum of N Gaussians and a constant background.""" name = "SumNGauss%d" % N attr = {} # parameters for i in range(N): key = "amplitude_%d" % i attr[key] = Parameter(key) key = "center_%d" % i attr[key] = Paramet...
python
def sum_of_gaussian_factory(N): """Return a model of the sum of N Gaussians and a constant background.""" name = "SumNGauss%d" % N attr = {} # parameters for i in range(N): key = "amplitude_%d" % i attr[key] = Parameter(key) key = "center_%d" % i attr[key] = Paramet...
[ "def", "sum_of_gaussian_factory", "(", "N", ")", ":", "name", "=", "\"SumNGauss%d\"", "%", "N", "attr", "=", "{", "}", "# parameters", "for", "i", "in", "range", "(", "N", ")", ":", "key", "=", "\"amplitude_%d\"", "%", "i", "attr", "[", "key", "]", "...
Return a model of the sum of N Gaussians and a constant background.
[ "Return", "a", "model", "of", "the", "sum", "of", "N", "Gaussians", "and", "a", "constant", "background", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/modeling/sumofgauss.py#L14-L56
train
Return a model of the sum of N Gaussians and a constant background.
guaix-ucm/numina
numina/array/wavecalib/apply_integer_offsets.py
apply_integer_offsets
def apply_integer_offsets(image2d, offx, offy): """Apply global (integer) offsets to image. Parameters ---------- image2d : numpy array Input image offx : int Offset in the X direction (must be integer). offy : int Offset in the Y direction (must be integer). Return...
python
def apply_integer_offsets(image2d, offx, offy): """Apply global (integer) offsets to image. Parameters ---------- image2d : numpy array Input image offx : int Offset in the X direction (must be integer). offy : int Offset in the Y direction (must be integer). Return...
[ "def", "apply_integer_offsets", "(", "image2d", ",", "offx", ",", "offy", ")", ":", "# protections", "if", "type", "(", "offx", ")", "!=", "int", "or", "type", "(", "offy", ")", "!=", "int", ":", "raise", "ValueError", "(", "'Invalid non-integer offsets'", ...
Apply global (integer) offsets to image. Parameters ---------- image2d : numpy array Input image offx : int Offset in the X direction (must be integer). offy : int Offset in the Y direction (must be integer). Returns ------- image2d_shifted : numpy array ...
[ "Apply", "global", "(", "integer", ")", "offsets", "to", "image", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/apply_integer_offsets.py#L21-L59
train
Apply global integer offsets to image.
guaix-ucm/numina
numina/array/cosmetics.py
ccdmask
def ccdmask(flat1, flat2=None, mask=None, lowercut=6.0, uppercut=6.0, siglev=1.0, mode='region', nmed=(7, 7), nsig=(15, 15)): """Find cosmetic defects in a detector using two flat field images. Two arrays representing flat fields of different exposure times are required. Cosmetic defects are se...
python
def ccdmask(flat1, flat2=None, mask=None, lowercut=6.0, uppercut=6.0, siglev=1.0, mode='region', nmed=(7, 7), nsig=(15, 15)): """Find cosmetic defects in a detector using two flat field images. Two arrays representing flat fields of different exposure times are required. Cosmetic defects are se...
[ "def", "ccdmask", "(", "flat1", ",", "flat2", "=", "None", ",", "mask", "=", "None", ",", "lowercut", "=", "6.0", ",", "uppercut", "=", "6.0", ",", "siglev", "=", "1.0", ",", "mode", "=", "'region'", ",", "nmed", "=", "(", "7", ",", "7", ")", "...
Find cosmetic defects in a detector using two flat field images. Two arrays representing flat fields of different exposure times are required. Cosmetic defects are selected as points that deviate significantly of the expected normal distribution of pixels in the ratio between `flat2` and `flat1`. The m...
[ "Find", "cosmetic", "defects", "in", "a", "detector", "using", "two", "flat", "field", "images", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/cosmetics.py#L41-L197
train
This function calculates the cosmetic defects in a detector using two flat field images.
guaix-ucm/numina
numina/array/cosmetics.py
cosmetics
def cosmetics(flat1, flat2 = None, mask=None, lowercut=6.0, uppercut=6.0, siglev=2.0): """Find cosmetic defects in a detector using two flat field images. Two arrays representing flat fields of different exposure times are required. Cosmetic defects are selected as points that deviate significantly of ...
python
def cosmetics(flat1, flat2 = None, mask=None, lowercut=6.0, uppercut=6.0, siglev=2.0): """Find cosmetic defects in a detector using two flat field images. Two arrays representing flat fields of different exposure times are required. Cosmetic defects are selected as points that deviate significantly of ...
[ "def", "cosmetics", "(", "flat1", ",", "flat2", "=", "None", ",", "mask", "=", "None", ",", "lowercut", "=", "6.0", ",", "uppercut", "=", "6.0", ",", "siglev", "=", "2.0", ")", ":", "if", "flat2", "is", "None", ":", "flat1", ",", "flat2", "=", "f...
Find cosmetic defects in a detector using two flat field images. Two arrays representing flat fields of different exposure times are required. Cosmetic defects are selected as points that deviate significantly of the expected normal distribution of pixels in the ratio between `flat2` and `flat1`. ...
[ "Find", "cosmetic", "defects", "in", "a", "detector", "using", "two", "flat", "field", "images", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/cosmetics.py#L225-L268
train
Find cosmetic defects in a detector using two flat field images.
PierreRust/apigpio
apigpio/utils.py
Debounce
def Debounce(threshold=100): """ Simple debouncing decorator for apigpio callbacks. Example: `@Debouncer() def my_cb(gpio, level, tick) print('gpio cb: {} {} {}'.format(gpio, level, tick)) ` The threshold can be given to the decorator as an argument (in millisec). This decor...
python
def Debounce(threshold=100): """ Simple debouncing decorator for apigpio callbacks. Example: `@Debouncer() def my_cb(gpio, level, tick) print('gpio cb: {} {} {}'.format(gpio, level, tick)) ` The threshold can be given to the decorator as an argument (in millisec). This decor...
[ "def", "Debounce", "(", "threshold", "=", "100", ")", ":", "threshold", "*=", "1000", "max_tick", "=", "0xFFFFFFFF", "class", "_decorated", "(", "object", ")", ":", "def", "__init__", "(", "self", ",", "pigpio_cb", ")", ":", "self", ".", "_fn", "=", "p...
Simple debouncing decorator for apigpio callbacks. Example: `@Debouncer() def my_cb(gpio, level, tick) print('gpio cb: {} {} {}'.format(gpio, level, tick)) ` The threshold can be given to the decorator as an argument (in millisec). This decorator can be used both on function and obj...
[ "Simple", "debouncing", "decorator", "for", "apigpio", "callbacks", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/utils.py#L4-L56
train
A debouncing decorator for apigpio callbacks.
morepath/more.jwtauth
more/jwtauth/refresh.py
verify_refresh_request
def verify_refresh_request(request): """ Wrapper around JWTIdentityPolicy.verify_refresh which verify if the request to refresh the token is valid. If valid it returns the userid which can be used to create to create an updated identity with ``remember_identity``. Otherwise it raises an exceptio...
python
def verify_refresh_request(request): """ Wrapper around JWTIdentityPolicy.verify_refresh which verify if the request to refresh the token is valid. If valid it returns the userid which can be used to create to create an updated identity with ``remember_identity``. Otherwise it raises an exceptio...
[ "def", "verify_refresh_request", "(", "request", ")", ":", "jwtauth_settings", "=", "request", ".", "app", ".", "settings", ".", "jwtauth", ".", "__dict__", ".", "copy", "(", ")", "identity_policy", "=", "JWTIdentityPolicy", "(", "*", "*", "jwtauth_settings", ...
Wrapper around JWTIdentityPolicy.verify_refresh which verify if the request to refresh the token is valid. If valid it returns the userid which can be used to create to create an updated identity with ``remember_identity``. Otherwise it raises an exception based on InvalidTokenError. :param request...
[ "Wrapper", "around", "JWTIdentityPolicy", ".", "verify_refresh", "which", "verify", "if", "the", "request", "to", "refresh", "the", "token", "is", "valid", ".", "If", "valid", "it", "returns", "the", "userid", "which", "can", "be", "used", "to", "create", "t...
1c3c5731612069a092e44cf612641c05edf1f083
https://github.com/morepath/more.jwtauth/blob/1c3c5731612069a092e44cf612641c05edf1f083/more/jwtauth/refresh.py#L4-L21
train
Wrapper around JWTIdentityPolicy. verify_refresh which returns the userid which can be used to create an updated identity with remember_identity.
guaix-ucm/numina
numina/array/peaks/detrend.py
detrend
def detrend(arr, x=None, deg=5, tol=1e-3, maxloop=10): """Compute a baseline trend of a signal""" xx = numpy.arange(len(arr)) if x is None else x base = arr.copy() trend = base pol = numpy.ones((deg + 1,)) for _ in range(maxloop): pol_new = numpy.polyfit(xx, base, deg) pol_norm ...
python
def detrend(arr, x=None, deg=5, tol=1e-3, maxloop=10): """Compute a baseline trend of a signal""" xx = numpy.arange(len(arr)) if x is None else x base = arr.copy() trend = base pol = numpy.ones((deg + 1,)) for _ in range(maxloop): pol_new = numpy.polyfit(xx, base, deg) pol_norm ...
[ "def", "detrend", "(", "arr", ",", "x", "=", "None", ",", "deg", "=", "5", ",", "tol", "=", "1e-3", ",", "maxloop", "=", "10", ")", ":", "xx", "=", "numpy", ".", "arange", "(", "len", "(", "arr", ")", ")", "if", "x", "is", "None", "else", "...
Compute a baseline trend of a signal
[ "Compute", "a", "baseline", "trend", "of", "a", "signal" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/peaks/detrend.py#L13-L29
train
Compute a baseline trend of a signal
arkottke/pysra
pysra/motion.py
Motion.pgv
def pgv(self, centimeters=False): """Peak-ground velocity [m/sec].""" if self._pgv is None: # Compute transfer function -- only over non-zero frequencies mask = ~np.isclose(self.angular_freqs, 0) tf = np.zeros_like(mask, dtype=np.complex) tf[mask] = 1 / (s...
python
def pgv(self, centimeters=False): """Peak-ground velocity [m/sec].""" if self._pgv is None: # Compute transfer function -- only over non-zero frequencies mask = ~np.isclose(self.angular_freqs, 0) tf = np.zeros_like(mask, dtype=np.complex) tf[mask] = 1 / (s...
[ "def", "pgv", "(", "self", ",", "centimeters", "=", "False", ")", ":", "if", "self", ".", "_pgv", "is", "None", ":", "# Compute transfer function -- only over non-zero frequencies", "mask", "=", "~", "np", ".", "isclose", "(", "self", ".", "angular_freqs", ","...
Peak-ground velocity [m/sec].
[ "Peak", "-", "ground", "velocity", "[", "m", "/", "sec", "]", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/motion.py#L58-L69
train
Peak - ground velocity [ m / sec ].
arkottke/pysra
pysra/motion.py
TimeSeriesMotion.calc_osc_accels
def calc_osc_accels(self, osc_freqs, osc_damping=0.05, tf=None): """Compute the pseudo-acceleration spectral response of an oscillator with a specific frequency and damping. Parameters ---------- osc_freq : float Frequency of the oscillator (Hz). osc_damping ...
python
def calc_osc_accels(self, osc_freqs, osc_damping=0.05, tf=None): """Compute the pseudo-acceleration spectral response of an oscillator with a specific frequency and damping. Parameters ---------- osc_freq : float Frequency of the oscillator (Hz). osc_damping ...
[ "def", "calc_osc_accels", "(", "self", ",", "osc_freqs", ",", "osc_damping", "=", "0.05", ",", "tf", "=", "None", ")", ":", "if", "tf", "is", "None", ":", "tf", "=", "np", ".", "ones_like", "(", "self", ".", "freqs", ")", "else", ":", "tf", "=", ...
Compute the pseudo-acceleration spectral response of an oscillator with a specific frequency and damping. Parameters ---------- osc_freq : float Frequency of the oscillator (Hz). osc_damping : float Fractional damping of the oscillator (dec). For example,...
[ "Compute", "the", "pseudo", "-", "acceleration", "spectral", "response", "of", "an", "oscillator", "with", "a", "specific", "frequency", "and", "damping", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/motion.py#L141-L170
train
Compute the pseudo - spectral response of an oscillator with a specific frequency and damping.
arkottke/pysra
pysra/motion.py
TimeSeriesMotion._calc_fourier_spectrum
def _calc_fourier_spectrum(self, fa_length=None): """Compute the Fourier Amplitude Spectrum of the time series.""" if fa_length is None: # Use the next power of 2 for the length n = 1 while n < self.accels.size: n <<= 1 else: n = f...
python
def _calc_fourier_spectrum(self, fa_length=None): """Compute the Fourier Amplitude Spectrum of the time series.""" if fa_length is None: # Use the next power of 2 for the length n = 1 while n < self.accels.size: n <<= 1 else: n = f...
[ "def", "_calc_fourier_spectrum", "(", "self", ",", "fa_length", "=", "None", ")", ":", "if", "fa_length", "is", "None", ":", "# Use the next power of 2 for the length", "n", "=", "1", "while", "n", "<", "self", ".", "accels", ".", "size", ":", "n", "<<=", ...
Compute the Fourier Amplitude Spectrum of the time series.
[ "Compute", "the", "Fourier", "Amplitude", "Spectrum", "of", "the", "time", "series", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/motion.py#L172-L186
train
Compute the Fourier Amplitude Spectrum of the time series.
arkottke/pysra
pysra/motion.py
TimeSeriesMotion._calc_sdof_tf
def _calc_sdof_tf(self, osc_freq, damping=0.05): """Compute the transfer function for a single-degree-of-freedom oscillator. The transfer function computes the pseudo-spectral acceleration. Parameters ---------- osc_freq : float natural frequency of the osci...
python
def _calc_sdof_tf(self, osc_freq, damping=0.05): """Compute the transfer function for a single-degree-of-freedom oscillator. The transfer function computes the pseudo-spectral acceleration. Parameters ---------- osc_freq : float natural frequency of the osci...
[ "def", "_calc_sdof_tf", "(", "self", ",", "osc_freq", ",", "damping", "=", "0.05", ")", ":", "return", "(", "-", "osc_freq", "**", "2.", "/", "(", "np", ".", "square", "(", "self", ".", "freqs", ")", "-", "np", ".", "square", "(", "osc_freq", ")", ...
Compute the transfer function for a single-degree-of-freedom oscillator. The transfer function computes the pseudo-spectral acceleration. Parameters ---------- osc_freq : float natural frequency of the oscillator [Hz] damping : float, optional da...
[ "Compute", "the", "transfer", "function", "for", "a", "single", "-", "degree", "-", "of", "-", "freedom", "oscillator", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/motion.py#L188-L208
train
Compute the pseudo - spectral acceleration for a single - degree - of - freedom entry.
arkottke/pysra
pysra/motion.py
TimeSeriesMotion.load_at2_file
def load_at2_file(cls, filename): """Read an AT2 formatted time series. Parameters ---------- filename: str Filename to open. """ with open(filename) as fp: next(fp) description = next(fp).strip() next(fp) part...
python
def load_at2_file(cls, filename): """Read an AT2 formatted time series. Parameters ---------- filename: str Filename to open. """ with open(filename) as fp: next(fp) description = next(fp).strip() next(fp) part...
[ "def", "load_at2_file", "(", "cls", ",", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "fp", ":", "next", "(", "fp", ")", "description", "=", "next", "(", "fp", ")", ".", "strip", "(", ")", "next", "(", "fp", ")", "parts", "="...
Read an AT2 formatted time series. Parameters ---------- filename: str Filename to open.
[ "Read", "an", "AT2", "formatted", "time", "series", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/motion.py#L211-L229
train
Reads an AT2 formatted time series.
arkottke/pysra
pysra/motion.py
TimeSeriesMotion.load_smc_file
def load_smc_file(cls, filename): """Read an SMC formatted time series. Format of the time series is provided by: https://escweb.wr.usgs.gov/nsmp-data/smcfmt.html Parameters ---------- filename: str Filename to open. """ from .tools impo...
python
def load_smc_file(cls, filename): """Read an SMC formatted time series. Format of the time series is provided by: https://escweb.wr.usgs.gov/nsmp-data/smcfmt.html Parameters ---------- filename: str Filename to open. """ from .tools impo...
[ "def", "load_smc_file", "(", "cls", ",", "filename", ")", ":", "from", ".", "tools", "import", "parse_fixed_width", "with", "open", "(", "filename", ")", "as", "fp", ":", "lines", "=", "list", "(", "fp", ")", "# 11 lines of strings", "lines_str", "=", "[",...
Read an SMC formatted time series. Format of the time series is provided by: https://escweb.wr.usgs.gov/nsmp-data/smcfmt.html Parameters ---------- filename: str Filename to open.
[ "Read", "an", "SMC", "formatted", "time", "series", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/motion.py#L232-L276
train
Read an SMC formatted time series.
SUNCAT-Center/CatHub
cathub/classification.py
SiteClassification.get_info
def get_info(self): """Return surface reconstruction as well as primary and secondary adsorption site labels""" reconstructed = self.is_reconstructed() site, site_type = self.get_site() return reconstructed, site, site_type
python
def get_info(self): """Return surface reconstruction as well as primary and secondary adsorption site labels""" reconstructed = self.is_reconstructed() site, site_type = self.get_site() return reconstructed, site, site_type
[ "def", "get_info", "(", "self", ")", ":", "reconstructed", "=", "self", ".", "is_reconstructed", "(", ")", "site", ",", "site_type", "=", "self", ".", "get_site", "(", ")", "return", "reconstructed", ",", "site", ",", "site_type" ]
Return surface reconstruction as well as primary and secondary adsorption site labels
[ "Return", "surface", "reconstruction", "as", "well", "as", "primary", "and", "secondary", "adsorption", "site", "labels" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/classification.py#L48-L56
train
Return surface reconstruction primary and secondary adsorption site labels
SUNCAT-Center/CatHub
cathub/classification.py
SiteClassification.check_dissociated
def check_dissociated(self, cutoff=1.2): """Check if adsorbate dissociates""" dissociated = False if not len(self.B) > self.nslab + 1: # only one adsorbate return dissociated adsatoms = [atom for atom in self.B[self.nslab:]] ads0, ads1 = set(atom.symbol for atom in ...
python
def check_dissociated(self, cutoff=1.2): """Check if adsorbate dissociates""" dissociated = False if not len(self.B) > self.nslab + 1: # only one adsorbate return dissociated adsatoms = [atom for atom in self.B[self.nslab:]] ads0, ads1 = set(atom.symbol for atom in ...
[ "def", "check_dissociated", "(", "self", ",", "cutoff", "=", "1.2", ")", ":", "dissociated", "=", "False", "if", "not", "len", "(", "self", ".", "B", ")", ">", "self", ".", "nslab", "+", "1", ":", "# only one adsorbate", "return", "dissociated", "adsatom...
Check if adsorbate dissociates
[ "Check", "if", "adsorbate", "dissociates" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/classification.py#L58-L77
train
Check if adsorbate dissociates
SUNCAT-Center/CatHub
cathub/classification.py
SiteClassification.is_reconstructed
def is_reconstructed(self, xy_cutoff=0.3, z_cutoff=0.4): """Compare initial and final slab configuration to determine if slab reconstructs during relaxation xy_cutoff: Allowed xy-movement is determined from the covalent radii as: xy_cutoff * np.mean(cradi...
python
def is_reconstructed(self, xy_cutoff=0.3, z_cutoff=0.4): """Compare initial and final slab configuration to determine if slab reconstructs during relaxation xy_cutoff: Allowed xy-movement is determined from the covalent radii as: xy_cutoff * np.mean(cradi...
[ "def", "is_reconstructed", "(", "self", ",", "xy_cutoff", "=", "0.3", ",", "z_cutoff", "=", "0.4", ")", ":", "assert", "self", ".", "A", ",", "'Initial slab geometry needed to classify reconstruction'", "# remove adsorbate", "A", "=", "self", ".", "A", "[", ":",...
Compare initial and final slab configuration to determine if slab reconstructs during relaxation xy_cutoff: Allowed xy-movement is determined from the covalent radii as: xy_cutoff * np.mean(cradii) z_cutoff: Allowed z-movement is determined as ...
[ "Compare", "initial", "and", "final", "slab", "configuration", "to", "determine", "if", "slab", "reconstructs", "during", "relaxation" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/classification.py#L105-L145
train
Compare initial and final slab configuration to determine if slab reconstructs during relaxation.
SUNCAT-Center/CatHub
cathub/classification.py
SiteClassification.get_site_dict
def get_site_dict(self, ads_pos): """Get dictionary with high symmetry sites close to adsorbate position. Top sites: Optained from the atomic positions of the top layer of the slab. Bridge sites: The average position of atomic pairs Hollow sites: Optained as ...
python
def get_site_dict(self, ads_pos): """Get dictionary with high symmetry sites close to adsorbate position. Top sites: Optained from the atomic positions of the top layer of the slab. Bridge sites: The average position of atomic pairs Hollow sites: Optained as ...
[ "def", "get_site_dict", "(", "self", ",", "ads_pos", ")", ":", "# Get top layer", "C", "=", "self", ".", "B", "[", "-", "self", ".", "ntop", "-", "1", ":", "-", "1", "]", "SC", "=", "C", "*", "(", "3", ",", "3", ",", "1", ")", "D", "=", "{"...
Get dictionary with high symmetry sites close to adsorbate position. Top sites: Optained from the atomic positions of the top layer of the slab. Bridge sites: The average position of atomic pairs Hollow sites: Optained as the Voronoi vertices 4-fold sites: As...
[ "Get", "dictionary", "with", "high", "symmetry", "sites", "close", "to", "adsorbate", "position", ".", "Top", "sites", ":", "Optained", "from", "the", "atomic", "positions", "of", "the", "top", "layer", "of", "the", "slab", ".", "Bridge", "sites", ":", "Th...
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/classification.py#L159-L254
train
Get the dictionary of site names and positions of the top - layer atom.
SUNCAT-Center/CatHub
cathub/classification.py
SiteClassification.get_under_bridge
def get_under_bridge(self): """Return element closest to the adsorbate in the subsurface layer""" C0 = self.B[-1:] * (3, 3, 1) ads_pos = C0.positions[4] C = self.get_subsurface_layer() * (3, 3, 1) dis = self.B.cell[0][0] * 2 ret = None for ele in C: ...
python
def get_under_bridge(self): """Return element closest to the adsorbate in the subsurface layer""" C0 = self.B[-1:] * (3, 3, 1) ads_pos = C0.positions[4] C = self.get_subsurface_layer() * (3, 3, 1) dis = self.B.cell[0][0] * 2 ret = None for ele in C: ...
[ "def", "get_under_bridge", "(", "self", ")", ":", "C0", "=", "self", ".", "B", "[", "-", "1", ":", "]", "*", "(", "3", ",", "3", ",", "1", ")", "ads_pos", "=", "C0", ".", "positions", "[", "4", "]", "C", "=", "self", ".", "get_subsurface_layer"...
Return element closest to the adsorbate in the subsurface layer
[ "Return", "element", "closest", "to", "the", "adsorbate", "in", "the", "subsurface", "layer" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/classification.py#L260-L276
train
Return element closest to the adsorbate in the subsurface layer
SUNCAT-Center/CatHub
cathub/classification.py
SiteClassification.get_under_hollow
def get_under_hollow(self): """ Return HCP if an atom is present below the adsorbate in the subsurface layer and FCC if not""" C0 = self.B[-1:] * (3, 3, 1) ads_pos = C0.positions[4] C = self.get_subsurface_layer() * (3, 3, 1) ret = 'FCC' if np.any([np.linalg.no...
python
def get_under_hollow(self): """ Return HCP if an atom is present below the adsorbate in the subsurface layer and FCC if not""" C0 = self.B[-1:] * (3, 3, 1) ads_pos = C0.positions[4] C = self.get_subsurface_layer() * (3, 3, 1) ret = 'FCC' if np.any([np.linalg.no...
[ "def", "get_under_hollow", "(", "self", ")", ":", "C0", "=", "self", ".", "B", "[", "-", "1", ":", "]", "*", "(", "3", ",", "3", ",", "1", ")", "ads_pos", "=", "C0", ".", "positions", "[", "4", "]", "C", "=", "self", ".", "get_subsurface_layer"...
Return HCP if an atom is present below the adsorbate in the subsurface layer and FCC if not
[ "Return", "HCP", "if", "an", "atom", "is", "present", "below", "the", "adsorbate", "in", "the", "subsurface", "layer", "and", "FCC", "if", "not" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/classification.py#L278-L291
train
Return HCP if an atom is present below the adsorbate in the subsurface layer and FCC if not
SUNCAT-Center/CatHub
cathub/classification.py
SiteClassification.get_site
def get_site(self, plot_voronoi_sites=False): """Return primaty (top, bridge, hollow, 4fold) and secondary (chemical elements in close environment) site designation""" if self.dissociated: return 'dissociated', '' if self.is_desorbed(): return 'desorbed', '' ...
python
def get_site(self, plot_voronoi_sites=False): """Return primaty (top, bridge, hollow, 4fold) and secondary (chemical elements in close environment) site designation""" if self.dissociated: return 'dissociated', '' if self.is_desorbed(): return 'desorbed', '' ...
[ "def", "get_site", "(", "self", ",", "plot_voronoi_sites", "=", "False", ")", ":", "if", "self", ".", "dissociated", ":", "return", "'dissociated'", ",", "''", "if", "self", ".", "is_desorbed", "(", ")", ":", "return", "'desorbed'", ",", "''", "if", "sel...
Return primaty (top, bridge, hollow, 4fold) and secondary (chemical elements in close environment) site designation
[ "Return", "primaty", "(", "top", "bridge", "hollow", "4fold", ")", "and", "secondary", "(", "chemical", "elements", "in", "close", "environment", ")", "site", "designation" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/classification.py#L293-L352
train
Return primaty bridge hollow and subsurface site designation
guaix-ucm/numina
numina/array/distortion.py
compute_distortion
def compute_distortion(x_orig, y_orig, x_rect, y_rect, order, debugplot): """Compute image distortion transformation. This function computes the following 2D transformation: x_orig = sum[i=0:order]( sum[j=0:j]( a_ij * x_rect**(i - j) * y_rect**j )) y_orig = sum[i=0:order]( sum[j=0:j]( b_ij * x_rect**(i...
python
def compute_distortion(x_orig, y_orig, x_rect, y_rect, order, debugplot): """Compute image distortion transformation. This function computes the following 2D transformation: x_orig = sum[i=0:order]( sum[j=0:j]( a_ij * x_rect**(i - j) * y_rect**j )) y_orig = sum[i=0:order]( sum[j=0:j]( b_ij * x_rect**(i...
[ "def", "compute_distortion", "(", "x_orig", ",", "y_orig", ",", "x_rect", ",", "y_rect", ",", "order", ",", "debugplot", ")", ":", "# protections", "npoints", "=", "len", "(", "x_orig", ")", "for", "xdum", "in", "[", "y_orig", ",", "x_rect", ",", "y_rect...
Compute image distortion transformation. This function computes the following 2D transformation: x_orig = sum[i=0:order]( sum[j=0:j]( a_ij * x_rect**(i - j) * y_rect**j )) y_orig = sum[i=0:order]( sum[j=0:j]( b_ij * x_rect**(i - j) * y_rect**j )) Parameters ---------- x_orig : numpy array ...
[ "Compute", "image", "distortion", "transformation", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/distortion.py#L25-L181
train
Compute image distortion transformation.
guaix-ucm/numina
numina/array/distortion.py
fmap
def fmap(order, aij, bij, x, y): """Evaluate the 2D polynomial transformation. u = sum[i=0:order]( sum[j=0:j]( a_ij * x**(i - j) * y**j )) v = sum[i=0:order]( sum[j=0:j]( b_ij * x**(i - j) * y**j )) Parameters ---------- order : int Order of the polynomial transformation. aij : num...
python
def fmap(order, aij, bij, x, y): """Evaluate the 2D polynomial transformation. u = sum[i=0:order]( sum[j=0:j]( a_ij * x**(i - j) * y**j )) v = sum[i=0:order]( sum[j=0:j]( b_ij * x**(i - j) * y**j )) Parameters ---------- order : int Order of the polynomial transformation. aij : num...
[ "def", "fmap", "(", "order", ",", "aij", ",", "bij", ",", "x", ",", "y", ")", ":", "u", "=", "np", ".", "zeros_like", "(", "x", ")", "v", "=", "np", ".", "zeros_like", "(", "y", ")", "k", "=", "0", "for", "i", "in", "range", "(", "order", ...
Evaluate the 2D polynomial transformation. u = sum[i=0:order]( sum[j=0:j]( a_ij * x**(i - j) * y**j )) v = sum[i=0:order]( sum[j=0:j]( b_ij * x**(i - j) * y**j )) Parameters ---------- order : int Order of the polynomial transformation. aij : numpy array Polynomial coefficents ...
[ "Evaluate", "the", "2D", "polynomial", "transformation", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/distortion.py#L184-L224
train
Evaluate the 2D polynomial transformation.
guaix-ucm/numina
numina/array/distortion.py
ncoef_fmap
def ncoef_fmap(order): """Expected number of coefficients in a 2D transformation of a given order. Parameters ---------- order : int Order of the 2D polynomial transformation. Returns ------- ncoef : int Expected number of coefficients. """ ncoef = 0 for i in ...
python
def ncoef_fmap(order): """Expected number of coefficients in a 2D transformation of a given order. Parameters ---------- order : int Order of the 2D polynomial transformation. Returns ------- ncoef : int Expected number of coefficients. """ ncoef = 0 for i in ...
[ "def", "ncoef_fmap", "(", "order", ")", ":", "ncoef", "=", "0", "for", "i", "in", "range", "(", "order", "+", "1", ")", ":", "for", "j", "in", "range", "(", "i", "+", "1", ")", ":", "ncoef", "+=", "1", "return", "ncoef" ]
Expected number of coefficients in a 2D transformation of a given order. Parameters ---------- order : int Order of the 2D polynomial transformation. Returns ------- ncoef : int Expected number of coefficients.
[ "Expected", "number", "of", "coefficients", "in", "a", "2D", "transformation", "of", "a", "given", "order", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/distortion.py#L227-L246
train
Returns the number of coefficients in a 2D polynomial transformation of a given order.
guaix-ucm/numina
numina/array/distortion.py
order_fmap
def order_fmap(ncoef): """Compute order corresponding to a given number of coefficients. Parameters ---------- ncoef : int Number of coefficients. Returns ------- order : int Order corresponding to the provided number of coefficients. """ loop = True order = 1...
python
def order_fmap(ncoef): """Compute order corresponding to a given number of coefficients. Parameters ---------- ncoef : int Number of coefficients. Returns ------- order : int Order corresponding to the provided number of coefficients. """ loop = True order = 1...
[ "def", "order_fmap", "(", "ncoef", ")", ":", "loop", "=", "True", "order", "=", "1", "while", "loop", ":", "loop", "=", "not", "(", "ncoef", "==", "ncoef_fmap", "(", "order", ")", ")", "if", "loop", ":", "order", "+=", "1", "if", "order", ">", "N...
Compute order corresponding to a given number of coefficients. Parameters ---------- ncoef : int Number of coefficients. Returns ------- order : int Order corresponding to the provided number of coefficients.
[ "Compute", "order", "corresponding", "to", "a", "given", "number", "of", "coefficients", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/distortion.py#L249-L274
train
Compute the order corresponding to a given number of coefficients.
guaix-ucm/numina
numina/array/distortion.py
rectify2d
def rectify2d(image2d, aij, bij, resampling, naxis1out=None, naxis2out=None, ioffx=None, ioffy=None, debugplot=0): """Rectify image applying the provided 2D transformation. The rectified image correspond to the transformation given by: u = sum[i=0:order]( sum[j...
python
def rectify2d(image2d, aij, bij, resampling, naxis1out=None, naxis2out=None, ioffx=None, ioffy=None, debugplot=0): """Rectify image applying the provided 2D transformation. The rectified image correspond to the transformation given by: u = sum[i=0:order]( sum[j...
[ "def", "rectify2d", "(", "image2d", ",", "aij", ",", "bij", ",", "resampling", ",", "naxis1out", "=", "None", ",", "naxis2out", "=", "None", ",", "ioffx", "=", "None", ",", "ioffy", "=", "None", ",", "debugplot", "=", "0", ")", ":", "# protections", ...
Rectify image applying the provided 2D transformation. The rectified image correspond to the transformation given by: u = sum[i=0:order]( sum[j=0:j]( a_ij * x**(i - j) * y**j )) v = sum[i=0:order]( sum[j=0:j]( b_ij * x**(i - j) * y**j )) Parameters ---------- image2d : 2d numpy array ...
[ "Rectify", "image", "applying", "the", "provided", "2D", "transformation", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/distortion.py#L277-L393
train
Rectify image applying the provided 2D transformation.
kyzima-spb/flask-pony
flask_pony/views.py
FormMixin.get_success_url
def get_success_url(self, obj=None): """ Args: obj (object): The object whose property values are used to build the URL. Returns: str: The URL to which to go if the form was processed successfully. """ if self.success_endpoint is None: raise A...
python
def get_success_url(self, obj=None): """ Args: obj (object): The object whose property values are used to build the URL. Returns: str: The URL to which to go if the form was processed successfully. """ if self.success_endpoint is None: raise A...
[ "def", "get_success_url", "(", "self", ",", "obj", "=", "None", ")", ":", "if", "self", ".", "success_endpoint", "is", "None", ":", "raise", "AttributeError", "(", "'You must assign the value of the attribute \"success_endpoint\".'", ")", "if", "obj", ":", "kwargs",...
Args: obj (object): The object whose property values are used to build the URL. Returns: str: The URL to which to go if the form was processed successfully.
[ "Args", ":", "obj", "(", "object", ")", ":", "The", "object", "whose", "property", "values", "are", "used", "to", "build", "the", "URL", "." ]
6cf28d70b7ebf415d58fa138fcc70b8dd57432c7
https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/views.py#L53-L69
train
Returns the URL to which the form was processed successfully.
kyzima-spb/flask-pony
flask_pony/views.py
BaseView.get_template_name
def get_template_name(self): """ Returns the name of the template. If the template_name property is not set, the value will be generated automatically based on the class name. Example: >>> class MyEntityAction(BaseView): pass >>> view = MyEntityAction() ...
python
def get_template_name(self): """ Returns the name of the template. If the template_name property is not set, the value will be generated automatically based on the class name. Example: >>> class MyEntityAction(BaseView): pass >>> view = MyEntityAction() ...
[ "def", "get_template_name", "(", "self", ")", ":", "if", "self", ".", "template_name", "is", "None", ":", "name", "=", "camelcase2list", "(", "self", ".", "__class__", ".", "__name__", ")", "name", "=", "'{}/{}.html'", ".", "format", "(", "name", ".", "p...
Returns the name of the template. If the template_name property is not set, the value will be generated automatically based on the class name. Example: >>> class MyEntityAction(BaseView): pass >>> view = MyEntityAction() >>> view.get_template_name() "my_...
[ "Returns", "the", "name", "of", "the", "template", "." ]
6cf28d70b7ebf415d58fa138fcc70b8dd57432c7
https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/views.py#L131-L148
train
Returns the name of the template.
zzyztyy/pyIGRF
pyIGRF/calculate.py
geodetic2geocentric
def geodetic2geocentric(theta, alt): """ Conversion from geodetic to geocentric coordinates by using the WGS84 spheroid. :param theta: colatitude (float, rad) :param alt: altitude (float, km) :return gccolat: geocentric colatitude (float, rad) d: gccolat minus theta (float, rad) ...
python
def geodetic2geocentric(theta, alt): """ Conversion from geodetic to geocentric coordinates by using the WGS84 spheroid. :param theta: colatitude (float, rad) :param alt: altitude (float, km) :return gccolat: geocentric colatitude (float, rad) d: gccolat minus theta (float, rad) ...
[ "def", "geodetic2geocentric", "(", "theta", ",", "alt", ")", ":", "ct", "=", "np", ".", "cos", "(", "theta", ")", "st", "=", "np", ".", "sin", "(", "theta", ")", "a2", "=", "40680631.6", "b2", "=", "40408296.0", "one", "=", "a2", "*", "st", "*", ...
Conversion from geodetic to geocentric coordinates by using the WGS84 spheroid. :param theta: colatitude (float, rad) :param alt: altitude (float, km) :return gccolat: geocentric colatitude (float, rad) d: gccolat minus theta (float, rad) r: geocentric radius (float, km)
[ "Conversion", "from", "geodetic", "to", "geocentric", "coordinates", "by", "using", "the", "WGS84", "spheroid", ".", ":", "param", "theta", ":", "colatitude", "(", "float", "rad", ")", ":", "param", "alt", ":", "altitude", "(", "float", "km", ")", ":", "...
3369ccafec34d18ca2c57f48b867cb2417078866
https://github.com/zzyztyy/pyIGRF/blob/3369ccafec34d18ca2c57f48b867cb2417078866/pyIGRF/calculate.py#L11-L36
train
Converts from geodetic to geocentric coordinates by using WGS84 spheroid.
zzyztyy/pyIGRF
pyIGRF/calculate.py
igrf12syn
def igrf12syn(isv, date, itype, alt, lat, elong): """ This is a synthesis routine for the 12th generation IGRF as agreed in December 2014 by IAGA Working Group V-MOD. It is valid 1900.0 to 2020.0 inclusive. Values for dates from 1945.0 to 2010.0 inclusive are definitive, otherwise they are non-d...
python
def igrf12syn(isv, date, itype, alt, lat, elong): """ This is a synthesis routine for the 12th generation IGRF as agreed in December 2014 by IAGA Working Group V-MOD. It is valid 1900.0 to 2020.0 inclusive. Values for dates from 1945.0 to 2010.0 inclusive are definitive, otherwise they are non-d...
[ "def", "igrf12syn", "(", "isv", ",", "date", ",", "itype", ",", "alt", ",", "lat", ",", "elong", ")", ":", "p", ",", "q", ",", "cl", ",", "sl", "=", "[", "0.", "]", "*", "105", ",", "[", "0.", "]", "*", "105", ",", "[", "0.", "]", "*", ...
This is a synthesis routine for the 12th generation IGRF as agreed in December 2014 by IAGA Working Group V-MOD. It is valid 1900.0 to 2020.0 inclusive. Values for dates from 1945.0 to 2010.0 inclusive are definitive, otherwise they are non-definitive. INPUT isv = 0 if main-field values are req...
[ "This", "is", "a", "synthesis", "routine", "for", "the", "12th", "generation", "IGRF", "as", "agreed", "in", "December", "2014", "by", "IAGA", "Working", "Group", "V", "-", "MOD", ".", "It", "is", "valid", "1900", ".", "0", "to", "2020", ".", "0", "i...
3369ccafec34d18ca2c57f48b867cb2417078866
https://github.com/zzyztyy/pyIGRF/blob/3369ccafec34d18ca2c57f48b867cb2417078866/pyIGRF/calculate.py#L39-L208
train
This routine is used to generate the IGRF for a given isv. It is used to generate the main - field model for the IAGA working group.
pylp/pylp
pylp/lib/stream.py
Stream.append_file
def append_file(self, file): """Append a new file in the stream.""" self.files.append(file) if self.transformer: future = asyncio.ensure_future(self.transformer.transform(file)) future.add_done_callback(self.handle_transform)
python
def append_file(self, file): """Append a new file in the stream.""" self.files.append(file) if self.transformer: future = asyncio.ensure_future(self.transformer.transform(file)) future.add_done_callback(self.handle_transform)
[ "def", "append_file", "(", "self", ",", "file", ")", ":", "self", ".", "files", ".", "append", "(", "file", ")", "if", "self", ".", "transformer", ":", "future", "=", "asyncio", ".", "ensure_future", "(", "self", ".", "transformer", ".", "transform", "...
Append a new file in the stream.
[ "Append", "a", "new", "file", "in", "the", "stream", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/stream.py#L33-L39
train
Append a new file in the stream.
pylp/pylp
pylp/lib/stream.py
Stream.flush_if_ended
def flush_if_ended(self): """Call 'flush' function if all files have been transformed.""" if self.ended and self.next and len(self.files) == self.transformed: future = asyncio.ensure_future(self.transformer.flush()) future.add_done_callback(lambda x: self.next.end_of_stream())
python
def flush_if_ended(self): """Call 'flush' function if all files have been transformed.""" if self.ended and self.next and len(self.files) == self.transformed: future = asyncio.ensure_future(self.transformer.flush()) future.add_done_callback(lambda x: self.next.end_of_stream())
[ "def", "flush_if_ended", "(", "self", ")", ":", "if", "self", ".", "ended", "and", "self", ".", "next", "and", "len", "(", "self", ".", "files", ")", "==", "self", ".", "transformed", ":", "future", "=", "asyncio", ".", "ensure_future", "(", "self", ...
Call 'flush' function if all files have been transformed.
[ "Call", "flush", "function", "if", "all", "files", "have", "been", "transformed", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/stream.py#L42-L46
train
Call flush function if all files have been transformed.
pylp/pylp
pylp/lib/stream.py
Stream.handle_transform
def handle_transform(self, task): """Handle a 'transform' callback.""" self.transformed += 1 file = task.result() if file: self.next.append_file(file) self.flush_if_ended()
python
def handle_transform(self, task): """Handle a 'transform' callback.""" self.transformed += 1 file = task.result() if file: self.next.append_file(file) self.flush_if_ended()
[ "def", "handle_transform", "(", "self", ",", "task", ")", ":", "self", ".", "transformed", "+=", "1", "file", "=", "task", ".", "result", "(", ")", "if", "file", ":", "self", ".", "next", ".", "append_file", "(", "file", ")", "self", ".", "flush_if_e...
Handle a 'transform' callback.
[ "Handle", "a", "transform", "callback", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/stream.py#L49-L57
train
Handle a transform callback.
pylp/pylp
pylp/lib/stream.py
Stream.pipe
def pipe(self, transformer): """Pipe this stream to another.""" if self.next: return stream = Stream() self.next = stream stream.prev = self self.transformer = transformer transformer.stream = self transformer.piped() for file in self.files: future = asyncio.ensure_future(self.transformer.tra...
python
def pipe(self, transformer): """Pipe this stream to another.""" if self.next: return stream = Stream() self.next = stream stream.prev = self self.transformer = transformer transformer.stream = self transformer.piped() for file in self.files: future = asyncio.ensure_future(self.transformer.tra...
[ "def", "pipe", "(", "self", ",", "transformer", ")", ":", "if", "self", ".", "next", ":", "return", "stream", "=", "Stream", "(", ")", "self", ".", "next", "=", "stream", "stream", ".", "prev", "=", "self", "self", ".", "transformer", "=", "transform...
Pipe this stream to another.
[ "Pipe", "this", "stream", "to", "another", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/stream.py#L66-L86
train
Pipe this stream to another.
pylp/pylp
pylp/utils/pipes.py
pipes
def pipes(stream, *transformers): """Pipe several transformers end to end.""" for transformer in transformers: stream = stream.pipe(transformer) return stream
python
def pipes(stream, *transformers): """Pipe several transformers end to end.""" for transformer in transformers: stream = stream.pipe(transformer) return stream
[ "def", "pipes", "(", "stream", ",", "*", "transformers", ")", ":", "for", "transformer", "in", "transformers", ":", "stream", "=", "stream", ".", "pipe", "(", "transformer", ")", "return", "stream" ]
Pipe several transformers end to end.
[ "Pipe", "several", "transformers", "end", "to", "end", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/utils/pipes.py#L11-L15
train
Pipe several transformers end to end.
guaix-ucm/numina
numina/core/dataholders.py
Parameter.convert
def convert(self, val): """Convert input values to type values.""" pre = super(Parameter, self).convert(val) if self.custom_validator is not None: post = self.custom_validator(pre) else: post = pre return post
python
def convert(self, val): """Convert input values to type values.""" pre = super(Parameter, self).convert(val) if self.custom_validator is not None: post = self.custom_validator(pre) else: post = pre return post
[ "def", "convert", "(", "self", ",", "val", ")", ":", "pre", "=", "super", "(", "Parameter", ",", "self", ")", ".", "convert", "(", "val", ")", "if", "self", ".", "custom_validator", "is", "not", "None", ":", "post", "=", "self", ".", "custom_validato...
Convert input values to type values.
[ "Convert", "input", "values", "to", "type", "values", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/dataholders.py#L342-L350
train
Convert input values to type values.
guaix-ucm/numina
numina/core/dataholders.py
Parameter.validate
def validate(self, val): """Validate values according to the requirement""" if self.validation: self.type.validate(val) if self.custom_validator is not None: self.custom_validator(val) return True
python
def validate(self, val): """Validate values according to the requirement""" if self.validation: self.type.validate(val) if self.custom_validator is not None: self.custom_validator(val) return True
[ "def", "validate", "(", "self", ",", "val", ")", ":", "if", "self", ".", "validation", ":", "self", ".", "type", ".", "validate", "(", "val", ")", "if", "self", ".", "custom_validator", "is", "not", "None", ":", "self", ".", "custom_validator", "(", ...
Validate values according to the requirement
[ "Validate", "values", "according", "to", "the", "requirement" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/dataholders.py#L352-L360
train
Validate the values according to the requirement
kyzima-spb/flask-pony
flask_pony/decorators.py
route
def route(obj, rule, *args, **kwargs): """Decorator for the View classes.""" def decorator(cls): endpoint = kwargs.get('endpoint', camel_to_snake(cls.__name__)) kwargs['view_func'] = cls.as_view(endpoint) obj.add_url_rule(rule, *args, **kwargs) return cls return decorator
python
def route(obj, rule, *args, **kwargs): """Decorator for the View classes.""" def decorator(cls): endpoint = kwargs.get('endpoint', camel_to_snake(cls.__name__)) kwargs['view_func'] = cls.as_view(endpoint) obj.add_url_rule(rule, *args, **kwargs) return cls return decorator
[ "def", "route", "(", "obj", ",", "rule", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "cls", ")", ":", "endpoint", "=", "kwargs", ".", "get", "(", "'endpoint'", ",", "camel_to_snake", "(", "cls", ".", "__name__", ")...
Decorator for the View classes.
[ "Decorator", "for", "the", "View", "classes", "." ]
6cf28d70b7ebf415d58fa138fcc70b8dd57432c7
https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/decorators.py#L20-L27
train
Decorator for the View classes.
arkottke/pysra
pysra/propagation.py
QuarterWaveLenCalculator.fit
def fit(self, target_type, target, adjust_thickness=False, adjust_site_atten=False, adjust_source_vel=False): """ Fit to a target crustal amplification or site term. The fitting process adjusts the velocity, site attenuation, and layer...
python
def fit(self, target_type, target, adjust_thickness=False, adjust_site_atten=False, adjust_source_vel=False): """ Fit to a target crustal amplification or site term. The fitting process adjusts the velocity, site attenuation, and layer...
[ "def", "fit", "(", "self", ",", "target_type", ",", "target", ",", "adjust_thickness", "=", "False", ",", "adjust_site_atten", "=", "False", ",", "adjust_source_vel", "=", "False", ")", ":", "density", "=", "self", ".", "profile", ".", "density", "nl", "="...
Fit to a target crustal amplification or site term. The fitting process adjusts the velocity, site attenuation, and layer thickness (if enabled) to fit a target values. The frequency range is specified by the input motion. Parameters ---------- target_type: str ...
[ "Fit", "to", "a", "target", "crustal", "amplification", "or", "site", "term", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L153-L247
train
Fit the crustal amplification or site term to a target value.
arkottke/pysra
pysra/propagation.py
LinearElasticCalculator._calc_waves
def _calc_waves(self, angular_freqs, profile): """Compute the wave numbers and amplitudes (up- and down-going). Parameters ---------- angular_freqs: :class:`numpy.ndarray` Angular frequency at which the waves are computed. profile: :class:`~.base.site.Profile` ...
python
def _calc_waves(self, angular_freqs, profile): """Compute the wave numbers and amplitudes (up- and down-going). Parameters ---------- angular_freqs: :class:`numpy.ndarray` Angular frequency at which the waves are computed. profile: :class:`~.base.site.Profile` ...
[ "def", "_calc_waves", "(", "self", ",", "angular_freqs", ",", "profile", ")", ":", "# Compute the complex wave numbers of the system", "wave_nums", "=", "np", ".", "empty", "(", "(", "len", "(", "profile", ")", ",", "len", "(", "angular_freqs", ")", ")", ",", ...
Compute the wave numbers and amplitudes (up- and down-going). Parameters ---------- angular_freqs: :class:`numpy.ndarray` Angular frequency at which the waves are computed. profile: :class:`~.base.site.Profile` Site profile.
[ "Compute", "the", "wave", "numbers", "and", "amplitudes", "(", "up", "-", "and", "down", "-", "going", ")", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L284-L338
train
Compute the wave numbers and amplitudes of the system and the waves.
arkottke/pysra
pysra/propagation.py
LinearElasticCalculator.wave_at_location
def wave_at_location(self, l): """Compute the wave field at specific location. Parameters ---------- l : site.Location :class:`site.Location` of the input Returns ------- `np.ndarray` Amplitude and phase of waves """ cterm...
python
def wave_at_location(self, l): """Compute the wave field at specific location. Parameters ---------- l : site.Location :class:`site.Location` of the input Returns ------- `np.ndarray` Amplitude and phase of waves """ cterm...
[ "def", "wave_at_location", "(", "self", ",", "l", ")", ":", "cterm", "=", "1j", "*", "self", ".", "_wave_nums", "[", "l", ".", "index", "]", "*", "l", ".", "depth_within", "if", "l", ".", "wave_field", "==", "WaveField", ".", "within", ":", "return",...
Compute the wave field at specific location. Parameters ---------- l : site.Location :class:`site.Location` of the input Returns ------- `np.ndarray` Amplitude and phase of waves
[ "Compute", "the", "wave", "field", "at", "specific", "location", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L340-L363
train
Compute the wave field at specific location.
arkottke/pysra
pysra/propagation.py
LinearElasticCalculator.calc_accel_tf
def calc_accel_tf(self, lin, lout): """Compute the acceleration transfer function. Parameters ---------- lin : :class:`~site.Location` Location of input lout : :class:`~site.Location` Location of output. Note that this would typically be midheight ...
python
def calc_accel_tf(self, lin, lout): """Compute the acceleration transfer function. Parameters ---------- lin : :class:`~site.Location` Location of input lout : :class:`~site.Location` Location of output. Note that this would typically be midheight ...
[ "def", "calc_accel_tf", "(", "self", ",", "lin", ",", "lout", ")", ":", "tf", "=", "self", ".", "wave_at_location", "(", "lout", ")", "/", "self", ".", "wave_at_location", "(", "lin", ")", "return", "tf" ]
Compute the acceleration transfer function. Parameters ---------- lin : :class:`~site.Location` Location of input lout : :class:`~site.Location` Location of output. Note that this would typically be midheight of the layer.
[ "Compute", "the", "acceleration", "transfer", "function", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L365-L378
train
Compute the acceleration transfer function.
arkottke/pysra
pysra/propagation.py
LinearElasticCalculator.calc_stress_tf
def calc_stress_tf(self, lin, lout, damped): """Compute the stress transfer function. Parameters ---------- lin : :class:`~site.Location` Location of input lout : :class:`~site.Location` Location of output. Note that this would typically be midheight ...
python
def calc_stress_tf(self, lin, lout, damped): """Compute the stress transfer function. Parameters ---------- lin : :class:`~site.Location` Location of input lout : :class:`~site.Location` Location of output. Note that this would typically be midheight ...
[ "def", "calc_stress_tf", "(", "self", ",", "lin", ",", "lout", ",", "damped", ")", ":", "tf", "=", "self", ".", "calc_strain_tf", "(", "lin", ",", "lout", ")", "if", "damped", ":", "# Scale by complex shear modulus to include the influence of", "# damping", "tf"...
Compute the stress transfer function. Parameters ---------- lin : :class:`~site.Location` Location of input lout : :class:`~site.Location` Location of output. Note that this would typically be midheight of the layer.
[ "Compute", "the", "stress", "transfer", "function", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L380-L400
train
Compute the stress transfer function.
arkottke/pysra
pysra/propagation.py
LinearElasticCalculator.calc_strain_tf
def calc_strain_tf(self, lin, lout): """Compute the strain transfer function from `lout` to `location_in`. The strain transfer function from the acceleration at layer `n` (outcrop) to the mid-height of layer `m` (within) is defined as Parameters ---------- lin :...
python
def calc_strain_tf(self, lin, lout): """Compute the strain transfer function from `lout` to `location_in`. The strain transfer function from the acceleration at layer `n` (outcrop) to the mid-height of layer `m` (within) is defined as Parameters ---------- lin :...
[ "def", "calc_strain_tf", "(", "self", ",", "lin", ",", "lout", ")", ":", "# FIXME: Correct discussion for using acceleration FAS", "# Strain(angFreq, z=h_m/2)", "# ------------------------ =", "# accel_n(angFreq)", "#", "# i k*_m [ A_m exp(i k*_m h_m / 2) - B_m exp(-i k*_m ...
Compute the strain transfer function from `lout` to `location_in`. The strain transfer function from the acceleration at layer `n` (outcrop) to the mid-height of layer `m` (within) is defined as Parameters ---------- lin : :class:`~site.Location` Location of...
[ "Compute", "the", "strain", "transfer", "function", "from", "lout", "to", "location_in", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L402-L448
train
Compute the strain transfer function from the acceleration at location lin to mid - height of layer m.
arkottke/pysra
pysra/propagation.py
EquivalentLinearCalculator._estimate_strains
def _estimate_strains(self): """Compute an estimate of the strains.""" # Estimate the strain based on the PGV and shear-wave velocity for l in self._profile: l.reset() l.strain = self._motion.pgv / l.initial_shear_vel
python
def _estimate_strains(self): """Compute an estimate of the strains.""" # Estimate the strain based on the PGV and shear-wave velocity for l in self._profile: l.reset() l.strain = self._motion.pgv / l.initial_shear_vel
[ "def", "_estimate_strains", "(", "self", ")", ":", "# Estimate the strain based on the PGV and shear-wave velocity", "for", "l", "in", "self", ".", "_profile", ":", "l", ".", "reset", "(", ")", "l", ".", "strain", "=", "self", ".", "_motion", ".", "pgv", "/", ...
Compute an estimate of the strains.
[ "Compute", "an", "estimate", "of", "the", "strains", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L514-L519
train
Compute an estimate of the strains.
arkottke/pysra
pysra/propagation.py
EquivalentLinearCalculator._calc_strain
def _calc_strain(self, loc_input, loc_layer, motion, *args): """Compute the strain used for iterations of material properties.""" strain_max = self._calc_strain_max(loc_input, loc_layer, motion, *args) return self.strain_ratio * strain_max
python
def _calc_strain(self, loc_input, loc_layer, motion, *args): """Compute the strain used for iterations of material properties.""" strain_max = self._calc_strain_max(loc_input, loc_layer, motion, *args) return self.strain_ratio * strain_max
[ "def", "_calc_strain", "(", "self", ",", "loc_input", ",", "loc_layer", ",", "motion", ",", "*", "args", ")", ":", "strain_max", "=", "self", ".", "_calc_strain_max", "(", "loc_input", ",", "loc_layer", ",", "motion", ",", "*", "args", ")", "return", "se...
Compute the strain used for iterations of material properties.
[ "Compute", "the", "strain", "used", "for", "iterations", "of", "material", "properties", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L557-L560
train
Compute the strain used for iterations of material properties.
arkottke/pysra
pysra/propagation.py
EquivalentLinearCalculator._calc_strain_max
def _calc_strain_max(self, loc_input, loc_layer, motion, *args): """Compute the effective strain at the center of a layer.""" return motion.calc_peak( self.calc_strain_tf(loc_input, loc_layer))
python
def _calc_strain_max(self, loc_input, loc_layer, motion, *args): """Compute the effective strain at the center of a layer.""" return motion.calc_peak( self.calc_strain_tf(loc_input, loc_layer))
[ "def", "_calc_strain_max", "(", "self", ",", "loc_input", ",", "loc_layer", ",", "motion", ",", "*", "args", ")", ":", "return", "motion", ".", "calc_peak", "(", "self", ".", "calc_strain_tf", "(", "loc_input", ",", "loc_layer", ")", ")" ]
Compute the effective strain at the center of a layer.
[ "Compute", "the", "effective", "strain", "at", "the", "center", "of", "a", "layer", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L562-L565
train
Compute the effective strain at the center of a layer.
arkottke/pysra
pysra/propagation.py
FrequencyDependentEqlCalculator._estimate_strains
def _estimate_strains(self): """Estimate the strains by running an EQL site response. This step was recommended in Section 8.3.1 of Zalachoris (2014). """ eql = EquivalentLinearCalculator() eql(self._motion, self._profile, self._loc_input)
python
def _estimate_strains(self): """Estimate the strains by running an EQL site response. This step was recommended in Section 8.3.1 of Zalachoris (2014). """ eql = EquivalentLinearCalculator() eql(self._motion, self._profile, self._loc_input)
[ "def", "_estimate_strains", "(", "self", ")", ":", "eql", "=", "EquivalentLinearCalculator", "(", ")", "eql", "(", "self", ".", "_motion", ",", "self", ".", "_profile", ",", "self", ".", "_loc_input", ")" ]
Estimate the strains by running an EQL site response. This step was recommended in Section 8.3.1 of Zalachoris (2014).
[ "Estimate", "the", "strains", "by", "running", "an", "EQL", "site", "response", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L606-L612
train
Estimate the strains by running an EQL site response.
guaix-ucm/numina
numina/core/recipes.py
timeit
def timeit(method): """Decorator to measure the time used by the recipe""" import datetime @functools.wraps(method) def timed_method(self, rinput): time_start = datetime.datetime.utcnow() result = method(self, rinput) time_end = datetime.datetime.utcnow() result.time_i...
python
def timeit(method): """Decorator to measure the time used by the recipe""" import datetime @functools.wraps(method) def timed_method(self, rinput): time_start = datetime.datetime.utcnow() result = method(self, rinput) time_end = datetime.datetime.utcnow() result.time_i...
[ "def", "timeit", "(", "method", ")", ":", "import", "datetime", "@", "functools", ".", "wraps", "(", "method", ")", "def", "timed_method", "(", "self", ",", "rinput", ")", ":", "time_start", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "r...
Decorator to measure the time used by the recipe
[ "Decorator", "to", "measure", "the", "time", "used", "by", "the", "recipe" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/recipes.py#L261-L276
train
Decorator to measure the time used by the recipe
guaix-ucm/numina
numina/core/recipes.py
BaseRecipe.save_intermediate_img
def save_intermediate_img(self, img, name): """Save intermediate FITS objects.""" if self.intermediate_results: img.writeto(name, overwrite=True)
python
def save_intermediate_img(self, img, name): """Save intermediate FITS objects.""" if self.intermediate_results: img.writeto(name, overwrite=True)
[ "def", "save_intermediate_img", "(", "self", ",", "img", ",", "name", ")", ":", "if", "self", ".", "intermediate_results", ":", "img", ".", "writeto", "(", "name", ",", "overwrite", "=", "True", ")" ]
Save intermediate FITS objects.
[ "Save", "intermediate", "FITS", "objects", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/recipes.py#L161-L164
train
Save intermediate FITS objects.
guaix-ucm/numina
numina/core/recipes.py
BaseRecipe.save_intermediate_array
def save_intermediate_array(self, array, name): """Save intermediate array object as FITS.""" if self.intermediate_results: fits.writeto(name, array, overwrite=True)
python
def save_intermediate_array(self, array, name): """Save intermediate array object as FITS.""" if self.intermediate_results: fits.writeto(name, array, overwrite=True)
[ "def", "save_intermediate_array", "(", "self", ",", "array", ",", "name", ")", ":", "if", "self", ".", "intermediate_results", ":", "fits", ".", "writeto", "(", "name", ",", "array", ",", "overwrite", "=", "True", ")" ]
Save intermediate array object as FITS.
[ "Save", "intermediate", "array", "object", "as", "FITS", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/recipes.py#L166-L169
train
Save intermediate array object as FITS.
guaix-ucm/numina
numina/core/recipes.py
BaseRecipe.set_base_headers
def set_base_headers(self, hdr): """Set metadata in FITS headers.""" hdr['NUMXVER'] = (__version__, 'Numina package version') hdr['NUMRNAM'] = (self.__class__.__name__, 'Numina recipe name') hdr['NUMRVER'] = (self.__version__, 'Numina recipe version') return hdr
python
def set_base_headers(self, hdr): """Set metadata in FITS headers.""" hdr['NUMXVER'] = (__version__, 'Numina package version') hdr['NUMRNAM'] = (self.__class__.__name__, 'Numina recipe name') hdr['NUMRVER'] = (self.__version__, 'Numina recipe version') return hdr
[ "def", "set_base_headers", "(", "self", ",", "hdr", ")", ":", "hdr", "[", "'NUMXVER'", "]", "=", "(", "__version__", ",", "'Numina package version'", ")", "hdr", "[", "'NUMRNAM'", "]", "=", "(", "self", ".", "__class__", ".", "__name__", ",", "'Numina reci...
Set metadata in FITS headers.
[ "Set", "metadata", "in", "FITS", "headers", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/recipes.py#L183-L188
train
Set metadata in FITS headers.
guaix-ucm/numina
numina/core/recipes.py
BaseRecipe.build_recipe_input
def build_recipe_input(self, ob, dal): """Build a RecipeInput object.""" result = {} # We have to decide if the ob input # is a plain description (ObservingBlock) # or if it contains the nested results (Obsres) # # it has to contain the tags corresponding to the ...
python
def build_recipe_input(self, ob, dal): """Build a RecipeInput object.""" result = {} # We have to decide if the ob input # is a plain description (ObservingBlock) # or if it contains the nested results (Obsres) # # it has to contain the tags corresponding to the ...
[ "def", "build_recipe_input", "(", "self", ",", "ob", ",", "dal", ")", ":", "result", "=", "{", "}", "# We have to decide if the ob input", "# is a plain description (ObservingBlock)", "# or if it contains the nested results (Obsres)", "#", "# it has to contain the tags correspond...
Build a RecipeInput object.
[ "Build", "a", "RecipeInput", "object", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/recipes.py#L190-L255
train
Build a RecipeInput object.
guaix-ucm/numina
numina/tools/subsets_of_fileinfo_from_txt.py
subsets_of_fileinfo_from_txt
def subsets_of_fileinfo_from_txt(filename): """Returns a dictionary with subsets of FileInfo instances from a TXT file. Each subset of files must be preceded by a line: @ <number> <label> where <number> indicates the number of files in that subset, and <label> is a label for that subset. Any additi...
python
def subsets_of_fileinfo_from_txt(filename): """Returns a dictionary with subsets of FileInfo instances from a TXT file. Each subset of files must be preceded by a line: @ <number> <label> where <number> indicates the number of files in that subset, and <label> is a label for that subset. Any additi...
[ "def", "subsets_of_fileinfo_from_txt", "(", "filename", ")", ":", "# check for input file", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "raise", "ValueError", "(", "\"File \"", "+", "filename", "+", "\" not found!\"", ")", "# read i...
Returns a dictionary with subsets of FileInfo instances from a TXT file. Each subset of files must be preceded by a line: @ <number> <label> where <number> indicates the number of files in that subset, and <label> is a label for that subset. Any additional text beyond <label> in the same line is ig...
[ "Returns", "a", "dictionary", "with", "subsets", "of", "FileInfo", "instances", "from", "a", "TXT", "file", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/tools/subsets_of_fileinfo_from_txt.py#L10-L95
train
Returns a dictionary with subsets of FileInfo instances from a TXT file.
guaix-ucm/numina
numina/array/__init__.py
subarray_match
def subarray_match(shape, ref, sshape, sref=None): """Compute the slice representation of intersection of two arrays. Given the shapes of two arrays and a reference point ref, compute the intersection of the two arrays. It returns a tuple of slices, that can be passed to the two \ images as indexes...
python
def subarray_match(shape, ref, sshape, sref=None): """Compute the slice representation of intersection of two arrays. Given the shapes of two arrays and a reference point ref, compute the intersection of the two arrays. It returns a tuple of slices, that can be passed to the two \ images as indexes...
[ "def", "subarray_match", "(", "shape", ",", "ref", ",", "sshape", ",", "sref", "=", "None", ")", ":", "# Reference point in im", "ref1", "=", "asarray", "(", "ref", ",", "dtype", "=", "'int'", ")", "if", "sref", "is", "not", "None", ":", "ref2", "=", ...
Compute the slice representation of intersection of two arrays. Given the shapes of two arrays and a reference point ref, compute the intersection of the two arrays. It returns a tuple of slices, that can be passed to the two \ images as indexes :param shape: the shape of the reference array :...
[ "Compute", "the", "slice", "representation", "of", "intersection", "of", "two", "arrays", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/__init__.py#L21-L74
train
Compute the slice representation of intersection of two arrays and a reference point ref.
guaix-ucm/numina
numina/array/__init__.py
rebin_scale
def rebin_scale(a, scale=1): """Scale an array to a new shape.""" newshape = tuple((side * scale) for side in a.shape) return rebin(a, newshape)
python
def rebin_scale(a, scale=1): """Scale an array to a new shape.""" newshape = tuple((side * scale) for side in a.shape) return rebin(a, newshape)
[ "def", "rebin_scale", "(", "a", ",", "scale", "=", "1", ")", ":", "newshape", "=", "tuple", "(", "(", "side", "*", "scale", ")", "for", "side", "in", "a", ".", "shape", ")", "return", "rebin", "(", "a", ",", "newshape", ")" ]
Scale an array to a new shape.
[ "Scale", "an", "array", "to", "a", "new", "shape", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/__init__.py#L171-L176
train
Scale an array to a new shape.
guaix-ucm/numina
numina/array/__init__.py
rebin
def rebin(a, newshape): """Rebin an array to a new shape.""" slices = [slice(0, old, float(old)/new) for old, new in zip(a.shape, newshape)] coordinates = numpy.mgrid[slices] # choose the biggest smaller integer index indices = coordinates.astype('i') return a[tuple(indices)]
python
def rebin(a, newshape): """Rebin an array to a new shape.""" slices = [slice(0, old, float(old)/new) for old, new in zip(a.shape, newshape)] coordinates = numpy.mgrid[slices] # choose the biggest smaller integer index indices = coordinates.astype('i') return a[tuple(indices)]
[ "def", "rebin", "(", "a", ",", "newshape", ")", ":", "slices", "=", "[", "slice", "(", "0", ",", "old", ",", "float", "(", "old", ")", "/", "new", ")", "for", "old", ",", "new", "in", "zip", "(", "a", ".", "shape", ",", "newshape", ")", "]", ...
Rebin an array to a new shape.
[ "Rebin", "an", "array", "to", "a", "new", "shape", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/__init__.py#L179-L187
train
Rebin an array to a new shape.
guaix-ucm/numina
numina/array/__init__.py
fixpix
def fixpix(data, mask, kind='linear'): """Interpolate 2D array data in rows""" if data.shape != mask.shape: raise ValueError if not numpy.any(mask): return data x = numpy.arange(0, data.shape[0]) for row, mrow in zip(data, mask): if numpy.any(mrow): # Interpolate if there'...
python
def fixpix(data, mask, kind='linear'): """Interpolate 2D array data in rows""" if data.shape != mask.shape: raise ValueError if not numpy.any(mask): return data x = numpy.arange(0, data.shape[0]) for row, mrow in zip(data, mask): if numpy.any(mrow): # Interpolate if there'...
[ "def", "fixpix", "(", "data", ",", "mask", ",", "kind", "=", "'linear'", ")", ":", "if", "data", ".", "shape", "!=", "mask", ".", "shape", ":", "raise", "ValueError", "if", "not", "numpy", ".", "any", "(", "mask", ")", ":", "return", "data", "x", ...
Interpolate 2D array data in rows
[ "Interpolate", "2D", "array", "data", "in", "rows" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/__init__.py#L190-L205
train
Interpolate 2D array data in rows
guaix-ucm/numina
numina/array/__init__.py
fixpix2
def fixpix2(data, mask, iterations=3, out=None): """Substitute pixels in mask by a bilinear least square fitting. """ out = out if out is not None else data.copy() # A binary mask, regions are ones binry = mask != 0 # Label regions in the binary mask lblarr, labl = ndimage.label(binry) ...
python
def fixpix2(data, mask, iterations=3, out=None): """Substitute pixels in mask by a bilinear least square fitting. """ out = out if out is not None else data.copy() # A binary mask, regions are ones binry = mask != 0 # Label regions in the binary mask lblarr, labl = ndimage.label(binry) ...
[ "def", "fixpix2", "(", "data", ",", "mask", ",", "iterations", "=", "3", ",", "out", "=", "None", ")", ":", "out", "=", "out", "if", "out", "is", "not", "None", "else", "data", ".", "copy", "(", ")", "# A binary mask, regions are ones", "binry", "=", ...
Substitute pixels in mask by a bilinear least square fitting.
[ "Substitute", "pixels", "in", "mask", "by", "a", "bilinear", "least", "square", "fitting", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/__init__.py#L208-L247
train
Substitute pixels in mask by a bilinear least square fitting.
guaix-ucm/numina
numina/array/__init__.py
numberarray
def numberarray(x, shape): """Return x if it is an array or create an array and fill it with x.""" try: iter(x) except TypeError: return numpy.ones(shape) * x else: return x
python
def numberarray(x, shape): """Return x if it is an array or create an array and fill it with x.""" try: iter(x) except TypeError: return numpy.ones(shape) * x else: return x
[ "def", "numberarray", "(", "x", ",", "shape", ")", ":", "try", ":", "iter", "(", "x", ")", "except", "TypeError", ":", "return", "numpy", ".", "ones", "(", "shape", ")", "*", "x", "else", ":", "return", "x" ]
Return x if it is an array or create an array and fill it with x.
[ "Return", "x", "if", "it", "is", "an", "array", "or", "create", "an", "array", "and", "fill", "it", "with", "x", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/__init__.py#L291-L298
train
Return x if it is an array or create an array and fill it with x.
druids/django-chamber
chamber/multidomains/auth/middleware.py
get_token
def get_token(request): """ Returns the token model instance associated with the given request token key. If no user is retrieved AnonymousToken is returned. """ if (not request.META.get(header_name_to_django(auth_token_settings.HEADER_NAME)) and config.CHAMBER_MULTIDOMAINS_OVERTAKER_AUT...
python
def get_token(request): """ Returns the token model instance associated with the given request token key. If no user is retrieved AnonymousToken is returned. """ if (not request.META.get(header_name_to_django(auth_token_settings.HEADER_NAME)) and config.CHAMBER_MULTIDOMAINS_OVERTAKER_AUT...
[ "def", "get_token", "(", "request", ")", ":", "if", "(", "not", "request", ".", "META", ".", "get", "(", "header_name_to_django", "(", "auth_token_settings", ".", "HEADER_NAME", ")", ")", "and", "config", ".", "CHAMBER_MULTIDOMAINS_OVERTAKER_AUTH_COOKIE_NAME", ")"...
Returns the token model instance associated with the given request token key. If no user is retrieved AnonymousToken is returned.
[ "Returns", "the", "token", "model", "instance", "associated", "with", "the", "given", "request", "token", "key", ".", "If", "no", "user", "is", "retrieved", "AnonymousToken", "is", "returned", "." ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/multidomains/auth/middleware.py#L13-L25
train
Returns the token model instance associated with the given request token key.
druids/django-chamber
chamber/multidomains/auth/middleware.py
MultiDomainsTokenAuthenticationMiddleware.process_request
def process_request(self, request): """ Lazy set user and token """ request.token = get_token(request) request.user = SimpleLazyObject(lambda: get_user(request)) request._dont_enforce_csrf_checks = dont_enforce_csrf_checks(request)
python
def process_request(self, request): """ Lazy set user and token """ request.token = get_token(request) request.user = SimpleLazyObject(lambda: get_user(request)) request._dont_enforce_csrf_checks = dont_enforce_csrf_checks(request)
[ "def", "process_request", "(", "self", ",", "request", ")", ":", "request", ".", "token", "=", "get_token", "(", "request", ")", "request", ".", "user", "=", "SimpleLazyObject", "(", "lambda", ":", "get_user", "(", "request", ")", ")", "request", ".", "_...
Lazy set user and token
[ "Lazy", "set", "user", "and", "token" ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/multidomains/auth/middleware.py#L30-L36
train
Lazy set user and token and dont_enforce_csrf_checks
guaix-ucm/numina
numina/array/display/ximplotxy.py
ximplotxy_jupyter
def ximplotxy_jupyter(x, y, fmt=None, **args): """Auxiliary function to call ximplotxy from a jupyter notebook. """ using_jupyter = True if fmt is None: return ximplotxy(x, y, using_jupyter=using_jupyter, **args) else: return ximplotxy(x, y, fmt, using_jupyter=using_jupyter, **args)
python
def ximplotxy_jupyter(x, y, fmt=None, **args): """Auxiliary function to call ximplotxy from a jupyter notebook. """ using_jupyter = True if fmt is None: return ximplotxy(x, y, using_jupyter=using_jupyter, **args) else: return ximplotxy(x, y, fmt, using_jupyter=using_jupyter, **args)
[ "def", "ximplotxy_jupyter", "(", "x", ",", "y", ",", "fmt", "=", "None", ",", "*", "*", "args", ")", ":", "using_jupyter", "=", "True", "if", "fmt", "is", "None", ":", "return", "ximplotxy", "(", "x", ",", "y", ",", "using_jupyter", "=", "using_jupyt...
Auxiliary function to call ximplotxy from a jupyter notebook.
[ "Auxiliary", "function", "to", "call", "ximplotxy", "from", "a", "jupyter", "notebook", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/ximplotxy.py#L20-L27
train
Auxiliary function to call ximplotxy from a jupyter notebook.
guaix-ucm/numina
numina/array/display/ximplotxy.py
ximplotxy
def ximplotxy(x, y, fmt=None, plottype=None, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, show=True, geometry=(0, 0, 640, 480), tight_layout=True, debugplot=0, using_jupyter=False, **kwargs): """ Parameters ---------- ...
python
def ximplotxy(x, y, fmt=None, plottype=None, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, show=True, geometry=(0, 0, 640, 480), tight_layout=True, debugplot=0, using_jupyter=False, **kwargs): """ Parameters ---------- ...
[ "def", "ximplotxy", "(", "x", ",", "y", ",", "fmt", "=", "None", ",", "plottype", "=", "None", ",", "xlim", "=", "None", ",", "ylim", "=", "None", ",", "xlabel", "=", "None", ",", "ylabel", "=", "None", ",", "title", "=", "None", ",", "show", "...
Parameters ---------- x : 1d numpy array, float Array containing the X coordinate. y : 1d numpy array, float Array containing the Y coordinate. fmt : str, optional Format string for quickly setting basic line properties. plottype : string Plot type. It can be 'loglog'...
[ "Parameters", "----------", "x", ":", "1d", "numpy", "array", "float", "Array", "containing", "the", "X", "coordinate", ".", "y", ":", "1d", "numpy", "array", "float", "Array", "containing", "the", "Y", "coordinate", ".", "fmt", ":", "str", "optional", "Fo...
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/ximplotxy.py#L31-L132
train
Plots the x - axis of the current window.
druids/django-chamber
chamber/utils/transaction.py
atomic
def atomic(func): """ Decorator helper that overrides django atomic decorator and automatically adds create revision. """ try: from reversion.revisions import create_revision return transaction.atomic(create_revision()(func)) except ImportError: return transaction.atomic(fun...
python
def atomic(func): """ Decorator helper that overrides django atomic decorator and automatically adds create revision. """ try: from reversion.revisions import create_revision return transaction.atomic(create_revision()(func)) except ImportError: return transaction.atomic(fun...
[ "def", "atomic", "(", "func", ")", ":", "try", ":", "from", "reversion", ".", "revisions", "import", "create_revision", "return", "transaction", ".", "atomic", "(", "create_revision", "(", ")", "(", "func", ")", ")", "except", "ImportError", ":", "return", ...
Decorator helper that overrides django atomic decorator and automatically adds create revision.
[ "Decorator", "helper", "that", "overrides", "django", "atomic", "decorator", "and", "automatically", "adds", "create", "revision", "." ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/utils/transaction.py#L14-L23
train
Decorator that overrides django atomic decorator that automatically adds create revision.
druids/django-chamber
chamber/utils/transaction.py
on_success
def on_success(handler, using=None): """ Register a handler or a function to be called after successful code pass. If transaction signals are not active the handler/function is called immediately. :param handler: handler or function that will be called. :param using: name of the database """ ...
python
def on_success(handler, using=None): """ Register a handler or a function to be called after successful code pass. If transaction signals are not active the handler/function is called immediately. :param handler: handler or function that will be called. :param using: name of the database """ ...
[ "def", "on_success", "(", "handler", ",", "using", "=", "None", ")", ":", "connection", "=", "get_connection", "(", "using", ")", "if", "getattr", "(", "connection", ",", "'transaction_signals_context_list'", ",", "False", ")", ":", "connection", ".", "transac...
Register a handler or a function to be called after successful code pass. If transaction signals are not active the handler/function is called immediately. :param handler: handler or function that will be called. :param using: name of the database
[ "Register", "a", "handler", "or", "a", "function", "to", "be", "called", "after", "successful", "code", "pass", ".", "If", "transaction", "signals", "are", "not", "active", "the", "handler", "/", "function", "is", "called", "immediately", ".", ":", "param", ...
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/utils/transaction.py#L84-L101
train
Register a handler or function to be called after successful code pass.
druids/django-chamber
chamber/utils/transaction.py
atomic_with_signals
def atomic_with_signals(func): """ Atomic decorator with transaction signals. """ try: from reversion.revisions import create_revision return transaction.atomic(create_revision()(transaction_signals(func))) except ImportError: return transaction.atomic(transaction_signals(fu...
python
def atomic_with_signals(func): """ Atomic decorator with transaction signals. """ try: from reversion.revisions import create_revision return transaction.atomic(create_revision()(transaction_signals(func))) except ImportError: return transaction.atomic(transaction_signals(fu...
[ "def", "atomic_with_signals", "(", "func", ")", ":", "try", ":", "from", "reversion", ".", "revisions", "import", "create_revision", "return", "transaction", ".", "atomic", "(", "create_revision", "(", ")", "(", "transaction_signals", "(", "func", ")", ")", ")...
Atomic decorator with transaction signals.
[ "Atomic", "decorator", "with", "transaction", "signals", "." ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/utils/transaction.py#L116-L125
train
Atomic decorator with transaction signals.
gatkin/declxml
declxml.py
parse_from_file
def parse_from_file( root_processor, # type: RootProcessor xml_file_path, # type: Text encoding='utf-8' # type: Text ): # type: (...) -> Any """ Parse the XML file using the processor starting from the root of the document. :param root_processor: Root processor of the XML doc...
python
def parse_from_file( root_processor, # type: RootProcessor xml_file_path, # type: Text encoding='utf-8' # type: Text ): # type: (...) -> Any """ Parse the XML file using the processor starting from the root of the document. :param root_processor: Root processor of the XML doc...
[ "def", "parse_from_file", "(", "root_processor", ",", "# type: RootProcessor", "xml_file_path", ",", "# type: Text", "encoding", "=", "'utf-8'", "# type: Text", ")", ":", "# type: (...) -> Any", "with", "open", "(", "xml_file_path", ",", "'r'", ",", "encoding", "=", ...
Parse the XML file using the processor starting from the root of the document. :param root_processor: Root processor of the XML document. :param xml_file_path: Path to XML file to parse. :param encoding: Encoding of the file. :return: Parsed value.
[ "Parse", "the", "XML", "file", "using", "the", "processor", "starting", "from", "the", "root", "of", "the", "document", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L264-L284
train
Parses the XML file using the root processor.
gatkin/declxml
declxml.py
parse_from_string
def parse_from_string( root_processor, # type: RootProcessor xml_string # type: Text ): # type: (...) -> Any """ Parse the XML string using the processor starting from the root of the document. :param xml_string: XML string to parse. See also :func:`declxml.parse_from_file` "...
python
def parse_from_string( root_processor, # type: RootProcessor xml_string # type: Text ): # type: (...) -> Any """ Parse the XML string using the processor starting from the root of the document. :param xml_string: XML string to parse. See also :func:`declxml.parse_from_file` "...
[ "def", "parse_from_string", "(", "root_processor", ",", "# type: RootProcessor", "xml_string", "# type: Text", ")", ":", "# type: (...) -> Any", "if", "not", "_is_valid_root_processor", "(", "root_processor", ")", ":", "raise", "InvalidRootProcessor", "(", "'Invalid root pr...
Parse the XML string using the processor starting from the root of the document. :param xml_string: XML string to parse. See also :func:`declxml.parse_from_file`
[ "Parse", "the", "XML", "string", "using", "the", "processor", "starting", "from", "the", "root", "of", "the", "document", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L287-L311
train
Parses the XML string using the processor starting from the root of the document.
gatkin/declxml
declxml.py
serialize_to_file
def serialize_to_file( root_processor, # type: RootProcessor value, # type: Any xml_file_path, # type: Text encoding='utf-8', # type: Text indent=None # type: Optional[Text] ): # type: (...) -> None """ Serialize the value to an XML file using the root processor....
python
def serialize_to_file( root_processor, # type: RootProcessor value, # type: Any xml_file_path, # type: Text encoding='utf-8', # type: Text indent=None # type: Optional[Text] ): # type: (...) -> None """ Serialize the value to an XML file using the root processor....
[ "def", "serialize_to_file", "(", "root_processor", ",", "# type: RootProcessor", "value", ",", "# type: Any", "xml_file_path", ",", "# type: Text", "encoding", "=", "'utf-8'", ",", "# type: Text", "indent", "=", "None", "# type: Optional[Text]", ")", ":", "# type: (...)...
Serialize the value to an XML file using the root processor. :param root_processor: Root processor of the XML document. :param value: Value to serialize. :param xml_file_path: Path to the XML file to which the serialized value will be written. :param encoding: Encoding of the file. :param indent: I...
[ "Serialize", "the", "value", "to", "an", "XML", "file", "using", "the", "root", "processor", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L314-L334
train
Serialize the value to an XML file using the root processor.
gatkin/declxml
declxml.py
serialize_to_string
def serialize_to_string( root_processor, # type: RootProcessor value, # type: Any indent=None # type: Optional[Text] ): # type: (...) -> Text """ Serialize the value to an XML string using the root processor. :return: The serialized XML string. See also :func:`declxml.se...
python
def serialize_to_string( root_processor, # type: RootProcessor value, # type: Any indent=None # type: Optional[Text] ): # type: (...) -> Text """ Serialize the value to an XML string using the root processor. :return: The serialized XML string. See also :func:`declxml.se...
[ "def", "serialize_to_string", "(", "root_processor", ",", "# type: RootProcessor", "value", ",", "# type: Any", "indent", "=", "None", "# type: Optional[Text]", ")", ":", "# type: (...) -> Text", "if", "not", "_is_valid_root_processor", "(", "root_processor", ")", ":", ...
Serialize the value to an XML string using the root processor. :return: The serialized XML string. See also :func:`declxml.serialize_to_file`
[ "Serialize", "the", "value", "to", "an", "XML", "string", "using", "the", "root", "processor", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L337-L371
train
Serialize the value to an XML string using the root processor.
gatkin/declxml
declxml.py
array
def array( item_processor, # type: Processor alias=None, # type: Optional[Text] nested=None, # type: Optional[Text] omit_empty=False, # type: bool hooks=None # type: Optional[Hooks] ): # type: (...) -> RootProcessor """ Create an array processor that can be used ...
python
def array( item_processor, # type: Processor alias=None, # type: Optional[Text] nested=None, # type: Optional[Text] omit_empty=False, # type: bool hooks=None # type: Optional[Hooks] ): # type: (...) -> RootProcessor """ Create an array processor that can be used ...
[ "def", "array", "(", "item_processor", ",", "# type: Processor", "alias", "=", "None", ",", "# type: Optional[Text]", "nested", "=", "None", ",", "# type: Optional[Text]", "omit_empty", "=", "False", ",", "# type: bool", "hooks", "=", "None", "# type: Optional[Hooks]"...
Create an array processor that can be used to parse and serialize array data. XML arrays may be nested within an array element, or they may be embedded within their parent. A nested array would look like: .. sourcecode:: xml <root-element> <some-element>ABC</some-element> ...
[ "Create", "an", "array", "processor", "that", "can", "be", "used", "to", "parse", "and", "serialize", "array", "data", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L374-L430
train
Returns an array processor that can parse and serialize array data.
gatkin/declxml
declxml.py
boolean
def boolean( element_name, # type: Text attribute=None, # type: Optional[Text] required=True, # type: bool alias=None, # type: Optional[Text] default=False, # type: Optional[bool] omit_empty=False, # type: bool hooks=None # type: Optional[Hooks] ): # ty...
python
def boolean( element_name, # type: Text attribute=None, # type: Optional[Text] required=True, # type: bool alias=None, # type: Optional[Text] default=False, # type: Optional[bool] omit_empty=False, # type: bool hooks=None # type: Optional[Hooks] ): # ty...
[ "def", "boolean", "(", "element_name", ",", "# type: Text", "attribute", "=", "None", ",", "# type: Optional[Text]", "required", "=", "True", ",", "# type: bool", "alias", "=", "None", ",", "# type: Optional[Text]", "default", "=", "False", ",", "# type: Optional[bo...
Create a processor for boolean values. :param element_name: Name of the XML element containing the value. Can also be specified using supported XPath syntax. :param attribute: If specified, then the value is searched for under the attribute within the element specified by element_name. If not s...
[ "Create", "a", "processor", "for", "boolean", "values", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L433-L473
train
Create a processor for boolean values.
gatkin/declxml
declxml.py
dictionary
def dictionary( element_name, # type: Text children, # type: List[Processor] required=True, # type: bool alias=None, # type: Optional[Text] hooks=None # type: Optional[Hooks] ): # type: (...) -> RootProcessor """ Create a processor for dictionary values. :pa...
python
def dictionary( element_name, # type: Text children, # type: List[Processor] required=True, # type: bool alias=None, # type: Optional[Text] hooks=None # type: Optional[Hooks] ): # type: (...) -> RootProcessor """ Create a processor for dictionary values. :pa...
[ "def", "dictionary", "(", "element_name", ",", "# type: Text", "children", ",", "# type: List[Processor]", "required", "=", "True", ",", "# type: bool", "alias", "=", "None", ",", "# type: Optional[Text]", "hooks", "=", "None", "# type: Optional[Hooks]", ")", ":", "...
Create a processor for dictionary values. :param element_name: Name of the XML element containing the dictionary value. Can also be specified using supported XPath syntax. :param children: List of declxml processor objects for processing the children contained within the dictionary. :param ...
[ "Create", "a", "processor", "for", "dictionary", "values", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L476-L499
train
Create a processor for dictionary values.
gatkin/declxml
declxml.py
floating_point
def floating_point( element_name, # type: Text attribute=None, # type: Optional[Text] required=True, # type: bool alias=None, # type: Optional[Text] default=0.0, # type: Optional[float] omit_empty=False, # type: bool hooks=None # type: Optional[Hooks] ): ...
python
def floating_point( element_name, # type: Text attribute=None, # type: Optional[Text] required=True, # type: bool alias=None, # type: Optional[Text] default=0.0, # type: Optional[float] omit_empty=False, # type: bool hooks=None # type: Optional[Hooks] ): ...
[ "def", "floating_point", "(", "element_name", ",", "# type: Text", "attribute", "=", "None", ",", "# type: Optional[Text]", "required", "=", "True", ",", "# type: bool", "alias", "=", "None", ",", "# type: Optional[Text]", "default", "=", "0.0", ",", "# type: Option...
Create a processor for floating point values. See also :func:`declxml.boolean`
[ "Create", "a", "processor", "for", "floating", "point", "values", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L502-L527
train
Create a processor for floating point values.
gatkin/declxml
declxml.py
integer
def integer( element_name, # type: Text attribute=None, # type: Optional[Text] required=True, # type: bool alias=None, # type: Optional[Text] default=0, # type: Optional[int] omit_empty=False, # type: bool hooks=None # type: Optional[Hooks] ): # type: (...
python
def integer( element_name, # type: Text attribute=None, # type: Optional[Text] required=True, # type: bool alias=None, # type: Optional[Text] default=0, # type: Optional[int] omit_empty=False, # type: bool hooks=None # type: Optional[Hooks] ): # type: (...
[ "def", "integer", "(", "element_name", ",", "# type: Text", "attribute", "=", "None", ",", "# type: Optional[Text]", "required", "=", "True", ",", "# type: bool", "alias", "=", "None", ",", "# type: Optional[Text]", "default", "=", "0", ",", "# type: Optional[int]",...
Create a processor for integer values. See also :func:`declxml.boolean`
[ "Create", "a", "processor", "for", "integer", "values", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L530-L555
train
Create a processor for integer values.
gatkin/declxml
declxml.py
named_tuple
def named_tuple( element_name, # type: Text tuple_type, # type: Type[Tuple] child_processors, # type: List[Processor] required=True, # type: bool alias=None, # type: Optional[Text] hooks=None # type: Optional[Hooks] ): # type: (...) -> RootProcessor """ ...
python
def named_tuple( element_name, # type: Text tuple_type, # type: Type[Tuple] child_processors, # type: List[Processor] required=True, # type: bool alias=None, # type: Optional[Text] hooks=None # type: Optional[Hooks] ): # type: (...) -> RootProcessor """ ...
[ "def", "named_tuple", "(", "element_name", ",", "# type: Text", "tuple_type", ",", "# type: Type[Tuple]", "child_processors", ",", "# type: List[Processor]", "required", "=", "True", ",", "# type: bool", "alias", "=", "None", ",", "# type: Optional[Text]", "hooks", "=",...
Create a processor for namedtuple values. :param tuple_type: The namedtuple type. See also :func:`declxml.dictionary`
[ "Create", "a", "processor", "for", "namedtuple", "values", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L558-L576
train
Create a new root processor for namedtuple values.
gatkin/declxml
declxml.py
string
def string( element_name, # type: Text attribute=None, # type: Optional[Text] required=True, # type: bool alias=None, # type: Optional[Text] default='', # type: Optional[Text] omit_empty=False, # type: bool strip_whitespace=True, # type: bool hooks=...
python
def string( element_name, # type: Text attribute=None, # type: Optional[Text] required=True, # type: bool alias=None, # type: Optional[Text] default='', # type: Optional[Text] omit_empty=False, # type: bool strip_whitespace=True, # type: bool hooks=...
[ "def", "string", "(", "element_name", ",", "# type: Text", "attribute", "=", "None", ",", "# type: Optional[Text]", "required", "=", "True", ",", "# type: bool", "alias", "=", "None", ",", "# type: Optional[Text]", "default", "=", "''", ",", "# type: Optional[Text]"...
Create a processor for string values. :param strip_whitespace: Indicates whether leading and trailing whitespace should be stripped from parsed string values. See also :func:`declxml.boolean`
[ "Create", "a", "processor", "for", "string", "values", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L579-L608
train
Create a processor for string values.
gatkin/declxml
declxml.py
user_object
def user_object( element_name, # type: Text cls, # type: Type[Any] child_processors, # type: List[Processor] required=True, # type: bool alias=None, # type: Optional[Text] hooks=None # type: Optional[Hooks] ): # type: (...) -> RootProcessor """ Create a ...
python
def user_object( element_name, # type: Text cls, # type: Type[Any] child_processors, # type: List[Processor] required=True, # type: bool alias=None, # type: Optional[Text] hooks=None # type: Optional[Hooks] ): # type: (...) -> RootProcessor """ Create a ...
[ "def", "user_object", "(", "element_name", ",", "# type: Text", "cls", ",", "# type: Type[Any]", "child_processors", ",", "# type: List[Processor]", "required", "=", "True", ",", "# type: bool", "alias", "=", "None", ",", "# type: Optional[Text]", "hooks", "=", "None"...
Create a processor for user objects. :param cls: Class object with a no-argument constructor or other callable no-argument object. See also :func:`declxml.dictionary`
[ "Create", "a", "processor", "for", "user", "objects", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L611-L629
train
Create a processor for user objects.
gatkin/declxml
declxml.py
_element_append_path
def _element_append_path( start_element, # type: ET.Element element_names # type: Iterable[Text] ): # type: (...) -> ET.Element """ Append the list of element names as a path to the provided start element. :return: The final element along the path. """ end_element = start_elem...
python
def _element_append_path( start_element, # type: ET.Element element_names # type: Iterable[Text] ): # type: (...) -> ET.Element """ Append the list of element names as a path to the provided start element. :return: The final element along the path. """ end_element = start_elem...
[ "def", "_element_append_path", "(", "start_element", ",", "# type: ET.Element", "element_names", "# type: Iterable[Text]", ")", ":", "# type: (...) -> ET.Element", "end_element", "=", "start_element", "for", "element_name", "in", "element_names", ":", "new_element", "=", "E...
Append the list of element names as a path to the provided start element. :return: The final element along the path.
[ "Append", "the", "list", "of", "element", "names", "as", "a", "path", "to", "the", "provided", "start", "element", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1390-L1406
train
Append the list of element names as a path to the provided start element.
gatkin/declxml
declxml.py
_element_find_from_root
def _element_find_from_root( root, # type: ET.Element element_path # type: Text ): # type: (...) -> Optional[ET.Element] """ Find the element specified by the given path starting from the root element of the document. The first component of the element path is expected to be the name ...
python
def _element_find_from_root( root, # type: ET.Element element_path # type: Text ): # type: (...) -> Optional[ET.Element] """ Find the element specified by the given path starting from the root element of the document. The first component of the element path is expected to be the name ...
[ "def", "_element_find_from_root", "(", "root", ",", "# type: ET.Element", "element_path", "# type: Text", ")", ":", "# type: (...) -> Optional[ET.Element]", "element", "=", "None", "element_names", "=", "element_path", ".", "split", "(", "'/'", ")", "if", "element_names...
Find the element specified by the given path starting from the root element of the document. The first component of the element path is expected to be the name of the root element. Return None if the element is not found.
[ "Find", "the", "element", "specified", "by", "the", "given", "path", "starting", "from", "the", "root", "element", "of", "the", "document", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1409-L1429
train
Find the element specified by the given path starting from the root element of the document.
gatkin/declxml
declxml.py
_element_get_or_add_from_parent
def _element_get_or_add_from_parent( parent, # type: ET.Element element_path # type: Text ): # type: (...) -> ET.Element """ Ensure all elements specified in the given path relative to the provided parent element exist. Create new elements along the path only when needed, and return t...
python
def _element_get_or_add_from_parent( parent, # type: ET.Element element_path # type: Text ): # type: (...) -> ET.Element """ Ensure all elements specified in the given path relative to the provided parent element exist. Create new elements along the path only when needed, and return t...
[ "def", "_element_get_or_add_from_parent", "(", "parent", ",", "# type: ET.Element", "element_path", "# type: Text", ")", ":", "# type: (...) -> ET.Element", "element_names", "=", "element_path", ".", "split", "(", "'/'", ")", "# Starting from the parent, walk the element path u...
Ensure all elements specified in the given path relative to the provided parent element exist. Create new elements along the path only when needed, and return the final element specified by the path.
[ "Ensure", "all", "elements", "specified", "in", "the", "given", "path", "relative", "to", "the", "provided", "parent", "element", "exist", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1432-L1460
train
Get or add an element from a parent element.
gatkin/declxml
declxml.py
_element_path_create_new
def _element_path_create_new(element_path): # type: (Text) -> Tuple[ET.Element, ET.Element] """ Create an entirely new element path. Return a tuple where the first item is the first element in the path, and the second item is the final element in the path. """ element_names = element_path.s...
python
def _element_path_create_new(element_path): # type: (Text) -> Tuple[ET.Element, ET.Element] """ Create an entirely new element path. Return a tuple where the first item is the first element in the path, and the second item is the final element in the path. """ element_names = element_path.s...
[ "def", "_element_path_create_new", "(", "element_path", ")", ":", "# type: (Text) -> Tuple[ET.Element, ET.Element]", "element_names", "=", "element_path", ".", "split", "(", "'/'", ")", "start_element", "=", "ET", ".", "Element", "(", "element_names", "[", "0", "]", ...
Create an entirely new element path. Return a tuple where the first item is the first element in the path, and the second item is the final element in the path.
[ "Create", "an", "entirely", "new", "element", "path", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1463-L1476
train
Create an entirely new element path.
gatkin/declxml
declxml.py
_hooks_apply_after_parse
def _hooks_apply_after_parse( hooks, # type: Optional[Hooks] state, # type: _ProcessorState value # type: Any ): # type: (...) -> Any """Apply the after parse hook.""" if hooks and hooks.after_parse: return hooks.after_parse(ProcessorStateView(state), value) return va...
python
def _hooks_apply_after_parse( hooks, # type: Optional[Hooks] state, # type: _ProcessorState value # type: Any ): # type: (...) -> Any """Apply the after parse hook.""" if hooks and hooks.after_parse: return hooks.after_parse(ProcessorStateView(state), value) return va...
[ "def", "_hooks_apply_after_parse", "(", "hooks", ",", "# type: Optional[Hooks]", "state", ",", "# type: _ProcessorState", "value", "# type: Any", ")", ":", "# type: (...) -> Any", "if", "hooks", "and", "hooks", ".", "after_parse", ":", "return", "hooks", ".", "after_p...
Apply the after parse hook.
[ "Apply", "the", "after", "parse", "hook", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1479-L1489
train
Applies the after parse hook.
gatkin/declxml
declxml.py
_hooks_apply_before_serialize
def _hooks_apply_before_serialize( hooks, # type: Optional[Hooks] state, # type: _ProcessorState value # type: Any ): # type: (...) -> Any """Apply the before serialize hook.""" if hooks and hooks.before_serialize: return hooks.before_serialize(ProcessorStateView(state), v...
python
def _hooks_apply_before_serialize( hooks, # type: Optional[Hooks] state, # type: _ProcessorState value # type: Any ): # type: (...) -> Any """Apply the before serialize hook.""" if hooks and hooks.before_serialize: return hooks.before_serialize(ProcessorStateView(state), v...
[ "def", "_hooks_apply_before_serialize", "(", "hooks", ",", "# type: Optional[Hooks]", "state", ",", "# type: _ProcessorState", "value", "# type: Any", ")", ":", "# type: (...) -> Any", "if", "hooks", "and", "hooks", ".", "before_serialize", ":", "return", "hooks", ".", ...
Apply the before serialize hook.
[ "Apply", "the", "before", "serialize", "hook", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1492-L1502
train
Applies the before serialize hook.
gatkin/declxml
declxml.py
_named_tuple_converter
def _named_tuple_converter(tuple_type): # type: (Type[Tuple]) -> _AggregateConverter """Return an _AggregateConverter for named tuples of the given type.""" def _from_dict(dict_value): if dict_value: return tuple_type(**dict_value) # Cannot construct a namedtuple value from an e...
python
def _named_tuple_converter(tuple_type): # type: (Type[Tuple]) -> _AggregateConverter """Return an _AggregateConverter for named tuples of the given type.""" def _from_dict(dict_value): if dict_value: return tuple_type(**dict_value) # Cannot construct a namedtuple value from an e...
[ "def", "_named_tuple_converter", "(", "tuple_type", ")", ":", "# type: (Type[Tuple]) -> _AggregateConverter", "def", "_from_dict", "(", "dict_value", ")", ":", "if", "dict_value", ":", "return", "tuple_type", "(", "*", "*", "dict_value", ")", "# Cannot construct a named...
Return an _AggregateConverter for named tuples of the given type.
[ "Return", "an", "_AggregateConverter", "for", "named", "tuples", "of", "the", "given", "type", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1511-L1528
train
Return an _AggregateConverter for named tuples of the given type.
gatkin/declxml
declxml.py
_number_parser
def _number_parser(str_to_number_func): """Return a function to parse numbers.""" def _parse_number_value(element_text, state): value = None try: value = str_to_number_func(element_text) except (ValueError, TypeError): state.raise_error(InvalidPrimitiveValue, ...
python
def _number_parser(str_to_number_func): """Return a function to parse numbers.""" def _parse_number_value(element_text, state): value = None try: value = str_to_number_func(element_text) except (ValueError, TypeError): state.raise_error(InvalidPrimitiveValue, ...
[ "def", "_number_parser", "(", "str_to_number_func", ")", ":", "def", "_parse_number_value", "(", "element_text", ",", "state", ")", ":", "value", "=", "None", "try", ":", "value", "=", "str_to_number_func", "(", "element_text", ")", "except", "(", "ValueError", ...
Return a function to parse numbers.
[ "Return", "a", "function", "to", "parse", "numbers", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1531-L1544
train
Return a function to parse numbers.
gatkin/declxml
declxml.py
_parse_boolean
def _parse_boolean(element_text, state): """Parse the raw XML string as a boolean value.""" value = None lowered_text = element_text.lower() if lowered_text == 'true': value = True elif lowered_text == 'false': value = False else: state.raise_error(InvalidPrimitiveValue,...
python
def _parse_boolean(element_text, state): """Parse the raw XML string as a boolean value.""" value = None lowered_text = element_text.lower() if lowered_text == 'true': value = True elif lowered_text == 'false': value = False else: state.raise_error(InvalidPrimitiveValue,...
[ "def", "_parse_boolean", "(", "element_text", ",", "state", ")", ":", "value", "=", "None", "lowered_text", "=", "element_text", ".", "lower", "(", ")", "if", "lowered_text", "==", "'true'", ":", "value", "=", "True", "elif", "lowered_text", "==", "'false'",...
Parse the raw XML string as a boolean value.
[ "Parse", "the", "raw", "XML", "string", "as", "a", "boolean", "value", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1547-L1559
train
Parse the raw XML string as a boolean value.
gatkin/declxml
declxml.py
_string_parser
def _string_parser(strip_whitespace): """Return a parser function for parsing string values.""" def _parse_string_value(element_text, _state): if element_text is None: value = '' elif strip_whitespace: value = element_text.strip() else: value = element...
python
def _string_parser(strip_whitespace): """Return a parser function for parsing string values.""" def _parse_string_value(element_text, _state): if element_text is None: value = '' elif strip_whitespace: value = element_text.strip() else: value = element...
[ "def", "_string_parser", "(", "strip_whitespace", ")", ":", "def", "_parse_string_value", "(", "element_text", ",", "_state", ")", ":", "if", "element_text", "is", "None", ":", "value", "=", "''", "elif", "strip_whitespace", ":", "value", "=", "element_text", ...
Return a parser function for parsing string values.
[ "Return", "a", "parser", "function", "for", "parsing", "string", "values", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1574-L1586
train
Return a parser function for parsing string values.
gatkin/declxml
declxml.py
_user_object_converter
def _user_object_converter(cls): # type: (Type[Any]) -> _AggregateConverter """Return an _AggregateConverter for a user object of the given class.""" def _from_dict(dict_value): try: object_value = cls(**dict_value) except TypeError: # Constructor does not support key...
python
def _user_object_converter(cls): # type: (Type[Any]) -> _AggregateConverter """Return an _AggregateConverter for a user object of the given class.""" def _from_dict(dict_value): try: object_value = cls(**dict_value) except TypeError: # Constructor does not support key...
[ "def", "_user_object_converter", "(", "cls", ")", ":", "# type: (Type[Any]) -> _AggregateConverter", "def", "_from_dict", "(", "dict_value", ")", ":", "try", ":", "object_value", "=", "cls", "(", "*", "*", "dict_value", ")", "except", "TypeError", ":", "# Construc...
Return an _AggregateConverter for a user object of the given class.
[ "Return", "an", "_AggregateConverter", "for", "a", "user", "object", "of", "the", "given", "class", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1589-L1610
train
Return an _AggregateConverter for a user object of the given class.
gatkin/declxml
declxml.py
_xml_namespace_strip
def _xml_namespace_strip(root): # type: (ET.Element) -> None """Strip the XML namespace prefix from all element tags under the given root Element.""" if '}' not in root.tag: return # Nothing to do, no namespace present for element in root.iter(): if '}' in element.tag: elem...
python
def _xml_namespace_strip(root): # type: (ET.Element) -> None """Strip the XML namespace prefix from all element tags under the given root Element.""" if '}' not in root.tag: return # Nothing to do, no namespace present for element in root.iter(): if '}' in element.tag: elem...
[ "def", "_xml_namespace_strip", "(", "root", ")", ":", "# type: (ET.Element) -> None", "if", "'}'", "not", "in", "root", ".", "tag", ":", "return", "# Nothing to do, no namespace present", "for", "element", "in", "root", ".", "iter", "(", ")", ":", "if", "'}'", ...
Strip the XML namespace prefix from all element tags under the given root Element.
[ "Strip", "the", "XML", "namespace", "prefix", "from", "all", "element", "tags", "under", "the", "given", "root", "Element", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1613-L1625
train
Strip the XML namespace prefix from all element tags under the given root Element.
gatkin/declxml
declxml.py
_Aggregate.parse_at_element
def parse_at_element( self, element, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the provided element as an aggregate.""" parsed_dict = self._dictionary.parse_at_element(element, state) return self._converter...
python
def parse_at_element( self, element, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the provided element as an aggregate.""" parsed_dict = self._dictionary.parse_at_element(element, state) return self._converter...
[ "def", "parse_at_element", "(", "self", ",", "element", ",", "# type: ET.Element", "state", "# type: _ProcessorState", ")", ":", "# type: (...) -> Any", "parsed_dict", "=", "self", ".", "_dictionary", ".", "parse_at_element", "(", "element", ",", "state", ")", "retu...
Parse the provided element as an aggregate.
[ "Parse", "the", "provided", "element", "as", "an", "aggregate", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L678-L686
train
Parse the provided element as an aggregate.
gatkin/declxml
declxml.py
_Aggregate.parse_at_root
def parse_at_root( self, root, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the root XML element as an aggregate.""" parsed_dict = self._dictionary.parse_at_root(root, state) return self._converter.from_dict(p...
python
def parse_at_root( self, root, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the root XML element as an aggregate.""" parsed_dict = self._dictionary.parse_at_root(root, state) return self._converter.from_dict(p...
[ "def", "parse_at_root", "(", "self", ",", "root", ",", "# type: ET.Element", "state", "# type: _ProcessorState", ")", ":", "# type: (...) -> Any", "parsed_dict", "=", "self", ".", "_dictionary", ".", "parse_at_root", "(", "root", ",", "state", ")", "return", "self...
Parse the root XML element as an aggregate.
[ "Parse", "the", "root", "XML", "element", "as", "an", "aggregate", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L688-L696
train
Parse the root XML element as an aggregate.
gatkin/declxml
declxml.py
_Aggregate.parse_from_parent
def parse_from_parent( self, parent, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the aggregate from the provided parent XML element.""" parsed_dict = self._dictionary.parse_from_parent(parent, state) return s...
python
def parse_from_parent( self, parent, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the aggregate from the provided parent XML element.""" parsed_dict = self._dictionary.parse_from_parent(parent, state) return s...
[ "def", "parse_from_parent", "(", "self", ",", "parent", ",", "# type: ET.Element", "state", "# type: _ProcessorState", ")", ":", "# type: (...) -> Any", "parsed_dict", "=", "self", ".", "_dictionary", ".", "parse_from_parent", "(", "parent", ",", "state", ")", "retu...
Parse the aggregate from the provided parent XML element.
[ "Parse", "the", "aggregate", "from", "the", "provided", "parent", "XML", "element", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L698-L706
train
Parse the aggregate from the provided parent XML element.
gatkin/declxml
declxml.py
_Aggregate.serialize
def serialize( self, value, # type: Any state # type: _ProcessorState ): # type: (...) -> ET.Element """Serialize the value to a new element and returns the element.""" dict_value = self._converter.to_dict(value) return self._dictionary.serialize...
python
def serialize( self, value, # type: Any state # type: _ProcessorState ): # type: (...) -> ET.Element """Serialize the value to a new element and returns the element.""" dict_value = self._converter.to_dict(value) return self._dictionary.serialize...
[ "def", "serialize", "(", "self", ",", "value", ",", "# type: Any", "state", "# type: _ProcessorState", ")", ":", "# type: (...) -> ET.Element", "dict_value", "=", "self", ".", "_converter", ".", "to_dict", "(", "value", ")", "return", "self", ".", "_dictionary", ...
Serialize the value to a new element and returns the element.
[ "Serialize", "the", "value", "to", "a", "new", "element", "and", "returns", "the", "element", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L708-L716
train
Serialize the value to a new element and returns the element.
gatkin/declxml
declxml.py
_Aggregate.serialize_on_parent
def serialize_on_parent( self, parent, # type: ET.Element value, # type: Any state # type: _ProcessorState ): # type: (...) -> None """Serialize the value and adds it to the parent.""" dict_value = self._converter.to_dict(value) self...
python
def serialize_on_parent( self, parent, # type: ET.Element value, # type: Any state # type: _ProcessorState ): # type: (...) -> None """Serialize the value and adds it to the parent.""" dict_value = self._converter.to_dict(value) self...
[ "def", "serialize_on_parent", "(", "self", ",", "parent", ",", "# type: ET.Element", "value", ",", "# type: Any", "state", "# type: _ProcessorState", ")", ":", "# type: (...) -> None", "dict_value", "=", "self", ".", "_converter", ".", "to_dict", "(", "value", ")", ...
Serialize the value and adds it to the parent.
[ "Serialize", "the", "value", "and", "adds", "it", "to", "the", "parent", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L718-L727
train
Serialize the value and adds it to the parent.
gatkin/declxml
declxml.py
_Array.parse_at_element
def parse_at_element( self, element, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the provided element as an array.""" item_iter = element.findall(self._item_processor.element_path) return self._parse(item_ite...
python
def parse_at_element( self, element, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the provided element as an array.""" item_iter = element.findall(self._item_processor.element_path) return self._parse(item_ite...
[ "def", "parse_at_element", "(", "self", ",", "element", ",", "# type: ET.Element", "state", "# type: _ProcessorState", ")", ":", "# type: (...) -> Any", "item_iter", "=", "element", ".", "findall", "(", "self", ".", "_item_processor", ".", "element_path", ")", "retu...
Parse the provided element as an array.
[ "Parse", "the", "provided", "element", "as", "an", "array", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L784-L792
train
Parse the provided element as an array.
gatkin/declxml
declxml.py
_Array.parse_at_root
def parse_at_root( self, root, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the root XML element as an array.""" if not self._nested: raise InvalidRootProcessor('Non-nested array "{}" cannot be root elemen...
python
def parse_at_root( self, root, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the root XML element as an array.""" if not self._nested: raise InvalidRootProcessor('Non-nested array "{}" cannot be root elemen...
[ "def", "parse_at_root", "(", "self", ",", "root", ",", "# type: ET.Element", "state", "# type: _ProcessorState", ")", ":", "# type: (...) -> Any", "if", "not", "self", ".", "_nested", ":", "raise", "InvalidRootProcessor", "(", "'Non-nested array \"{}\" cannot be root elem...
Parse the root XML element as an array.
[ "Parse", "the", "root", "XML", "element", "as", "an", "array", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L794-L813
train
Parse the root XML element as an array.
gatkin/declxml
declxml.py
_Array.parse_from_parent
def parse_from_parent( self, parent, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the array data from the provided parent XML element.""" item_iter = parent.findall(self._item_path) return self._parse(item_ite...
python
def parse_from_parent( self, parent, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the array data from the provided parent XML element.""" item_iter = parent.findall(self._item_path) return self._parse(item_ite...
[ "def", "parse_from_parent", "(", "self", ",", "parent", ",", "# type: ET.Element", "state", "# type: _ProcessorState", ")", ":", "# type: (...) -> Any", "item_iter", "=", "parent", ".", "findall", "(", "self", ".", "_item_path", ")", "return", "self", ".", "_parse...
Parse the array data from the provided parent XML element.
[ "Parse", "the", "array", "data", "from", "the", "provided", "parent", "XML", "element", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L815-L823
train
Parse the array data from the provided parent XML element.
gatkin/declxml
declxml.py
_Array.serialize
def serialize( self, value, # type: Any state # type: _ProcessorState ): # type: (...) -> ET.Element """Serialize the value into a new Element object and return it.""" if self._nested is None: state.raise_error(InvalidRootProcessor, ...
python
def serialize( self, value, # type: Any state # type: _ProcessorState ): # type: (...) -> ET.Element """Serialize the value into a new Element object and return it.""" if self._nested is None: state.raise_error(InvalidRootProcessor, ...
[ "def", "serialize", "(", "self", ",", "value", ",", "# type: Any", "state", "# type: _ProcessorState", ")", ":", "# type: (...) -> ET.Element", "if", "self", ".", "_nested", "is", "None", ":", "state", ".", "raise_error", "(", "InvalidRootProcessor", ",", "'Cannot...
Serialize the value into a new Element object and return it.
[ "Serialize", "the", "value", "into", "a", "new", "Element", "object", "and", "return", "it", "." ]
3a2324b43aee943e82a04587fbb68932c6f392ba
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L825-L844
train
Serialize the value into a new Element object and return it.