single elements of numpy arrays are not of native type
This commit is contained in:
parent
1f624ddbf5
commit
ce2e0a01f5
|
@ -41,8 +41,10 @@ class NiceDumper(yaml.SafeDumper):
|
||||||
return self.represent_data(data.tolist())
|
return self.represent_data(data.tolist())
|
||||||
if isinstance(data, Rotation):
|
if isinstance(data, Rotation):
|
||||||
return self.represent_data(data.quaternion.tolist())
|
return self.represent_data(data.quaternion.tolist())
|
||||||
else:
|
if hasattr(data, 'dtype'):
|
||||||
return super().represent_data(data)
|
return self.represent_data(data.item())
|
||||||
|
|
||||||
|
return super().represent_data(data)
|
||||||
|
|
||||||
def ignore_aliases(self,
|
def ignore_aliases(self,
|
||||||
data: Any) -> bool:
|
data: Any) -> bool:
|
||||||
|
|
|
@ -46,7 +46,8 @@ class TestConfig:
|
||||||
assert Config.load(tmp_path/'config.yaml') == config
|
assert Config.load(tmp_path/'config.yaml') == config
|
||||||
|
|
||||||
def test_numpy(self,tmp_path):
|
def test_numpy(self,tmp_path):
|
||||||
assert Config({'A':np.ones(3,'i')}).__repr__() == Config({'A':[1,1,1]}).__repr__()
|
assert Config({'A':np.ones(3,'i'), 'B':np.ones(1)[0]}).__repr__() == \
|
||||||
|
Config({'A':[1,1,1], 'B':1.0}).__repr__()
|
||||||
|
|
||||||
def test_abstract_is_valid(self):
|
def test_abstract_is_valid(self):
|
||||||
with pytest.raises(NotImplementedError):
|
with pytest.raises(NotImplementedError):
|
||||||
|
|
Loading…
Reference in New Issue