zoomy_core.misc.misc module#
Shared utilities: SymPy-friendly arrays, dynamic structs, and runtime paths.
- class zoomy_core.misc.misc.ZArray(iterable, *args, **kwargs)#
Bases:
MutableDenseNDimArrayEnhanced SymPy Array that supports matrix multiplication (@) and vector algebra (+, -) with lists and Zstructs.
- tomatrix()#
Return a SymPy
Matrix(rank-2 arrays only).
- flatten()#
Flattens the N-dimensional array into a 1D ZArray. Uses the internal _array list which is inherently flat in SymPy NDimArrays.
- subs(*args, **kwargs)#
Substitutes expressions within the ZArray. Supports SymPy’s standard subs API: .subs(old, new), .subs({old: new}), or .subs([(old, new)])
- xreplace(rule)#
Element-wise xreplace — sympy’s fast pattern-free substitution.
ZArray inherits from
MutableDenseNDimArraywhich does not definexreplace; we apply it per-element and rebuild.
- doit(**kwargs)#
Element-wise
.doit()— evaluates unevaluated Derivative / Integral / Function calls. Same pattern asxreplace.
- expand(**kwargs)#
Element-wise
sp.expand.
- diff(*args, **kwargs)#
Element-wise differentiation — returns a ZArray of the same shape.
- property is_zero_matrix#
All entries are symbolically zero. Mirrors
sp.MatrixBase.is_zero_matrixso consumers that branch on zero operators (e.g. splitter’s algebraic-row detection) work uniformly.
- property flat#
Flat.
- zoomy_core.misc.misc.get_main_directory()#
Get main directory.
- class zoomy_core.misc.misc.Zstruct(**kwargs)#
Bases:
SimpleNamespaceDynamic structure that behaves like a Namespace but supports iteration and index access (based on insertion order).
- length()#
- get_list(recursive=True)#
Nested list view of values (used when flattening symbolic trees).
- Parameters:
recursive (bool) –
- as_dict(recursive=True)#
Serialize to plain dicts (recursive for nested
Zstruct).- Parameters:
recursive (bool) –
- items(recursive=False)#
Items.
- Parameters:
recursive (bool) –
- keys()#
Keys.
- values()#
Values.
- contains(key)#
Contains.
- update(zstruct, recursive=True)#
Update.
- Parameters:
recursive (bool) –
- classmethod from_dict(d)#
Build a
Zstructtree from nested dicts.
- class zoomy_core.misc.misc.Settings(**kwargs)#
Bases:
ZstructRun configuration (output paths, snapshots, etc.) for drivers and solvers.
- classmethod default()#
Reasonable defaults for local runs and tests.
- classmethod from_json(filepath)#
Load settings from a JSON file on disk.
- write_json(filepath=None)#
Persist settings next to the simulation output unless
filepathis given.