Skip to content

Commit

Permalink
Not all axis values are numeric values
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Jeandet <[email protected]>
  • Loading branch information
jeandet committed Dec 5, 2022
1 parent 5cae787 commit 3541f6d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions speasy/core/data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ def to_dictionary(self, array_to_list=False) -> Dict[str, object]:

@staticmethod
def from_dictionary(dictionary: Dict[str, str or Dict[str, str] or List], dtype=np.float) -> "DataContainer":
return DataContainer(values=np.array(dictionary["values"], dtype=dtype), meta=dictionary["meta"],
name=dictionary["name"],
is_time_dependent=dictionary["is_time_dependent"])
try:
return DataContainer(values=np.array(dictionary["values"], dtype=dtype), meta=dictionary["meta"],
name=dictionary["name"],
is_time_dependent=dictionary["is_time_dependent"])
except ValueError:
return DataContainer(values=np.array(dictionary["values"]), meta=dictionary["meta"],
name=dictionary["name"],
is_time_dependent=dictionary["is_time_dependent"])

@staticmethod
def reserve_like(other: 'DataContainer', length: int = 0) -> 'DataContainer':
Expand All @@ -98,10 +103,10 @@ def __setitem__(self, k, v: 'DataContainer'):

def __eq__(self, other: 'DataContainer') -> bool:
return self.__meta == other.__meta and \
self.__name == other.__name and \
self.is_time_dependent == other.is_time_dependent and \
np.all(self.__values.shape == other.__values.shape) and \
np.array_equal(self.__values, other.__values, equal_nan=True)
self.__name == other.__name and \
self.is_time_dependent == other.is_time_dependent and \
np.all(self.__values.shape == other.__values.shape) and \
np.array_equal(self.__values, other.__values, equal_nan=True)

def replace_val_by_nan(self, val):
if self.__values.dtype != np.float:
Expand Down

0 comments on commit 3541f6d

Please sign in to comment.