soft-matter / trackpy

Python particle tracking toolkit
http://soft-matter.github.io/trackpy
Other
443 stars 131 forks source link

Fix for issue #734 #735

Closed kevin-duclos closed 7 months ago

kevin-duclos commented 1 year ago

Change traj.set_index call to avoid Pandas error: 'ValueError: cannot reindex on an axis with duplicate labels'.

nkeim commented 8 months ago

Thanks @kevin-duclos . The error in #734 makes sense, except it should occur any time that there are many particles, including in the trackpy tests. So I'm confused.

I made changes to subtract_drift() and its docstring that I think address @caspervdw 's concern. However, at least temporarily, I added some lines to the tests that are supposed to trigger this error. We'll see if any of the CI environments catch it.

nkeim commented 8 months ago

OK, I think this is ready to merge. In addition to the fix by @kevin-duclos , we now include two tests with no particle column:

I think this is ready to merge. @caspervdw does this address your question? @kevin-duclos do you think this still fixes the bug?

nkeim commented 7 months ago

Just bumping this issue, especially for @kevin-duclos : Is this OK to merge?

kevin-duclos commented 7 months ago

All good with me, @nkeim. Thanks!

xyc2718 commented 6 months ago

After the 0.6.2 update, the dataframe processed by subtract_drift() poses an issue for imsd() due to the presence of "particle" in both row and column indices. To address this, it needs to use dataframe.reset_index(drop=True) before running the function to ensure proper execution.