-
Notifications
You must be signed in to change notification settings - Fork 4
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
Replace quantities with pint #9
Conversation
@sensej: could you check why it hangs a bit during the alignment test? With pint it now also happens with Python 2.7 and with Travis CI. |
The |
Maybe we should give it a second thought and when we decide to go for it we have to fix all the tests, because |
It works, but the quantities must be declared that they contain a Numpy array np.round(np.array([2.3]) * q.mm) will work. One the one hand I think this is a good idea, because it forces people (and us) to think about what they are doing. One the other hand, it's definitely more work on some parts. |
@sensej There are still four tests failing and I think they are because we use the |
It came from the fact that pint quantities are more strict, e.g. you cannot do |
Ha! You can, but you cannot do |
There should also be a |
Yeah that wrapping looks really what we need. If it's really not your fault, you could file a bug about your problems. pint is also on GitHub. |
But back to a more strategic topic: How should we proceed? Does pint fix your performance issues? If you are okay with merging into master, I will squash some commits and review the docs. |
In fact it does not matter (performance-wise). If you convert to the base units first, pint and quantities are similar in performance. But I also dislike the numpy dependency. So, if there are no other crucial hiccups let's use pint. |
Actually, when you convert a numpy array and its size is less than million elements pint is faster than quantities, but as the array grows larger it gets the other way around. |
My gut tells me that we handle way more mini arrays with units than big ones. |
The quantities package is nice "but extremely slow". This
results in 0.5 ms per conversion. Moreover, quantities has a hard dependency on Numpy which I don't like too much.
This change replaces quantities with pint:
concert.quantities
which exports one module variable calledq
. In the future we can easily exchange the implementation without requiring users to change their code. But this also means, that we have to change the current imports fromimport quantities as q
tofrom concert.quantities import q
.1 / q.mm
by eitherq.dimensionless / q.mm
orq.count / q.mm
. For motors I prefer the latter, because counts should easily map to steps.