Open ajasja opened 2 years ago
Thanks for this report and for the workaround! This is weird, since this counter
class attribute doesn't generally cause issues, and I doubt that your version of Python has a uniquely different implementation of __slots__
. Could the real issue be that we are not calling the reset_counter()
classmethod before attempting to access self.counter
? Based on a brief look at 'link_iter()
that doesn't seem possible…
I'd love to know if anyone else is encountering this. @ajasja were you seeing this error very consistently before you fixed it, or was it only with certain data or scripts?
The suggested change is reasonable, but I just want to make sure that we are not seeing signs of an edge-case bug somewhere else in trackpy…
Thanks @nkeim ! I was getting this on every invocation (if that is what you mean by consistent:) But I can try to run the same code on google colab if it helps.
Thanks. I guess I'd like to know if it's an issue with the specific data you're tracking or the parameters you're using—this bug is not triggered in any of our tests, and it hasn't been reported before. Have you tried this with a different portion of your data, or with a different search_radius
for link
?
Just as a sanity check, can you also please verify that the first line of Linker.init_level
, which should be linking.py
line 461, is a call to Point.reset_counter()
? I ask because your traceback involves init_level
, and the error you're getting should be impossible once Point.reset_counter
has been called.
Also, could you please check that the following code snippet runs on the same Python you use for trackpy?
class Cls:
__slots__ = ['a']
o = Cls()
Cls.b = []
o.b.append('test')
print(o.b)
This should be the minimum example to reproduce the issue you're seeing with counter
. It produces the output ['test']
on my Python 3.8.
Sorry, I missed the point in my original code snippet. Please see the edited version!
Hi, that snippets does indeed work
And I do have a call to reset counter.
I've tried a search radius of 1,2,3,4,5 px.
Here is the data 2B9_SingleMolecule_1nM_A8fibres_25C_75mMNaCl_100-200__locs_lq_box5_grad600_drift0.zip
import trackpy as tp
for max_link_displacement_px in [2]:
locs = pd.read_hdf('2B9_SingleMolecule_1nM_A8fibres_25C_75mMNaCl_100-200__locs_lq_box5_grad600_drift0.hdf5', 'locs')
locs['mass']=locs.photons
tray = tp.link(locs, max_link_displacement_px)
I'm getting an error when I try to link a trajectory![image](https://user-images.githubusercontent.com/19926/166451693-80b81b6b-d43d-4842-b268-1c5029a197e9.png)
Stack trace
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) d:\data\2022-04-26_WALKER_DATA\2022-04-26__analysis\10-analyse-picked.ipynb Cell 5' inI fixed the error by adding
'counter'
to__slots__
on line 104 of utils.py (https://github.com/soft-matter/trackpy/blob/a316c658ffd03d4b6fe705b9bedd63c1ab8276c0/trackpy/linking/utils.py#L104)pytrack; 0.50. Python: 3.8.5 OS: Win10