Skip to content

memory not stable between runs #776

@freemansw1

Description

@freemansw1

It seems that memory, under certain conditions, is not stable/deterministic. I've put an example below. At some times, the value of particle at index 10 is 3, and at others it is 4. Both are reasonable choices, but it should always select one or the other, not both.

I've tried to dig into the source code with an eye to a PR, but frankly I'm struggling to understand how the memory module works. I'm happy to put some effort into a PR, but need a bit more insight there before putting one together.

I'm on an M2 Mac, Python 3.12.7, trackpy version 0.6.4.

import pandas as pd
import trackpy
import numpy as np

y_coords = [2, 3, 0, 10, 3, 1, 11, 4, 1, 2, 12, 5, 0]
x_coords = [3, 4, 4, 14, 4, 5, 15, 5, 2, 6, 16, 6, 1]
frame =    [2, 2, 2,  2, 3, 3,  3, 4, 4, 4,  4, 5, 5]

trackpy_df = pd.DataFrame({"y": y_coords, "x": x_coords, "frame": frame})
pred = trackpy.predict.NearestVelocityPredict(                
        initial_guess_positions=[[1,2],[4,5]],
        initial_guess_vels=[[1,1],[-1,-1]],
        pos_columns=['y', 'x'],
        span=1,
)
out = pred.link_df(trackpy_df, search_range = 1.8, memory=1, t_column="frame", neighbor_strategy="BTree",
                adaptive_step=None,
                adaptive_stop=None,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions