power-grid-model
power-grid-model copied to clipboard
[FEATURE] Expose numpy dtypes of PGM arrays
It would be nice if the numpy dtypes of the of the PGM input and output arrays are directly accessible.
This would make it easier to extend PGM arrays (e.g. as done in APG project)
example of exposed dtypes:
class Base:
"""Base dtype"""
id: np.int8 = np.iinfo(np.int8).min
class Node(Base):
"""Node data type"""
u_rated: np.float64 = np.nan
node_type: np.int8 = np.iinfo(np.int8).min
I've discussed this before with @bramstoeller
Is it still desirable to only expose the numpy dtype
s? or do we want to make this actual wrappers using overloaded __setattr__
and __getattr__
methods?
e.g.
nodes = NodeInput(3) # creates new object with nodes.data = initialize_array("input", "node", 3)
nodes.data # raw data
# attribute wrappers
nodes.id = [1, 2, 3] # exposes nodes.data["id"]
# element access
node_0 = nodes[0] # exposes an InputNode wrapper around nodes.data[0]
node_0.data # exposes nodes.data[0]
node_0.id = 1 # exposes nodes.data[0]["id"]