-
Notifications
You must be signed in to change notification settings - Fork 132
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
FIX: Fix prediction bugs #710
Conversation
Fixes additional find_link prediction tests.
Includes a more helpful error message.
I'd love for another maintainer to look this over before merging, since it's an API change (and a lot more changes behind the scenes). @caspervdw since you were the only other person to work on |
Thanks for the confirmation, @freemansw1 ! It seems like this PR has gotten some use over the last 2 months, and considering that it fixes a bug, I will go ahead and merge. |
This PR closes #699 . It tests for and (hopefully) fixes both the
link_df
issue and the coordinate switching issue. It makes the order ofpos_columns
used by the linker match the order used by the predictor, whereas before trackpy tried to keep them in reverse order (for backward compatibility, perhaps?). The PR includes some safeguards (tested) against prediction with ambiguous or conflictingpos_columns
.There is (unfortunately) a breaking API change when supplying an initial velocity guess to a predictor. Since these guesses are supplied as arrays (not DataFrames), the order of the coordinates has always been ambiguous. In recent versions including v0.5.1, the order has implicitly been the reverse of the order in the subsequent linking step, so that the columns in the velocity guess typically corresponded to e.g.
['x', 'y', 'z']
. I hope you'll agree that this is confusing at best. With this new PR, the predictor uses the samepos_columns
as the linker, which is typically e.g.['z', 'y', 'x']
.Because of this change,
NearestVelocityPredict
andDriftPredict
now requirepos_columns
to be specified along with any initial velocity guess. There is additional logic to make sure this is the samepos_columns
subsequently used by the linking step (the user doesn't need to specifypos_columns
a second time). Requiringpos_columns
is good for users who are currently supplying initial velocity guesses, since their code will stop working until they resolve this ambiguity, instead of trackpy silently misinterpreting their velocity guess.Finally, prediction when using
find_link()
etc. is still barely supported. Even though we test it extensively, using it requires a few things to be done manually that would ordinarily be handled automatically by the predictor instance. The best "documentation" is the code near the end oftest_predict.py
, which is not a good situation.Still to do in this PR:
Suggested future enhancements:
find_link
with a predictor.pos_columns
.I think this API change suggests that we should include these fixes in v0.6. That is inconvenient, but all of the prediction features were usable with enough luck and/or workarounds, and the more correct handling of
pos_columns
will surely break some existing scripts. I have drafted release notes accordingly.