Example #1
0
def test_chrange_basic(to):
    fg = Dataset(np.arange(1, 1000, 1), np.sin(np.arange(1, 1000, 1)))
    fg.chrange(current_unit="PHz", target_unit=to)
    if to == "thz":
        np.testing.assert_array_almost_equal(np.min(fg.x), 1000)
    elif to == "ghz":
        np.testing.assert_array_almost_equal(np.min(fg.x), 1000000)
Example #2
0
def test_chrange_basic_noninplace(to):
    fg = Dataset(np.arange(1, 1000, 1), np.sin(np.arange(1, 1000, 1)))
    ifg = fg.chrange(current_unit="PHz", target_unit=to, inplace=False)
    if to == "thz":
        np.testing.assert_array_almost_equal(np.min(ifg.x), 1000)
    elif to == "ghz":
        np.testing.assert_array_almost_equal(np.min(ifg.x), 1000000)
    np.testing.assert_array_equal(fg.x, np.arange(1, 1000, 1))
Example #3
0
def test_chrange_errors():
    fg = Dataset(np.arange(1, 1000, 1), np.sin(np.arange(1, 1000, 1)))
    with pytest.raises(ValueError):
        fg.chrange(current_unit="PHz", target_unit="undefined")