-
Notifications
You must be signed in to change notification settings - Fork 29
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
A bug with multiple type tags with units #393
Comments
This is likely not a bug of pylabrad, but a bug of scalabrad. Here is the error message from labrad.bat:
This is likely the problematic function: https://github.com/labrad/scalabrad/blob/master/core/src/main/scala/org/labrad/data/Data.scala#L836-L859 |
Unit annotations on server methods are meant to specify a single unit that the server wants, and then the labrad manager transparently converts the units given by the client to the units specified by the server, which fails if the units are not compatible. Specifying multiple incompatible units for a parameter on a server method was not something we intended to support. We could add support for this, but my suggestion would be instead to create separate server settings, e.g. have a I guess the options are:
I should also note that I think interpreting |
Hi Matthew, Nice to see you here again! Regarding the options, both options are OK to work with. Personally, I feel option 2 is the more logical one, but it seems too strict to me. I mean, if input like ['s', 'i', 'b'] is allowed, why not allow ['v[dBm]', 'v[mV]']? Indeed, there is risk of potential errors, but it is nothing that we don't already have. About the unitless float, maybe you could consider using v[]? But you would still need to allow 'v' to be accepted for those old servers. Btw, right now using 'v[]' as an input tag will generate a strange error that I can't understand. Compared to options 1/2, the more severe problem is the lack of documentation. Option 1 or 2, or even no change to current manager are all workable with, as long as there exists corresponding wiki page. A sentence like "Specifying multiple incompatible units for a parameter on a server method is not supported." could save one quite a few hours if not a few days. There are people (myself included) who are more than happy to improve the labrad wiki pages. |
Python 3.9.8 + pylabrad 0.98.2 here...
When writing a server, I use the format to do type tags like this:
_input = ['v', 'w'] #This is working
_input = ['v[mV]', 'w'] #This is working
_input = ['v[mV]', 'w[s]'] #This is working
_input = ['v[dBm]', 'v[mV]'] #This is NOT working
It seems that when two (same) float types with (different) units are provided, labrad only recognizes and checks the first unit. As a result, the input with unit of mV in this case will never pass the unit check:
File "C:\LabRAD\WPy64-3980\python-3.9.8.amd64\lib\site-packages\labrad\concurrent.py", line 84, in wrapped
result = yield defer.maybeDeferred(func, *args, **kw)
Error: java.lang.IllegalArgumentException: requirement failed: cannot convert units 'mV' to 'dBm'
My current work-around is to bypass the type tags and then test the units separately:
_input = ['v']
...
if _input.isCompatible(dBm):
...
But what happens here really looks like a bug to me.
The text was updated successfully, but these errors were encountered: