dbeab7509cfec1314b6529d57fbd090ce744695c,trackpy/motion.py,,compute_drift,#Any#Any#Any#,237

Before Change


    // I do here a copy because a "inplace=True" would sort the original "traj" which is perhaps unwanted/unexpected
    traj = pandas_sort(traj, "frame")
    // Probe by particle, take the difference between frames.
    delta = traj.groupby("particle", sort=False).apply(lambda x :
                                    x.set_index("frame", drop=False).diff())
    // Keep only deltas between frames that are consecutive.
    delta = delta[delta["frame"] == 1]
    // Restore the original frame column (replacing delta frame).
    del delta["frame"]
    delta.reset_index("particle", drop=True, inplace=True)
    delta.reset_index("frame", drop=False, inplace=True)
    dx = delta.groupby("frame").mean()
    if smoothing > 0:
        dx = pd.rolling_mean(dx, smoothing, min_periods=0)
    x = dx.cumsum(0)[pos_columns]
    return x


def subtract_drift(traj, drift=None, inplace=False):

After Change


    // Compute the per frame averages. Keep only deltas of the same particle,
    // and between frames that are consecutive, and of the same particle.
    mask = (f_diff["particle"] == 0) & (f_diff["frame_diff"] == 1)
    dx = f_diff.loc[mask, pos_columns + ["frame"]].groupby("frame").mean()
    if smoothing > 0:
        dx = pd.rolling_mean(dx, smoothing, min_periods=0)
    return dx.cumsum()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: soft-matter/trackpy
Commit Name: dbeab7509cfec1314b6529d57fbd090ce744695c
Time: 2017-07-27
Author: caspervdw@gmail.com
File Name: trackpy/motion.py
Class Name:
Method Name: compute_drift


Project Name: analysiscenter/batchflow
Commit Name: fa0c013fc201cebf5c9aceb0098cf7cc9094a34f
Time: 2020-04-02
Author: dimonovez@gmail.com
File Name: batchflow/utils.py
Class Name:
Method Name: print_results


Project Name: instacart/lore
Commit Name: 10332a44b9a5c2d637f614df392fe9c796dfdf0a
Time: 2018-06-01
Author: montana@instacart.com
File Name: lore/encoders.py
Class Name: Unique
Method Name: fit