Skip to content

Commit ccacd58

Browse files
committed
[doc/tutorial] Add tuple dtype description
1 parent 656f4d8 commit ccacd58

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

doc/tutorial.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,11 @@ the stored metadata:
736736
+-----------------------------------+---------------------------------------+
737737
| odml.DType.url or 'url' | "https://en.wikipedia.org/wiki/Earth" |
738738
+-----------------------------------+---------------------------------------+
739+
| odml.DType.tuple | "(39.12; 67.19)" |
740+
+-----------------------------------+---------------------------------------+
739741

740-
The available types are implemented in the odml.types Module. Note that the
741-
last three data types, it not defined, cannot be deduced, but are instead
742+
The available types are implemented in the 'odml.dtypes' Module. Note that the
743+
last four data types, if not defined, cannot be deduced, but are instead
742744
always interpreted as string.
743745

744746
If we append now our new Property to the previously created sub-Section
@@ -782,6 +784,29 @@ Note that it is also possible to add a metadata entry later on::
782784
u'Blind Passenger']
783785

784786

787+
The tuple datatype you might have noticed in the dtype table above has to be
788+
specially handled. It is intended to enforce a specific number of datapoints
789+
for each value entry. This is useful in case of 2D or 3D data, where all
790+
datapoints always have to be present for each entry.
791+
The dtype itself has to contain the number corresponding to the required value
792+
data points. For the value data points themselves, they have to be enclosed
793+
by brackets and separated by a semicolon.
794+
795+
>>> pixel_prop = odml.Property(name="pixel map")
796+
>>> pixel_prop.dtype = "2-tuple"
797+
>>> pixel_prop.value = ["(1; 2)", "(3; 4)"]
798+
799+
>>> voxel_prop = odml.Property(name="voxel map")
800+
>>> voxel_prop.dtype = "3-tuple"
801+
>>> voxel_prop.value = "(1; 2; 3)"
802+
803+
Please note, that inconsistent tuple values will raise an error:
804+
805+
>>> tprop = odml.Property(name="tuple fail")
806+
>>> tprop.dtype = "3-tuple"
807+
>>> tprop.value = ["(1; 2)"]
808+
809+
785810
Printing XML-representation of an odML file:
786811
--------------------------------------------
787812

0 commit comments

Comments
 (0)