{"action":"created","comment":{"url":"https://api.github.com/repos/simphony/simphony-common/pulls/comments/25149296","id":25149296,"diff_hunk":"@@ -0,0 +1,194 @@\n+from simphony.core.cuba import CUBA\n+from simphony.cuds.lattice import MetaLattice\n+from simphony.cuds.lattice import LatticeNode\n+from simphony.io.indexed_data_container_table import IndexedDataContainerTable\n+from simphony.io.data_container_description import NoUIDRecord\n+from simphony.core.data_container import DataContainer\n+\n+import numpy as np\n+\n+\n+class FileLattice(MetaLattice):\n+    \"\"\"\n+    FileLattice object to use in file lattices.\n+\n+    Attributes\n+    ----------\n+    file : CudsFile\n+        reference to PyTables file where the lattice is or will be located\n+    name : str\n+        name of the lattice\n+    type : string\n+        Bravais lattice type (should agree with the _base_vect below).\n+    base_vect : D x float\n+        defines a Bravais lattice (an alternative for primitive vectors).\n+    size : D x size\n+        number of lattice nodes (in the direction of each axis).\n+    origin : D x float\n+        origin of lattice\n+    record : tables.IsDescription\n+        A class that describes column types for PyTables table.\n+\n+    Returns\n+    ----------\n+    FileLattice\n+        The lattice newly added to the file or existing in the file.\n+\n+    \"\"\"\n+    def __init__(self, file, name, type, base_vect, size, origin,\n+                 record=None):\n+        # Construct a default FileLattice\n+        super(FileLattice, self).__init__(\n+            name, type, base_vect, size, origin)\n+        self._file = file._file\n+        self._group = file._file.root.lattice\n+        self._record = record\n+\n+        # If Lattice not in file, create a lattice\n+        if self.name not in self._file.root.lattice:\n+            if self._record is None:\n+                # If record not specified use NoUIDRecord\n+                self._record = NoUIDRecord\n+            self._table = IndexedDataContainerTable(\n+                self._group, name, self._record, np.prod(self._size))\n+            for i in xrange(np.prod(self._size)):\n+                self._table.append(DataContainer())\n+\n+            # Set table attributes\n+            lattice = self._group._f_getChild(self.name)\n+            lattice.attrs.type = self._type\n+            lattice.attrs.base_vect = self._base_vect\n+            lattice.attrs.size = self._size\n+            lattice.attrs.origin = self._origin\n+\n+        # If Lattice already in file, return a reference\n+        else:\n+            self._table = IndexedDataContainerTable(self._group, self.name)\n+            lattice = self._group._f_getChild(self.name)\n+            self._type = lattice.attrs.type\n+            self._base_vect = lattice.attrs.base_vect\n+            self._size = lattice.attrs.size\n+            self._origin = lattice.attrs.origin\n+\n+    def get_node(self, index):\n+        \"\"\"Get a copy of the node corresponding to the given index.\n+\n+        Parameters:\n+        -----------\n+        index: tuple of D x int (node index coordinate)\n+\n+        Returns:\n+        -----------\n+        A reference to a LatticeNode object\n+\n+        \"\"\"\n+        n = self._get_row_number(index)\n+        dcs = {}\n+        colnum = 0\n+        for column in xrange(self._table._table.description.mask.shape[0]):","path":"simphony/io/file_lattice.py","position":88,"original_position":88,"commit_id":"f04a2cf74a5eac9ce1d466b04b62f5a40c137d15","original_commit_id":"f04a2cf74a5eac9ce1d466b04b62f5a40c137d15","user":{"login":"tuopuu","id":8424971,"avatar_url":"https://avatars.githubusercontent.com/u/8424971?v=3","gravatar_id":"","url":"https://api.github.com/users/tuopuu","html_url":"https://github.com/tuopuu","followers_url":"https://api.github.com/users/tuopuu/followers","following_url":"https://api.github.com/users/tuopuu/following{/other_user}","gists_url":"https://api.github.com/users/tuopuu/gists{/gist_id}","starred_url":"https://api.github.com/users/tuopuu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuopuu/subscriptions","organizations_url":"https://api.github.com/users/tuopuu/orgs","repos_url":"https://api.github.com/users/tuopuu/repos","events_url":"https://api.github.com/users/tuopuu/events{/privacy}","received_events_url":"https://api.github.com/users/tuopuu/received_events","type":"User","site_admin":false},"body":"You are right. self._table[n] does the same job in much cleaner way.","created_at":"2015-02-23T08:39:19Z","updated_at":"2015-02-23T08:39:19Z","html_url":"https://github.com/simphony/simphony-common/pull/67#discussion_r25149296","pull_request_url":"https://api.github.com/repos/simphony/simphony-common/pulls/67","_links":{"self":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/comments/25149296"},"html":{"href":"https://github.com/simphony/simphony-common/pull/67#discussion_r25149296"},"pull_request":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/67"}}},"pull_request":{"url":"https://api.github.com/repos/simphony/simphony-common/pulls/67","id":29523470,"html_url":"https://github.com/simphony/simphony-common/pull/67","diff_url":"https://github.com/simphony/simphony-common/pull/67.diff","patch_url":"https://github.com/simphony/simphony-common/pull/67.patch","issue_url":"https://api.github.com/repos/simphony/simphony-common/issues/67","number":67,"state":"open","locked":false,"title":"PR: File lattice2","user":{"login":"tuopuu","id":8424971,"avatar_url":"https://avatars.githubusercontent.com/u/8424971?v=3","gravatar_id":"","url":"https://api.github.com/users/tuopuu","html_url":"https://github.com/tuopuu","followers_url":"https://api.github.com/users/tuopuu/followers","following_url":"https://api.github.com/users/tuopuu/following{/other_user}","gists_url":"https://api.github.com/users/tuopuu/gists{/gist_id}","starred_url":"https://api.github.com/users/tuopuu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuopuu/subscriptions","organizations_url":"https://api.github.com/users/tuopuu/orgs","repos_url":"https://api.github.com/users/tuopuu/repos","events_url":"https://api.github.com/users/tuopuu/events{/privacy}","received_events_url":"https://api.github.com/users/tuopuu/received_events","type":"User","site_admin":false},"body":"FileLattice now supports CustomRecord.","created_at":"2015-02-18T13:05:23Z","updated_at":"2015-02-23T08:39:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3a376388540eb83e8d12d8a7f8bdf6c9d445f844","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/simphony/simphony-common/pulls/67/commits","review_comments_url":"https://api.github.com/repos/simphony/simphony-common/pulls/67/comments","review_comment_url":"https://api.github.com/repos/simphony/simphony-common/pulls/comments{/number}","comments_url":"https://api.github.com/repos/simphony/simphony-common/issues/67/comments","statuses_url":"https://api.github.com/repos/simphony/simphony-common/statuses/f04a2cf74a5eac9ce1d466b04b62f5a40c137d15","head":{"label":"simphony:file_lattice2","ref":"file_lattice2","sha":"f04a2cf74a5eac9ce1d466b04b62f5a40c137d15","user":{"login":"simphony","id":8048249,"avatar_url":"https://avatars.githubusercontent.com/u/8048249?v=3","gravatar_id":"","url":"https://api.github.com/users/simphony","html_url":"https://github.com/simphony","followers_url":"https://api.github.com/users/simphony/followers","following_url":"https://api.github.com/users/simphony/following{/other_user}","gists_url":"https://api.github.com/users/simphony/gists{/gist_id}","starred_url":"https://api.github.com/users/simphony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simphony/subscriptions","organizations_url":"https://api.github.com/users/simphony/orgs","repos_url":"https://api.github.com/users/simphony/repos","events_url":"https://api.github.com/users/simphony/events{/privacy}","received_events_url":"https://api.github.com/users/simphony/received_events","type":"Organization","site_admin":false},"repo":{"id":22651892,"name":"simphony-common","full_name":"simphony/simphony-common","owner":{"login":"simphony","id":8048249,"avatar_url":"https://avatars.githubusercontent.com/u/8048249?v=3","gravatar_id":"","url":"https://api.github.com/users/simphony","html_url":"https://github.com/simphony","followers_url":"https://api.github.com/users/simphony/followers","following_url":"https://api.github.com/users/simphony/following{/other_user}","gists_url":"https://api.github.com/users/simphony/gists{/gist_id}","starred_url":"https://api.github.com/users/simphony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simphony/subscriptions","organizations_url":"https://api.github.com/users/simphony/orgs","repos_url":"https://api.github.com/users/simphony/repos","events_url":"https://api.github.com/users/simphony/events{/privacy}","received_events_url":"https://api.github.com/users/simphony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simphony/simphony-common","description":"The native implementation of the Simphony cuds objects","fork":false,"url":"https://api.github.com/repos/simphony/simphony-common","forks_url":"https://api.github.com/repos/simphony/simphony-common/forks","keys_url":"https://api.github.com/repos/simphony/simphony-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simphony/simphony-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simphony/simphony-common/teams","hooks_url":"https://api.github.com/repos/simphony/simphony-common/hooks","issue_events_url":"https://api.github.com/repos/simphony/simphony-common/issues/events{/number}","events_url":"https://api.github.com/repos/simphony/simphony-common/events","assignees_url":"https://api.github.com/repos/simphony/simphony-common/assignees{/user}","branches_url":"https://api.github.com/repos/simphony/simphony-common/branches{/branch}","tags_url":"https://api.github.com/repos/simphony/simphony-common/tags","blobs_url":"https://api.github.com/repos/simphony/simphony-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simphony/simphony-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simphony/simphony-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/simphony/simphony-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simphony/simphony-common/statuses/{sha}","languages_url":"https://api.github.com/repos/simphony/simphony-common/languages","stargazers_url":"https://api.github.com/repos/simphony/simphony-common/stargazers","contributors_url":"https://api.github.com/repos/simphony/simphony-common/contributors","subscribers_url":"https://api.github.com/repos/simphony/simphony-common/subscribers","subscription_url":"https://api.github.com/repos/simphony/simphony-common/subscription","commits_url":"https://api.github.com/repos/simphony/simphony-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/simphony/simphony-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/simphony/simphony-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/simphony/simphony-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/simphony/simphony-common/contents/{+path}","compare_url":"https://api.github.com/repos/simphony/simphony-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simphony/simphony-common/merges","archive_url":"https://api.github.com/repos/simphony/simphony-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simphony/simphony-common/downloads","issues_url":"https://api.github.com/repos/simphony/simphony-common/issues{/number}","pulls_url":"https://api.github.com/repos/simphony/simphony-common/pulls{/number}","milestones_url":"https://api.github.com/repos/simphony/simphony-common/milestones{/number}","notifications_url":"https://api.github.com/repos/simphony/simphony-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simphony/simphony-common/labels{/name}","releases_url":"https://api.github.com/repos/simphony/simphony-common/releases{/id}","created_at":"2014-08-05T17:05:12Z","updated_at":"2015-02-13T09:45:16Z","pushed_at":"2015-02-20T12:01:58Z","git_url":"git://github.com/simphony/simphony-common.git","ssh_url":"git@github.com:simphony/simphony-common.git","clone_url":"https://github.com/simphony/simphony-common.git","svn_url":"https://github.com/simphony/simphony-common","homepage":null,"size":2055,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":23,"forks":3,"open_issues":23,"watchers":5,"default_branch":"master"}},"base":{"label":"simphony:master","ref":"master","sha":"c22bec9841d87dfd20309fff54f4c8e2a98fa1ab","user":{"login":"simphony","id":8048249,"avatar_url":"https://avatars.githubusercontent.com/u/8048249?v=3","gravatar_id":"","url":"https://api.github.com/users/simphony","html_url":"https://github.com/simphony","followers_url":"https://api.github.com/users/simphony/followers","following_url":"https://api.github.com/users/simphony/following{/other_user}","gists_url":"https://api.github.com/users/simphony/gists{/gist_id}","starred_url":"https://api.github.com/users/simphony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simphony/subscriptions","organizations_url":"https://api.github.com/users/simphony/orgs","repos_url":"https://api.github.com/users/simphony/repos","events_url":"https://api.github.com/users/simphony/events{/privacy}","received_events_url":"https://api.github.com/users/simphony/received_events","type":"Organization","site_admin":false},"repo":{"id":22651892,"name":"simphony-common","full_name":"simphony/simphony-common","owner":{"login":"simphony","id":8048249,"avatar_url":"https://avatars.githubusercontent.com/u/8048249?v=3","gravatar_id":"","url":"https://api.github.com/users/simphony","html_url":"https://github.com/simphony","followers_url":"https://api.github.com/users/simphony/followers","following_url":"https://api.github.com/users/simphony/following{/other_user}","gists_url":"https://api.github.com/users/simphony/gists{/gist_id}","starred_url":"https://api.github.com/users/simphony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simphony/subscriptions","organizations_url":"https://api.github.com/users/simphony/orgs","repos_url":"https://api.github.com/users/simphony/repos","events_url":"https://api.github.com/users/simphony/events{/privacy}","received_events_url":"https://api.github.com/users/simphony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simphony/simphony-common","description":"The native implementation of the Simphony cuds objects","fork":false,"url":"https://api.github.com/repos/simphony/simphony-common","forks_url":"https://api.github.com/repos/simphony/simphony-common/forks","keys_url":"https://api.github.com/repos/simphony/simphony-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simphony/simphony-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simphony/simphony-common/teams","hooks_url":"https://api.github.com/repos/simphony/simphony-common/hooks","issue_events_url":"https://api.github.com/repos/simphony/simphony-common/issues/events{/number}","events_url":"https://api.github.com/repos/simphony/simphony-common/events","assignees_url":"https://api.github.com/repos/simphony/simphony-common/assignees{/user}","branches_url":"https://api.github.com/repos/simphony/simphony-common/branches{/branch}","tags_url":"https://api.github.com/repos/simphony/simphony-common/tags","blobs_url":"https://api.github.com/repos/simphony/simphony-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simphony/simphony-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simphony/simphony-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/simphony/simphony-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simphony/simphony-common/statuses/{sha}","languages_url":"https://api.github.com/repos/simphony/simphony-common/languages","stargazers_url":"https://api.github.com/repos/simphony/simphony-common/stargazers","contributors_url":"https://api.github.com/repos/simphony/simphony-common/contributors","subscribers_url":"https://api.github.com/repos/simphony/simphony-common/subscribers","subscription_url":"https://api.github.com/repos/simphony/simphony-common/subscription","commits_url":"https://api.github.com/repos/simphony/simphony-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/simphony/simphony-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/simphony/simphony-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/simphony/simphony-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/simphony/simphony-common/contents/{+path}","compare_url":"https://api.github.com/repos/simphony/simphony-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simphony/simphony-common/merges","archive_url":"https://api.github.com/repos/simphony/simphony-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simphony/simphony-common/downloads","issues_url":"https://api.github.com/repos/simphony/simphony-common/issues{/number}","pulls_url":"https://api.github.com/repos/simphony/simphony-common/pulls{/number}","milestones_url":"https://api.github.com/repos/simphony/simphony-common/milestones{/number}","notifications_url":"https://api.github.com/repos/simphony/simphony-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simphony/simphony-common/labels{/name}","releases_url":"https://api.github.com/repos/simphony/simphony-common/releases{/id}","created_at":"2014-08-05T17:05:12Z","updated_at":"2015-02-13T09:45:16Z","pushed_at":"2015-02-20T12:01:58Z","git_url":"git://github.com/simphony/simphony-common.git","ssh_url":"git@github.com:simphony/simphony-common.git","clone_url":"https://github.com/simphony/simphony-common.git","svn_url":"https://github.com/simphony/simphony-common","homepage":null,"size":2055,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":23,"forks":3,"open_issues":23,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/67"},"html":{"href":"https://github.com/simphony/simphony-common/pull/67"},"issue":{"href":"https://api.github.com/repos/simphony/simphony-common/issues/67"},"comments":{"href":"https://api.github.com/repos/simphony/simphony-common/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/67/comments"},"review_comment":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/67/commits"},"statuses":{"href":"https://api.github.com/repos/simphony/simphony-common/statuses/f04a2cf74a5eac9ce1d466b04b62f5a40c137d15"}}}}