-
Notifications
You must be signed in to change notification settings - Fork 315
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
New AMI430 driver #700
Conversation
2) added a mock IP module to mock IP instruments 3) added a debug module to debug the AMI430 instrument
…rdinates. Work in progress
…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.
2) Made proper tests
2) Made proper tests
…uments 2) Made test to verify that the correct error is raised if we intentionally exceed the field limits
… Tests to verify this are also included.
…e mocking mechanism
…e mocking mechanism
…rdinates. Added tests to verify if we can get spherical coordinates. Also, when getting single field values, return a single float instead of an array of length one
2) Added test to verify that the correct warnings are raised if we change the default maximum ramp rate 3) Added test to verify that an error is raised if the ramp rate larger then the maximum
<component name="VcsDirectoryMappings"> | ||
<mapping directory="$PROJECT_DIR$" vcs="Git" /> | ||
</component> | ||
</project> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
qcodes/instrument/base.py
Outdated
self.name = str(name) | ||
self.testing = testing |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah good point
There was a problem hiding this comment.
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
There was a problem hiding this 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
qcodes/instrument/base.py
Outdated
def get_mock_messages(self): | ||
""" | ||
For testing purposes we might want to get log messages from the mocker. | ||
:return: mocker_messages: list, str |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
qcodes/instrument/mockers/ami430.py
Outdated
from datetime import datetime | ||
|
||
|
||
class MockAMI430(object): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
qcodes/instrument/mockers/ami430.py
Outdated
: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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
docs/examples/AMI430_live_test.ipynb
Outdated
@@ -0,0 +1,463 @@ | |||
{ |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
docs/examples/AMI430_live_test.ipynb
Outdated
"outputs": [], | ||
"source": [ | ||
"import sys \n", | ||
"sys.path.append(r\"C:\\Users\\a-sochat\\development\\Qcodes_QUTech\")\n", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
docs/examples/AMI430_live_test.ipynb
Outdated
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"![title](AMI430_test_cartesian.jpg)\n", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
qcodes/tests/test_ami430.py
Outdated
"theta": np.random.uniform(0, 180), | ||
"phi": np.random.uniform(0, 360), | ||
"rho": np.random.uniform(0, 1) | ||
}[coordinate_name] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
qcodes/instrument/mockers/ami430.py
Outdated
""" | ||
: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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
qcodes/math/field_vector.py
Outdated
1) There are contradictory inputs (e.g. x=3, y=4, z=0 and rho=6) | ||
""" | ||
|
||
for _ in range(1): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Author: sohail chatoor <[email protected]> New AMI430 driver (#700)
Author: sohail chatoor <[email protected]> New AMI430 driver (#700)
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