Skip to content

Commit

Permalink
MNT: Remove use of DataFrame.append
Browse files Browse the repository at this point in the history
  • Loading branch information
nkeim committed Nov 22, 2023
1 parent 2021f28 commit 35336c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions trackpy/tests/test_legacy_linking.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,9 @@ def test_drop_link(self):
# The resulting subnet causes the trajectory to be broken
# when link_strategy is 'drop' and search_range is large enough.
N = 2
f_1particle = DataFrame({'x': np.arange(N), 'y': np.ones(N), 'frame': np.arange(N)})
f = f_1particle.append(DataFrame(
{'x': [3], 'y': [1], 'frame': [1]}), ignore_index=True)
f = DataFrame({'x': list(np.arange(N)) + [3],
'y': np.ones(N+1),
'frame': list(np.arange(N)) + [1]})
f_expected_without_subnet = f.copy()
f_expected_without_subnet['particle'] = [0, 0, 1]
# The linker assigns new particle IDs in arbitrary order. So
Expand Down
6 changes: 3 additions & 3 deletions trackpy/tests/test_linking.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,9 @@ def test_drop_link(self):
# The resulting subnet causes the trajectory to be broken
# when link_strategy is 'drop' and search_range is large enough.
N = 2
f_1particle = DataFrame({'x': np.arange(N), 'y': np.ones(N), 'frame': np.arange(N)})
f = f_1particle.append(DataFrame(
{'x': [3], 'y': [1], 'frame': [1]}), ignore_index=True)
f = DataFrame({'x': list(np.arange(N)) + [3],
'y': np.ones(N+1),
'frame': list(np.arange(N)) + [1]})
f_expected_without_subnet = f.copy()
f_expected_without_subnet['particle'] = [0, 0, 1]
# The linker assigns new particle IDs in arbitrary order. So
Expand Down
4 changes: 3 additions & 1 deletion trackpy/tests/test_static.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pandas

from trackpy.static import *
import pandas as pd
import numpy as np
Expand Down Expand Up @@ -175,7 +177,7 @@ def _rings_3d(self):
'z': np.concatenate(refz)})

# The last index is the center particle, which is used to calculate g_r
df = df.append(pd.DataFrame({'x': [0.], 'y': [0.], 'z':[0.]}))
df = pandas.concat([df, pd.DataFrame({'x': [0.], 'y': [0.], 'z':[0.]})])
return df


Expand Down

0 comments on commit 35336c4

Please sign in to comment.