transparently handle Rotation/Orientation objects
slow but very convenient
This commit is contained in:
parent
15517c4d4f
commit
1f383ddeff
|
@ -5,6 +5,9 @@ import abc
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
from . import Rotation
|
||||||
|
from . import Orientation
|
||||||
|
|
||||||
class NiceDumper(yaml.SafeDumper):
|
class NiceDumper(yaml.SafeDumper):
|
||||||
"""Make YAML readable for humans."""
|
"""Make YAML readable for humans."""
|
||||||
|
|
||||||
|
@ -19,8 +22,12 @@ class NiceDumper(yaml.SafeDumper):
|
||||||
|
|
||||||
def represent_data(self, data):
|
def represent_data(self, data):
|
||||||
"""Cast Config objects and its subclasses to dict."""
|
"""Cast Config objects and its subclasses to dict."""
|
||||||
return self.represent_data(dict(data)) if isinstance(data, dict) and type(data) != dict else \
|
if isinstance(data, dict) and type(data) != dict:
|
||||||
super().represent_data(data)
|
return self.represent_data(dict(data))
|
||||||
|
if isinstance(data, (Rotation, Orientation)):
|
||||||
|
return self.represent_data(data.as_quaternion())
|
||||||
|
else:
|
||||||
|
return super().represent_data(data)
|
||||||
|
|
||||||
def ignore_aliases(self, data):
|
def ignore_aliases(self, data):
|
||||||
"""No references."""
|
"""No references."""
|
||||||
|
|
Loading…
Reference in New Issue