Mixins

The galactic.context.mixins package defines mixins classes for defining new types of contexts:

  • ConcreteIndividual for defining individuals that own their identifier as a field
  • ConcreteAttribute for defining attributes that own their name and their type as fields
  • ContextHolder for defining elements that own their context as a field
  • PopulationHolder for defining elements that own their population as a field
  • ModelHolder for defining elements that own their model as a field
  • AttributesHolder for defining models that own their attributes as a field
  • IndividualsHolder for defining population that own their individuals as a field
  • ValuesHolder for defining individuals that own their values as a field

They are widely used for defining

in the galactic.context.memory package.

New in version 0.0.1.

class galactic.context.mixins.ConcreteIndividual(**kwargs)[source]

The ConcreteIndividual class is a mixin used in subclassing the Individual class for storing their identifier as a field.

New in version 0.0.1.

__init__(**kwargs)[source]

Initialise an individual.

Keyword Arguments:
 identifier (str) – the individual identifier

New in version 0.0.1.

identifier

Get the individual identifier.

Returns:the individual identifier
Return type:str

New in version 0.0.1.

class galactic.context.mixins.ConcreteAttribute(**kwargs)[source]

The ConcreteAttribute class is a mixin used in subclassing the Attribute class for storing their name and their type as a class.

New in version 0.0.1.

__init__(**kwargs)[source]

Initialise an attribute

Keyword Arguments:
 
  • name (str) – the attribute name
  • type (type) – the attribute type

New in version 0.0.1.

name

Get the attribute name.

Returns:the attribute name
Return type:str

New in version 0.0.1.

type

Get the attribute type.

Returns:the attribute type
Return type:type

New in version 0.0.1.

class galactic.context.mixins.ContextHolder(**kwargs)[source]

The ContextHolder[C] is a mixin used for storing an element context as a field.

It’s a generic class that depends of a Context subclass C.

New in version 0.0.1.

__init__(**kwargs)[source]

Initialise an element by setting its context.

Keyword Arguments:
 context (C) – the context

New in version 0.0.1.

context

Get the context.

Returns:the context
Return type:C

New in version 0.0.1.

class galactic.context.mixins.PopulationHolder(**kwargs)[source]

The PopulationHolder[P] is a mixin used for storing an element population as a field.

It’s a generic class that depends of a Population subclass P.

New in version 0.0.1.

__init__(**kwargs)[source]

Initialise an element by setting its population.

Keyword Arguments:
 population (P) – the population

New in version 0.0.1.

population

Get the population.

Returns:the population
Return type:P

New in version 0.0.1.

class galactic.context.mixins.ModelHolder(**kwargs)[source]

The ModelHolder[M] class is a mixin used for storing an element model as a field.

It’s a generic class that depends of a Model subclass M.

New in version 0.0.1.

__init__(**kwargs)[source]

Initialise an element by setting its model.

Keyword Arguments:
 model (M) – the model

New in version 0.0.1.

model

Get the model.

Returns:the model
Return type:M

New in version 0.0.1.

class galactic.context.mixins.AttributesHolder(**kwargs)[source]

The AttributesHolder[A] class is a mixin used for storing the model attributes in memory.

It’s a generic class that depends of an Attribute subclass A.

New in version 0.0.1.

__init__(**kwargs)[source]

Initialise an attribute holder.

Keyword Arguments:
 attributes (Iterable[A]) – the attributes

New in version 0.0.1.

class galactic.context.mixins.IndividualsHolder(**kwargs)[source]

The IndividualsHolder[X] class is a mixin used for storing the population individuals in memory.

It’s a generic class that depends of an Individual subclass X.

New in version 0.0.1.

__init__(**kwargs)[source]

Initialise an individuals holder.

Keyword Arguments:
 individuals (Iterable[A]) – the individuals

New in version 0.0.1.

class galactic.context.mixins.ValuesHolder(**kwargs)[source]

The ValuesHolder[A] class is a mixin for storing the individual values in memory.

It’s a generic class that depends of an Attribute subclass A.

New in version 0.0.1.

__init__(**kwargs)[source]

Initialise a values holder.

Keyword Arguments:
 values (Mapping[str, object]) – the initial (name, value) pairs

New in version 0.0.1.