Collection of lnPi objects (lnpiseries)#

Classes:

lnPiCollection(data, *[, index, name, ...])

Wrapper around pandas.Series for collection of lnPiMasked objects.

class lnpy.lnpiseries.lnPiCollection(data, *, index=None, name=None, dtype=None, xarray_output=True, concat_dim='sample', concat_coords='different', unstack=True, base_class='first')[source]#

Bases: AccessorMixin, MyAttrsMixin

Wrapper around pandas.Series for collection of lnPiMasked objects.

Parameters:

Note

Underlying data is created from pd.Series(data, index=index, dtype=dtype, name=name)

Attributes:

series

Underlying series.

s

Alias to series()

values

Series values

items

Alias to values

index

Series index

name

Series name

loc

Indexer by value.

iloc

Index by position.

query

Query data.

zloc

Positional indexer for everything but phase.

mloc

Index with pandas index

state_kws

state_kws from first lnPiMasked

nlnz

Number of unique lnzs

index_frame

Values (from xarray.DataArray) for each sample.

xge

Accessor to GrandCanonicalEnsemble.

wfe

Accessor to wFreeEnergyPhases from wfe_phases.

wfe_phases

Accessor to wFreeEnergyCollection from wfe.

wlnPi

Deprecated accessor to wFreeEnergyCollection from wlnPi.

wlnPi_single

Deprecated accessor to wFreeEnergyPhases from wlnPi_single.

spinodal

Accessor to Spinodals

binodal

Accessor to Binodals

Methods:

apply_series_function(func)

Apply function to series and wrap.

xs(key[, axis, level, drop_level, wrap])

Interface to pandas.Series.xs()

append(to_append[, ignore_index, ...])

Interface to pandas.concat()

droplevel(level)

New object with dropped level

apply(func[, convert_dtype, args, wrap])

Interface to pandas.Series.apply()

sort_index(*args, **kwargs)

Interface to pandas.Series.sort_index()

groupby([by, level, as_index, sort, ...])

Wrapper around pandas.Series.groupby().

groupby_allbut(drop, *[, wrap])

Groupby all but columns in drop

concat_like(objs, **concat_kws)

Concat a sequence of objects like self

concat(objs, *args[, concat_kws])

Create collection from sequence of objects

get_index_level([level])

Get index values for specified level

wrap_list_results(items)

Utility to wrap output in :class:xarray.DataArray

from_list(items, index, **kwargs)

Create collection from list of lnPiMasked objects.

from_builder(lnzs, build_phases[, ...])

Build collection from scalar builder

to_dataarray([dtype, reset_index])

Convert collection to a DataArray

from_labels(ref, labels, lnzs[, features, ...])

Create from reference lnPiMasked and labels array

from_dataarray(ref, da[, grouper, ...])

Create a collection from DataArray of labels

property series#

Underlying series.

property s#

Alias to series()

property values#

Series values

property items#

Alias to values

property index#

Series index

property name#

Series name

apply_series_function(func)[source]#

Apply function to series and wrap.

xs(key, axis=0, level=None, drop_level=False, wrap=True)[source]#

Interface to pandas.Series.xs()

append(to_append, ignore_index=False, verify_integrity=True, concat_kws=None)[source]#

Interface to pandas.concat()

Parameters:
  • to_append (object) – Object to append

  • ignore_index (bool, default False)

  • verify_integrity (bool, default True)

  • concat_kws (mapping, optional) – Extra arguments to

See also

pandas.concat

droplevel(level)[source]#

New object with dropped level

apply(func, convert_dtype=True, args=(), wrap=False, **kwds)[source]#

Interface to pandas.Series.apply()

sort_index(*args, **kwargs)[source]#

Interface to pandas.Series.sort_index()

groupby(by=None, *, level=None, as_index=True, sort=True, group_keys=True, observed=False, dropna=True, wrap=False)[source]#

Wrapper around pandas.Series.groupby().

Parameters:

wrap (bool, default False) – if True, try to wrap output in class of self

groupby_allbut(drop, *, wrap=False, **kwargs)[source]#

Groupby all but columns in drop

concat_like(objs, **concat_kws)[source]#

Concat a sequence of objects like self

classmethod concat(objs, *args, concat_kws=None, **kwargs)[source]#

Create collection from sequence of objects

loc[source]#

Indexer by value. See pandas.Series.loc

iloc[source]#

Index by position. See pandas.Series.iloc

query[source]#

Query data. See pandas.DataFrame.query()

zloc[source]#

Positional indexer for everything but phase.

mloc[source]#

Index with pandas index

property state_kws#

state_kws from first lnPiMasked

property nlnz#

Number of unique lnzs

index_frame[source]#

Values (from xarray.DataArray) for each sample.

includes a column ‘lnz_index’ which is the unique lnz values regardless of phase

get_index_level(level='phase')[source]#

Get index values for specified level

wrap_list_results(items)[source]#

Utility to wrap output in :class:xarray.DataArray

classmethod from_list(items, index, **kwargs)[source]#

Create collection from list of lnPiMasked objects.

Parameters:
  • items (sequence of lnPiMasked) – Sequence of lnPi

  • index (sequence) – Sequence of phases ID for each lnPi

  • **kwargs – Extra keyword arguments to cls

Returns:

lnPiCollection

classmethod from_builder(lnzs, build_phases, build_kws=None, base_class='first', **kwargs)[source]#

Build collection from scalar builder

Parameters:
  • lnzs (sequence of float) – One dimensional array of lnz value for the varying component.

  • build_phases (callable()) – Typically one of PhaseCreator.build_phases_mu or PhaseCreator.build_phases_dmu

  • build_kws (optional) – optional arguments to build_phases

  • **kwargs – Extra arguments to from_list()

Returns:

lnPiCollection

to_dataarray(dtype=None, reset_index=True)[source]#

Convert collection to a DataArray

Parameters:
  • dtype (numpy.dtype, optional) – Default to numpy.uint8.

  • reset_index (bool, default True)

classmethod from_labels(ref, labels, lnzs, features=None, include_boundary=False, labels_kws=None, check_features=True, **kwargs)[source]#

Create from reference lnPiMasked and labels array

Parameters:
  • ref (lnPiMasked)

  • labels (sequence of ndarray of int) – Each labels[i] is a labels array for each value of lnzs[i]. That is, the labels for different phases at a given value of lnz.

  • lnzs (sequence) – Each lnzs[i] will be passed to ref.reweight.

  • features (sequence of int) – If specified, extract only those locations where labels == feature for all values feature in features. That is, select a subset of unique label values.

  • include_boundary (bool) – if True, include boundary regions in output mask

  • labels_kws (mapping, optional)

  • check_features (bool) – if True, then make sure each feature is in labels

  • **kwargs – Extra arguments past to from_list()

classmethod from_dataarray(ref, da, grouper='sample', include_boundary=False, labels_kws=None, features=None, check_features=True, **kwargs)[source]#

Create a collection from DataArray of labels

Parameters:
  • ref (lnPiMasked)

  • da (DataArray or int) – Labels.

  • grouper (Hashable) – Name of dimension(s) to group along to give a single label array

  • features (sequence of int) – If specified, extract only those locations where labels == feature for all values feature in features. That is, select a subset of unique label values.

  • check_features (bool) – if True, then make sure each feature is in labels

See also

from_labels

xge[source]#

Accessor to GrandCanonicalEnsemble.

wfe[source]#

Accessor to wFreeEnergyPhases from wfe_phases.

wfe_phases[source]#

Accessor to wFreeEnergyCollection from wfe.

property wlnPi#

Deprecated accessor to wFreeEnergyCollection from wlnPi.

Alias to wfe

property wlnPi_single#

Deprecated accessor to wFreeEnergyPhases from wlnPi_single.

Alias to wfe_phases

spinodal[source]#

Accessor to Spinodals

binodal[source]#

Accessor to Binodals