Skip to content

Object Attributes🍋

ObjectAttribute (Entity) 🍋

Base class holding elements information/meta-data defining object attributes. It does not hold the attribute data directly but simply points to the database to retrieve it dynamically so that the values are always up-to-date.

An attribute can be either static or dynamic, i-e its value will be recomputed according to the defined expression/condition each time. Therefore it is not valid to have a dynamic attribute without expression.

An ObjectAttribute requires a parent ObjectDB, it is therefore not advised to instantiate any descendant of this class directly. Object attribute creation should be done through the GeoRefObject instead.

Parameters:

Name Type Description Default
db ObjectDB

reference ObjectDB to get data from.

required
name str

attribute name.

required
expr str

[Optional] attribute is computed as a condition or expression of other attributes.

None
dynamic bool

[Optional] attributes values are recomputed each time the data is requested. expr must be defined if attribute is dynamic.

False
read_only bool

[Optional] attribute data is protected.

False

Exceptions:

Type Description
ValueError

ObjectDB or name is not provided.

ValueError

Attribute is dynamic but expr is not provided.

Attributes:

Name Type Description
name str

name of the attribute.

expr str

expression or condition to compute the attribute data.

dynamic bool

if True, data is recomputed by ObjectDB each time it is accessed.

read_only bool

wheter the attribute is considered read-only.

dynamic: bool property readonly 🍋

Return whether the attribute is dynamic, i-e. its data is recomputed using the provided expression.

Returns:

Type Description
bool

True if dynamic, False otherwise.

expr: str property readonly 🍋

Return the attribute expression if provided at creation, otherwise None.

Returns:

Type Description
str

Attribute expression.

name: str property readonly 🍋

Return the attribute name.

Returns:

Type Description
str

Attribute name.

read_only: bool property readonly 🍋

Return whether the attribute is read-only, i-e. its data is protected.

Returns:

Type Description
bool

True if read-only, False otherwise.

data(self, region=None) 🍋

Return the data associated to this attribute. If dynamic, the data will be recomputed first according to its provided expression.

Returns:

Type Description
np.ndarray

Underlying attribute data array.

ObjectProperty (ObjectAttribute) 🍋

Property attribute class. See ObjectAttribute for more information.

Parameters:

Name Type Description Default
db ObjectDB

reference ObjectDB to get data from.

required
name str

property name.

required
kind PropertyKind

[Optional] property kind, see PropertyKind enum for more available kind.

None
unit Unit

[Optional] property unit, see Unit in pint for more information.

None
expr str

[Optional] property is computed as an expression of other attributes.

None
dynamic bool

[Optional] attributes values are recomputed each time the data is requested. expr must be defined if property is dynamic.

False
read_only bool

[Optional] attribute data is protected.

False

Exceptions:

Type Description
ValueError

ObjectDB or name is not provided.

ValueError

Property is dynamic but expr is not provided.

Attributes:

Name Type Description
kind PropertyKind

property kind if defined, otherwise None.

unit Unit

property unit if defined, otherwise None.

kind: PropertyKind property readonly 🍋

Return the kind associated to the property if any, None otherwise.

Returns:

Type Description
PropertyKind

Property kind.

unit: Unit property readonly 🍋

Return the unit associated to the property if any, None otherwise.

Returns:

Type Description
Unit

Pint Unit.

ObjectRegion (ObjectAttribute) 🍋

Region attribute class. See ObjectAttribute for more information.

Parameters:

Name Type Description Default
db ObjectDB

reference ObjectDB to get data from.

required
name str

region name.

required
condition str

[Optional] region is computed as a condition of other attributes.

None
dynamic bool

[Optional] attributes values are recomputed each time the data is requested. expr must be defined if property is dynamic.

False
read_only bool

[Optional] attribute data is protected.

False

Exceptions:

Type Description
ValueError

ObjectDB or name is not provided.

ValueError

Region is dynamic but expr is not provided.

Back to top