예제 #1
0
 def test_with_string_type(self):
     """Test that an extraction that is to match a string is not changed
     by passing through this function, other than to make a single entry
     into a list."""
     value = "kittens"
     result = create_constraint(value)
     self.assertEqual(result, [value])
예제 #2
0
    def test_with_float_type(self):
        """Test that an extraction that is to match a float results in the
        creation of a lambda function which matches the expected values."""
        value = 10.0
        result = create_constraint(value)
        self.assertTrue(islambda(result))

        crd = self.i_crd.copy(points=value)
        self.assertTrue(result(crd.cell(0)))
        crd = self.f_crd.copy(points=value)
        self.assertTrue(result(crd.cell(0)))
        crd = self.i_crd.copy(points=20)
        self.assertFalse(result(crd.cell(0)))
예제 #3
0
    def test_with_int_type(self):
        """Test that an extraction that is to match an integer results in the
        creation of a lambda function. This is done in case unit conversion
        is applied, in which case the cube data may be converted imprecisely,
        e.g. 273.15K might become 1.0E-8C, which will not match a 0C constraint
        unless we use the lambda function to add some tolerance."""
        value = 10
        result = create_constraint(value)
        self.assertTrue(islambda(result))

        crd = self.i_crd.copy(points=value)
        self.assertTrue(result(crd.cell(0)))
        crd = self.f_crd.copy(points=value)
        self.assertTrue(result(crd.cell(0)))