-
Notifications
You must be signed in to change notification settings - Fork 100
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
Changes to Phase objects #1375
Comments
Note you get |
In NICERsoft, photon_phase.py code does this:
I think that should still work because it uses tuple unpacking, right? Elsewhere it does this:
This should get all the fractional parts and make a regular array instead of a And yet another code does this:
This was to work around the crazy |
Yes, those will break. is it possible to update NICERsoft? |
Yes, it is easy for me to update NICERsoft on github. The tricky bit is that it means all the NICERsoft uses must update NICERsoft and PINT at the same time. Unfortunately, I never packaged up NICERsoft so it has no setup.py and isn't pip-installable, so there isn't a good mechanism for enforcing version on dependencies like PINT |
I think if I change |
OK, I made that change to NICERsoft |
Great, that should work with both versions. |
This change will also break my Fermi pulsar timing code. It's not a big deal for me to fix it. The code published along with the "Fermi PTA" paper is referenced to a specific commit of PINT, but I can see some user in the future being bitten if they have a fresh copy of PINT. Probably also not a big deal. |
I'm a little concerned that tuple unpacking does not agree with indexing. People expect It seems the existing interface has us somewhat painted into a corner. I'm not quite sure what the best way forward is. |
I do think we should encourage people to use I don't know if it's a useful analogy, but in recent versions |
I agree the tuple vs. array interfaces conflict a bit. Options would be:
but it would mean iteration goes over the elements.
|
How we implement it is a detail. But yes, the problem regardless of implementation is that we want:
I don't really see how to build a consistent interface meeting all these criteria. The current interface ditches easy indexing; the proposed interface makes iteration and indexing differ from each other. Is there a possible alternative syntax for indexing? |
What about adding a |
Doesn't this still break backward compatibility? Or maybe I haven't understood your suggestion? Can you elaborate? One suggestion I had would be to make Phase objects look like (be?) 2-D Quantity objects. Then |
I am wary of assuming that the phases will always be at most 1D, since there could be cases (e.g., simulations) where 2D or higher might be needed. For the moment in the PR (which was merged) I removed the |
As part of #1371, I am proposing a change to the
Phase
objects. They were defined as a named tuple, so that the integer & fraction parts could be accessed asp.int
andp.frac
, or asp[0]
andp[1]
. However, this meant that if the object is an array you need to first get the integer/fractional parts, do any slicing, and then repack. So I changed the interface by implementing__getitem__
. Now you can do:so the integer and fraction parts can still be accessed through
.int
and.frac
, which return quantity arrays. But you can also slice directly. And tuple unpacking still works, which means that iteration through the object returns the integer/fractional parts rather than individual elements. So:prints the integer and fraction parts, not each element (this could be changed).
Does anybody have opinions about this? Ways to make the interface deprecation clear?
The text was updated successfully, but these errors were encountered: