当前位置: 首页>>代码示例>>Python>>正文


Python CurveDB.set_data方法代码示例

本文整理汇总了Python中pyinstruments.curvestore.models.CurveDB.set_data方法的典型用法代码示例。如果您正苦于以下问题:Python CurveDB.set_data方法的具体用法?Python CurveDB.set_data怎么用?Python CurveDB.set_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyinstruments.curvestore.models.CurveDB的用法示例。


在下文中一共展示了CurveDB.set_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_import_export_with_childs

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
    def test_import_export_with_childs(self):
        from pyinstruments import CurveDB
        c = CurveDB()
        s = pandas.Series([1,2,1])
        c.set_data(s)
        c.name = 'to_be_exported'
        c.save()
        
        c2 = CurveDB()
        s2 = pandas.Series([1,3,1])
        c2.set_data(s2)
        c2.name = 'to_be_exported_child'
        c2.move(c)
        
        queryset = CurveDB.objects.filter(id__in=[c.id, c2.id])
        from pyinstruments.curvestore.export import export_zip, import_zip
        export_zip(queryset, osp.dirname(__file__) + '/tests/temp_files/' +\
                    'test_export1.zip')
        c.delete()
        import_zip(osp.dirname(__file__) + '/tests/temp_files/' + \
                    'test_export1.zip')
        q = CurveDB.objects.filter_param('name', value='to_be_exported_child')

        self.assertEqual(q.count(), 1)
        self.assertLess((q[0].data - s2).abs().max(), 0.001)
开发者ID:tjzhaomengyi,项目名称:pyinstruments,代码行数:27,代码来源:tests.py

示例2: test_insert

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_insert(self):
     print_and_log("================================")
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.save()
     
     tic = time.time()
     for i in range(100):
         curve.save()
     print_and_log("time for saving 100 times the same simple dummy curve: " , time.time() - tic)
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:12,代码来源:tests.py

示例3: test_delete

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_delete(self):
     from curve import Curve
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.params["dummy"] = 24.5
     for j in range(100):
         curve.params['coucou' + str(j)] = j
     curve.save()
     tic = time.time()
     curve.delete()
     print_and_log("time for deleting one curve: ", time.time() - tic)
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:13,代码来源:tests.py

示例4: test_insert3

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_insert3(self):
     print_and_log("================================")
     
     for i in range(3):
         curve = CurveDB()
         curve.set_data(pandas.Series([1,4,6]))
         for j in range(100):
             curve.params['coucou' + str(j)] = i*j
         tic = time.time()
         curve.save()
         print_and_log("time for saving 1 curve with 100 parameters (new curve each time): " + str(time.time() - tic))
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:13,代码来源:tests.py

示例5: test_save_curve_only

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_save_curve_only(self):
     from curve import Curve
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.save()
     print_and_log("================================")
     for i in range(3):
         for j in range(100):
             curve.params['coucou' + str(j)] = i*j
         tic = time.time()
         Curve.save(curve, curve.get_full_filename())
         print_and_log("time for saving 1 curve with 100 parameters in h5: " + str(time.time() - tic))
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:14,代码来源:tests.py

示例6: test_insert2

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_insert2(self):
     print_and_log("================================")
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.save()
     
     for i in range(3):
         for j in range(100):
             curve.params['coucou' + str(j)] = i*j
         tic = time.time()
         curve.save()
         print_and_log("time for saving 1 curve with 100 parameters (always same curve, values changing): " + str(time.time() - tic))
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:14,代码来源:tests.py

示例7: test_remove_param

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_remove_param(self):
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.save()
     
     for i in range(20):
         curve.params['coucou' + str(i)] = i
     curve.save()
     curve = CurveDB.objects.get(id=curve.id)
     curve.params.pop("coucou12")
     curve.save()
     curve = CurveDB.objects.get(id=curve.id)
     self.assertTrue("coucou12" not in curve.params)
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:15,代码来源:tests.py

示例8: test_insert_bad_param_string

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_insert_bad_param_string(self):
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.params['some_string_param'] = 'coucou'
     curve.save()
     def do_some_crap():
         curve.params['some_string_param'] = 15.
         curve.save()
     self.assertRaises(ValueError, do_some_crap)
     def do_other_crap():
         curve = CurveDB()
         curve.params['some_string_param'] = 15.
         curve.save()
     self.assertRaises(ValueError, do_other_crap)
开发者ID:tjzhaomengyi,项目名称:pyinstruments,代码行数:16,代码来源:tests.py

示例9: test_alter_params_only

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_alter_params_only(self):
     from curve import Curve
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.params["dummy"] = 24.5
     for j in range(100):
         curve.params['coucou' + str(j)] = j
     curve.save()
     tic = time.time()
     curve.params["dummy"] = 25.5
     models.PROFILING = True
     curve.save_params()
     print_and_log("================================")
     print_and_log("time for altering just one value: ", time.time() - tic)
     models.PROFILING = False
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:17,代码来源:tests.py

示例10: test_clear_columns

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_clear_columns(self):
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.save()
     
     curve.params['dummy_name'] = 89
     curve.save()
     curve = CurveDB.objects.get(id=curve.id)
     self.assertTrue("dummy_name" in [o.name for o in ParamColumn.objects.all()])
     
     curve.params.pop('dummy_name')
     curve.save()
     self.assertTrue("dummy_name" in [o.name for o in ParamColumn.objects.all()])
     clear_unused_columns()
     self.assertFalse("dummy_name" in [o.name for o in ParamColumn.objects.all()])
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:17,代码来源:tests.py

示例11: test_save_altered_curve

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_save_altered_curve(self):
     from curve import Curve
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.save()
     
     
     print_and_log("================================")
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     for i in range(5):
         for j in range(100):
             curve.params['coucou' + str(j)] = i*j
         tic = time.time()
         curve.save_params()
         print_and_log("time for saving 100 parameters in db only, same curve each time: " + str(time.time() - tic))
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:18,代码来源:tests.py

示例12: test_insert_param

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_insert_param(self):
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.save()
     
     for i in range(100):
         curve.params['coucou' + str(i)] = i
     curve.save()
     cu = CurveDB.objects.get(id=curve.id)
     self.assertTrue(cu.params['coucou12']==12)
     
     cu.params['coucou12'] = 45.
     cu.save()
     cu2 = CurveDB.objects.get(id=curve.id)
     self.assertTrue(cu2.params['coucou12']==45.)
     
     search = CurveDB.objects.filter_param('coucou12', value__gte=44)
     self.assertTrue(cu2 in search)
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:20,代码来源:tests.py

示例13: test_save_params_only

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
 def test_save_params_only(self):
     from curve import Curve
     models.PROFILE_SAVE = True
     curve = CurveDB()
     curve.set_data(pandas.Series([1,4,6]))
     curve.save()
     
     
     print_and_log("================================")
     
     for i in range(5):
         curve = CurveDB()
         curve.set_data(pandas.Series([1,4,6]))
         for j in range(100):
             curve.params['coucou' + str(j)] = i*j
         tic = time.time()
         curve.save_params()
         print_and_log("time for saving 100 parameters in db only, new curve each time: " + str(time.time() - tic))
     print_and_log("================================")
     for i in range(5):
         curve = CurveDB()
         curve.set_data(pandas.Series([1,4,6]))
         for j in range(100):
             curve.params['coucou' + str(j)] = i*j
         tic = time.time()
         curve.save()
         print_and_log("time for saving 1 curve with 100 parameters, new curve each time: " + str(time.time() - tic))
     models.PROFILE_SAVE = False
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:30,代码来源:tests.py

示例14: SimpleTest

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
class SimpleTest(TestCase):
    def test_curve_save(self):
        """
        Tests that a curve can be saved.
        """
        self.curve = CurveDB()
        self.curve.set_data(pandas.Series([1,4,6]))
        self.curve.save()
    
    def test_curve_filter_param_string(self):
        """
        Tests that a curve can be retrieved by a string param.
        """
        self.curve = CurveDB()
        self.curve.params['name'] = 'some_name'
        self.curve.set_data(pandas.Series([1,4,6]))
        self.curve.save()

        qs = CurveDB.objects.filter_param('name', value='some_name')
        self.assertTrue(self.curve in qs)
        
    def test_curve_filter_param_float(self):
        """
        Tests that a curve can be retrieved by a string param.
        """
        
        self.curve = CurveDB()
        self.curve.params['name'] = 'some_name'
        self.curve.params['Q'] = 1e6
        self.curve.set_data(pandas.Series([1,4,6]))
        self.curve.save()

        qs = CurveDB.objects.filter_param('Q', value=1e6)
        self.assertTrue(self.curve in qs)
        
    def test_curve_filter_param_float_lte(self):
        """
        Tests that a curve can be retrieved by a string param.
        """
        self.curve = CurveDB()
        self.curve.params['name'] = 'some_name'
        self.curve.params['Q'] = 1e6
        self.curve.set_data(pandas.Series([1,4,6]))
        self.curve.save()

        qs = CurveDB.objects.filter_param('Q', value__lte=1e7)
        self.assertTrue(self.curve in qs)
        qs = CurveDB.objects.filter_param('Q', value__gte=1e7)
        self.assertFalse(self.curve in qs)
        
    def test_curve_filter_param_boolean(self):
        """
        Tests that a curve can be retrieved by a string param.
        """
        self.curve = CurveDB()
        self.curve.params['name'] = 'some_name'
        self.curve.params['Q'] = 1e6
        self.curve.params['nice_curve'] = True
        self.curve.set_data(pandas.Series([1,4,6]))
        self.curve.save()

        qs = CurveDB.objects.filter_param('nice_curve', value=True)
        self.assertTrue(self.curve in qs)
        qs = CurveDB.objects.filter_param('nice_curve', value=False)
        self.assertFalse(self.curve in qs)
    
    def test_curve_filter_param_text(self):
        """
        Tests that a curve can be retrieved by a string param.
        """
        self.curve = CurveDB()
        self.curve.params['comment'] = 'bla bla bla'
        self.curve.params['Q'] = 1e6
        self.curve.params['nice_curve'] = True
        self.curve.set_data(pandas.Series([1,4,6]))
        self.curve.save()

        qs = CurveDB.objects.filter_param('comment', value__contains='bla')
        self.assertTrue(self.curve in qs)
        qs = CurveDB.objects.filter_param('nice_curve', value__contains='blo')
        self.assertFalse(self.curve in qs)
        
    def test_curve_filter_date(self):
        """
        Tests that a curve can be retrieved by a date.
        """
        self.curve = CurveDB()
        self.curve.params['comment'] = 'bla bla bla'
        self.curve.params['Q'] = 1e6
        self.curve.params['nice_curve'] = True
        self.curve.set_data(pandas.Series([1,4,6]))
        self.curve.save()

        qs = CurveDB.objects.filter_param('date', value__lte=datetime.now())
        self.assertTrue(self.curve in qs)
        qs = CurveDB.objects.filter_param('date', value__gte=datetime.now())
        self.assertFalse(self.curve in qs)
        
        
    def test_curve_filter_tag(self):
#.........这里部分代码省略.........
开发者ID:vsteinmetz,项目名称:pyinstruments,代码行数:103,代码来源:tests.py

示例15: TestImportExport

# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import set_data [as 别名]
class TestImportExport(TestCurvestore):
    def test_import_export(self):
        from pyinstruments import CurveDB
        c = CurveDB()
        s = pandas.Series([1,2,1])
        c.set_data(s)
        c.name = 'to_be_exported'
        c.save()
        queryset = CurveDB.objects.filter(id=c.id)
        from pyinstruments.curvestore.export import export_zip, import_zip
        export_zip(queryset, osp.dirname(__file__) + '/tests/temp_files/' + \
                    'test_export1.zip')
        c.delete()
        import_zip(osp.dirname(__file__) + '/tests/temp_files/' +\
                    'test_export1.zip')
        q = CurveDB.objects.filter_param('name',value='to_be_exported')
        self.assertEqual(q.count(), 1)
        self.assertLess((q[0].data - s).abs().max(), 0.001)
    
    def test_import_export_with_childs(self):
        from pyinstruments import CurveDB
        c = CurveDB()
        s = pandas.Series([1,2,1])
        c.set_data(s)
        c.name = 'to_be_exported'
        c.save()
        
        c2 = CurveDB()
        s2 = pandas.Series([1,3,1])
        c2.set_data(s2)
        c2.name = 'to_be_exported_child'
        c2.move(c)
        
        queryset = CurveDB.objects.filter(id__in=[c.id, c2.id])
        from pyinstruments.curvestore.export import export_zip, import_zip
        export_zip(queryset, osp.dirname(__file__) + '/tests/temp_files/' +\
                    'test_export1.zip')
        c.delete()
        import_zip(osp.dirname(__file__) + '/tests/temp_files/' + \
                    'test_export1.zip')
        q = CurveDB.objects.filter_param('name', value='to_be_exported_child')

        self.assertEqual(q.count(), 1)
        self.assertLess((q[0].data - s2).abs().max(), 0.001)

    def test_backupreload(self):
        self.curve = CurveDB()
        self.curve.params['comment'] = 'bla bla bla'
        self.curve.params['Q'] = 1e6
        self.curve.params['nice_curve'] = True
        self.curve.tags.append('new_tag')
        self.curve.set_data(pandas.Series([1,4,6]))
        self.curve.save()
        self.curve.tags.append('other_tag')
        self.curve.save()
        self.curve2 = CurveDB()
        self.curve2.set_data(pandas.Series([1,4,6]))
        self.curve2.tags.append('new_tag')
        self.curve2.params['Q'] = 5e6
        self.curve2.save()
        self.curve2.move(self.curve)
        self.curve2 = CurveDB()
        self.curve2.set_data(pandas.Series([1,4,6]))
        self.curve2.tags.append('new_tag')
        self.curve2.params['Q'] = 5e6
        self.curve2.save()
        self.curve2.move(self.curve)
        
        tags = self.curve.tags
        curveid = self.curve.id
        from pyinstruments.curvestore import export
        export.backup_database(osp.dirname(__file__) + '/tests/temp_files/' +\
                    'test_backup_database.txt')
        CurveDB.objects.all().delete()
        Tag.objects.all().delete()
        print "Number of curves before reimport: ", CurveDB.objects.all().count()
        print "Number of tags: ", Tag.objects.all().count()
        
        export.reload_database(osp.dirname(__file__) + '/tests/temp_files/' + \
                    'test_backup_database.txt')

        print "Number of curves after reimport: ", CurveDB.objects.all().count()
        print "Number of tags: ", Tag.objects.all().count()

        curve = CurveDB.objects.get(pk=curveid) 
        
        self.assertEqual(curve.params["Q"], 1e6)
        self.assertEqual(curve.tags, tags)
开发者ID:tjzhaomengyi,项目名称:pyinstruments,代码行数:90,代码来源:tests.py


注:本文中的pyinstruments.curvestore.models.CurveDB.set_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。