Question: Are there any compulsory reasons to specifically use NumPy arrays and NumPy data types to store values in the basic CUBA keys? This is defined in simphony/core/keywords.py and type casting of the values is done in simphony.cuds.meta.validation.cast_data_type(). An option would be to use native Python types (int, float, string, etc.) instead of NumPy types.
The reason I'm asking this is that we are planning to use PyYaml functionality to serialize CUDSComponents into a Yaml script file that is easy to read and edit. Using NumPy types, the default emitted Yaml of a CUBA.BOX object would look like this:
---
!!python/object:simphony.cuds.meta.box.Box
_data: !!python/object/new:simphony.cuds.meta.box._RestrictedDataContainer
dictitems:
? !!python/object/apply:simphony.core.cuba.CUBA [129]
: some_name
? !!python/object/apply:simphony.core.cuba.CUBA [134]
: - !!python/object/apply:numpy.core.multiarray._reconstruct
args:
- &id001 !!python/name:numpy.ndarray ''
- !!python/tuple [0]
- b
state: !!python/tuple
- 1
- !!python/tuple [3]
- !!python/object/apply:numpy.dtype
args: [f8, 0, 1]
state: !!python/tuple [3, <, null, null, null, -1, -1, 0]
- false
- !!binary |
AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhA
- !!python/object/apply:numpy.core.multiarray._reconstruct
args:
- *id001
- !!python/tuple [0]
- b
state: !!python/tuple
- 1
- !!python/tuple [3]
- !!python/object/apply:numpy.dtype
args: [f8, 0, 1]
state: !!python/tuple [3, <, null, null, null, -1, -1, 0]
- false
- !!binary |
AAAAAAAACMAAAAAAAADwPwAAAAAAAPC/
- !!python/object/apply:numpy.core.multiarray._reconstruct
args:
- *id001
- !!python/tuple [0]
- b
state: !!python/tuple
- 1
- !!python/tuple [3]
- !!python/object/apply:numpy.dtype
args: [f8, 0, 1]
state: !!python/tuple [3, <, null, null, null, -1, -1, 0]
- false
- !!binary |
AAAAAAAA8D8AAAAAAADwPwAAAAAAAPA/
? !!python/object/apply:simphony.core.cuba.CUBA [164]
: some_description
_definition: A simple hexahedron box object
_uid: !!python/object:uuid.UUID {int: 269147399971988598877834418230928817611}
However, with the simple change of the data type of CUBA.VECTOR (currently numpy.float64) to native Python list of floats, the same script becomes:
---
!!python/object:simphony.cuds.meta.box.Box
_data: !!python/object/new:simphony.cuds.meta.box._RestrictedDataContainer
dictitems:
? !!python/object/apply:simphony.core.cuba.CUBA [129]
: some_name
? !!python/object/apply:simphony.core.cuba.CUBA [134]
: [[1.0, 2.0, 3.0], [-3.0, 1.0, -1.0], [1.0, 1.0, 1.0]]
? !!python/object/apply:simphony.core.cuba.CUBA [164]
: some_description
_definition: A simple hexahedron box object
_uid: !!python/object:uuid.UUID {int: 269147399971988598877834418230928817611}
Also, please, note that the Yaml script format shown above is subject to changes due to some other issues regarding numbering of the CUBA keys etc.
@kemattil, @ahashibon, @kitchoi, @mehdisadeghi, @roigcarlo please, I'd like to hear your opinions on this issue.
Question: Are there any compulsory reasons to specifically use NumPy arrays and NumPy data types to store values in the basic CUBA keys? This is defined in simphony/core/keywords.py and type casting of the values is done in
simphony.cuds.meta.validation.cast_data_type(). An option would be to use native Python types (int, float, string, etc.) instead of NumPy types.The reason I'm asking this is that we are planning to use PyYaml functionality to serialize CUDSComponents into a Yaml script file that is easy to read and edit. Using NumPy types, the default emitted Yaml of a CUBA.BOX object would look like this:
However, with the simple change of the data type of CUBA.VECTOR (currently numpy.float64) to native Python list of floats, the same script becomes:
Also, please, note that the Yaml script format shown above is subject to changes due to some other issues regarding numbering of the CUBA keys etc.
@kemattil, @ahashibon, @kitchoi, @mehdisadeghi, @roigcarlo please, I'd like to hear your opinions on this issue.