Comment #5 on issue 135 by
bton...@gmail.com: Is this a bug in write_file?
http://code.google.com/p/pydicom/issues/detail?id=135
I've tested the simple cases of assignment to an element of DVHData in
0.9.6 and 0.9.8, and yes, the behavior is quite different (in 0.9.6, the
internal representation returned by dataset.data_element is different from
that accessed as a list element).
Also, in 0.9.8 the incorrect type assignment can be "white-washed" by a
write/read cycle, as you suggest. This doesn't seem very efficient, though.
Sticking to just 0.9.8, my feeling about all this is that this behavior
isn't consistent with the project design goal to "to have a single copy of
the data" (quoting from the developer's guide).
I ran into this issue earlier, when I had trouble getting overrides to work
when DS got changed to decimal-string (I now know why that didn't work--my
overrides tested for data element type).
I would like to avoid making copies of all dicom objects, since that just
makes it easy to lose track of them. The current behavior of assignment
(silently accepting a type change that is inconsistent with the VR), isn't
going to work well in my projects. My workaround is to work with copies of
the data, and only use all-at-once assignments of element lists--no
assignments to individual members of the list.
My feeling is that this would all be safer, if pydicom exposed (and
required?) a setter/getter for accessing data elements. Has that been
considered (i.e. explicit get()/set() or get_value/set_value)? I see you're
using "value" as a setter/getter in dataelem. Is it possible to modify
self.value in DataElement to typecast from strings (and floats) to
valuerep.DSfloat, when self.VR == DS?
And, it goes without saying, thanks for a great library.