{"action":"created","comment":{"url":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/comments/200670908","pull_request_review_id":135036523,"id":200670908,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDY3MDkwOA==","diff_hunk":"@@ -1,6 +1,190 @@\n from typing import Union, cast\n+from operator import xor\n+import enum\n+import warnings\n \n-from qcodes import Parameter, Instrument\n+from qcodes import Parameter, ManualParameter, Instrument\n+\n+\n+class ParameterScaler(Parameter):\n+    \"\"\"\n+    Parameter Scaler\n+\n+    To be used when you use a physical voltage divider or an amplifier to set\n+    or get a quantity.\n+\n+    Initialize the parameter by passing the parameter to be measured/set\n+    and the value of the division OR the gain.\n+\n+    The scaling value can be either a scalar value or a Qcodes Parameter.\n+\n+    The parameter scaler acts a your original parameter, but will set the right\n+    value, and store the gain/division in the metadata.\n+\n+    Examples:\n+        Resistive voltage divider\n+        >>> vd = ParameterScaler(dac.chan0, division = 10)\n+\n+        Voltage multiplier\n+        >>> vb = ParameterScaler(dac.chan0, gain = 30, name = 'Vb')\n+\n+        Transimpedance amplifier\n+        >>> Id = ParameterScaler(multimeter.amplitude, division = 1e6, name = 'Id', unit = 'A')\n+\n+    Args:\n+        output: Physical Parameter that need conversion\n+        division: the division value\n+        gain: the gain value\n+        label: label of this parameter, by default uses 'output' label\n+            but attaches _amplified or _attenuated depending if gain\n+            or division has been specified\n+        name: name of this parameter, by default uses 'output' name\n+            but attaches _amplified or _attenuated depending if gain\n+            or division has been specified\n+        unit: resulting unit. It uses the one of 'output' by default\n+    \"\"\"\n+\n+    class Role(enum.Enum):\n+        GAIN = enum.auto()\n+        DIVISION = enum.auto()\n+\n+\n+    def __init__(self,\n+                 output: Parameter,\n+                 division: Union[int, float, Parameter] = None,\n+                 gain: Union[int, float, Parameter] = None,\n+                 name: str=None,\n+                 label: str=None,\n+                 unit: str=None) -> None:\n+        self.wrapped_parameter = output\n+        self.wrapped_instrument = getattr(output, \"_instrument\", None)\n+\n+        # Set the role, either as divider or amplifier\n+        # Raise an error if nothing is specified\n+        is_divider = division is not None\n+        is_amplifier = gain is not None\n+\n+        if not xor(is_divider, is_amplifier):\n+            raise ValueError('Provide only division OR gain')","path":"qcodes/instrument_drivers/devices.py","position":null,"original_position":69,"commit_id":"875bdd49302072df5a5fb605df3fd05cbb8480e3","original_commit_id":"74baebbbe831ddc84f33070114248b76b41f9781","user":{"login":"YakBizzarro","id":767740,"node_id":"MDQ6VXNlcjc2Nzc0MA==","avatar_url":"https://avatars1.githubusercontent.com/u/767740?v=4","gravatar_id":"","url":"https://api.github.com/users/YakBizzarro","html_url":"https://github.com/YakBizzarro","followers_url":"https://api.github.com/users/YakBizzarro/followers","following_url":"https://api.github.com/users/YakBizzarro/following{/other_user}","gists_url":"https://api.github.com/users/YakBizzarro/gists{/gist_id}","starred_url":"https://api.github.com/users/YakBizzarro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YakBizzarro/subscriptions","organizations_url":"https://api.github.com/users/YakBizzarro/orgs","repos_url":"https://api.github.com/users/YakBizzarro/repos","events_url":"https://api.github.com/users/YakBizzarro/events{/privacy}","received_events_url":"https://api.github.com/users/YakBizzarro/received_events","type":"User","site_admin":false},"body":"Role is needed in the case when the multiplier is not a simple scalar, but a Qcodes parameter (look at the last example). In this case 1/division should be computed every time that we set a value, or (like a do), perform a multiplication, depending on the role value","created_at":"2018-07-06T14:29:28Z","updated_at":"2018-07-06T14:29:28Z","html_url":"https://github.com/QCoDeS/Qcodes/pull/1069#discussion_r200670908","pull_request_url":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/1069","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/comments/200670908"},"html":{"href":"https://github.com/QCoDeS/Qcodes/pull/1069#discussion_r200670908"},"pull_request":{"href":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/1069"}},"in_reply_to_id":200183816},"pull_request":{"url":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/1069","id":183500236,"node_id":"MDExOlB1bGxSZXF1ZXN0MTgzNTAwMjM2","html_url":"https://github.com/QCoDeS/Qcodes/pull/1069","diff_url":"https://github.com/QCoDeS/Qcodes/pull/1069.diff","patch_url":"https://github.com/QCoDeS/Qcodes/pull/1069.patch","issue_url":"https://api.github.com/repos/QCoDeS/Qcodes/issues/1069","number":1069,"state":"open","locked":false,"title":"Add paramterScaler with an usage example and deprecate VoltageDivider","user":{"login":"YakBizzarro","id":767740,"node_id":"MDQ6VXNlcjc2Nzc0MA==","avatar_url":"https://avatars1.githubusercontent.com/u/767740?v=4","gravatar_id":"","url":"https://api.github.com/users/YakBizzarro","html_url":"https://github.com/YakBizzarro","followers_url":"https://api.github.com/users/YakBizzarro/followers","following_url":"https://api.github.com/users/YakBizzarro/following{/other_user}","gists_url":"https://api.github.com/users/YakBizzarro/gists{/gist_id}","starred_url":"https://api.github.com/users/YakBizzarro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YakBizzarro/subscriptions","organizations_url":"https://api.github.com/users/YakBizzarro/orgs","repos_url":"https://api.github.com/users/YakBizzarro/repos","events_url":"https://api.github.com/users/YakBizzarro/events{/privacy}","received_events_url":"https://api.github.com/users/YakBizzarro/received_events","type":"User","site_admin":false},"body":"Here I propose an enhanced version of the VoltageDivider. Compared to it, it has the ability to set either a division or a gain, depending on the nature of the instrument attached to it. Unit of the resulting parameter can be changed. Moreover, the gain/division can be a Qcodes parameter, in the case that is set by a remote instrument and not locally.\r\nWe are using this object in SpinQubit group in QuTech since few months with modules in IVVI/SPI racks, so it's well tested on the field.\r\n\r\n@WilliamHPNielsen, @jenshnielsen\r\n","created_at":"2018-04-23T17:10:21Z","updated_at":"2018-07-06T14:29:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"879a4f055e400ba0d5c733dc265a4f429ec32bfa","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":222346531,"node_id":"MDU6TGFiZWwyMjIzNDY1MzE=","url":"https://api.github.com/repos/QCoDeS/Qcodes/labels/enhancement","name":"enhancement","color":"fbca04","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/1069/commits","review_comments_url":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/1069/comments","review_comment_url":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/QCoDeS/Qcodes/issues/1069/comments","statuses_url":"https://api.github.com/repos/QCoDeS/Qcodes/statuses/875bdd49302072df5a5fb605df3fd05cbb8480e3","head":{"label":"YakBizzarro:paramterscaler","ref":"paramterscaler","sha":"875bdd49302072df5a5fb605df3fd05cbb8480e3","user":{"login":"YakBizzarro","id":767740,"node_id":"MDQ6VXNlcjc2Nzc0MA==","avatar_url":"https://avatars1.githubusercontent.com/u/767740?v=4","gravatar_id":"","url":"https://api.github.com/users/YakBizzarro","html_url":"https://github.com/YakBizzarro","followers_url":"https://api.github.com/users/YakBizzarro/followers","following_url":"https://api.github.com/users/YakBizzarro/following{/other_user}","gists_url":"https://api.github.com/users/YakBizzarro/gists{/gist_id}","starred_url":"https://api.github.com/users/YakBizzarro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YakBizzarro/subscriptions","organizations_url":"https://api.github.com/users/YakBizzarro/orgs","repos_url":"https://api.github.com/users/YakBizzarro/repos","events_url":"https://api.github.com/users/YakBizzarro/events{/privacy}","received_events_url":"https://api.github.com/users/YakBizzarro/received_events","type":"User","site_admin":false},"repo":{"id":85819753,"node_id":"MDEwOlJlcG9zaXRvcnk4NTgxOTc1Mw==","name":"Qcodes","full_name":"YakBizzarro/Qcodes","owner":{"login":"YakBizzarro","id":767740,"node_id":"MDQ6VXNlcjc2Nzc0MA==","avatar_url":"https://avatars1.githubusercontent.com/u/767740?v=4","gravatar_id":"","url":"https://api.github.com/users/YakBizzarro","html_url":"https://github.com/YakBizzarro","followers_url":"https://api.github.com/users/YakBizzarro/followers","following_url":"https://api.github.com/users/YakBizzarro/following{/other_user}","gists_url":"https://api.github.com/users/YakBizzarro/gists{/gist_id}","starred_url":"https://api.github.com/users/YakBizzarro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YakBizzarro/subscriptions","organizations_url":"https://api.github.com/users/YakBizzarro/orgs","repos_url":"https://api.github.com/users/YakBizzarro/repos","events_url":"https://api.github.com/users/YakBizzarro/events{/privacy}","received_events_url":"https://api.github.com/users/YakBizzarro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/YakBizzarro/Qcodes","description":"Modular data acquisition framework","fork":true,"url":"https://api.github.com/repos/YakBizzarro/Qcodes","forks_url":"https://api.github.com/repos/YakBizzarro/Qcodes/forks","keys_url":"https://api.github.com/repos/YakBizzarro/Qcodes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/YakBizzarro/Qcodes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/YakBizzarro/Qcodes/teams","hooks_url":"https://api.github.com/repos/YakBizzarro/Qcodes/hooks","issue_events_url":"https://api.github.com/repos/YakBizzarro/Qcodes/issues/events{/number}","events_url":"https://api.github.com/repos/YakBizzarro/Qcodes/events","assignees_url":"https://api.github.com/repos/YakBizzarro/Qcodes/assignees{/user}","branches_url":"https://api.github.com/repos/YakBizzarro/Qcodes/branches{/branch}","tags_url":"https://api.github.com/repos/YakBizzarro/Qcodes/tags","blobs_url":"https://api.github.com/repos/YakBizzarro/Qcodes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/YakBizzarro/Qcodes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/YakBizzarro/Qcodes/git/refs{/sha}","trees_url":"https://api.github.com/repos/YakBizzarro/Qcodes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/YakBizzarro/Qcodes/statuses/{sha}","languages_url":"https://api.github.com/repos/YakBizzarro/Qcodes/languages","stargazers_url":"https://api.github.com/repos/YakBizzarro/Qcodes/stargazers","contributors_url":"https://api.github.com/repos/YakBizzarro/Qcodes/contributors","subscribers_url":"https://api.github.com/repos/YakBizzarro/Qcodes/subscribers","subscription_url":"https://api.github.com/repos/YakBizzarro/Qcodes/subscription","commits_url":"https://api.github.com/repos/YakBizzarro/Qcodes/commits{/sha}","git_commits_url":"https://api.github.com/repos/YakBizzarro/Qcodes/git/commits{/sha}","comments_url":"https://api.github.com/repos/YakBizzarro/Qcodes/comments{/number}","issue_comment_url":"https://api.github.com/repos/YakBizzarro/Qcodes/issues/comments{/number}","contents_url":"https://api.github.com/repos/YakBizzarro/Qcodes/contents/{+path}","compare_url":"https://api.github.com/repos/YakBizzarro/Qcodes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/YakBizzarro/Qcodes/merges","archive_url":"https://api.github.com/repos/YakBizzarro/Qcodes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/YakBizzarro/Qcodes/downloads","issues_url":"https://api.github.com/repos/YakBizzarro/Qcodes/issues{/number}","pulls_url":"https://api.github.com/repos/YakBizzarro/Qcodes/pulls{/number}","milestones_url":"https://api.github.com/repos/YakBizzarro/Qcodes/milestones{/number}","notifications_url":"https://api.github.com/repos/YakBizzarro/Qcodes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/YakBizzarro/Qcodes/labels{/name}","releases_url":"https://api.github.com/repos/YakBizzarro/Qcodes/releases{/id}","deployments_url":"https://api.github.com/repos/YakBizzarro/Qcodes/deployments","created_at":"2017-03-22T11:26:54Z","updated_at":"2017-03-22T11:26:57Z","pushed_at":"2018-07-06T09:56:44Z","git_url":"git://github.com/YakBizzarro/Qcodes.git","ssh_url":"git@github.com:YakBizzarro/Qcodes.git","clone_url":"https://github.com/YakBizzarro/Qcodes.git","svn_url":"https://github.com/YakBizzarro/Qcodes","homepage":"http://qcodes.github.io/Qcodes","size":19819,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"QCoDeS:master","ref":"master","sha":"dadc1aba6c8fa4f6b2921114719d8e530c973583","user":{"login":"QCoDeS","id":20478252,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwNDc4MjUy","avatar_url":"https://avatars3.githubusercontent.com/u/20478252?v=4","gravatar_id":"","url":"https://api.github.com/users/QCoDeS","html_url":"https://github.com/QCoDeS","followers_url":"https://api.github.com/users/QCoDeS/followers","following_url":"https://api.github.com/users/QCoDeS/following{/other_user}","gists_url":"https://api.github.com/users/QCoDeS/gists{/gist_id}","starred_url":"https://api.github.com/users/QCoDeS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QCoDeS/subscriptions","organizations_url":"https://api.github.com/users/QCoDeS/orgs","repos_url":"https://api.github.com/users/QCoDeS/repos","events_url":"https://api.github.com/users/QCoDeS/events{/privacy}","received_events_url":"https://api.github.com/users/QCoDeS/received_events","type":"Organization","site_admin":false},"repo":{"id":37137879,"node_id":"MDEwOlJlcG9zaXRvcnkzNzEzNzg3OQ==","name":"Qcodes","full_name":"QCoDeS/Qcodes","owner":{"login":"QCoDeS","id":20478252,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwNDc4MjUy","avatar_url":"https://avatars3.githubusercontent.com/u/20478252?v=4","gravatar_id":"","url":"https://api.github.com/users/QCoDeS","html_url":"https://github.com/QCoDeS","followers_url":"https://api.github.com/users/QCoDeS/followers","following_url":"https://api.github.com/users/QCoDeS/following{/other_user}","gists_url":"https://api.github.com/users/QCoDeS/gists{/gist_id}","starred_url":"https://api.github.com/users/QCoDeS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QCoDeS/subscriptions","organizations_url":"https://api.github.com/users/QCoDeS/orgs","repos_url":"https://api.github.com/users/QCoDeS/repos","events_url":"https://api.github.com/users/QCoDeS/events{/privacy}","received_events_url":"https://api.github.com/users/QCoDeS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/QCoDeS/Qcodes","description":"Modular data acquisition framework","fork":false,"url":"https://api.github.com/repos/QCoDeS/Qcodes","forks_url":"https://api.github.com/repos/QCoDeS/Qcodes/forks","keys_url":"https://api.github.com/repos/QCoDeS/Qcodes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/QCoDeS/Qcodes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/QCoDeS/Qcodes/teams","hooks_url":"https://api.github.com/repos/QCoDeS/Qcodes/hooks","issue_events_url":"https://api.github.com/repos/QCoDeS/Qcodes/issues/events{/number}","events_url":"https://api.github.com/repos/QCoDeS/Qcodes/events","assignees_url":"https://api.github.com/repos/QCoDeS/Qcodes/assignees{/user}","branches_url":"https://api.github.com/repos/QCoDeS/Qcodes/branches{/branch}","tags_url":"https://api.github.com/repos/QCoDeS/Qcodes/tags","blobs_url":"https://api.github.com/repos/QCoDeS/Qcodes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/QCoDeS/Qcodes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/QCoDeS/Qcodes/git/refs{/sha}","trees_url":"https://api.github.com/repos/QCoDeS/Qcodes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/QCoDeS/Qcodes/statuses/{sha}","languages_url":"https://api.github.com/repos/QCoDeS/Qcodes/languages","stargazers_url":"https://api.github.com/repos/QCoDeS/Qcodes/stargazers","contributors_url":"https://api.github.com/repos/QCoDeS/Qcodes/contributors","subscribers_url":"https://api.github.com/repos/QCoDeS/Qcodes/subscribers","subscription_url":"https://api.github.com/repos/QCoDeS/Qcodes/subscription","commits_url":"https://api.github.com/repos/QCoDeS/Qcodes/commits{/sha}","git_commits_url":"https://api.github.com/repos/QCoDeS/Qcodes/git/commits{/sha}","comments_url":"https://api.github.com/repos/QCoDeS/Qcodes/comments{/number}","issue_comment_url":"https://api.github.com/repos/QCoDeS/Qcodes/issues/comments{/number}","contents_url":"https://api.github.com/repos/QCoDeS/Qcodes/contents/{+path}","compare_url":"https://api.github.com/repos/QCoDeS/Qcodes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/QCoDeS/Qcodes/merges","archive_url":"https://api.github.com/repos/QCoDeS/Qcodes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/QCoDeS/Qcodes/downloads","issues_url":"https://api.github.com/repos/QCoDeS/Qcodes/issues{/number}","pulls_url":"https://api.github.com/repos/QCoDeS/Qcodes/pulls{/number}","milestones_url":"https://api.github.com/repos/QCoDeS/Qcodes/milestones{/number}","notifications_url":"https://api.github.com/repos/QCoDeS/Qcodes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/QCoDeS/Qcodes/labels{/name}","releases_url":"https://api.github.com/repos/QCoDeS/Qcodes/releases{/id}","deployments_url":"https://api.github.com/repos/QCoDeS/Qcodes/deployments","created_at":"2015-06-09T14:42:14Z","updated_at":"2018-07-06T14:14:23Z","pushed_at":"2018-07-06T14:14:10Z","git_url":"git://github.com/QCoDeS/Qcodes.git","ssh_url":"git@github.com:QCoDeS/Qcodes.git","clone_url":"https://github.com/QCoDeS/Qcodes.git","svn_url":"https://github.com/QCoDeS/Qcodes","homepage":"http://qcodes.github.io/Qcodes","size":40790,"stargazers_count":39,"watchers_count":39,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":67,"mirror_url":null,"archived":false,"open_issues_count":207,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":67,"open_issues":207,"watchers":39,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/1069"},"html":{"href":"https://github.com/QCoDeS/Qcodes/pull/1069"},"issue":{"href":"https://api.github.com/repos/QCoDeS/Qcodes/issues/1069"},"comments":{"href":"https://api.github.com/repos/QCoDeS/Qcodes/issues/1069/comments"},"review_comments":{"href":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/1069/comments"},"review_comment":{"href":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/QCoDeS/Qcodes/pulls/1069/commits"},"statuses":{"href":"https://api.github.com/repos/QCoDeS/Qcodes/statuses/875bdd49302072df5a5fb605df3fd05cbb8480e3"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"YakBizzarro"}}