pept.tracking.Condition#

class pept.tracking.Condition(*conditions)[source]#

Bases: Filter

Select only data satisfying multiple conditions, given as a string, a function or list thereof; e.g. Condition("error < 15") selects all points whose “error” column value is smaller than 15.

Filter signature:

PointData -> Condition.fit_sample -> PointData
 LineData -> Condition.fit_sample -> LineData

In the simplest case, a column name is specified, plus a comparison, e.g. Condition("error < 15, y > 100"); multiple conditions may be concatenated using a comma.

More complex conditions - where the column name is not the first operand - can be constructed using single quotes, e.g. using NumPy functions in Condition("np.isfinite('x')") to filter out NaNs and Infs. Quotes can be used to index columns too: Condition("'0' < 150") selects all rows whose first column is smaller than 150.

Generally, you can use any function returning a boolean mask, either as a string of code Condition("np.isclose('x', 3)") or a user-defined function receiving a NumPy array Condition(lambda x: x[:, 0] < 10).

Finally, multiple such conditions may be supplied separately: Condition(lambda x: x[:, -1] > 10, "'t' < 50").

__init__(*conditions)[source]#

Methods

__init__(*conditions)

copy([deep])

Create a deep copy of an instance of this class, including all inner attributes.

fit(samples[, executor, max_workers, verbose])

Apply self.fit_sample (implemented by subclasses) according to the execution policy.

fit_sample(sample)

load(filepath)

Load a saved / pickled PEPTObject object from filepath.

save(filepath)

Save a PEPTObject instance as a binary pickle object.

Attributes

conditions

property conditions#
fit_sample(sample: IterableSamples)[source]#
copy(deep=True)#

Create a deep copy of an instance of this class, including all inner attributes.

fit(samples, executor='joblib', max_workers=None, verbose=True)#

Apply self.fit_sample (implemented by subclasses) according to the execution policy. Simply return a list of processed samples. If you need a reduction step (e.g. stack all processed samples), apply it in the subclass.

static load(filepath)#

Load a saved / pickled PEPTObject object from filepath.

Most often the full object state was saved using the .save method.

Parameters
filepathfilename or file handle

If filepath is a path (rather than file handle), it is relative to where python is called.

Returns
pept.PEPTObject subclass instance

The loaded object.

Examples

Save a LineData instance, then load it back:

>>> lines = pept.LineData([[1, 2, 3, 4, 5, 6, 7]])
>>> lines.save("lines.pickle")
>>> lines_reloaded = pept.LineData.load("lines.pickle")
save(filepath)#

Save a PEPTObject instance as a binary pickle object.

Saves the full object state, including inner attributes, in a portable binary format. Load back the object using the load method.

Parameters
filepathfilename or file handle

If filepath is a path (rather than file handle), it is relative to where python is called.

Examples

Save a LineData instance, then load it back:

>>> lines = pept.LineData([[1, 2, 3, 4, 5, 6, 7]])
>>> lines.save("lines.pickle")
>>> lines_reloaded = pept.LineData.load("lines.pickle")