Skip to content

Commit

Permalink
Add per-Index data format
Browse files Browse the repository at this point in the history
  • Loading branch information
PProfizi committed Jun 7, 2023
1 parent 7f7e051 commit 053a7b4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/ansys/dpf/post/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ class ref_labels:
dpf.locations.time_freq: ref_labels.set_ids,
}

label_default_format = {
ref_labels.results: ":.3e",
ref_labels.time: ":.3e",
ref_labels.modes: ":.0f",
ref_labels.set_ids: ":.0f",
ref_labels.step: ":.0f",
ref_labels.components: "",
ref_labels.element_ids: ":.0f",
ref_labels.node_ids: ":.0f",
ref_labels.elemental_nodal: ":.0f",
ref_labels.frequencies: ":.3e",
ref_labels.overall: "",
}


class Index(ABC):
"""A Pandas style API to manipulate indexes."""
Expand All @@ -47,6 +61,7 @@ def __init__(
name: str,
values: Union[List, None] = None,
scoping: Union[dpf.Scoping, None] = None,
fmt: str = None,
):
"""Creates an Index object to use in a DataFrame.
Expand All @@ -58,13 +73,18 @@ def __init__(
Values taken by the Index.
scoping:
Scoping corresponding to this index to keep a weak reference.
fmt:
Data string formatting for this index.
"""
self._name = name.replace(" ", "_")
self._values = values
self._dtype = None
self._len = None
self._scoping_ref = None
self._data_fmt = None
if fmt:
self._data_fmt = fmt
else:
self._data_fmt = label_default_format[self._name]
# if scoping is None and values is None:
# raise ValueError("Arguments 'values' and 'scoping' cannot both be None.")
if scoping is not None:
Expand Down

0 comments on commit 053a7b4

Please sign in to comment.