Esempio n. 1
0
 def test_selarg(self):
     """Test chaining with arguments."""
     routine = cch.Chain(self.ifile, self.ifile[:-3]+'seltest.nc')
     sellvl12 = routine.sellevidx(12)
     res = sellvl12.execute()
     assert np.array_equal(ncd.Dataset(res)['ua'][:],
                           ncd.Dataset(self.sellev)['ua'][:])
     os.remove(res)
Esempio n. 2
0
 def test_single_concatination(self):
     """Test if cdochain works with only one input."""
     routine = cch.Chain(self.ifile, self.tmp_iter[:-3]+'-mer-ch.nc')
     meridian = routine.mermean().zonmean()
     res = meridian.execute()
     assert np.array_equal(ncd.Dataset(res)['tas'][:],
                           self.data_iter['tas'][:])
     os.remove(res)
Esempio n. 3
0
def test_reusage_of_source():
    """Source ready for reuse."""
    source = cch.Chain(ifile=inputs[0], ofile='/tmp/tmp.nc')
    h2 = source.mermean()
    h1 = source.sellevidx(2).zonmean()
    h3 = source.sellevidx(1)
    assert h2._ifile == inputs[0]
    assert h3._ifile == inputs[0]
    assert h1._ifile != inputs[0]
    assert 'mermean' not in h1._ifile
Esempio n. 4
0
def test_entry_is_list():
    source = cch.Chain(ifile=inputs[0], ofile='/tmp/tmp.nc')
    plvls = [0.99, 4.28, 11.12, 23.15, 42.59]
    plvls_str = ','.join([str(x) for x in plvls])
    calc = source.ml2pl(plvls)
    assert str(calc._last_command) == '-ml2pl,{} {}'.format(plvls_str, inputs[0])
Esempio n. 5
0
 def test_str_format(self):
     """Testing successfull string formation."""
     routine = cch.Chain(self.ifile, self.ifile[:-3]+'str_test.nc')
     res = routine.sellevidx(24)
     assert res._last_command.to_cmdstr() == "-sellevidx,24 {}".format(
         self.ifile)
Esempio n. 6
0
def test_valid_method():
    """Test if one valid input is accepted."""
    init = cch.Chain("inputfile", "outputfile.nc", "options")
    init.mermean("32")
Esempio n. 7
0
def test_invalid_method():
    """Test if invalid input raises proper exception."""
    init = cch.Chain("inputfile", "outputfile.nc", "options")
    with pytest.raises(ex.InvalidMethod):
        init.coolmean("32")
Esempio n. 8
0
def test_initializing():
    """Test if initilalisation is working."""
    init = cch.Chain("inputfile", "outputfile.nc", "options")
    assert isinstance(init, cch.Chain)
Esempio n. 9
0
def test_return_types_in_chain(output, expected):
    init = cch.Chain(inputs[0], output)
    lvl = init.sellevidx(3).execute()
    assert isinstance(lvl, expected)
Esempio n. 10
0
def test_multiple_files_glob(filelist):
    """Test the usage of multiple files as input."""
    out = cch.Chain(ifile=filelist, ofile='./tests/testdata/outputs.nc')
    assert out._ifile == '/tmp/outputs.nc'
    os.remove(out._ifile)