Exemple #1
0
def test_unit_override(test_var):
    """Test that we can override a variable's bad unit string."""
    test_var.units = 'C'
    new_var = UnitLinker(test_var)
    new_var.units = 'degC'
    assert_array_equal(new_var[:], np.arange(5) * units.degC)
Exemple #2
0
def test_unit_override_obj(test_var):
    """Test that we can override with an object."""
    test_var.units = 'C'
    new_var = UnitLinker(test_var)
    new_var.units = units.degC
    assert_array_equal(new_var[:], np.arange(5) * units.degC)
Exemple #3
0
def test_unit_override_obj(test_var):
    """Test that we can override with an object."""
    test_var.units = 'C'
    new_var = UnitLinker(test_var)
    new_var.units = units.degC
    assert_array_equal(new_var[:], np.arange(5) * units.degC)
Exemple #4
0
def test_attribute_forwarding(test_var):
    """Test that we are properly able to access attributes from the variable."""
    test_var.att = 'abc'
    new_var = UnitLinker(test_var)
    assert new_var.att == test_var.att
Exemple #5
0
def test_unit_override(test_var):
    """Test that we can override a variable's bad unit string."""
    test_var.units = 'C'
    new_var = UnitLinker(test_var)
    new_var.units = 'degC'
    assert_array_equal(new_var[:], np.arange(5) * units.degC)
Exemple #6
0
def test_unit_linker_bad(test_var):
    """Test that UnitLinker ignores bad unit strings."""
    test_var.units = 'badunit'
    new_var = UnitLinker(test_var)
    assert_array_equal(new_var[:], np.arange(5))
Exemple #7
0
def test_unit_linker_missing(test_var):
    """Test that UnitLinker works with missing units."""
    new_var = UnitLinker(test_var)
    assert_array_equal(new_var[:], np.arange(5))
Exemple #8
0
def test_unit_linker_get_units(test_var):
    """Test that we can get the units from UnitLinker."""
    test_var.units = 'knots'
    new_var = UnitLinker(test_var)
    assert new_var.units == units('knots')
Exemple #9
0
def test_unit_linker(test_var):
    """Test that UnitLinker successfully adds units."""
    test_var.units = 'meters'
    new_var = UnitLinker(test_var)
    assert_array_equal(new_var[:], np.arange(5) * units.m)