コード例 #1
0
 def setup(self):
     """
     All the data in dummy1 of 'plus10' is the data in default + 10
     So the addition of 'ascend' and 'plus10' should be no
     more than 10 off from the addition of just 'ascend'
     TODO: actually check the math on this
     """
     self.testC = pysat.Constellation(name='test_add_similar')
     self.refC = pysat.Constellation(
         [pysat.Instrument('pysat', 'testing', tag='ascend')])
コード例 #2
0
 def setup(self):
     """
     All the data in dummy1 of testadd3 is the data in testadd1 + 10
     So the addition of testadd1 and testadd3 should be no more than 10 off from
     the addition of just testadd1
     TODO: actually check the math on this
     """
     self.testC = pysat.Constellation(name='test_add_similar')
     self.refC = pysat.Constellation(
         [pysat.Instrument('pysat', 'testadd1', clean_level='clean')])
コード例 #3
0
    def test_custom_keyword_instantiation(self):
        """Test adding custom methods at Instrument instantiation
        """

        self.testConst.custom_attach(mult_data, args=self.custom_args,
                                     kwargs={'dkey': 'mlt'})
        self.testConst.custom_attach(mult_data, args=self.custom_args)

        # Create another instance of pysat.Instrument and add custom
        # via the input keyword
        custom = [{'function': mult_data, 'args': self.custom_args,
                   'kwargs': {'dkey': 'mlt'}},
                  {'function': mult_data, 'args': self.custom_args}]
        testConst2 = pysat.Constellation(instruments=[
            pysat.Instrument('pysat', 'testing', num_samples=10,
                             clean_level='clean', custom=custom)
            for i in range(5)])

        # Ensure all instruments within both constellations have the same
        # custom_* attributes
        for i, inst in enumerate(self.testConst.instruments):
            inst2 = testConst2.instruments[i]
            assert inst.custom_functions == inst2.custom_functions
            assert inst.custom_args == inst2.custom_args
            assert inst.custom_kwargs == inst2.custom_kwargs
コード例 #4
0
 def setup(self):
     """
     The data in testadd1['dummy1'] is just ascending integers 0 to the
     length of the other data, testadd2 has the same data but negative.
     The addition of these two signals should be zero everywhere.
     """
     self.testC = pysat.Constellation(name='test_add_opposite')
コード例 #5
0
    def setup(self):
        '''Runs before every method to create a clean testing setup'''
        insts = []
        for i in range(5):
            insts.append(pysat.Instrument('pysat','testing', tag='10', clean_level='clean'))

        self.testConst = pysat.Constellation(insts)
コード例 #6
0
 def test_getitem(self):
     """Test Constellation iteration through instruments attribute
     """
     self.in_kwargs['const_module'] = None
     self.const = pysat.Constellation(**self.in_kwargs)
     tst_get_inst = self.const[:]
     pysat.utils.testing.assert_lists_equal(self.instruments, tst_get_inst)
コード例 #7
0
ファイル: test_avg.py プロジェクト: JonathonMSmith/pysat
 def setup(self):
     insts = []
     for i in range(5):
         insts.append(
             pysat.Instrument('pysat', 'testing', clean_level='clean'))
     self.testC = pysat.Constellation(instruments=insts)
     self.testI = pysat.Instrument('pysat', 'testing', clean_level='clean')
コード例 #8
0
    def test_construct_raises_noniterable_error(self):
        """Attempt to construct a Constellation by const_module and list
        """
        with pytest.raises(ValueError) as verr:
            self.const = pysat.Constellation(instruments=self.instruments[0])

        assert str(verr).find("instruments argument must be list-like")
コード例 #9
0
 def test_construct_constellation(self, ikey, ival, ilen):
     """Construct a Constellation with good input
     """
     if ikey is not None:
         self.in_kwargs[ikey] = ival
     self.const = pysat.Constellation(**self.in_kwargs)
     assert len(self.const.instruments) == ilen
コード例 #10
0
 def setup(self):
     """Create instruments and a constellation for each test."""
     self.instruments = [
         pysat.Instrument('pysat', 'testing', clean_level='clean')
         for i in range(2)
     ]
     self.const = pysat.Constellation(self.instruments)
コード例 #11
0
ファイル: test_ssnl_ave.py プロジェクト: lisatibbetts/pysat
 def setup(self):
     insts = []
     for i in range(5):
         insts.append(pysat.Instrument('pysat', 'testing',
                                       clean_level='clean'))
     self.testC = pysat.Constellation(instruments=insts)
     self.testI = pysat.Instrument('pysat', 'testing', clean_level='clean')
     self.bounds = (pysat.datetime(2008, 1, 1), pysat.datetime(2008, 1, 3))
コード例 #12
0
    def test_str_wo_inst(self):
        """Test Constellation string output without instruments loaded
        """
        self.const = pysat.Constellation()
        out_str = self.const.__str__()

        assert out_str.find("pysat Constellation ") >= 0
        assert out_str.find("No loaded Instruments") > 0
コード例 #13
0
    def test_repr_w_inst(self):
        """Test Constellation string output with instruments loaded
        """
        self.in_kwargs['const_module'] = None
        self.const = pysat.Constellation(**self.in_kwargs)
        out_str = self.const.__repr__()

        assert out_str.find("Constellation(instruments") >= 0
コード例 #14
0
ファイル: test_avg.py プロジェクト: JonathonMSmith/pysat
 def setup(self):
     insts = []
     for i in range(2):
         insts.append(
             pysat.Instrument('pysat',
                              'testing',
                              clean_level='clean',
                              root_date=pysat.datetime(2009, 1, i + 1)))
     self.testC = pysat.Constellation(instruments=insts)
コード例 #15
0
ファイル: test_constellation.py プロジェクト: raniabe31/pysat
 def setup(self):
     """
     The constellation consists of a single instrument, so performing
     addition on it should just return the instrument's data within
     the bounds
     """
     insts = []
     self.testInst = pysat.Instrument('pysat', 'testing', 'fives',
                                      clean_level='clean')
     insts.append(self.testInst)
     self.testConst = pysat.Constellation(insts)
コード例 #16
0
ファイル: test_avg.py プロジェクト: pysat/pysatSeasons
 def setup(self):
     insts = []
     for i in range(2):
         r_date = dt.datetime(2009, 1, i + 1)
         insts.append(
             pysat.Instrument('pysat',
                              'testing',
                              clean_level='clean',
                              root_date=r_date))
     self.testC = pysat.Constellation(instruments=insts)
     self.bounds = (dt.datetime(2008, 1, 1), dt.datetime(2008, 1, 3))
コード例 #17
0
    def setup(self):
        """Runs before every method to create a clean testing setup"""
        warnings.simplefilter("always")

        instruments = [
            pysat.Instrument(platform='pysat',
                             name='testing',
                             sat_id='10',
                             clean_level='clean') for i in range(2)
        ]
        self.testC = pysat.Constellation(instruments)
コード例 #18
0
 def setup(self):
     """Runs before every method to create a clean testing setup
     """
     self.testConst = pysat.Constellation(instruments=[
         pysat.Instrument('pysat', 'testing', num_samples=10,
                          clean_level='clean',
                          update_files=True)
         for i in range(5)])
     self.load_date = pysat.instruments.pysat_testing._test_dates['']['']
     self.testConst.load(date=self.load_date)
     self.custom_args = [2]
コード例 #19
0
    def test_bounds_passthrough(self):
        """Ensure bounds are applied to each instrument within Constellation"""

        # Create costellation
        self.const = pysat.Constellation(instruments=self.instruments)

        # Set bounds
        self.start_date = dt.datetime(2009, 1, 1)
        self.stop_date = dt.datetime(2010, 1, 1)
        self.const.bounds = (self.start_date, self.stop_date)

        # Ensure constellation reports correct dates
        assert self.const.bounds[0:2] == ([self.start_date], [self.stop_date])

        # Test bounds are the same for all instruments
        for instrument in self.const:
            assert instrument.bounds == self.const.bounds
コード例 #20
0
    def test_single_attachment_of_custom_function(self):
        """Test successful attachment of custom function
        """

        # Define a custom function
        def double_mlt(inst):
            dmlt = 2.0 * inst.data.mlt
            dmlt.name = 'doubleMLT'
            inst.data[dmlt.name] = dmlt
            return

        # Initialize the constellation
        self.in_kwargs['const_module'] = None
        self.const = pysat.Constellation(**self.in_kwargs)

        # Add the custom function
        self.const.custom_attach(double_mlt, at_pos='end')
        self.const.load(2009, 1)

        # Test the added value
        for inst in self.const:
            assert 'doubleMLT' in inst.data.columns
            assert (inst['doubleMLT'] == 2.0 * inst['mlt']).all()
コード例 #21
0
 def test_construct_by_list(self):
     """Construct a Constellation with a list."""
     const = pysat.Constellation(self.instruments)
     assert len(const.instruments) == 2
コード例 #22
0
ファイル: test_avg.py プロジェクト: JonathonMSmith/pysat
 def setup(self):
     insts = []
     insts.append(
         pysat.Instrument('pysat', 'testing2d', clean_level='clean'))
     self.testC = pysat.Constellation(insts)
コード例 #23
0
ファイル: test_constellation.py プロジェクト: raniabe31/pysat
 def setup(self):
     """Runs before every method to create a clean testing setup."""
     self.testConst = \
         pysat.Constellation([pysat.Instrument('pysat', 'testing',
                                               sat_id='10',
                                               clean_level='clean')])
コード例 #24
0
 def test_construct_null(self):
     """Attempt to construct a Constellation with
     no arguments."""
     const = pysat.Constellation()
     assert len(const.instruments) == 0
コード例 #25
0
 def setup(self):
     self.const1 = pysat.Constellation(name='testing')
     self.const2 = pysat.Constellation(name='single_test')
コード例 #26
0
 def test_construct_bad_instruments(self):
     """Attempt to construct a Constellation with
     a bad instrument 'list.'"""
     pysat.Constellation(instruments=42)
コード例 #27
0
 def test_construct_both(self):
     """Attempt to construct a Constellation by name and list.
     Raises an error."""
     pysat.Constellation(instruments=self.instruments, name='testing')
コード例 #28
0
 def setup(self):
     '''Runs before every method to create a clean testing setup.'''
     self.testConst = pysat.Constellation([
         pysat.Instrument('pysat', 'testing', tag='10', clean_level='clean')
     ])
コード例 #29
0
    def test_construct_by_name(self):
        """Construct a Constellation by name.

        Should access a predefined Constellation."""
        const = pysat.Constellation(name='testing')
        assert len(const.instruments) == 5
コード例 #30
0
 def setup(self):
     self.const = pysat.Constellation(name='test_diff2')