{"action":"created","comment":{"url":"https://api.github.com/repos/simphony/simphony-common/pulls/comments/84237048","pull_request_review_id":5025983,"id":84237048,"diff_hunk":"@@ -0,0 +1,174 @@\n+# -*- coding: utf-8 -*-\n+from abc import ABCMeta, abstractmethod\n+\n+\n+class ABCDataset(object):\n+    \"\"\"Abstract base class for a dataset.\n+    \"\"\"\n+    __metaclass__ = ABCMeta\n+\n+    @abstractmethod\n+    def add(self, iterable):  # pragma: no cover\n+        \"\"\"Adds a set of objects from the provided iterable\n+        to the dataset.\n+\n+        If any object has no uids, the dataset will generate a new\n+        uid for it. If the object has already an uid, it won't add the\n+        object if an object with the same type uid already exists.\n+        If the user wants to replace an existing object in the container\n+        there is an 'update' method for that purpose.\n+\n+        Parameters\n+        ----------\n+        iterable : iterable of objects\n+            the new set of objects that will be included in the container.\n+\n+        Returns\n+        -------\n+        uids : list of uuid.UUID\n+            The uids of the added objects.\n+\n+        Raises\n+        ------\n+        ValueError :\n+            when there is an object with an uids that already exists\n+            in the dataset.\n+        \"\"\"\n+\n+    @abstractmethod\n+    def update(self, iterable):  # pragma: no cover\n+        \"\"\"Updates a set of objects from the provided iterable.\n+\n+        Takes the uids of the objects and searches inside the dataset for\n+        those objects. If the object exists, they are replaced in the\n+        dataset. If any object doesn't exist, it will raise an exception.\n+\n+        Parameters\n+        ----------\n+\n+        iterable : iterable of objects\n+            the objects that will be replaced.\n+\n+        Raises\n+        ------\n+        ValueError :\n+            If any object inside the iterable does not exist.\n+        \"\"\"\n+\n+    @abstractmethod\n+    def get(self, uid):  # pragma: no cover\n+        \"\"\"Returns a copy of the object with the 'uid' id.\n+\n+        Parameters\n+        ----------\n+\n+        uid : uuid.UUID\n+            the uid of the object\n+\n+        Raises\n+        ------\n+        KeyError :\n+            when the object is not in the container.\n+\n+        Returns\n+        -------\n+        object :\n+            A copy of the internally stored info.\n+        \"\"\"\n+\n+    @abstractmethod\n+    def remove(self, uids):  # pragma: no cover\n+        \"\"\"Remove the object with the provided uids from the container.\n+\n+        The uids inside the iterable should exists in the container. Otherwise\n+        an exception will be raised.\n+\n+        Parameters\n+        ----------\n+        uids : iterable of uuid.UUID\n+            the uids of the objects to be removed.\n+\n+        Raises\n+        ------\n+        KeyError :\n+            If any object doesn't exist.\n+        \"\"\"\n+\n+    @abstractmethod\n+    def iter(self, uids=None, item_type=None):  # pragma: no cover\n+        \"\"\"Generator method for iterating over the objects of the container.\n+\n+        It can receive any kind of sequence of uids to iterate over\n+        those concrete objects. If nothing is passed as parameter, it will\n+        iterate over all the objects.\n+\n+        Parameters\n+        ----------\n+        uids : iterable of uuid.UUID, optional\n+            sequence containing the uids of the objects that will be\n+            iterated. When the uids are provided, then the objects are\n+            returned in the same order the uids are returned by the iterable.\n+            If uids is None, then all objects are returned by the iterable\n+            and there is no restriction on the order that they are returned.\n+\n+        Yields\n+        ------\n+        object : Particle\n+            The object item.\n+\n+        Raises\n+        ------\n+        KeyError :\n+            if any of the ids passed as parameters are not in the dataset.\n+        \"\"\"\n+\n+    @abstractmethod\n+    def has(self, uid):  # pragma: no cover\n+        \"\"\"Checks if an object with the given uid already exists\n+        in the dataset.\n+\n+        Parameters\n+        ----------\n+        uid : uuid.UUID\n+            the uid of the object\n+\n+        Returns\n+        -------\n+        True if the uid is found, False otherwise.\n+        \"\"\"\n+\n+    @abstractmethod\n+    def has_type(self, item_type):  # pragma: no cover\n+        \"\"\"Checks if the specified CUDSItem type is present\n+        in the dataset.\n+\n+        Parameters\n+        ----------\n+        item_type : CUDSItem\n+            The CUDSItem enum of the type of the items to return the count of.\n+\n+        Returns\n+        -------\n+        True if the type is present, False otherwise.\n+        \"\"\"\n+\n+    @abstractmethod\n+    def count_of(self, item_type):  # pragma: no cover","path":"simphony/cuds/abc_dataset.py","position":156,"original_position":156,"commit_id":"bbccbf46f10626681c311ba20271d9297b463bfb","original_commit_id":"597a10eb48a0fee7ba37b0e7d3e8e3be4e5589f9","user":{"login":"stefanoborini","id":132967,"avatar_url":"https://avatars.githubusercontent.com/u/132967?v=3","gravatar_id":"","url":"https://api.github.com/users/stefanoborini","html_url":"https://github.com/stefanoborini","followers_url":"https://api.github.com/users/stefanoborini/followers","following_url":"https://api.github.com/users/stefanoborini/following{/other_user}","gists_url":"https://api.github.com/users/stefanoborini/gists{/gist_id}","starred_url":"https://api.github.com/users/stefanoborini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefanoborini/subscriptions","organizations_url":"https://api.github.com/users/stefanoborini/orgs","repos_url":"https://api.github.com/users/stefanoborini/repos","events_url":"https://api.github.com/users/stefanoborini/events{/privacy}","received_events_url":"https://api.github.com/users/stefanoborini/received_events","type":"User","site_admin":false},"body":"That's possible, yes.","created_at":"2016-10-20T08:48:44Z","updated_at":"2016-10-20T08:48:45Z","html_url":"https://github.com/simphony/simphony-common/pull/326#discussion_r84237048","pull_request_url":"https://api.github.com/repos/simphony/simphony-common/pulls/326","_links":{"self":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/comments/84237048"},"html":{"href":"https://github.com/simphony/simphony-common/pull/326#discussion_r84237048"},"pull_request":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/326"}}},"pull_request":{"url":"https://api.github.com/repos/simphony/simphony-common/pulls/326","id":89985777,"html_url":"https://github.com/simphony/simphony-common/pull/326","diff_url":"https://github.com/simphony/simphony-common/pull/326.diff","patch_url":"https://github.com/simphony/simphony-common/pull/326.patch","issue_url":"https://api.github.com/repos/simphony/simphony-common/issues/326","number":326,"state":"open","locked":false,"title":"Generic interface for Mesh","user":{"login":"stefanoborini","id":132967,"avatar_url":"https://avatars.githubusercontent.com/u/132967?v=3","gravatar_id":"","url":"https://api.github.com/users/stefanoborini","html_url":"https://github.com/stefanoborini","followers_url":"https://api.github.com/users/stefanoborini/followers","following_url":"https://api.github.com/users/stefanoborini/following{/other_user}","gists_url":"https://api.github.com/users/stefanoborini/gists{/gist_id}","starred_url":"https://api.github.com/users/stefanoborini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefanoborini/subscriptions","organizations_url":"https://api.github.com/users/stefanoborini/orgs","repos_url":"https://api.github.com/users/stefanoborini/repos","events_url":"https://api.github.com/users/stefanoborini/events{/privacy}","received_events_url":"https://api.github.com/users/stefanoborini/received_events","type":"User","site_admin":false},"body":"This PR introduces the generic interface for datasets and applies it to the Mesh object, with minimal disruption to the internals and no disruptions to the old interface. \r\nWe expect a loss of efficiency but that's the price to pay for not knowing the uid->type association. At the moment, it's probably not wise to implement optimization strategies to solve this issue, and will be part of a separate PR once we migrated all objects.","created_at":"2016-10-19T10:56:21Z","updated_at":"2016-10-20T08:48:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b0806f2273457eab60b5d25885c0b3e07a41f8b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/simphony/simphony-common/pulls/326/commits","review_comments_url":"https://api.github.com/repos/simphony/simphony-common/pulls/326/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/326/comments","statuses_url":"https://api.github.com/repos/simphony/simphony-common/statuses/bbccbf46f10626681c311ba20271d9297b463bfb","head":{"label":"simphony:generic-interface-mesh","ref":"generic-interface-mesh","sha":"bbccbf46f10626681c311ba20271d9297b463bfb","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}","deployments_url":"https://api.github.com/repos/simphony/simphony-common/deployments","created_at":"2014-08-05T17:05:12Z","updated_at":"2016-01-12T13:55:35Z","pushed_at":"2016-10-19T21:09:45Z","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":5847,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":27,"forks":4,"open_issues":27,"watchers":6,"default_branch":"master"}},"base":{"label":"simphony:master","ref":"master","sha":"70bb9f025171c03b667e1a1778b73be655042b0d","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}","deployments_url":"https://api.github.com/repos/simphony/simphony-common/deployments","created_at":"2014-08-05T17:05:12Z","updated_at":"2016-01-12T13:55:35Z","pushed_at":"2016-10-19T21:09:45Z","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":5847,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":27,"forks":4,"open_issues":27,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/326"},"html":{"href":"https://github.com/simphony/simphony-common/pull/326"},"issue":{"href":"https://api.github.com/repos/simphony/simphony-common/issues/326"},"comments":{"href":"https://api.github.com/repos/simphony/simphony-common/issues/326/comments"},"review_comments":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/326/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/326/commits"},"statuses":{"href":"https://api.github.com/repos/simphony/simphony-common/statuses/bbccbf46f10626681c311ba20271d9297b463bfb"}}}}
{"actor":{"display_login":"stefanoborini"}}