Пример #1
0
 def test_dataset_label(self):
     test_ds = DataSet('test_ds_1')
     test_ds.save()
     self.assertEqual(test_ds.label, 'test_ds_1')
     if pyfusion.orm_manager.IS_ACTIVE:
         session = pyfusion.orm_manager.Session()
         db_ods = session.query(DataSet).filter_by(label='test_ds_1')
Пример #2
0
    def test_ORM_flucstrucs(self):
        """ check that flucstrucs can be saved to database"""
        n_ch = 10
        n_samples = 1024
        multichannel_data = get_multimode_test_data(
            channels=get_n_channels(n_ch),
            timebase=Timebase(np.arange(n_samples) * 1.e-6),
            noise=0.01)
        # produce a dataset of flucstrucs
        #print ">> ", multichannel_data.channels
        fs_data = multichannel_data.flucstruc(min_dphase=-2 * np.pi)
        print type(fs_data)
        #print list(fs_data)[0].dphase[0].channel_1
        #print '---'
        # save our dataset to the database
        fs_data.save()
        if pyfusion.orm_manager.IS_ACTIVE:
            session = pyfusion.orm_manager.Session()
            d1 = DataSet('test_dataset_1')
            d1.save()
            d2 = DataSet('test_dataset_2')
            d2.save()

            # get our dataset from database
            our_dataset = session.query(DataSet).order_by("id").first()
            self.assertEqual(our_dataset.created, fs_data.created)

            self.assertEqual(len([i for i in our_dataset.data]),
                             len(our_dataset))

            #check flucstrucs have freq, t0 and d_phase..
            #for i in our_dataset.data:
            #    print i
            #print 'w'
            #assert False

            #our guinea pig flucstruc:
            test_fs = our_dataset.pop()
            self.assertTrue(isinstance(test_fs.freq, float))
            self.assertTrue(isinstance(test_fs.t0, float))

            # now, are the phase data correct?

            self.assertTrue(isinstance(test_fs.dphase, BaseOrderedDataSet))
            self.assertEqual(len(test_fs.dphase), n_ch - 1)

            # what if we close the session and try again?

            session.close()
            session = pyfusion.orm_manager.Session()

            ds_again = session.query(DataSet).order_by("id").first()
            fs_again = list(ds_again)[0]
            """
Пример #3
0
    def test_ORM_flucstrucs(self):
        """ check that flucstrucs can be saved to database"""
        n_ch = 10
        n_samples = 1024
        multichannel_data = get_multimode_test_data(channels=get_n_channels(n_ch),
                                                    timebase = Timebase(np.arange(n_samples)*1.e-6),
                                                    noise = 0.01)
        # produce a dataset of flucstrucs
        #print ">> ", multichannel_data.channels
        fs_data = multichannel_data.flucstruc(min_dphase = -2*np.pi)
        print type(fs_data)
        #print list(fs_data)[0].dphase[0].channel_1
        #print '---'
        # save our dataset to the database
        fs_data.save()
        if pyfusion.orm_manager.IS_ACTIVE:
            session = pyfusion.orm_manager.Session()
            d1 = DataSet('test_dataset_1')
            d1.save()
            d2 = DataSet('test_dataset_2')
            d2.save()

            # get our dataset from database
            our_dataset = session.query(DataSet).order_by("id").first()
            self.assertEqual(our_dataset.created, fs_data.created)

            self.assertEqual(len([i for i in our_dataset.data]), len(our_dataset))

            #check flucstrucs have freq, t0 and d_phase..
            #for i in our_dataset.data:
            #    print i
            #print 'w'
            #assert False

            #our guinea pig flucstruc:
            test_fs = our_dataset.pop()
            self.assertTrue(isinstance(test_fs.freq, float))
            self.assertTrue(isinstance(test_fs.t0, float))

            # now, are the phase data correct?

            self.assertTrue(isinstance(test_fs.dphase, BaseOrderedDataSet))
            self.assertEqual(len(test_fs.dphase), n_ch-1)

            # what if we close the session and try again?

            session.close()
            session = pyfusion.orm_manager.Session()

            ds_again = session.query(DataSet).order_by("id").first()
            fs_again = list(ds_again)[0]
            """