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___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_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)
run, model, q, tk, neurons, timing, mut, mp, genpop, g, score) f.write(s) if i >= start: if not server and not pretend: os.system('../src/ev -r %s -e' % (run)) s = 'ev -r %s -p %d -g %d -t 30 --sim %s --model %s --neurons %s '\ '-q %d --top %s --timing %s --mut %s --mp %s --fitness meanxv'%(run, genpop, genpop, sim, model, neurons, q, top, timing, mut, mp) debug(s) e = 0 if not pretend: if server: r['runs'].append(Run(run, s)) else: e = os.system('../src/' + s) if e: error('%s', s) failed += 1 i += 1 count += 1 if server and not pretend: transaction.commit() debug('%d OK, %d FAILED, %d SKIPPED', i, failed, skipped) if __name__ == '__main__': main()
def setup2(self): run = Run.read_csv(self.TEST_DATA2) return run
def setup1(self): run = Run.read_csv(self.TEST_DATA1) return run