sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def date(self) -> datetime.datetime:
"""Date of the experiment (start of exposure)"""
return self._data['Date'] - datetime.timedelta(0, float(self.exposuretime), 0) | Date of the experiment (start of exposure) | entailment |
def flux(self) -> ErrorValue:
"""X-ray flux in photons/sec."""
try:
return ErrorValue(self._data['Flux'], self._data.setdefault('FluxError',0.0))
except KeyError:
return 1 / self.pixelsizex / self.pixelsizey / ErrorValue(self._data['NormFactor'],
... | X-ray flux in photons/sec. | entailment |
def nonlinear_leastsquares(x: np.ndarray, y: np.ndarray, dy: np.ndarray, func: Callable, params_init: np.ndarray,
verbose: bool = False, **kwargs):
"""Perform a non-linear least squares fit, return the results as
ErrorValue() instances.
Inputs:
x: one-dimensional numpy ar... | Perform a non-linear least squares fit, return the results as
ErrorValue() instances.
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
dy: absolute error (square root of the variance) of the dependent
... | entailment |
def nonlinear_odr(x, y, dx, dy, func, params_init, **kwargs):
"""Perform a non-linear orthogonal distance regression, return the results as
ErrorValue() instances.
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
... | Perform a non-linear orthogonal distance regression, return the results as
ErrorValue() instances.
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
dx: absolute error (square root of the variance) of the independ... | entailment |
def simultaneous_nonlinear_leastsquares(xs, ys, dys, func, params_inits, verbose=False, **kwargs):
"""Do a simultaneous nonlinear least-squares fit and return the fitted
parameters as instances of ErrorValue.
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordin... | Do a simultaneous nonlinear least-squares fit and return the fitted
parameters as instances of ErrorValue.
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordinate vectors (1d numpy ndarrays)
`dys`: tuple of the errors of ordinate vectors (1d numpy ndarrays or N... | entailment |
def nlsq_fit(x, y, dy, func, params_init, verbose=False, **kwargs):
"""Perform a non-linear least squares fit
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
dy: absolute error (square root of the variance) of t... | Perform a non-linear least squares fit
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
dy: absolute error (square root of the variance) of the dependent
variable. Either a one-dimensional numpy array or ... | entailment |
def simultaneous_nlsq_fit(xs, ys, dys, func, params_inits, verbose=False,
**kwargs):
"""Do a simultaneous nonlinear least-squares fit
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordinate vectors (1d numpy ndarrays)
`dys`: tuple o... | Do a simultaneous nonlinear least-squares fit
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordinate vectors (1d numpy ndarrays)
`dys`: tuple of the errors of ordinate vectors (1d numpy ndarrays or Nones)
`func`: fitting function (the same for all the datasets... | entailment |
def tostring(self: 'ErrorValue', extra_digits: int = 0, plusminus: str = ' +/- ', fmt: str = None) -> str:
"""Make a string representation of the value and its uncertainty.
Inputs:
-------
``extra_digits``: integer
how many extra digits should be shown (plus or minus... | Make a string representation of the value and its uncertainty.
Inputs:
-------
``extra_digits``: integer
how many extra digits should be shown (plus or minus, zero means
that the number of digits should be defined by the magnitude of
the uncer... | entailment |
def random(self: 'ErrorValue') -> np.ndarray:
"""Sample a random number (array) of the distribution defined by
mean=`self.val` and variance=`self.err`^2.
"""
if isinstance(self.val, np.ndarray):
# IGNORE:E1103
return np.random.randn(self.val.shape) * self.err + se... | Sample a random number (array) of the distribution defined by
mean=`self.val` and variance=`self.err`^2. | entailment |
def evalfunc(cls, func, *args, **kwargs):
"""Evaluate a function with error propagation.
Inputs:
-------
``func``: callable
this is the function to be evaluated. Should return either a
number or a np.ndarray.
``*args``: other positional ar... | Evaluate a function with error propagation.
Inputs:
-------
``func``: callable
this is the function to be evaluated. Should return either a
number or a np.ndarray.
``*args``: other positional arguments of func. Arguments which are
... | entailment |
def Fsphere(q, R):
"""Scattering form-factor amplitude of a sphere normalized to F(q=0)=V
Inputs:
-------
``q``: independent variable
``R``: sphere radius
Formula:
--------
``4*pi/q^3 * (sin(qR) - qR*cos(qR))``
"""
return 4 * np.pi / q ** 3 * (np.sin(q * R) - q * R ... | Scattering form-factor amplitude of a sphere normalized to F(q=0)=V
Inputs:
-------
``q``: independent variable
``R``: sphere radius
Formula:
--------
``4*pi/q^3 * (sin(qR) - qR*cos(qR))`` | entailment |
def GeneralGuinier(q, G, Rg, s):
"""Generalized Guinier scattering
Inputs:
-------
``q``: independent variable
``G``: factor
``Rg``: radius of gyration
``s``: dimensionality parameter (can be 1, 2, 3)
Formula:
--------
``G/q**(3-s)*exp(-(q^2*Rg^2)/s)``
"... | Generalized Guinier scattering
Inputs:
-------
``q``: independent variable
``G``: factor
``Rg``: radius of gyration
``s``: dimensionality parameter (can be 1, 2, 3)
Formula:
--------
``G/q**(3-s)*exp(-(q^2*Rg^2)/s)`` | entailment |
def GuinierPorod(q, G, Rg, alpha):
"""Empirical Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``G``: factor of the Guinier-branch
``Rg``: radius of gyration
``alpha``: power-law exponent
Formula:
--------
``G * exp(-q^2*Rg^2/3)`` if ``... | Empirical Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``G``: factor of the Guinier-branch
``Rg``: radius of gyration
``alpha``: power-law exponent
Formula:
--------
``G * exp(-q^2*Rg^2/3)`` if ``q<q_sep`` and ``a*q^alpha`` otherwise.
... | entailment |
def PorodGuinier(q, a, alpha, Rg):
"""Empirical Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``a``: factor of the power-law branch
``alpha``: power-law exponent
``Rg``: radius of gyration
Formula:
--------
``G * exp(-q^2*Rg^2/3)`` if ... | Empirical Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``a``: factor of the power-law branch
``alpha``: power-law exponent
``Rg``: radius of gyration
Formula:
--------
``G * exp(-q^2*Rg^2/3)`` if ``q>q_sep`` and ``a*q^alpha`` otherwise.
... | entailment |
def PorodGuinierPorod(q, a, alpha, Rg, beta):
"""Empirical Porod-Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``a``: factor of the first power-law branch
``alpha``: exponent of the first power-law branch
``Rg``: radius of gyration
``beta``: ex... | Empirical Porod-Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``a``: factor of the first power-law branch
``alpha``: exponent of the first power-law branch
``Rg``: radius of gyration
``beta``: exponent of the second power-law branch
Formula:
... | entailment |
def GuinierPorodGuinier(q, G, Rg1, alpha, Rg2):
"""Empirical Guinier-Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``G``: factor for the first Guinier-branch
``Rg1``: the first radius of gyration
``alpha``: the power-law exponent
``Rg2``: the s... | Empirical Guinier-Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``G``: factor for the first Guinier-branch
``Rg1``: the first radius of gyration
``alpha``: the power-law exponent
``Rg2``: the second radius of gyration
Formula:
--------
... | entailment |
def DampedPowerlaw(q, a, alpha, sigma):
"""Damped power-law
Inputs:
-------
``q``: independent variable
``a``: factor
``alpha``: exponent
``sigma``: hwhm of the damping Gaussian
Formula:
--------
``a*q^alpha*exp(-q^2/(2*sigma^2))``
"""
return a * q *... | Damped power-law
Inputs:
-------
``q``: independent variable
``a``: factor
``alpha``: exponent
``sigma``: hwhm of the damping Gaussian
Formula:
--------
``a*q^alpha*exp(-q^2/(2*sigma^2))`` | entailment |
def LogNormSpheres(q, A, mu, sigma, N=1000):
"""Scattering of a population of non-correlated spheres (radii from a log-normal distribution)
Inputs:
-------
``q``: independent variable
``A``: scaling factor
``mu``: expectation of ``ln(R)``
``sigma``: hwhm of ``ln(R)``
No... | Scattering of a population of non-correlated spheres (radii from a log-normal distribution)
Inputs:
-------
``q``: independent variable
``A``: scaling factor
``mu``: expectation of ``ln(R)``
``sigma``: hwhm of ``ln(R)``
Non-fittable inputs:
--------------------
... | entailment |
def GaussSpheres(q, A, R0, sigma, N=1000, weighting='intensity'):
"""Scattering of a population of non-correlated spheres (radii from a gaussian distribution)
Inputs:
-------
``q``: independent variable
``A``: scaling factor
``R0``: expectation of ``R``
``sigma``: hwhm of ``... | Scattering of a population of non-correlated spheres (radii from a gaussian distribution)
Inputs:
-------
``q``: independent variable
``A``: scaling factor
``R0``: expectation of ``R``
``sigma``: hwhm of ``R``
``weighting``: 'intensity' (default), 'volume' or 'number'
... | entailment |
def PowerlawGuinierPorodConst(q, A, alpha, G, Rg, beta, C):
"""Sum of a Power-law, a Guinier-Porod curve and a constant.
Inputs:
-------
``q``: independent variable (momentum transfer)
``A``: scaling factor of the power-law
``alpha``: power-law exponent
``G``: scaling factor... | Sum of a Power-law, a Guinier-Porod curve and a constant.
Inputs:
-------
``q``: independent variable (momentum transfer)
``A``: scaling factor of the power-law
``alpha``: power-law exponent
``G``: scaling factor of the Guinier-Porod curve
``Rg``: Radius of gyration
... | entailment |
def GuinierPorodMulti(q, G, *Rgsalphas):
"""Empirical multi-part Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``G``: factor for the first Guinier-branch
other arguments: [Rg1, alpha1, Rg2, alpha2, Rg3 ...] the radii of
gyration and power-law exponents... | Empirical multi-part Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``G``: factor for the first Guinier-branch
other arguments: [Rg1, alpha1, Rg2, alpha2, Rg3 ...] the radii of
gyration and power-law exponents of the consecutive parts
Formula:
----... | entailment |
def PorodGuinierMulti(q, A, *alphasRgs):
"""Empirical multi-part Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``A``: factor for the first Power-law-branch
other arguments: [alpha1, Rg1, alpha2, Rg2, alpha3 ...] the radii of
gyration and power-law expo... | Empirical multi-part Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``A``: factor for the first Power-law-branch
other arguments: [alpha1, Rg1, alpha2, Rg2, alpha3 ...] the radii of
gyration and power-law exponents of the consecutive parts
Formula:
... | entailment |
def GeneralGuinierPorod(q, factor, *args, **kwargs):
"""Empirical generalized multi-part Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``factor``: factor for the first branch
other arguments (*args): the defining arguments of the consecutive
parts... | Empirical generalized multi-part Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``factor``: factor for the first branch
other arguments (*args): the defining arguments of the consecutive
parts: radius of gyration (``Rg``) and dimensionality
... | entailment |
def DebyeChain(q, Rg):
"""Scattering form-factor intensity of a Gaussian chain (Debye)
Inputs:
-------
``q``: independent variable
``Rg``: radius of gyration
Formula:
--------
``2*(exp(-a)-1+a)/a^2`` where ``a=(q*Rg)^2``
"""
a = (q * Rg) ** 2
return 2 * (np.exp(... | Scattering form-factor intensity of a Gaussian chain (Debye)
Inputs:
-------
``q``: independent variable
``Rg``: radius of gyration
Formula:
--------
``2*(exp(-a)-1+a)/a^2`` where ``a=(q*Rg)^2`` | entailment |
def ExcludedVolumeChain(q, Rg, nu):
"""Scattering intensity of a generalized excluded-volume Gaussian chain
Inputs:
-------
``q``: independent variable
``Rg``: radius of gyration
``nu``: excluded volume exponent
Formula:
--------
``(u^(1/nu)*gamma(0.5/nu)*gammainc_l... | Scattering intensity of a generalized excluded-volume Gaussian chain
Inputs:
-------
``q``: independent variable
``Rg``: radius of gyration
``nu``: excluded volume exponent
Formula:
--------
``(u^(1/nu)*gamma(0.5/nu)*gammainc_lower(0.5/nu,u)-
gamma(1/nu)*gam... | entailment |
def BorueErukhimovich(q, C, r0, s, t):
"""Borue-Erukhimovich model of microphase separation in polyelectrolytes
Inputs:
-------
``q``: independent variable
``C``: scaling factor
``r0``: typical el.stat. screening length
``s``: dimensionless charge concentration
``t``... | Borue-Erukhimovich model of microphase separation in polyelectrolytes
Inputs:
-------
``q``: independent variable
``C``: scaling factor
``r0``: typical el.stat. screening length
``s``: dimensionless charge concentration
``t``: dimensionless temperature
Formula:
... | entailment |
def BorueErukhimovich_Powerlaw(q, C, r0, s, t, nu):
"""Borue-Erukhimovich model ending in a power-law.
Inputs:
-------
``q``: independent variable
``C``: scaling factor
``r0``: typical el.stat. screening length
``s``: dimensionless charge concentration
``t``: dimensi... | Borue-Erukhimovich model ending in a power-law.
Inputs:
-------
``q``: independent variable
``C``: scaling factor
``r0``: typical el.stat. screening length
``s``: dimensionless charge concentration
``t``: dimensionless temperature
``nu``: excluded volume paramete... | entailment |
def sample(self, data, interval):
'''Sample a patch from the data object
Parameters
----------
data : dict
A data dict as produced by pumpp.Pump.transform
interval : slice
The time interval to sample
Returns
-------
data_slice : ... | Sample a patch from the data object
Parameters
----------
data : dict
A data dict as produced by pumpp.Pump.transform
interval : slice
The time interval to sample
Returns
-------
data_slice : dict
`data` restricted to `interv... | entailment |
def indices(self, data):
'''Generate patch indices
Parameters
----------
data : dict of np.ndarray
As produced by pumpp.transform
Yields
------
start : int >= 0
The start index of a sample patch
'''
duration = self.data_du... | Generate patch indices
Parameters
----------
data : dict of np.ndarray
As produced by pumpp.transform
Yields
------
start : int >= 0
The start index of a sample patch | entailment |
def indices(self, data):
'''Generate patch start indices
Parameters
----------
data : dict of np.ndarray
As produced by pumpp.transform
Yields
------
start : int >= 0
The start index of a sample patch
'''
duration = self.d... | Generate patch start indices
Parameters
----------
data : dict of np.ndarray
As produced by pumpp.transform
Yields
------
start : int >= 0
The start index of a sample patch | entailment |
def indices(self, data):
'''Generate patch indices
Parameters
----------
data : dict of np.ndarray
As produced by pumpp.transform
Yields
------
start : int >= 0
The start index of a sample patch
'''
duration = self.data_du... | Generate patch indices
Parameters
----------
data : dict of np.ndarray
As produced by pumpp.transform
Yields
------
start : int >= 0
The start index of a sample patch | entailment |
def scope(self, key):
'''Apply the name scope to a key
Parameters
----------
key : string
Returns
-------
`name/key` if `name` is not `None`;
otherwise, `key`.
'''
if self.name is None:
return key
return '{:s}/{:s}'.fo... | Apply the name scope to a key
Parameters
----------
key : string
Returns
-------
`name/key` if `name` is not `None`;
otherwise, `key`. | entailment |
def register(self, field, shape, dtype):
'''Register a field as a tensor with specified shape and type.
A `Tensor` of the given shape and type will be registered in this
object's `fields` dict.
Parameters
----------
field : str
The name of the field
... | Register a field as a tensor with specified shape and type.
A `Tensor` of the given shape and type will be registered in this
object's `fields` dict.
Parameters
----------
field : str
The name of the field
shape : iterable of `int` or `None`
The... | entailment |
def merge(self, data):
'''Merge an array of output dictionaries into a single dictionary
with properly scoped names.
Parameters
----------
data : list of dict
Output dicts as produced by `pumpp.task.BaseTaskTransformer.transform`
or `pumpp.feature.Feature... | Merge an array of output dictionaries into a single dictionary
with properly scoped names.
Parameters
----------
data : list of dict
Output dicts as produced by `pumpp.task.BaseTaskTransformer.transform`
or `pumpp.feature.FeatureExtractor.transform`.
Ret... | entailment |
def add(self, operator):
'''Add an operator to the Slicer
Parameters
----------
operator : Scope (TaskTransformer or FeatureExtractor)
The new operator to add
'''
if not isinstance(operator, Scope):
raise ParameterError('Operator {} must be a Task... | Add an operator to the Slicer
Parameters
----------
operator : Scope (TaskTransformer or FeatureExtractor)
The new operator to add | entailment |
def data_duration(self, data):
'''Compute the valid data duration of a dict
Parameters
----------
data : dict
As produced by pumpp.transform
Returns
-------
length : int
The minimum temporal extent of a dynamic observation in data
... | Compute the valid data duration of a dict
Parameters
----------
data : dict
As produced by pumpp.transform
Returns
-------
length : int
The minimum temporal extent of a dynamic observation in data | entailment |
def crop(self, data):
'''Crop a data dictionary down to its common time
Parameters
----------
data : dict
As produced by pumpp.transform
Returns
-------
data_cropped : dict
Like `data` but with all time-like axes truncated to the
... | Crop a data dictionary down to its common time
Parameters
----------
data : dict
As produced by pumpp.transform
Returns
-------
data_cropped : dict
Like `data` but with all time-like axes truncated to the
minimum common duration | entailment |
def transform_audio(self, y):
'''Compute the Mel spectrogram
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, n_mels)
The Mel spectrogram
... | Compute the Mel spectrogram
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, n_mels)
The Mel spectrogram | entailment |
def empty(self, duration):
'''Empty vector annotations.
This returns an annotation with a single observation
vector consisting of all-zeroes.
Parameters
----------
duration : number >0
Length of the track
Returns
-------
ann : jams.A... | Empty vector annotations.
This returns an annotation with a single observation
vector consisting of all-zeroes.
Parameters
----------
duration : number >0
Length of the track
Returns
-------
ann : jams.Annotation
The empty annota... | entailment |
def transform_annotation(self, ann, duration):
'''Apply the vector transformation.
Parameters
----------
ann : jams.Annotation
The input annotation
duration : number > 0
The duration of the track
Returns
-------
data : dict
... | Apply the vector transformation.
Parameters
----------
ann : jams.Annotation
The input annotation
duration : number > 0
The duration of the track
Returns
-------
data : dict
data['vector'] : np.ndarray, shape=(dimension,)
... | entailment |
def inverse(self, vector, duration=None):
'''Inverse vector transformer'''
ann = jams.Annotation(namespace=self.namespace, duration=duration)
if duration is None:
duration = 0
ann.append(time=0, duration=duration, value=vector)
return ann | Inverse vector transformer | entailment |
def set_transition(self, p_self):
'''Set the transition matrix according to self-loop probabilities.
Parameters
----------
p_self : None, float in (0, 1), or np.ndarray [shape=(n_labels,)]
Optional self-loop probability(ies), used for Viterbi decoding
'''
if ... | Set the transition matrix according to self-loop probabilities.
Parameters
----------
p_self : None, float in (0, 1), or np.ndarray [shape=(n_labels,)]
Optional self-loop probability(ies), used for Viterbi decoding | entailment |
def empty(self, duration):
'''Empty label annotations.
Constructs a single observation with an empty value (None).
Parameters
----------
duration : number > 0
The duration of the annotation
'''
ann = super(DynamicLabelTransformer, self).empty(duratio... | Empty label annotations.
Constructs a single observation with an empty value (None).
Parameters
----------
duration : number > 0
The duration of the annotation | entailment |
def transform_annotation(self, ann, duration):
'''Transform an annotation to dynamic label encoding.
Parameters
----------
ann : jams.Annotation
The annotation to convert
duration : number > 0
The duration of the track
Returns
-------
... | Transform an annotation to dynamic label encoding.
Parameters
----------
ann : jams.Annotation
The annotation to convert
duration : number > 0
The duration of the track
Returns
-------
data : dict
data['tags'] : np.ndarray, s... | entailment |
def inverse(self, encoded, duration=None):
'''Inverse transformation'''
ann = jams.Annotation(namespace=self.namespace, duration=duration)
for start, end, value in self.decode_intervals(encoded,
duration=duration,
... | Inverse transformation | entailment |
def transform_annotation(self, ann, duration):
'''Transform an annotation to static label encoding.
Parameters
----------
ann : jams.Annotation
The annotation to convert
duration : number > 0
The duration of the track
Returns
-------
... | Transform an annotation to static label encoding.
Parameters
----------
ann : jams.Annotation
The annotation to convert
duration : number > 0
The duration of the track
Returns
-------
data : dict
data['tags'] : np.ndarray, sh... | entailment |
def inverse(self, encoded, duration=None):
'''Inverse static tag transformation'''
ann = jams.Annotation(namespace=self.namespace, duration=duration)
if np.isrealobj(encoded):
detected = (encoded >= 0.5)
else:
detected = encoded
for vd in self.encoder.i... | Inverse static tag transformation | entailment |
def transform_audio(self, y):
'''Compute the time position encoding
Parameters
----------
y : np.ndarray
Audio buffer
Returns
-------
data : dict
data['relative'] = np.ndarray, shape=(n_frames, 2)
data['absolute'] = np.ndarray... | Compute the time position encoding
Parameters
----------
y : np.ndarray
Audio buffer
Returns
-------
data : dict
data['relative'] = np.ndarray, shape=(n_frames, 2)
data['absolute'] = np.ndarray, shape=(n_frames, 2)
Re... | entailment |
def add(self, operator):
'''Add an operation to this pump.
Parameters
----------
operator : BaseTaskTransformer, FeatureExtractor
The operation to add
Raises
------
ParameterError
if `op` is not of a correct type
'''
if no... | Add an operation to this pump.
Parameters
----------
operator : BaseTaskTransformer, FeatureExtractor
The operation to add
Raises
------
ParameterError
if `op` is not of a correct type | entailment |
def transform(self, audio_f=None, jam=None, y=None, sr=None, crop=False):
'''Apply the transformations to an audio file, and optionally JAMS object.
Parameters
----------
audio_f : str
Path to audio file
jam : optional, `jams.JAMS`, str or file-like
Opti... | Apply the transformations to an audio file, and optionally JAMS object.
Parameters
----------
audio_f : str
Path to audio file
jam : optional, `jams.JAMS`, str or file-like
Optional JAMS object/path to JAMS file/open file descriptor.
If provided, th... | entailment |
def sampler(self, n_samples, duration, random_state=None):
'''Construct a sampler object for this pump's operators.
Parameters
----------
n_samples : None or int > 0
The number of samples to generate
duration : int > 0
The duration (in frames) of each sa... | Construct a sampler object for this pump's operators.
Parameters
----------
n_samples : None or int > 0
The number of samples to generate
duration : int > 0
The duration (in frames) of each sample patch
random_state : None, int, or np.random.RandomState... | entailment |
def fields(self):
'''A dictionary of fields constructed by this pump'''
out = dict()
for operator in self.ops:
out.update(**operator.fields)
return out | A dictionary of fields constructed by this pump | entailment |
def layers(self):
'''Construct Keras input layers for all feature transformers
in the pump.
Returns
-------
layers : {field: keras.layers.Input}
A dictionary of keras input layers, keyed by the corresponding
fields.
'''
layermap = dict()
... | Construct Keras input layers for all feature transformers
in the pump.
Returns
-------
layers : {field: keras.layers.Input}
A dictionary of keras input layers, keyed by the corresponding
fields. | entailment |
def set_transition_beat(self, p_self):
'''Set the beat-tracking transition matrix according to
self-loop probabilities.
Parameters
----------
p_self : None, float in (0, 1), or np.ndarray [shape=(2,)]
Optional self-loop probability(ies), used for Viterbi decoding
... | Set the beat-tracking transition matrix according to
self-loop probabilities.
Parameters
----------
p_self : None, float in (0, 1), or np.ndarray [shape=(2,)]
Optional self-loop probability(ies), used for Viterbi decoding | entailment |
def set_transition_down(self, p_self):
'''Set the downbeat-tracking transition matrix according to
self-loop probabilities.
Parameters
----------
p_self : None, float in (0, 1), or np.ndarray [shape=(2,)]
Optional self-loop probability(ies), used for Viterbi decoding... | Set the downbeat-tracking transition matrix according to
self-loop probabilities.
Parameters
----------
p_self : None, float in (0, 1), or np.ndarray [shape=(2,)]
Optional self-loop probability(ies), used for Viterbi decoding | entailment |
def transform_annotation(self, ann, duration):
'''Apply the beat transformer
Parameters
----------
ann : jams.Annotation
The input annotation
duration : number > 0
The duration of the audio
Returns
-------
data : dict
... | Apply the beat transformer
Parameters
----------
ann : jams.Annotation
The input annotation
duration : number > 0
The duration of the audio
Returns
-------
data : dict
data['beat'] : np.ndarray, shape=(n, 1)
B... | entailment |
def inverse(self, encoded, downbeat=None, duration=None):
'''Inverse transformation for beats and optional downbeats'''
ann = jams.Annotation(namespace=self.namespace, duration=duration)
beat_times = np.asarray([t for t, _ in self.decode_events(encoded,
... | Inverse transformation for beats and optional downbeats | entailment |
def transform_annotation(self, ann, duration):
'''Transform an annotation to the beat-position encoding
Parameters
----------
ann : jams.Annotation
The annotation to convert
duration : number > 0
The duration of the track
Returns
-------... | Transform an annotation to the beat-position encoding
Parameters
----------
ann : jams.Annotation
The annotation to convert
duration : number > 0
The duration of the track
Returns
-------
data : dict
data['position'] : np.nda... | entailment |
def transform_audio(self, y):
'''Compute the tempogram
Parameters
----------
y : np.ndarray
Audio buffer
Returns
-------
data : dict
data['tempogram'] : np.ndarray, shape=(n_frames, win_length)
The tempogram
'''
... | Compute the tempogram
Parameters
----------
y : np.ndarray
Audio buffer
Returns
-------
data : dict
data['tempogram'] : np.ndarray, shape=(n_frames, win_length)
The tempogram | entailment |
def transform_audio(self, y):
'''Apply the scale transform to the tempogram
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['temposcale'] : np.ndarray, shape=(n_frames, n_fmt)
The sca... | Apply the scale transform to the tempogram
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['temposcale'] : np.ndarray, shape=(n_frames, n_fmt)
The scale transform magnitude coefficients | entailment |
def transform_annotation(self, ann, duration):
'''Apply the structure agreement transformation.
Parameters
----------
ann : jams.Annotation
The segment annotation
duration : number > 0
The target duration
Returns
-------
data : d... | Apply the structure agreement transformation.
Parameters
----------
ann : jams.Annotation
The segment annotation
duration : number > 0
The target duration
Returns
-------
data : dict
data['agree'] : np.ndarray, shape=(n, n), ... | entailment |
def transform_audio(self, y):
'''Compute the STFT magnitude and phase.
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, 1 + n_fft//2)
STFT magnitu... | Compute the STFT magnitude and phase.
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, 1 + n_fft//2)
STFT magnitude
data['phase'] : np.ndarra... | entailment |
def transform_audio(self, y):
'''Compute the STFT with phase differentials.
Parameters
----------
y : np.ndarray
the audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, 1 + n_fft//2)
The STF... | Compute the STFT with phase differentials.
Parameters
----------
y : np.ndarray
the audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, 1 + n_fft//2)
The STFT magnitude
data['dphase'] :... | entailment |
def transform_audio(self, y):
'''Compute the STFT
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, 1 + n_fft//2)
The STFT magnitude
'''
... | Compute the STFT
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, 1 + n_fft//2)
The STFT magnitude | entailment |
def _pad_nochord(target, axis=-1):
'''Pad a chord annotation with no-chord flags.
Parameters
----------
target : np.ndarray
the input data
axis : int
the axis along which to pad
Returns
-------
target_pad
`target` expanded by 1 along the specified `axis`.
... | Pad a chord annotation with no-chord flags.
Parameters
----------
target : np.ndarray
the input data
axis : int
the axis along which to pad
Returns
-------
target_pad
`target` expanded by 1 along the specified `axis`.
The expanded dimension will be 0 when `... | entailment |
def empty(self, duration):
'''Empty chord annotations
Parameters
----------
duration : number
The length (in seconds) of the empty annotation
Returns
-------
ann : jams.Annotation
A chord annotation consisting of a single `no-chord` obser... | Empty chord annotations
Parameters
----------
duration : number
The length (in seconds) of the empty annotation
Returns
-------
ann : jams.Annotation
A chord annotation consisting of a single `no-chord` observation. | entailment |
def transform_annotation(self, ann, duration):
'''Apply the chord transformation.
Parameters
----------
ann : jams.Annotation
The chord annotation
duration : number > 0
The target duration
Returns
-------
data : dict
... | Apply the chord transformation.
Parameters
----------
ann : jams.Annotation
The chord annotation
duration : number > 0
The target duration
Returns
-------
data : dict
data['pitch'] : np.ndarray, shape=(n, 12)
data... | entailment |
def transform_annotation(self, ann, duration):
'''Apply the chord transformation.
Parameters
----------
ann : jams.Annotation
The chord annotation
duration : number > 0
The target duration
Returns
-------
data : dict
... | Apply the chord transformation.
Parameters
----------
ann : jams.Annotation
The chord annotation
duration : number > 0
The target duration
Returns
-------
data : dict
data['pitch'] : np.ndarray, shape=(n, 12)
`pi... | entailment |
def set_transition(self, p_self):
'''Set the transition matrix according to self-loop probabilities.
Parameters
----------
p_self : None, float in (0, 1), or np.ndarray [shape=(n_labels,)]
Optional self-loop probability(ies), used for Viterbi decoding
'''
if ... | Set the transition matrix according to self-loop probabilities.
Parameters
----------
p_self : None, float in (0, 1), or np.ndarray [shape=(n_labels,)]
Optional self-loop probability(ies), used for Viterbi decoding | entailment |
def simplify(self, chord):
'''Simplify a chord string down to the vocabulary space'''
# Drop inversions
chord = re.sub(r'/.*$', r'', chord)
# Drop any additional or suppressed tones
chord = re.sub(r'\(.*?\)', r'', chord)
# Drop dangling : indicators
chord = re.sub... | Simplify a chord string down to the vocabulary space | entailment |
def transform_annotation(self, ann, duration):
'''Transform an annotation to chord-tag encoding
Parameters
----------
ann : jams.Annotation
The annotation to convert
duration : number > 0
The duration of the track
Returns
-------
... | Transform an annotation to chord-tag encoding
Parameters
----------
ann : jams.Annotation
The annotation to convert
duration : number > 0
The duration of the track
Returns
-------
data : dict
data['chord'] : np.ndarray, shape... | entailment |
def transform_audio(self, y):
'''Compute the CQT
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape = (n_frames, n_bins)
The CQT magnitude
data['p... | Compute the CQT
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape = (n_frames, n_bins)
The CQT magnitude
data['phase']: np.ndarray, shape = mag.shape
... | entailment |
def transform_audio(self, y):
'''Compute CQT magnitude.
Parameters
----------
y : np.ndarray
the audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, n_bins)
The CQT magnitude
'''
... | Compute CQT magnitude.
Parameters
----------
y : np.ndarray
the audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, n_bins)
The CQT magnitude | entailment |
def transform_audio(self, y):
'''Compute the CQT with unwrapped phase
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, n_bins)
CQT magnitude
... | Compute the CQT with unwrapped phase
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, n_bins)
CQT magnitude
data['dphase'] : np.ndarray, shap... | entailment |
def transform_audio(self, y):
'''Compute the HCQT
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape = (n_frames, n_bins, n_harmonics)
The CQT magnitude
... | Compute the HCQT
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape = (n_frames, n_bins, n_harmonics)
The CQT magnitude
data['phase']: np.ndarray, shape =... | entailment |
def _index(self, value):
'''Rearrange a tensor according to the convolution mode
Input is assumed to be in (channels, bins, time) format.
'''
if self.conv in ('channels_last', 'tf'):
return np.transpose(value, (2, 1, 0))
else: # self.conv in ('channels_first', 'th... | Rearrange a tensor according to the convolution mode
Input is assumed to be in (channels, bins, time) format. | entailment |
def transform_audio(self, y):
'''Compute HCQT magnitude.
Parameters
----------
y : np.ndarray
the audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, n_bins)
The CQT magnitude
'''
... | Compute HCQT magnitude.
Parameters
----------
y : np.ndarray
the audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, n_bins)
The CQT magnitude | entailment |
def transform_audio(self, y):
'''Compute the HCQT with unwrapped phase
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, n_bins)
CQT magnitude
... | Compute the HCQT with unwrapped phase
Parameters
----------
y : np.ndarray
The audio buffer
Returns
-------
data : dict
data['mag'] : np.ndarray, shape=(n_frames, n_bins)
CQT magnitude
data['dphase'] : np.ndarray, sha... | entailment |
def fill_value(dtype):
'''Get a fill-value for a given dtype
Parameters
----------
dtype : type
Returns
-------
`np.nan` if `dtype` is real or complex
0 otherwise
'''
if np.issubdtype(dtype, np.floating) or np.issubdtype(dtype, np.complexfloating):
return dtype(np.nan)... | Get a fill-value for a given dtype
Parameters
----------
dtype : type
Returns
-------
`np.nan` if `dtype` is real or complex
0 otherwise | entailment |
def empty(self, duration):
'''Create an empty jams.Annotation for this task.
This method should be overridden by derived classes.
Parameters
----------
duration : int >= 0
Duration of the annotation
'''
return jams.Annotation(namespace=self.namespace... | Create an empty jams.Annotation for this task.
This method should be overridden by derived classes.
Parameters
----------
duration : int >= 0
Duration of the annotation | entailment |
def transform(self, jam, query=None):
'''Transform jam object to make data for this task
Parameters
----------
jam : jams.JAMS
The jams container object
query : string, dict, or callable [optional]
An optional query to narrow the elements of `jam.annotat... | Transform jam object to make data for this task
Parameters
----------
jam : jams.JAMS
The jams container object
query : string, dict, or callable [optional]
An optional query to narrow the elements of `jam.annotations`
to be considered.
... | entailment |
def encode_events(self, duration, events, values, dtype=np.bool):
'''Encode labeled events as a time-series matrix.
Parameters
----------
duration : number
The duration of the track
events : ndarray, shape=(n,)
Time index of the events
values : ... | Encode labeled events as a time-series matrix.
Parameters
----------
duration : number
The duration of the track
events : ndarray, shape=(n,)
Time index of the events
values : ndarray, shape=(n, m)
Values array. Must have the same first ind... | entailment |
def encode_intervals(self, duration, intervals, values, dtype=np.bool,
multi=True, fill=None):
'''Encode labeled intervals as a time-series matrix.
Parameters
----------
duration : number
The duration (in frames) of the track
intervals : np.... | Encode labeled intervals as a time-series matrix.
Parameters
----------
duration : number
The duration (in frames) of the track
intervals : np.ndarray, shape=(n, 2)
The list of intervals
values : np.ndarray, shape=(n, m)
The (encoded) values... | entailment |
def decode_events(self, encoded, transition=None, p_state=None, p_init=None):
'''Decode labeled events into (time, value) pairs
Real-valued inputs are thresholded at 0.5.
Optionally, viterbi decoding can be applied to each event class.
Parameters
----------
encoded : n... | Decode labeled events into (time, value) pairs
Real-valued inputs are thresholded at 0.5.
Optionally, viterbi decoding can be applied to each event class.
Parameters
----------
encoded : np.ndarray, shape=(n_frames, m)
Frame-level annotation encodings as produced b... | entailment |
def decode_intervals(self, encoded, duration=None, multi=True, sparse=False,
transition=None, p_state=None, p_init=None):
'''Decode labeled intervals into (start, end, value) triples
Parameters
----------
encoded : np.ndarray, shape=(n_frames, m)
Fra... | Decode labeled intervals into (start, end, value) triples
Parameters
----------
encoded : np.ndarray, shape=(n_frames, m)
Frame-level annotation encodings as produced by
``encode_intervals``
duration : None or float > 0
The max duration of the annota... | entailment |
def transform(self, y, sr):
'''Transform an audio signal
Parameters
----------
y : np.ndarray
The audio signal
sr : number > 0
The native sampling rate of y
Returns
-------
dict
Data dictionary containing features ext... | Transform an audio signal
Parameters
----------
y : np.ndarray
The audio signal
sr : number > 0
The native sampling rate of y
Returns
-------
dict
Data dictionary containing features extracted from y
See Also
... | entailment |
def phase_diff(self, phase):
'''Compute the phase differential along a given axis
Parameters
----------
phase : np.ndarray
Input phase (in radians)
Returns
-------
dphase : np.ndarray like `phase`
The phase differential.
'''
... | Compute the phase differential along a given axis
Parameters
----------
phase : np.ndarray
Input phase (in radians)
Returns
-------
dphase : np.ndarray like `phase`
The phase differential. | entailment |
def layers(self):
'''Construct Keras input layers for the given transformer
Returns
-------
layers : {field: keras.layers.Input}
A dictionary of keras input layers, keyed by the corresponding
field keys.
'''
from keras.layers import Input
... | Construct Keras input layers for the given transformer
Returns
-------
layers : {field: keras.layers.Input}
A dictionary of keras input layers, keyed by the corresponding
field keys. | entailment |
def n_frames(self, duration):
'''Get the number of frames for a given duration
Parameters
----------
duration : number >= 0
The duration, in seconds
Returns
-------
n_frames : int >= 0
The number of frames at this extractor's sampling rat... | Get the number of frames for a given duration
Parameters
----------
duration : number >= 0
The duration, in seconds
Returns
-------
n_frames : int >= 0
The number of frames at this extractor's sampling rate and
hop length | entailment |
def start(component, exact):
# type: (str, str) -> None
""" Create a new release branch.
Args:
component (str):
Version component to bump when creating the release. Can be *major*,
*minor* or *patch*.
exact (str):
The exact version to set for the release.... | Create a new release branch.
Args:
component (str):
Version component to bump when creating the release. Can be *major*,
*minor* or *patch*.
exact (str):
The exact version to set for the release. Overrides the component
argument. This allows to re-rel... | entailment |
def tag(message):
# type: () -> None
""" Tag the current commit with the current version. """
release_ver = versioning.current()
message = message or 'v{} release'.format(release_ver)
with conf.within_proj_dir():
log.info("Creating release tag")
git.tag(
author=git.lates... | Tag the current commit with the current version. | entailment |
def lint(exclude, skip_untracked, commit_only):
# type: (List[str], bool, bool) -> None
""" Lint python files.
Args:
exclude (list[str]):
A list of glob string patterns to test against. If the file/path
matches any of those patters, it will be filtered out.
skip_untr... | Lint python files.
Args:
exclude (list[str]):
A list of glob string patterns to test against. If the file/path
matches any of those patters, it will be filtered out.
skip_untracked (bool):
If set to **True** it will skip all files not tracked by git.
comm... | entailment |
def tool(name):
# type: (str) -> FunctionType
""" Decorator for defining lint tools.
Args:
name (str):
The name of the tool. This name will be used to identify the tool
in `pelconf.yaml`.
"""
global g_tools
def decorator(fn): # pylint: disable=missing-docstring... | Decorator for defining lint tools.
Args:
name (str):
The name of the tool. This name will be used to identify the tool
in `pelconf.yaml`. | entailment |
def pep8_check(files):
# type: (List[str]) -> int
""" Run code checks using pep8.
Args:
files (list[str]):
A list of files to check
Returns:
bool: **True** if all files passed the checks, **False** otherwise.
pep8 tool is **very** fast. Especially compared to pylint an... | Run code checks using pep8.
Args:
files (list[str]):
A list of files to check
Returns:
bool: **True** if all files passed the checks, **False** otherwise.
pep8 tool is **very** fast. Especially compared to pylint and the bigger the
code base the bigger the difference. If y... | entailment |
def pylint_check(files):
# type: (List[str]) -> int
""" Run code checks using pylint.
Args:
files (list[str]):
A list of files to check
Returns:
bool: **True** if all files passed the checks, **False** otherwise.
"""
files = fs.wrap_paths(files)
cfg_path = conf.... | Run code checks using pylint.
Args:
files (list[str]):
A list of files to check
Returns:
bool: **True** if all files passed the checks, **False** otherwise. | entailment |
def run(self):
# type: () -> bool
""" Run all linters and report results.
Returns:
bool: **True** if all checks were successful, **False** otherwise.
"""
with util.timed_block() as t:
files = self._collect_files()
log.info("Collected <33>{} <32>f... | Run all linters and report results.
Returns:
bool: **True** if all checks were successful, **False** otherwise. | entailment |
def send_to_azure(instance, data, replace=True, types=None, primary_key=(), sub_commit=True):
"""
data = {
"table_name" : 'name_of_the_azure_schema' + '.' + 'name_of_the_azure_table' #Must already exist,
"columns_name" : [first_column_name,second_column_name,...,last_column_name],
"row... | data = {
"table_name" : 'name_of_the_azure_schema' + '.' + 'name_of_the_azure_table' #Must already exist,
"columns_name" : [first_column_name,second_column_name,...,last_column_name],
"rows" : [[first_raw_value,second_raw_value,...,last_raw_value],...]
} | entailment |
def getdict(source):
"""Returns a standard python Dict with computed values
from the DynDict
:param source: (DynDict) input
:return: (dict) Containing computed values
"""
std_dict = {}
for var, val in source.iteritems():
std_dict[var] = source[var]
return std_dict | Returns a standard python Dict with computed values
from the DynDict
:param source: (DynDict) input
:return: (dict) Containing computed values | entailment |
def enrich_app(self, name, value):
'''
Add a new property to the app (with setattr)
Args:
name (str): the name of the new property
value (any): the value of the new property
'''
#Method shouldn't be added: https://stackoverflow.com/a/28060251/3042398
... | Add a new property to the app (with setattr)
Args:
name (str): the name of the new property
value (any): the value of the new property | entailment |
def linfit(x_true, y, sigmay=None, relsigma=True, cov=False, chisq=False, residuals=False):
"""
Least squares linear fit.
Fit a straight line `f(x_true) = a + bx` to points `(x_true, y)`. Returns
coefficients `a` and `b` that minimize the squared error.
Parameters
----------
x_t... | Least squares linear fit.
Fit a straight line `f(x_true) = a + bx` to points `(x_true, y)`. Returns
coefficients `a` and `b` that minimize the squared error.
Parameters
----------
x_true : array_like
one dimensional array of `x_true` data with `n`>2 data points.
y : array_li... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.