Author: bugman Date: Wed Oct 22 11:44:55 2014 New Revision: 26341 URL: http://svn.gna.org/viewcvs/relax?rev=26341&view=rev Log: Lists of lists containing rows of None are now better supported by the lib.xml functions. The object_to_xml() function will now convert the float parts to IEEE-754 byte arrays, and the None parts will be stored as None in the <ieee_754_byte_array> list node. The matching xml_to_object() method has also been modified to read in this new node format. This affects the results.write and state.save user functions (as well as the results.read and state.load user functions). Modified: trunk/lib/xml.py Modified: trunk/lib/xml.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/xml.py?rev=26341&r1=26340&r2=26341&view=diff ============================================================================== --- trunk/lib/xml.py (original) +++ trunk/lib/xml.py Wed Oct 22 11:44:55 2014 @@ -178,10 +178,16 @@ val_elem.appendChild(doc.createTextNode(repr(ieee_obj))) # Store matrices of floats as IEEE-754 byte arrays. - elif lib.arg_check.is_float_matrix(value, raise_error=False): + elif lib.arg_check.is_float_matrix(value, none_elements=True, raise_error=False): # The converted list. ieee_obj = [] for i in range(len(value)): + # Handle None elements. + if value[i] == None: + ieee_obj.append(None) + continue + + # A normal float list or numpy array. ieee_obj.append([]) for j in range(len(value[i])): ieee_obj[-1].append(floatAsByteArray(value[i][j])) @@ -272,6 +278,10 @@ for j in range(len(value[i])): value[i][j] = packBytesAsPyFloat(ieee_value[i][j]) + # None values. + elif ieee_value[i] == None: + value[i] = None + # Normal list. else: value[i] = packBytesAsPyFloat(ieee_value[i])