pycsamt.api.property#

Common object and metadata helpers for pyCSAMT APIs.

Classes

MetadataMixin()

Small mixin for attaching free-form object metadata.

PyCSAMTObject()

Root object for lightweight pyCSAMT API behavior.

class pycsamt.api.property.MetadataMixin[source]#

Bases: object

Small mixin for attaching free-form object metadata.

The mixin is intentionally separate from PyCSAMTObject so the universal root class remains lightweight.

metadata: dict[str, Any]#
ensure_metadata()[source]#

Return the metadata mapping, creating it when needed.

Return type:

dict[str, Any]

update_metadata(**metadata)[source]#

Update metadata in place and return self.

Parameters:

metadata (Any)

Return type:

MetadataMixin

metadata_dict()[source]#

Return a shallow copy of attached metadata.

Return type:

dict[str, Any]

class pycsamt.api.property.PyCSAMTObject[source]#

Bases: object

Root object for lightweight pyCSAMT API behavior.

PyCSAMTObject provides a small, dependency-light base for readable object display and shallow introspection. It is not an electromagnetic numerical class and does not assume EDI, MT, TEM, ModEM, Occam, or AI semantics.

Subclasses may override __repr__ or __str__ freely. For smaller customization, define __repr_fields__ or __repr_exclude__ on the subclass.

Variables:
  • __repr_fields__ (iterable of str or None) – Explicit field order for __repr__. If None, dataclass fields, __dict__ keys, and __slots__ names are discovered automatically.

  • __repr_exclude__ (set of str) – Attribute names excluded from automatic displays.

  • __repr_max_fields__ (int) – Maximum number of fields shown in __repr__.

  • __repr_max_string__ (int) – Maximum string length before shortening.

Examples

>>> class Obj(PyCSAMTObject):
...     def __init__(self):
...         self.name = "S001"
...         self.verbose = 2
...         self.values = [1, 2, 3]
>>> repr(Obj())
"Obj(name='S001', values=list(len=3, sample=[1, 2, 3]))"
summary(*, max_fields=None)[source]#

Return a short one-line object summary.

Parameters:

max_fields (int | None)

Return type:

str

to_dict(*, public_only=True, max_depth=1)[source]#

Return a shallow dictionary representation.

Parameters:
  • public_only (bool)

  • max_depth (int)

Return type:

dict[str, Any]

update(**kwargs)[source]#

Set attributes from keyword arguments and validate.

Parameters:

kwargs (Any)

Return type:

PyCSAMTObject

clone(**overrides)[source]#

Return a shallow copy with optional attribute overrides.

Parameters:

overrides (Any)

Return type:

PyCSAMTObject

validate()[source]#

Validate object state.

Subclasses can override this hook. The base implementation intentionally accepts all states.

Return type:

None