90.0
are significant.
Floating-point numbers in Python cannot provide exact decimal representation, so additional information is required to
specify the precision of a floating-point value before importing it into Granta MI. This example illustrates how
significant figures can be set when importing point and range attribute values, as well as how that information is
represented when exporting attribute values which have significant figures information.
Connect to MI
Get a database and table.Create a new record
Create a newRecord object.
Edit the record’s attributes
Values with precision
To add precision information to a floating-point value, use theValueWithPrecision class. To simplify the import
of values with similar resolution but different exponents, specifying significant digits is done by
specifying a number of digits after the decimal point.
Point attributes
To set significant figures on a single-valued point attribute, set the attribute.value property to an instance of
ValueWithPrecision.
.value property
to a tuple of ParameterizedPointValue with ValueWithPrecision values.
Range attributes
Set the.value property to a Range object, providing high and low values with precision.
Write your changes to MI
First, specify the attributes on the record which you want to update on the server. Then write the changes to MI. The list of updatedRecord objects is returned.
Output the record’s attributes
Access the attribute values via the same properties you used to assign them. Significant figures information is available via the.trailing_zero_information property.
The test temperature has been stored with 1 digit of precision. The trailing zero information includes the entered
value, the entered unit, as well as the number of significant figures stored with the value. The additional properties
as_decimal and number_of_digits help convert the information back to a more accessible representations: