Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #378 from simphony/uid_datasets
Browse files Browse the repository at this point in the history
Problem: datasets do not have uids
  • Loading branch information
stefanoborini committed Jan 25, 2017
2 parents 0c8b3db + 74d8cbd commit 5c2a0f5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
6 changes: 6 additions & 0 deletions simphony/cuds/lattice.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import uuid
import numpy as np

from ..core import CUBA
Expand Down Expand Up @@ -37,6 +38,11 @@ def __init__(self, name, primitive_cell, size, origin):
self._items_count = {
CUBA.NODE: lambda: self._size
}
self._uid = uuid.uuid4()

@property
def uid(self):
return self._uid

def count_of(self, item_type):
""" Return the count of item_type in the container.
Expand Down
6 changes: 6 additions & 0 deletions simphony/cuds/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def __init__(self, name):
CUBA.CELL: lambda: self._cells
}

self._uid = uuid.uuid4()

@property
def uid(self):
return self._uid

@property
def data(self):
return dc.DataContainer(self._data)
Expand Down
10 changes: 8 additions & 2 deletions simphony/cuds/particles.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
import uuid

from ..core import CUBA
from ..core.data_container import DataContainer
from . import ABCParticles
from .particles_items import Particle, Bond
from ..core import CUBA
from ..core.data_container import DataContainer


class Particles(ABCParticles):
Expand Down Expand Up @@ -43,6 +43,12 @@ def __init__(self, name):
CUBA.BOND: lambda: self._bonds
}

self._uid = uuid.uuid4()

@property
def uid(self):
return self._uid

@property
def data(self):
return DataContainer(self._data)
Expand Down
10 changes: 5 additions & 5 deletions simphony/cuds/tests/test_meta_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ def test_NoseHooverBoundary(self):
nose_hoover = meta_class.NoseHoover(material=[material])
self.assertIsNotNone(nose_hoover.data)

def test_not_sharing_mutable(self):
box1 = meta_class.Box()
box2 = meta_class.Box()
box1.vector[0][0] = 3.
self.assertNotEqual(box1.vector[0][0], box2.vector[0][0])
def test_whether_data_is_reference(self):
material = meta_class.Material()
data = material.data

self.assertEqual(data, material.data)

0 comments on commit 5c2a0f5

Please sign in to comment.