rc.data.models§

Models for data storage.

Classes§

DesignMatrix

The familiar user format of DesignMatrix which is fat (has many columns).

NormalDesignMatrix

The internal format of DesignMatrix, which is thin (has few columns).

Normalization

Normalization of a Repo.

Repo

A Repository of data and models. Informally a dataset and all the things we'd like to do to it.

Module Contents§

class DesignMatrix(path, data=None, **options)[source]§

Bases: rc.base.Table

Inheritance diagram of rc.data.models.DesignMatrix

The familiar user format of DesignMatrix which is fat (has many columns).

Parameters:
  • path (Store)

  • data (rc.base.definitions.Self | rc.base.definitions.Pd.DataFrame | None)

  • options (rc.base.definitions.Any)

Label§

Class attribute aliasing acceptable Types for column (or index) labels.

skeleton: rc.base.Pd.DataFrame§

DataFrame of the minimal, skeleton DesignMatrix.

defaultOptions: rc.base.MetaData§

Default file handling DesignMatrix.Options().

classmethod create(path, src, columns_in_l='')[source]§

Reformat the NormalDesignMatrix in src as a Self(DesignMatrix).

Parameters:
  • path (rc.base.Store.Path) – The Path to store the DesignMatrix created, overwritten if existing.

  • src (NormalDesignMatrix) – The NormalDesignMatrix to reformat.

  • columns_in_l (Label)

Return type:

rc.base.Self

Returns: The NormalDesignMatrix created at dst.

classmethod copy(src, dst='')[source]§

Reformat this DesignMatrix to a NormalDesignMatrix.

Parameters:
  • src (rc.base.Self) – The DesignMatrix to reformat.

  • dst (rc.base.Store.Path) – Optional Path to the NormalDesignMatrix. Defaults to '', which overwrites src.

Return type:

NormalDesignMatrix

Returns: The NormalDesignMatrix created at dst.

class NormalDesignMatrix(path, data=None, **options)[source]§

Bases: DesignMatrix

Inheritance diagram of rc.data.models.NormalDesignMatrix

The internal format of DesignMatrix, which is thin (has few columns).

Parameters:
  • path (Store)

  • data (rc.base.definitions.Self | rc.base.definitions.Pd.DataFrame | None)

  • options (rc.base.definitions.Any)

create(path, src)[source]§

Reformat the NormalDesignMatrix in src as a Self(DesignMatrix).

Parameters:
  • path (rc.base.Store.Path) – The Path to store the DesignMatrix created, overwritten if existing.

  • src (NormalDesignMatrix) – The NormalDesignMatrix to reformat.

Return type:

rc.base.Self

Returns: The NormalDesignMatrix created at dst.

copy(src, dst='')[source]§

Reformat this DesignMatrix to a NormalDesignMatrix.

Parameters:
  • src (rc.base.Self) – The DesignMatrix to reformat.

  • dst (rc.base.Store.Path) – Optional Path to the NormalDesignMatrix. Defaults to '', which overwrites src.

Return type:

NormalDesignMatrix

Returns: The NormalDesignMatrix created at dst.

class Normalization(path, **tables)[source]§

Bases: rc.base.DataBase

Inheritance diagram of rc.data.models.Normalization

Normalization of a Repo.

Parameters:
  • path (rc.base.Store.Path)

  • tables (rc.base.Table | PD.DataFrame)

class NamedTables[source]§

Bases: rc.base.NamedTuple

Inheritance diagram of rc.data.models.Normalization.NamedTables

Must be overridden.

__call__(name)[source]§

Returns the Table named name.

Parameters:

name (str)

Return type:

rc.base.Table | rc.base.Matrix | rc.base.MetaData

options: NamedTables[rc.base.MetaData]§

Class attribute of the form NamedTables(**{names[i]: options[i], ...}). Override as necessary for bespoke Table.options. Elements of options[i] found in Table.writeOptions populate self[i].options.write, the remainder populate self[i].options.read.

__call__(**meta)[source]§

Optimize and update self.

Parameters:

**meta (rc.base.Any) – Optimization MetaData.

Return type:

rc.base.Self

Returns: self

classmethod create(path, data, **meta)[source]§

Create a Normalization in path.

Parameters:
  • path (rc.base.Store.Path) – The folder to store the Normalization in. Need not exist, any existing Tables will be overwritten if it does.

  • **meta (rc.base.Any) – Optimization MetaData.

  • data (DesignMatrix)

  • **meta

Return type:

rc.base.Self

Returns: The Normalization created.

class Repo(path, **tables)[source]§

Bases: rc.base.DataBase

Inheritance diagram of rc.data.models.Repo

A Repository of data and models. Informally a dataset and all the things we’d like to do to it.

Parameters:
  • path (Store)

  • tables (Table | rc.base.definitions.Pd.DataFrame)

class NamedTables[source]§

Bases: rc.base.NamedTuple

Inheritance diagram of rc.data.models.Repo.NamedTables

Must be overridden.

__call__(name)[source]§

Returns the Table named name.

Parameters:

name (str)

Return type:

rc.base.Table | rc.base.Matrix | rc.base.MetaData

options: NamedTables[rc.base.MetaData]§

Class attribute of the form NamedTables(**{names[i]: options[i], ...}). Override as necessary for bespoke Table.options. Elements of options[i] found in Table.writeOptions populate self[i].options.write, the remainder populate self[i].options.read.

property fold§

The current fold.

__len__()[source]§

1 + K proper folds in self.

Return type:

int

__getitem__(fold)[source]§

Indexer returns the Path (s) to the Folds indexed or sliced by fold.

Parameters:

fold (int | slice)

Return type:

rc.base.Path | rc.base.Tuple[rc.base.Path, Ellipsis]

__setitem__(fold, tables)[source]§

Indexer creates the Fold (s) named or sliced by name.

Parameters:
  • fold (int | slice)

  • tables (rc.base.Table | rc.base.Matrix | rc.base.Tuple[rc.base.Table | rc.base.Matrix, Ellipsis])

__call__(**meta)[source]§

Optimize and update self.

Parameters:

**meta (rc.base.Any) – Optimization MetaData.

Return type:

rc.base.Self

Returns: self