{"action":"created","comment":{"url":"https://api.github.com/repos/simphony/simphony-common/pulls/comments/49056222","id":49056222,"diff_hunk":"@@ -0,0 +1,121 @@\n+from simphony.core.data_container import DataContainer\n+from simphony.core.material_relations_information import (\n+    MATERIAL_RELATIONSHIP_INFORMATION)\n+\n+\n+class MaterialRelation(object):\n+    \"\"\" Class represents relationships between materials\n+\n+    MaterialRelation provides a general interface for describing the\n+    (physics/chemistry) relations between different materials\n+\n+    Attributes\n+    ----------\n+    kind: CUDSMaterialRelation\n+        Describes the kind of the MaterialRelation\n+\n+    name : str\n+        name of the material-relation\n+\n+    materials: list of uids\n+        materials where this relation applies\n+\n+    parameters: DataContainer\n+        the required parameters\n+\n+    description: str\n+        user-defined description of the material-relation\n+\n+    supported_parameters: list of CUBA\n+        CUBA values required/allowed for the parameters\n+\n+    allowed_number_materials : list of int\n+        list with all possible configurations of avaliable\n+        number of materials in the relation\n+\n+    \"\"\"\n+\n+    def __init__(self, name, kind, materials, parameters, description=\"\"):\n+\n+        info = MATERIAL_RELATIONSHIP_INFORMATION[kind]\n+        self._allowed_number_materials = info.allowed_number_materials\n+        self._supported_parameters = [\n+            parameter.cuba_key for parameter in info.supported_parameters]\n+\n+        self._name = name\n+        self._kind = kind\n+        self._description = description\n+\n+        self._check_materials(materials)\n+        self._materials = materials\n+\n+        self._check_parameters(parameters)\n+        self._parameters = parameters\n+\n+    @property\n+    def name(self):\n+        return self._name\n+\n+    @name.setter\n+    def name(self, value):\n+        if isinstance(value, basestring):\n+            self._name = value\n+        else:\n+            message = 'Expected string but received {!r}'\n+            raise TypeError(message.format(type(basestring)))\n+\n+    @property\n+    def description(self):\n+        return self._description\n+\n+    @description.setter\n+    def description(self, value):\n+        if isinstance(value, basestring):\n+            self._description = value\n+        else:\n+            message = 'Expected string but received {!r}'\n+            raise TypeError(message.format(type(basestring)))\n+\n+    @property\n+    def supported_parameters(self):\n+        return set(self._supported_parameters)\n+\n+    @property\n+    def materials(self):\n+        return list(self._materials)\n+\n+    @materials.setter\n+    def _set_materials(self, value):\n+        self._check_materials(value)\n+        self._materials = value\n+\n+    def _check_materials(self, value):\n+        if(len(value) not in self._allowed_number_materials):\n+            error_str = \"Incorrect number of materials, expected: {}\"\n+            raise ValueError(\n+                error_str.format(\n+                    len(value),\n+                    self._allowed_number_materials\n+                )\n+            )\n+\n+    @property\n+    def parameters(self):\n+        return DataContainer(self._parameters)\n+\n+    @parameters.setter\n+    def parameters(self, value):\n+        self._check_parameters(value)\n+        self._parameters = DataContainer(value)\n+\n+    def _check_parameters(self, value):\n+        if (set(self._supported_parameters) != set(value.keys())):","path":"simphony/material_relations/material_relation.py","position":null,"original_position":112,"commit_id":"2bf473294fb1474d3705c9032fecffed4ab343ca","original_commit_id":"53ebeaf2c61c620f55c1d2364ebbe37942e7a381","user":{"login":"roigcarlo","id":1935791,"avatar_url":"https://avatars.githubusercontent.com/u/1935791?v=3","gravatar_id":"","url":"https://api.github.com/users/roigcarlo","html_url":"https://github.com/roigcarlo","followers_url":"https://api.github.com/users/roigcarlo/followers","following_url":"https://api.github.com/users/roigcarlo/following{/other_user}","gists_url":"https://api.github.com/users/roigcarlo/gists{/gist_id}","starred_url":"https://api.github.com/users/roigcarlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roigcarlo/subscriptions","organizations_url":"https://api.github.com/users/roigcarlo/orgs","repos_url":"https://api.github.com/users/roigcarlo/repos","events_url":"https://api.github.com/users/roigcarlo/events{/privacy}","received_events_url":"https://api.github.com/users/roigcarlo/received_events","type":"User","site_admin":false},"body":"@nathanfranklin, @mehdisadeghi I agree that we can derive the information from let's say ```material_relations_information.py```, add get the default values from the CUBA keys, but the user will still have to supply such information If I understand the new approach correctly, right?\r\n\r\nWhat I don't understand is, why we should add an additional factory method to do exactly the same as ```lj_mat = LennardJones(name, materials)```?","created_at":"2016-01-07T09:44:28Z","updated_at":"2016-01-07T09:44:28Z","html_url":"https://github.com/simphony/simphony-common/pull/253#discussion_r49056222","pull_request_url":"https://api.github.com/repos/simphony/simphony-common/pulls/253","_links":{"self":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/comments/49056222"},"html":{"href":"https://github.com/simphony/simphony-common/pull/253#discussion_r49056222"},"pull_request":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/253"}}},"pull_request":{"url":"https://api.github.com/repos/simphony/simphony-common/pulls/253","id":53577340,"html_url":"https://github.com/simphony/simphony-common/pull/253","diff_url":"https://github.com/simphony/simphony-common/pull/253.diff","patch_url":"https://github.com/simphony/simphony-common/pull/253.patch","issue_url":"https://api.github.com/repos/simphony/simphony-common/issues/253","number":253,"state":"open","locked":false,"title":"Feature material relation","user":{"login":"roigcarlo","id":1935791,"avatar_url":"https://avatars.githubusercontent.com/u/1935791?v=3","gravatar_id":"","url":"https://api.github.com/users/roigcarlo","html_url":"https://github.com/roigcarlo","followers_url":"https://api.github.com/users/roigcarlo/followers","following_url":"https://api.github.com/users/roigcarlo/following{/other_user}","gists_url":"https://api.github.com/users/roigcarlo/gists{/gist_id}","starred_url":"https://api.github.com/users/roigcarlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roigcarlo/subscriptions","organizations_url":"https://api.github.com/users/roigcarlo/orgs","repos_url":"https://api.github.com/users/roigcarlo/repos","events_url":"https://api.github.com/users/roigcarlo/events{/privacy}","received_events_url":"https://api.github.com/users/roigcarlo/received_events","type":"User","site_admin":false},"body":"This implementes #226\r\n\r\nThe status of the PR is the following:\r\n- [x] Add MaterialRelation class\r\n- [x] Add Tests\r\n- [ ] Add temporal material_relations.py container\r\n- [ ] Add documentation\r\n\r\nAs requested by @ahashibon the following point has not been implemented yet.\r\n- [ ] Creating a SP object to contain these material relations (i.e. add_material_relation, get_material_relation, delete_material_relation, update_material_relation) (plus tests and documentation)\r\n\r\n","created_at":"2015-12-14T15:17:26Z","updated_at":"2016-01-07T09:44:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"63cedc15e1d64513b8ab3790a497c0676a1f65c5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/simphony/simphony-common/pulls/253/commits","review_comments_url":"https://api.github.com/repos/simphony/simphony-common/pulls/253/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/253/comments","statuses_url":"https://api.github.com/repos/simphony/simphony-common/statuses/2bf473294fb1474d3705c9032fecffed4ab343ca","head":{"label":"simphony:feature-material-relation","ref":"feature-material-relation","sha":"2bf473294fb1474d3705c9032fecffed4ab343ca","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-12-03T12:39:17Z","pushed_at":"2016-01-05T15:34:09Z","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":5195,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":19,"forks":3,"open_issues":19,"watchers":6,"default_branch":"master"}},"base":{"label":"simphony:master","ref":"master","sha":"0e1c28752c8b0d8640b20c0f11a2ff5ea2a692d3","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-12-03T12:39:17Z","pushed_at":"2016-01-05T15:34:09Z","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":5195,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":19,"forks":3,"open_issues":19,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/253"},"html":{"href":"https://github.com/simphony/simphony-common/pull/253"},"issue":{"href":"https://api.github.com/repos/simphony/simphony-common/issues/253"},"comments":{"href":"https://api.github.com/repos/simphony/simphony-common/issues/253/comments"},"review_comments":{"href":"https://api.github.com/repos/simphony/simphony-common/pulls/253/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/253/commits"},"statuses":{"href":"https://api.github.com/repos/simphony/simphony-common/statuses/2bf473294fb1474d3705c9032fecffed4ab343ca"}}}}