def test_RunSet___getitem__single_column(self): run1 = Run.read_csv(self.TEST_DATA_FILEPATH, name='run1') run2 = Run.read_csv(self.TEST_DATA_FILEPATH, name='run2') runset = RunSet([run1, run2]) data = runset['A'] data1 = data['run1'].squeeze().tolist() data2 = data['run2'].squeeze().tolist() expected = [1., 9., 6., 4., 7., 3., 5., 4.] self.assertAllClose(data1, expected) self.assertAllClose(data2, expected)
def test_RunSet___setitem__(self): run1 = Run.read_csv(self.TEST_DATA_FILEPATH, name='run1') run2 = Run.read_csv(self.TEST_DATA_FILEPATH, name='run2') runset = RunSet([run1, run2]) runset['A'] = 3. a1 = runset.runs['run1']['A'].tolist() a2 = runset.runs['run2']['A'].tolist() expected = [3., 3., 3., 3., 3., 3., 3., 3.] self.assertAllClose(expected, a1) self.assertAllClose(expected, a2)
def test_RunSet_set_index(self): run1 = Run.read_csv(self.TEST_DATA_FILEPATH, name='run1') runset = RunSet([run1]) runset.set_index('TIME') indices = run1.index.tolist() expected = [0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7] self.assertAllClose(expected, indices)
def from_file(cls, xname, yname, filepath, *args, name=None, description="", run_name=None, run_description="", run_kwargs={}, **kwargs): run = Run.read_csv(filepath, name=run_name, description=run_description, **run_kwargs) return Envelope(xname, yname, run, *args, name=name, description=description, **kwargs)
def test_RunSet_remove_run_does_not_delete_actual_run(self): run1 = Run.read_csv(self.TEST_DATA_FILEPATH, name='run1') runset = RunSet([run1]) runset.remove_run('run1') self.assertEqual(run1['A'][0], 1.)
def test_RunSet_remove_run(self): run1 = Run.read_csv(self.TEST_DATA_FILEPATH, name='run1') runset = RunSet([run1]) self.assertTrue('run1' in runset.runs) runset.remove_run('run1') self.assertFalse('run1' in runset.runs)
def test_RunSet_add_run(self): run1 = Run.read_csv(self.TEST_DATA_FILEPATH, name='run1') runset = RunSet() runset.add_run(run1) self.assertTrue('run1' in runset.runs)
def test_RunSet_constructor(self): run1 = Run.read_csv(self.TEST_DATA_FILEPATH, name='run1') run2 = Run.read_csv(self.TEST_DATA_FILEPATH, name='run2') runset = RunSet([run1, run2]) self.assertTrue(isinstance(runset, RunSet))
def test_Run___setitem__whole_column(self): run = Run.read_csv(self.TEST_DATA_FILEPATH) run['A'] = [3., 3., 3., 3., 3., 3., 3., 3.] a = run['A'].tolist() expected = [3., 3., 3., 3., 3., 3., 3., 3.] self.assertAllClose(a, expected)
def test_Run___setitem__single_value(self): run = Run.read_csv(self.TEST_DATA_FILEPATH) run['A'] = 3. a = run['A'].tolist() expected = [3., 3., 3., 3., 3., 3., 3., 3.] self.assertAllClose(a, expected)
def test_read_csv_returns_run(self): run = Run.read_csv(self.TEST_DATA_FILEPATH) self.assertTrue(isinstance(run, Run))
def test_read_csv_returns_dataframe_instance(self): run = Run.read_csv(self.TEST_DATA_FILEPATH) self.assertTrue(isinstance(run, pd.DataFrame))
def setup_run2(self): return Run.read_csv(self.TEST_DATA2)
def setup2(self): run = Run.read_csv(self.TEST_DATA2) return run
def setup1(self): run = Run.read_csv(self.TEST_DATA1) return run