Collection of lnPi objects (lnpiseries)#

Classes:

lnPiCollection(data[, index, xarray_output, ...])

Wrapper around pandas.Series for collection of lnPiMasked objects.

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

Bases: AccessorMixin

Wrapper around pandas.Series for collection of lnPiMasked objects.

Parameters:
  • data (sequence of lnPiMasked) – \(\ln \Pi(N)\) instances to consider.

  • index (array-like, pandas.Index, pandas.MultiIndex, optional) – Index to apply to Series.

  • xarray_output (bool, default True) – If True, then wrap lnPiCollection outputs in DataArray

  • concat_dim (str, optional) – Name of dimensions to concat results along. Also Used by xGrandCanonical.

  • concat_coords (string, optional) – parameters coords `to :func:`xarray.concat

  • unstack (bool, default True) – If True, then outputs will be unstacked using xarray.DataArray.unstack()

  • single_state (bool, default True) – If True, verify that all data has same shape, and value of state_kws. That is, all lnpi are for a single state.

  • *args **kwargs – Extra arguments to Series constructor

Methods:

new_like([data, index])

Create new object with optional new data/index

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[, 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[, ref, ...])

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

Attributes:

series

View of the underlying pandas.Series

s

Alias to series()

values

Series values

items

Alias to values

index

Series index

name

Series name

state_kws

state_kws from first lnPiMasked

nlnz

Number of unique lnzs

index_frame

Values (from xarray.DataArray) for each sample.

xge

Accessor to xGrandCanonical.

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

new_like(data=None, index=None, **kwargs)[source]#

Create new object with optional new data/index

property series#

View of the underlying pandas.Series

property s#

Alias to series()

property values#

Series values

property items#

Alias to values

property index#

Series index

property name#

Series name

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, inplace=False)[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

  • inplace (bool, default False)

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, concat_kws=None, *args, **kwargs)[source]#

Create collection from sequence of objects

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

  • *args – Extra positional arguments to cls

  • **kwargs – Extra keyword arguments to cls

Returns:

lnPiCollection

classmethod from_builder(lnzs, build_phases, ref=None, build_kws=None, nmax=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.

  • ref (lnPiMasked) – lnpi_phases to reweight to get list of lnpi’s

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

  • build_kws (optional) – optional arguments to build_phases

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 xGrandCanonical.

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