Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New AMI430 driver #700

Merged
merged 30 commits into from
Sep 4, 2017
Merged

New AMI430 driver #700

merged 30 commits into from
Sep 4, 2017

Conversation

sohailc
Copy link
Member

@sohailc sohailc commented Aug 10, 2017

This should fix issue 648.

#648

I have added some tests to see if this is the case.

I have also added an environment.yml file so that to install the enviromnent to develop and run qcodes, we can just do (from the command line):

git clone
cd qcodes
conda env create

sohail chatoor and others added 16 commits August 7, 2017 16:22
2) added a mock IP module to mock IP instruments
3) added a debug module to debug the AMI430 instrument
…cylindrical coodinates. By keeping a prepresnetation of the vector in all three systems, there is less risk of loss of information so that e.g. the field strength can be ramped up given previous supplied phi and theta.

The spherical and cylindrical tests seem to work.
…uments

2) Made test to verify that the correct error is raised if we intentionally exceed the field limits
@sohailc sohailc mentioned this pull request Aug 16, 2017
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should go into version control?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably add it to .gitignore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, I cannot remove this file from the PR. Any idea's?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok Lets leave it for now, If it contains local specific information we can remove it later

environment.yml Outdated
channels:
- anaconda
- conda-forge
- dsdale24
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the channels should just be:

- defaults
- conda-forge

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dsdate24 is not used and the preferred name for the default is default. With the setup above I ended up with all packages looking like they are outdated because default has higher priority than anaconda

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make the changes as you suggest and see if I can create a working environment.

self.name = str(name)
self.testing = testing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be a private attribute _testing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good point

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also make it a property that cannot be set and get rid of the is_testing method below. Whichever way you prefer but there should only be one public attribute/method

Copy link
Collaborator

@jenshnielsen jenshnielsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Left some more inline comments

def get_mock_messages(self):
"""
For testing purposes we might want to get log messages from the mocker.
:return: mocker_messages: list, str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are generally using google style with sphinx napoleon http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html rather than native formatting of doc strings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will adjust the doc strings

"functions": {name: func.snapshot(update=update) for name, func in self.functions.items()},
"submodules": {name: subm.snapshot(update=update) for name, subm in self.submodules.items()},
"__class__": full_class(self)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have not been enforcing it but we have been trying to move towards pep8 and <79 char per line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not exactly understand why this is giving me pep8 issues. My pycharm editor also complains about this line, but I do not understand why.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line is longer than 79 characters now? no. The wrapping was to make it shorter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is complaining that the dictionary can be re-written as a dict literal. So literal:

some_dict = {"A": 1, "B": 2}

vs.

dict(A=1, B=1).

But as far as I can see the dictionary is literal, so I do not understand the complaint.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link has some explaination: link, but I do not understand how this applies here. Anyway, I do not think this issue is very important and I propose to ignore it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that seems wrong to me. I think its safe to ignore that

from datetime import datetime


class MockAMI430(object):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to inherit from object. We only support python3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

:param msg_str: string, the message string the mock instrument gets through the network socket.
:param key: string, one of the keys in self.handlers
:return: (match, args), (bool, string), if the key and the msg_str match, then match = True. If any arguments
are present in the message string these will be passed along.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Google style

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@@ -0,0 +1,463 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should go in the drivers example folder (1 below this one)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

"outputs": [],
"source": [
"import sys \n",
"sys.path.append(r\"C:\\Users\\a-sochat\\development\\Qcodes_QUTech\")\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed. We should aim at having all notebooks something that users can run if they have the right hardware

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because the notebook is not in the root folder of the qcodes module. If the qcodes module is not in a location where python can find it, we need to specifically add the module path to the system path. If the user running this notebook has qcodes installed in a standard location then this is not necessary. I will remove the line from the notebook

"cell_type": "markdown",
"metadata": {},
"source": [
"![title](AMI430_test_cartesian.jpg)\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this image added to the repository

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I should remove the picture all togehter. I don't think we should have large images in the repo. A comment that we have manually checked that the instrument displays show that the correct currents are reached should suffice.

"theta": np.random.uniform(0, 180),
"phi": np.random.uniform(0, 360),
"rho": np.random.uniform(0, 1)
}[coordinate_name]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use hypothesis https://hypothesis.readthedocs.io/en/latest/ in any test that relies on random data

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know that module but I will familiarize myself and use it here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It not needed, only a suggestion because I think it's cool and we are already using it. Feel free to leave as it is

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow thats a useful library. Good to know!

"""
:param msg: string, a message received through the socket communication layer
:return: string or None, If the type of message requests a value (a get message) then this value is returned
by this function. A set message will return a None value.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

google style

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

1) There are contradictory inputs (e.g. x=3, y=4, z=0 and rho=6)
"""

for _ in range(1):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this for loop needed?

I would remove it and replace the breaks with return. That should be equivalent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a break statement only works in loops.Your suggestions would indeed be equivalent. Ideally we want to have a single exit point in fuctions, however my solution is not ideal either. I will replace the breaks by return.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw... the situation would be a little trickier if after the loop we had other code. We could not simply return as the rest of the code would not be reachable. A better solution has been implemented in the code. See the updated PR shortly

@jenshnielsen jenshnielsen merged commit 5acbeeb into microsoft:master Sep 4, 2017
giulioungaretti pushed a commit that referenced this pull request Sep 4, 2017
Author: sohail chatoor <[email protected]>

    New AMI430 driver  (#700)
giulioungaretti pushed a commit that referenced this pull request Sep 4, 2017
Author: sohail chatoor <[email protected]>

    New AMI430 driver  (#700)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants