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

Before Change


        pos_columns = ["x", "y"]
    // the groupby...diff works only if the trajectory Dataframe is sorted along frame
    // 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)

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: 4

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: catalyst-cooperative/pudl
Commit Name: 6bd4147eae6085142288b355660c250e8184d62f
Time: 2017-11-16
Author: cgosnell@catalyst.coop
File Name: pudl/outputs.py
Class Name:
Method Name: generation_eia923


Project Name: catalyst-cooperative/pudl
Commit Name: fbd16b4f301f09b8868b60a4762700f3251e2cdc
Time: 2019-12-05
Author: zane.selvans@catalyst.coop
File Name: src/pudl/transform/ferc1.py
Class Name:
Method Name: plant_in_service