예제 #1
0
 def __init__(self, name='', age=0.0, distances=(), uuid=None):
     self.name = name
     self.age = age
     self.distances = distances  # km walked the last n days
     self.__soft_entity__ = softpy.entity_t(
         get_meta_name='Person',
         get_meta_version='0.1',
         get_meta_namespace='http://sintef.no/meta/soft',
         get_dimensions=['ndays'],
         get_dimension_size=[len(distances)],
         load=self.load,
         store=self.store,
         id=uuid)
예제 #2
0
 def __init__(self, name='', age=0.0, distances=(), uuid=None):
     self.name = name
     self.age = age
     self.distances = distances  # km walked the last n days
     self.__soft_entity__ = softpy.entity_t(
         get_meta_name='Person',
         get_meta_version='0.1',
         get_meta_namespace='http://sintef.no/meta/soft',
         get_dimensions=['ndays'],
         get_dimension_size=[len(distances)],
         load=self.load,
         store=self.store, 
         id=uuid)
예제 #3
0
 def __init__(self, name='', age=0.0, distances=(), uuid=None):
     self.name = name
     self.age = age
     self.distances = distances  # km walked the last n days
     self.__soft_entity__ = softpy.entity_t(
         'Person',  # get_meta_name
         '0.1',  # get_meta_version
         'http://sintef.no/meta/soft',  # get_meta_namespace
         ['ndays'],  # get_dimensions
         [len(distances)],  # get_dimension_size
         self.store,  # store
         self.load,  # load
         uuid,  # id
         None,  # user_data
     )
예제 #4
0
    softpy.datamodel_append_array_double(
        datamodel, 'positions',
        np.array([(0.0, 0.0, 0.0), (0.5, 0.5, 0.5)]).flatten())

def load(e, datamodel):
    d = e.user_data
    d.name = softpy.datamodel_get_string(datamodel, 'name')
    d.spgr = softpy.datamodel_get_int32(datamodel, 'spacegroup_no')
    d.latt = softpy.datamodel_get_double(datamodel, 'lattice_parameter')
    d.posi = softpy.datamodel_get_array_double(datamodel, 'positions')

e = softpy.entity_t(get_meta_name='MyStructure',
                    #get_meta_version='0.1.1',
                    get_meta_version=lambda self: '0.1.1',
                    get_meta_namespace='http://sintef.no/meta/soft',
                    get_dimensions=['I', 'J'],
                    get_dimension_size=[3, 4],
                    load=load,
                    store=store,
                    user_data=Data())

assert softpy.entity_get_meta_name(e) == 'MyStructure'
assert softpy.entity_get_meta_version(e) == '0.1.1'
assert softpy.entity_get_meta_namespace(e) == 'http://sintef.no/meta/soft'
assert softpy.entity_get_dimensions(e) == ['I', 'J']
assert softpy.entity_get_dimension_size(e, 'I') == 3
assert softpy.entity_get_dimension_size(e, 'J') == 4
assert softpy.entity_get_id(e) == e.id

assert e.name == 'MyStructure'
assert e.version == '0.1.1'
예제 #5
0
    softpy.datamodel_append_array_double(
        datamodel, 'positions', 
        np.array([(0.0, 0.0, 0.0), (0.5, 0.5, 0.5)]).flatten())

def load(e, datamodel):
    d = e.user_data
    d.name = softpy.datamodel_get_string(datamodel, 'name')
    d.spgr = softpy.datamodel_get_int32(datamodel, 'spacegroup_no')
    d.latt = softpy.datamodel_get_double(datamodel, 'lattice_parameter')
    d.posi = softpy.datamodel_get_array_double(datamodel, 'positions')

e = softpy.entity_t(get_meta_name='MyStructure',
                    #get_meta_version='0.1.1',
                    get_meta_version=lambda self: '0.1.1',
                    get_meta_namespace='http://sintef.no/meta/soft',
                    get_dimensions=['I', 'J'],
                    get_dimension_size=[3, 4],
                    load=load,
                    store=store, 
                    user_data=Data())

assert softpy.entity_get_meta_name(e) == 'MyStructure'
assert softpy.entity_get_meta_version(e) == '0.1.1'
assert softpy.entity_get_meta_namespace(e) == 'http://sintef.no/meta/soft'
assert softpy.entity_get_dimensions(e) == ['I', 'J']
assert softpy.entity_get_dimension_size(e, 'I') == 3
assert softpy.entity_get_dimension_size(e, 'J') == 4
assert softpy.entity_get_id(e) == e.id

assert e.name == 'MyStructure'
assert e.version == '0.1.1'
예제 #6
0

def load(e, datamodel):
    d = e.user_data
    d.name = softpy.datamodel_get_string(datamodel, 'name')
    d.spgr = softpy.datamodel_get_int32(datamodel, 'spacegroup_no')
    d.latt = softpy.datamodel_get_double(datamodel, 'lattice_parameter')
    d.posi = softpy.datamodel_get_array_double(datamodel, 'positions')


e = softpy.entity_t(
    'MyStructure',  # get_meta_name
    lambda self: '0.1.1',  # get_meta_version
    'http://sintef.no/meta/soft',  # get_meta_namespace
    ['I', 'J'],  # get_dimensions
    [3, 4],  # get_dimension_size
    store,  # store
    load,  # load
    None,  # id
    Data(),  # user_data
)

assert softpy.entity_get_meta_name(e) == 'MyStructure'
assert softpy.entity_get_meta_version(e) == '0.1.1'
assert softpy.entity_get_meta_namespace(e) == 'http://sintef.no/meta/soft'
assert softpy.entity_get_dimensions(e) == ['I', 'J']
assert softpy.entity_get_dimension_size(e, 'I') == 3
assert softpy.entity_get_dimension_size(e, 'J') == 4
assert softpy.entity_get_id(e) == e.id

assert e.name == 'MyStructure'