本文整理汇总了Python中prov.model.ProvDocument.update方法的典型用法代码示例。如果您正苦于以下问题:Python ProvDocument.update方法的具体用法?Python ProvDocument.update怎么用?Python ProvDocument.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prov.model.ProvDocument
的用法示例。
在下文中一共展示了ProvDocument.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_document_update_simple
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import update [as 别名]
def test_document_update_simple(self):
d1 = ProvDocument()
d1.set_default_namespace(EX_URI)
d1.entity('e')
b1 = d1.bundle('b1')
b1.entity('e')
d2 = ProvDocument()
d2.set_default_namespace(EX_URI)
d2.entity('e')
b1 = d2.bundle('b1')
b1.entity('e')
b2 = d2.bundle('b2')
b2.entity('e')
self.assertRaises(ProvException, lambda: d1.update(1))
d1.update(d2)
self.assertEqual(len(d1.get_records()), 2)
self.assertEqual(len(d1.bundles), 2)
示例2: NIDMObjectsUnitTesting
# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import update [as 别名]
class NIDMObjectsUnitTesting(unittest.TestCase):
"""
Unit testing of NIDM objects (compared to examples provided in
nidm-results.owl)
"""
def setUp(self):
self.export_dir = os.path.join(TEST_FOLDER, 'nidm')
if not os.path.isdir(self.export_dir):
os.mkdir(self.export_dir)
# Retreive owl file for NIDM-Results
owl_file = os.path.join(TERM_RESULTS_DIR, 'nidm-results.owl')
assert owl_file
self.owl = OwlReader(owl_file)
self.doc = ProvDocument()
# self.bundle = ProvBundle(identifier=NIIRI[software_lc+'_results_id'])
self.provn_file = os.path.join(self.export_dir, 'unit_test.provn')
namespaces_file = os.path.join(TERM_RESULTS_DIR, "templates", \
"Namespaces.txt")
namespaces_fid = open(namespaces_file)
self.prefixes = namespaces_fid.read()
namespaces_fid.close()
self.to_delete_files = [self.provn_file]
self.gt_ttl_files = list()
def test_design_matrix(self):
mat = np.matrix('1 2; 3 4')
mat_image = os.path.join(os.path.dirname(TEST_FOLDER), "data", \
"fmri.feat", "design.png")
design_matrix = DesignMatrix(mat, mat_image, self.export_dir)
self.doc.update(design_matrix.export())
# In the FSL export the design matrix contains both the Design Matrix
# entity and the Image entity representing the design matrix
# visualisation.
self.to_delete_files.append(os.path.join(self.export_dir, \
"DesignMatrix.csv"))
self.to_delete_files.append(os.path.join(self.export_dir, \
"DesignMatrix.png"))
gt_file = self.owl.get_example(NIDM['DesignMatrix'])
self.gt_ttl_files = [os.path.join(TERM_RESULTS_DIR, \
gt_file.replace("file://./", "")),
os.path.join(TERM_RESULTS_DIR, "examples", "Image-DesignMatrix.txt")]
self._create_gt_and_compare("Design Matrix")
def test_data(self):
data = Data(grand_mean_scaling=True, target=100.0)
self.doc.update(data.export())
gt_file = self.owl.get_example(NIDM['Data'])
self.gt_ttl_files.append(os.path.join(TERM_RESULTS_DIR, \
gt_file.replace("file://./", "")))
self._create_gt_and_compare("Data")
# INDEPEDENT_CORR = NIDM['IndependentError']
# SERIALLY_CORR = NIDM['SeriallyCorrelatedError']
# COMPOUND_SYMMETRY_CORR = NIDM['CompoundSymmetricError']
# ARBITRARILY_CORR = NIDM['ArbitriralyCorrelatedError']
# def test_error_model_indepdt_global(self):
# error_distribution = GAUSSIAN_DISTRIBUTION
# variance_homo = True
# variance_spatial = SPATIALLY_GLOBAL
# dependance = INDEPEDENT_CORR
# dependance_spatial = SPATIALLY_GLOBAL
# error_model = ErrorModel(error_distribution, variance_homo,
# variance_spatial, dependance, dependance_spatial)
# self.doc.update(error_model.export())
# nidm_classes = {
# "ErrorModel": dict(
# error_model_id="niiri:error_model_id",
# noise_distribution="nidm:GaussianDistribution",
# variance_homo="true",
# variance_spatial="nidm:SpatiallyGlobal",
# dependence="nidm:IndependentError",
# dependence_spatial="nidm:SpatiallyLocal"
# )
# }
# self._create_gt_and_compare(nidm_classes, "Data")
def _create_gt_and_compare(self, class_name):
# Write-out current example in a provn file and convert to turtle
provn_fid = open(self.provn_file, 'w')
provn_fid.write(self.doc.get_provn())
provn_fid.close()
ttl_file = self.provn_file.replace(".provn", ".ttl")
#.........这里部分代码省略.........