Example #1
0
    def test_predict_interface_multiple_samples(self):
        from iris.cube import CubeList
        # Get the actual test data
        #  Use the class method `eval_fn` so 'self' doesn't get passed
        expected = CubeList([type(self).eval_fn(p, job_n=i) for i, p in enumerate(self.test_params)])
        expected = expected.concatenate_cube()

        pred_m, pred_var = self.model.predict(self.test_params)

        assert_allclose(expected.data, pred_m.data, rtol=1e-3)
        assert pred_m.name() == 'Emulated ' + (expected.name() or 'data')
        assert pred_var.name() == 'Variance in emulated ' + (expected.name() or 'data')
        assert pred_m.units == expected.units
        assert pred_var.units == expected.units
Example #2
0
    def test_predict_interface_multiple_samples(self):
        from iris.cube import CubeList
        # Get the actual test data
        #  Use the class method `eval_fn` so 'self' doesn't get passed
        expected = CubeList([
            type(self).eval_fn(p, job_n=i)
            for i, p in enumerate(self.test_params)
        ])
        expected = expected.concatenate_cube()

        pred_m, pred_var = self.model.predict(self.test_params)

        # For some reason the relative tolerance has to be
        # higher here than in the other tests???
        assert_allclose(expected.data, pred_m.data, rtol=1e-1)
        assert pred_m.name() == 'Emulated ' + (expected.name() or 'data')
        assert_allclose(np.full_like(expected.data, np.NaN),
                        pred_var.data,
                        equal_nan=True)
        assert pred_var.name() == 'Variance in emulated ' + expected.name()
        assert pred_m.units == expected.units
Example #3
0
def test_all():
    """Check that cubes returned using the 'name_constraint' are not lazy"""
    constraint = name_constraint(["dummy1"])
    dummy1_cube = Cube(da.zeros((1, 1), chunks=(1, 1)), long_name="dummy2")
    dummy2_cube = Cube(da.zeros((1, 1), chunks=(1, 1)), long_name="dummy1")
    assert dummy1_cube.has_lazy_data()
    assert dummy2_cube.has_lazy_data()

    res = CubeList([dummy1_cube, dummy2_cube
                    ]).extract_cube(Constraint(cube_func=constraint))
    assert res.name() == "dummy1"
    assert not res.has_lazy_data()