Example #1
0
def test_generic_return(basic_spectrum):
    m = basic_spectrum.take([2, 3])
    assert isinstance(m, Spectrum)
    assert m.equals(Spectrum([3, 4], index=[4.4, 5.5]))

    m = basic_spectrum.sort_index()
    assert isinstance(m, Spectrum)
Example #2
0
def test_unary_operation(basic_spectrum):
    basic_spectrum[2.2] += 1
    assert isinstance(basic_spectrum, Spectrum)
    assert basic_spectrum[2.2] == 2

    basic_spectrum[2.2] -= 1
    basic_spectrum += 1
    assert isinstance(basic_spectrum, Spectrum)
    assert basic_spectrum.equals(
        Spectrum([2, 3, 4, 5],
                 index=[2.2, 3.3, 4.4, 5.5],
                 wavelengths=[2.2, 3.3, 4.4, 5.5]))
Example #3
0
def basic_spectrum():
    return Spectrum([1, 2, 3, 4],
                    index=[2.2, 3.3, 4.4, 5.5],
                    wavelengths=[2.2, 3.3, 4.4, 5.5])
Example #4
0
def test_get_metadata_slice(metadata_spectrum):
    assert metadata_spectrum[1:].metadata.equals(
        Spectrum(['a', 'b', 'c'], index=['foo', 'bar', 'bat']))
Example #5
0
def floatwv_metadata_spectrum():
    return Spectrum([1, 2, 3, 'a', 'b', 'c'],
                    index=[1.10001, 2.222222, 3.33300015, 'foo', 'bar', 'bat'],
                    wavelengths=[1.10001, 2.222222, 3.33300015],
                    metadata=['foo', 'bar', 'bat'])
Example #6
0
def floatwv_spectrum():
    return Spectrum([1, 2, 3],
                    index=[1.10001, 2.222222, 3.33300015],
                    wavelengths=[1.10001, 2.222222, 3.33300015])
Example #7
0
def metadata_spectrum():
    return Spectrum([1, 2, 3, 4, 'a', 'b', 'c'],
                    index=[2.2, 3.3, 4.4, 5.5, 'foo', 'bar', 'bat'],
                    wavelengths=[2.2, 3.3, 4.4, 5.5],
                    metadata=['foo', 'bar', 'bat'])
Example #8
0
def long_spectrum():
    return Spectrum([1, 1.5, 2, 2.5, 5, 3, 3.5, 7, 4, 4.5, 5],
                    index=np.arange(1, 12),
                    wavelengths=np.arange(1, 12))