Exemplo n.º 1
0
 def cfcheck(tasmin, tasmax):
     for da in (tasmin, tasmax):
         cfchecks.check_valid(da, "standard_name", "air_temperature")
     cfchecks.check_valid(tasmin, "cell_methods",
                          "*time: minimum within days*")
     cfchecks.check_valid(tasmax, "cell_methods",
                          "*time: maximum within days*")
     check_units(tasmax, tasmin.attrs["units"])
Exemplo n.º 2
0
 def test_user_error(self):
     with pytest.raises(ValidationError):
         check_units("deg C", "[temperature]")
Exemplo n.º 3
0
    def test_basic(self):
        check_units("%", "[]")
        check_units("pct", "[]")
        check_units("mm/day", "[precipitation]")
        check_units("mm/s", "[precipitation]")
        check_units("kg/m2/s", "[precipitation]")
        check_units("kg/m2", "[length]")
        check_units("cms", "[discharge]")
        check_units("m3/s", "[discharge]")
        check_units("m/s", "[speed]")
        check_units("km/h", "[speed]")

        with set_options(data_validation="raise"):
            with pytest.raises(ValidationError):
                check_units("mm", "[precipitation]")

            with pytest.raises(ValidationError):
                check_units("m3", "[discharge]")