def test_to_dataframe(self, units=True): measurement = htf.Measurement('test_multidim') measurement.with_dimensions('ms', 'assembly', htf.Dimension('my_zone')) if units: measurement.with_units('°C') measure_column_name = 'degree Celsius' else: measure_column_name = 'value' for t in range(5): for assembly in ['A', 'B', 'C']: for zone in range(3): temp = zone + t dims = (t, assembly, zone) measurement.measured_value[dims] = temp measurement.outcome = measurements.Outcome.PASS df = measurement.to_dataframe() coordinates = (1, 'A', 2) query = '(ms == %s) & (assembly == "%s") & (my_zone == %s)' % ( coordinates) self.assertEqual(measurement.measured_value[coordinates], df.query(query)[measure_column_name].values[0])
"""Test phase that sets a measurement.""" test.measurements.level_none = 0 time.sleep(1) test.measurements.level_some = 8 time.sleep(1) test.measurements.level_all = 9 time.sleep(1) level_all = test.get_measurement('level_all') assert level_all.value == 9 @htf.measures( htf.Measurement('dimensions').with_dimensions(units.HERTZ), htf.Measurement('lots_of_dims').with_dimensions( units.HERTZ, units.SECOND, htf.Dimension(description='my_angle', unit=units.RADIAN))) def dimensions(test): for dim in range(5): test.measurements.dimensions[dim] = 1 << dim for x, y, z in zip(range(1, 5), range(21, 25), range(101, 105)): test.measurements.lots_of_dims[x, y, z] = x + y + z @htf.measures( htf.Measurement('replaced_min_only').in_range('{min}', 5, type=int), htf.Measurement('replaced_max_only').in_range(0, '{max}', type=int), htf.Measurement('replaced_min_max').in_range('{min}', '{max}', type=int), ) def measures_with_args(test, min, max): test.measurements.replaced_min_only = 1 test.measurements.replaced_max_only = 1