Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @preferred_representation.setter
- def preferred_representation(self, value):
- # In reality do validation of `value` and allow string input
- rep_dict = {'spherical': SphericalRepresentation,
- 'cartesian': CartesianRepresentation,
- 'unitspherical': UnitSphericalRepresentation,
- 'cylindrical': CylindricalRepresentation}
- # If value is a string, parse it
- if type(value) is str and value.lower() in rep_dict:
- value = rep_dict[value.lower()]
- # Converted to representation object, now check allowed representations
- if value in self._representations:
- self._preferred_representation = value
- else:
- raise ValueError('{0} is not a valid representation for {1}'.format(value, self.__class__))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement