本文整理汇总了Python中pyinstruments.curvestore.models.CurveDB.move方法的典型用法代码示例。如果您正苦于以下问题:Python CurveDB.move方法的具体用法?Python CurveDB.move怎么用?Python CurveDB.move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyinstruments.curvestore.models.CurveDB
的用法示例。
在下文中一共展示了CurveDB.move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_import_export_with_childs
# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import move [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)
示例2: TestImportExport
# 需要导入模块: from pyinstruments.curvestore.models import CurveDB [as 别名]
# 或者: from pyinstruments.curvestore.models.CurveDB import move [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)