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 yaml
|
||||
|
||||
from . import Rotation
|
||||
from . import Orientation
|
||||
|
||||
class NiceDumper(yaml.SafeDumper):
|
||||
"""Make YAML readable for humans."""
|
||||
|
||||
|
@ -19,8 +22,12 @@ class NiceDumper(yaml.SafeDumper):
|
|||
|
||||
def represent_data(self, data):
|
||||
"""Cast Config objects and its subclasses to dict."""
|
||||
return self.represent_data(dict(data)) if isinstance(data, dict) and type(data) != dict else \
|
||||
super().represent_data(data)
|
||||
if isinstance(data, dict) and type(data) != dict:
|
||||
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):
|
||||
"""No references."""
|
||||
|
|
Loading…
Reference in New Issue