import csdmpy as cp
# create dimensions and dependent variables
dimension1 = cp.as_dimension(np.arange(10), application = {"test": "d0"})
dimension1.reciprocal.application = {"test": "reciprocal-d0"}
dimension2 = cp.as_dimension(np.arange(20), application = {"test": "d1"})
dimension2.reciprocal.application = {"test": "reciprocal-d1"}
data = cp.as_dependent_variable(np.random.rand(20, 10), application = {"test": "dv0"})
# create csdm object
before = cp.new()
before.application = {"test": "root"}
before.add_dimension(dimension1)
before.add_dimension(dimension2)
before.add_dependent_variable(data)
# save
before.save('test_file.csdf')
# expected the result to be same
after = cp.load('test_file.csdf', application=True)
print(before.application, after.application)
print(before.dimensions[0].application, after.dimensions[0].application)
print(before.dimensions[0].reciprocal.application, after.dimensions[0].reciprocal.application)
print(before.dimensions[1].application, after.dimensions[1].application)
print(before.dimensions[1].reciprocal.application, after.dimensions[1].reciprocal.application)
print(before.dependent_variables[0].application, after.dependent_variables[0].application)
{'test': 'root'} {}
{'test': 'd0'} {'test': 'd0'}
{'test': 'reciprocal-d0'} {'test': 'reciprocal-d0'}
{'test': 'd1'} {'test': 'd1'}
{'test': 'reciprocal-d1'} {'test': 'reciprocal-d1'}
{'test': 'dv0'} {'test': 'dv0'}