Skip to main content
Import numeric data with explicitly-specified precision information by specifying the number of significant figures. For example: the temperature during a test is measured using a thermocouple with an accuracy of 0.1 °C for measurements below 100 °C. Measures for multiple tests might be in the form: 90.6 °C, 90.0 °C, 89.9 °C. The trailing zeros in 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 new Record object.
Previous cell output:

Edit the record’s attributes

Values with precision

To add precision information to a floating-point value, use the ValueWithPrecision 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.
Previous cell output:

Point attributes

To set significant figures on a single-valued point attribute, set the attribute .value property to an instance of ValueWithPrecision.
Previous cell output:
To set significant figures on a multi-valued point attribute and assign parameter values, set the .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 updated Record 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:
Previous cell output:
Previous cell output:
Define a function to format ranges as strings with the appropriate inclusive or exclusive inequality symbols and at the stored precision.
Previous cell output:
Previous cell output: