@@ -237,7 +237,7 @@ The Document
237237If you loaded the example odML file, let's have a first look at the Document::
238238
239239 >>> print odmlEX
240- <Doc 42 by Douglas Adams (2 sections)>
240+ <Doc 42 by D. N. Adams (2 sections)>
241241
242242As you can see, the printout gives you a short summary of the Document of the
243243loaded example odML file.
@@ -293,7 +293,7 @@ Let's check out all attributes with the following commands::
293293 >>> print(odmlEX.parent)
294294 None
295295 >>> print(odmlEX.repository)
296- http://portal.g-node.org/odml/terminologies/v1.0 /terminologies.xml
296+ http://portal.g-node.org/odml/terminologies/v1.1 /terminologies.xml
297297 >>> print(odmlEX.version)
298298 42
299299
@@ -307,7 +307,7 @@ Sections were attached to the Document of our example odML file using the
307307following command::
308308
309309 >>> print(odmlEX.sections)
310- [< Section TheCrew[ crew] (4)>, < Section TheStarship[ starship] (1)> ]
310+ [Section[4/2] {name = TheCrew, type = crew, id = ...}, Section[1/7] {name = TheStarship, type = starship, id = ...} ]
311311
312312As expected from the Document printout our example contains two Sections. The
313313printout and attributes of a Section are explained in the next chapter.
@@ -324,31 +324,32 @@ look at the first Section in the sections list attached to the Document in our
324324example odML file::
325325
326326 >>> print(odmlEX.sections['TheCrew'])
327- < Section TheCrew[ crew] (4)>
327+ Section[4/2] {name = TheCrew, type = crew, id = ...}
328328 >>> print(odmlEX.sections[0])
329- < Section TheCrew[ crew] (4)>
329+ Section[4/2] {name = TheCrew, type = crew, id = ...}
330330 >>> print(odmlEX['TheCrew'])
331- < Section TheCrew[ crew] (4)>
331+ Section[4/2] {name = TheCrew, type = crew, id = ...}
332332 >>> print(odmlEX[0])
333- < Section TheCrew[ crew] (4)>
333+ Section[4/2] {name = TheCrew, type = crew, id = ...}
334334
335335In the following we will call Sections explicitly by their name using the
336336short cut notation.
337337
338338The printout of a Section is similar to the Document printout and gives you
339339already the following information:
340340
341- - ``<...> `` indicates that you are looking at an object
342341- ``Section `` tells you that you are looking at an odML Section
343- - ``TheCrew `` is the name of this Section
344- - ``[...] `` highlights the type of the Section (here ``crew ``)
345- - ``(4) `` states that this Section has four Sections directly attached to it
342+ - ``[4/2] `` states that this Section has four Sections and two Properties directly attached to it
343+ - ``{...} `` provides ``name ``, ``type `` and ``id `` of the Section
344+ - ``name `` is the name of this Section, 'TheCrew' in the example case
345+ - ``type `` provides the type of the Section, 'crew' in the example case
346+ - ``id `` provides the uuid of the Section, the actual value has been omitted in the example to improve readability.
347+
346348
347- Note that the Section printout tells you nothing about the number of attached
348- Properties or again about the depth of a possible sub-Section tree below the
349- directly attached ones. It also only list the type of the Section as one of the
350- Section attributes. In total, a Section can be defined by the following 5
351- attributes:
349+ Note that the Section printout tells you nothing about the depth of a possible
350+ sub-Section tree below the directly attached ones. It also only list the type
351+ of the Section as one of the Section attributes. In total, a Section can be
352+ defined by the following 5 attributes:
352353
353354name
354355 - Returns the name of this Section. Should indicate what kind of
@@ -413,27 +414,27 @@ To see which Sections are directly attached to the Section 'TheCrew' again use
413414the following command::
414415
415416 >>> print(odmlEX['TheCrew'].sections)
416- [< Section Arthur Philip Dent[ crew/person] (0)> ,
417- < Section Zaphod Beeblebrox[ crew/person] (0)> ,
418- < Section Tricia Marie McMillan[ crew/person] (0)> ,
419- < Section Ford Prefect[ crew/person] (0)> ]
417+ [Section[0/5] {name = Arthur Philip Dent, type = crew/person, id = ...} ,
418+ Section[0/5] {name = Zaphod Beeblebrox, type = crew/person, id = ...} ,
419+ Section[0/5] {name = Tricia Marie McMillan, type = crew/person, id = ...} ,
420+ Section[0/5] {name = Ford Prefect, type = crew/person, id = ...} ]
420421
421422Or, for accessing these sub-Sections::
422423
423424 >>> print(odmlEX['TheCrew'].sections['Ford Prefect'])
424- < Section Ford Prefect[ crew/person] (0)>
425+ Section[0/5] {name = Ford Prefect, type = crew/person, id = ...}
425426 >>> print(odmlEX['TheCrew'].sections[3])
426- < Section Ford Prefect[ crew/person] (0)>
427+ Section[0/5] {name = Ford Prefect, type = crew/person, id = ...}
427428 >>> print(odmlEX['TheCrew']['Ford Prefect'])
428- < Section Ford Prefect[ crew/person] (0)>
429+ Section[0/5] {name = Ford Prefect, type = crew/person, id = ...}
429430 >>> print(odmlEX['TheCrew'][3])
430- < Section Ford Prefect[ crew/person] (0)>
431+ Section[0/5] {name = Ford Prefect, type = crew/person, id = ...}
431432
432433As you learned, besides sub-Sections, a Section can also have Properties
433434attached. Let's see which Properties are attached to the Section 'TheCrew'::
434435
435436 >>> print(odmlEX['TheCrew'].properties)
436- [< Property NameCrewMembers>, < Property NoCrewMembers> ]
437+ [Property: {name = NameCrewMembers}, Property: {name = NoCrewMembers} ]
437438
438439The printout and attributes of a Property are explained in the next chapter.
439440
@@ -445,17 +446,17 @@ Properties need to be called explicitly via the properties function of a
445446Section. You can then either call a Property by name or by index::
446447
447448 >>> print(odmlEX['TheCrew'].properties['NoCrewMembers'])
448- < Property NoCrewMembers>
449+ Property: {name = NoCrewMembers}
449450 >>> print(odmlEX['TheCrew'].properties[1])
450- < Property NoCrewMembers>
451+ Property: {name = NoCrewMembers}
451452
452453In the following we will only call Properties explicitly by their name.
453454
454455The Property printout is reduced and only gives you information about the
455456following:
456457
457- - ``<...> `` indicates that you are looking at an object
458458- ``Property `` tells you that you are looking at an odML Property
459+ - ``{...} `` provides the ``name `` of the Property
459460- ``NoCrewMembers `` is the name of this Property
460461
461462Note that the Property printout tells you nothing about the number of Values,
@@ -478,7 +479,7 @@ document
478479parent
479480 - Returns the parent Section to which this Property was attached to.
480481
481- value
482+ values
482483 - Returns the metadata of this Property. Can be either a single metadata or
483484 multiple, but homogeneous metadata (all with same dtype and unit). For
484485 this reason, the output is always provided as a list.
@@ -518,7 +519,7 @@ Let's check which attributes were defined for the Property 'NoCrewMembers'::
518519 Number of crew members
519520 >>> print(odmlEX['TheCrew'].properties['NoCrewMembers'].document)
520521 <Doc 42 by D. N. Adams (2 sections)>
521- >>> print(odmlEX['TheCrew'].properties['NoCrewMembers'].value )
522+ >>> print(odmlEX['TheCrew'].properties['NoCrewMembers'].values )
522523 [4]
523524 >>> print(odmlEX['TheCrew'].properties['NoCrewMembers'].dtype)
524525 int
@@ -533,22 +534,22 @@ Let's check which attributes were defined for the Property 'NoCrewMembers'::
533534 >>> print(odmlEX['TheCrew'].properties['NoCrewMembers'].dependency_value)
534535 None
535536
536- As mentioned the value attribute of a Property can only contain multiple
537+ As mentioned the values attribute of a Property can only contain multiple
537538metadata when they have the same ``dtype `` and ``unit ``, as it is the case for
538539the Property 'NameCrewMembers'::
539540
540- >>> print(odmlEX['TheCrew'].properties['NameCrewMembers'].value )
541- [u 'Arthur Philip Dent',
542- u 'Zaphod Beeblebrox',
543- u 'Tricia Marie McMillan',
544- u 'Ford Prefect']
541+ >>> print(odmlEX['TheCrew'].properties['NameCrewMembers'].values )
542+ ['Arthur Philip Dent',
543+ 'Zaphod Beeblebrox',
544+ 'Tricia Marie McMillan',
545+ 'Ford Prefect']
545546 >>> print(odmlEX['TheCrew'].properties['NameCrewMembers'].dtype)
546547 person
547548 >>> print(odmlEX['TheCrew'].properties['NameCrewMembers'].unit)
548549 None
549550
550- NOTE: 'property.value ' will always return a copy! Any direct changes to the
551- returned list will have no affect on the actual property value . If you want to
551+ NOTE: 'property.values ' will always return a copy! Any direct changes to the
552+ returned list will have no affect on the actual property values . If you want to
552553make changes to a property value, either use the 'append', 'extend' and 'remove'
553554methods or assign a new value list to the property.
554555
@@ -664,7 +665,7 @@ updated::
664665 >>> print(MYodML)
665666 <Doc 42 by Douglas Adams (1 sections)>
666667 >>> print(MYodML.sections)
667- [< Section TheCrew[ crew] (0)> ]
668+ [Section[0/0] {name = TheCrew, type = crew, id = ...} ]
668669
669670 >>> print(sec1.document)
670671 <Doc 42 by D. N. Adams (1 sections)>
@@ -680,12 +681,12 @@ Let's try this with the next Section we create::
680681 parent=sec1)
681682
682683 >>> print(sec2)
683- < Section Arthur Philip Dent[ crew/person] (0)>
684+ Section[0/0] {name = Arthur Philip Dent, type = crew/person, id = ...}
684685
685686 >>> print(sec2.document)
686687 <Doc 42 by D. N. Adams (1 sections)>
687688 >>> print(sec2.parent)
688- < Section TheCrew[ crew] (1)>
689+ [ Section[1/0] {name = TheCrew, type = crew, id = ...}
689690
690691Note that all of our created Sections do not contain any Properties yet. Let's
691692see if we can change this...
@@ -698,7 +699,7 @@ Let's create our first Property::
698699
699700 >>> prop1 = odml.Property(name="Gender",
700701 definition="Sex of the subject",
701- value ="male")
702+ values ="male")
702703
703704Note that again, only the name attribute is obligatory for creating a Property.
704705The remaining attributes can be defined later on, or are automatically
@@ -752,16 +753,16 @@ automatically update its parent attribute::
752753 >>> print(prop1.document)
753754 <Doc 42 by D. N. Adams (1 sections)>
754755 >>> print(prop1.parent)
755- < Section Arthur Philip Dent[ crew/person] (0)>
756+ Section[0/1] {name = Arthur Philip Dent, type = crew/person, id = ...}
756757
757758Next, let us create a Property with multiple metadata entries::
758759
759760 >>> prop2 = odml.Property(name="NameCrewMembers",
760761 definition="List of crew members names",
761- value =["Arthur Philip Dent",
762- "Zaphod Beeblebrox",
763- "Tricia Marie McMillan",
764- "Ford Prefect"],
762+ values =["Arthur Philip Dent",
763+ "Zaphod Beeblebrox",
764+ "Tricia Marie McMillan",
765+ "Ford Prefect"],
765766 dtype=odml.DType.person)
766767
767768As you learned before, in such a case, the metadata entries must be
@@ -776,12 +777,12 @@ previously created Section 'TheCrew'::
776777Note that it is also possible to add a metadata entry later on::
777778
778779 >>> prop2.append("Blind Passenger")
779- >>> print(MYodML['TheCrew'].properties['NameCrewMembers'].value )
780- [u 'Arthur Philip Dent',
781- u 'Zaphod Beeblebrox',
782- u 'Tricia Marie McMillan',
783- u 'Ford Prefect',
784- u 'Blind Passenger']
780+ >>> print(MYodML['TheCrew'].properties['NameCrewMembers'].values )
781+ ['Arthur Philip Dent',
782+ 'Zaphod Beeblebrox',
783+ 'Tricia Marie McMillan',
784+ 'Ford Prefect',
785+ 'Blind Passenger']
785786
786787
787788The tuple datatype you might have noticed in the dtype table above has to be
@@ -794,17 +795,17 @@ by brackets and separated by a semicolon.
794795
795796 >>> pixel_prop = odml.Property(name = " pixel map" )
796797 >>> pixel_prop.dtype = " 2-tuple"
797- >>> pixel_prop.value = [" (1; 2)" , " (3; 4)" ]
798+ >>> pixel_prop.values = [" (1; 2)" , " (3; 4)" ]
798799
799800 >>> voxel_prop = odml.Property(name = " voxel map" )
800801 >>> voxel_prop.dtype = " 3-tuple"
801- >>> voxel_prop.value = " (1; 2; 3)"
802+ >>> voxel_prop.values = " (1; 2; 3)"
802803
803804Please note, that inconsistent tuple values will raise an error:
804805
805806 >>> tprop = odml.Property(name = " tuple fail" )
806807 >>> tprop.dtype = " 3-tuple"
807- >>> tprop.value = [" (1; 2)" ]
808+ >>> tprop.values = [" (1; 2)" ]
808809
809810
810811Printing XML-representation of an odML file:
@@ -883,13 +884,13 @@ After creating a Property with metadata the data type can be changed and the
883884format of the corresponding entry will converted to the new data type, if the
884885new format is valid for the given metadata::
885886
886- >>> test_dtype_conv = odml.Property('p', value =1.0)
887- >>> print(test_dtype_conv.value )
887+ >>> test_dtype_conv = odml.Property('p', values =1.0)
888+ >>> print(test_dtype_conv.values )
888889 [1.0]
889890 >>> print(test_dtype_conv.dtype)
890891 float
891892 >>> test_dtype_conv.dtype = odml.DType.int
892- >>> print(test_dtype_conv.value )
893+ >>> print(test_dtype_conv.values )
893894 [1]
894895 >>> print(test_dtype_conv.dtype)
895896 int
@@ -899,22 +900,18 @@ If the conversion is invalid a ValueError is raised.
899900Also note, that during such a process metadata loss may occur if a float is
900901converted to an integer and then back to a float::
901902
902- >>> test_dtype_conv = odml.Property('p', value =42.42)
903- >>> print(test_dtype_conv.value )
903+ >>> test_dtype_conv = odml.Property('p', values =42.42)
904+ >>> print(test_dtype_conv.values )
904905 [42.42]
905906 >>> test_dtype_conv.dtype = odml.DType.int
906907 >>> test_dtype_conv.dtype = odml.DType.float
907- >>> print(test_dtype_conv.value )
908+ >>> print(test_dtype_conv.values )
908909 [42.0]
909910
910911
911912Advanced knowledge on Properties
912913--------------------------------
913914
914- Dependencies & dependency values
915- ********************************
916- (coming soon)
917-
918915Advanced knowledge on Sections
919916------------------------------
920917
0 commit comments