Skip to content

Commit

Permalink
Updated for new Pandas warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Luque committed Apr 10, 2024
1 parent 50071da commit 85cb9c5
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
Binary file modified docs/source/.static/video/gert_body_20170810T120654.mp4
Binary file not shown.
Binary file modified docs/source/.static/video/gert_imu_20170810T120654.mp4
Binary file not shown.
2 changes: 1 addition & 1 deletion skdiveMove/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@

__author__ = "Sebastian Luque <[email protected]>"
__license__ = "AGPLv3"
__version__ = "0.3.2.post2"
__version__ = "0.3.3"
__all__ = ["TDR", "calibrate", "dump_config_template"]
7 changes: 3 additions & 4 deletions skdiveMove/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,9 @@ def _one_dive_stats(x, interval, has_speed=False):
onames = onames_nospeed

res_df = pd.DataFrame(res, columns=onames)
for tcol in range(3):
for tcol in onames[:3]:
# This is per POSIXct convention in R
res_df.iloc[:, tcol] = pd.to_datetime(res_df.iloc[:, tcol],
unit="s")
res_df[tcol] = pd.to_datetime(res_df[tcol], unit="s")

return res_df

Expand Down Expand Up @@ -252,7 +251,7 @@ def rle_key(x):
2020-01-01 00:02:30+00:00 6
2020-01-01 00:02:40+00:00 6
2020-01-01 00:02:50+00:00 6
Freq: 10S, dtype: int64
Freq: 10s, dtype: int64
"""
xout = x.ne(x.shift()).cumsum()
Expand Down
10 changes: 5 additions & 5 deletions skdiveMove/imutools/imu2body.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,14 @@ class IMU2Body(IMUBase):
... savgol_parms=(99, 2))
>>> print(imu) # doctest: +ELLIPSIS
IMU -- Class IMU2Body object
Source File ...
IMU: <xarray.Dataset>
Source File ...
IMU: <xarray.Dataset> ...
Dimensions: ...
Coordinates:
* timestamp (timestamp) datetime64[ns] ...
* accelerometer (accelerometer) object 'x' 'y' 'z'
* magnetometer (magnetometer) object 'x' 'y' 'z'
* gyroscope (gyroscope) object 'x' 'y' 'z'
* accelerometer (accelerometer) <U1 12B 'x' 'y' 'z'
* magnetometer (magnetometer) <U1 12B 'x' 'y' 'z'
* gyroscope (gyroscope) <U1 12B 'x' 'y' 'z'
Data variables:
depth (timestamp) float64 ...
acceleration (timestamp, accelerometer) float64 ...
Expand Down
4 changes: 2 additions & 2 deletions skdiveMove/imutools/imucalibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ class IMUcalibrate(IMUBase):
>>> print(imucal) # doctest: +ELLIPSIS
IMU -- Class IMUcalibrate object
Source File None
IMU: <xarray.Dataset>
IMU: <xarray.Dataset> ...
Dimensions: (timestamp_utc: 268081, axis: 3)
Coordinates:
* axis (axis) object 'x' 'y' 'z'
* axis (axis) <U1 12B 'x' 'y' 'z'
* timestamp_utc (timestamp_utc) datetime64[ns] ...
Data variables:
acceleration (timestamp_utc, axis) float64 ...
Expand Down
5 changes: 3 additions & 2 deletions skdiveMove/tdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ def dive_stats(self, depth_deriv=True):

postdive_dur = (postdive_ids.reset_index()
.groupby("postdive_id")
.apply(lambda x: x.iloc[-1] - x.iloc[0]))
.apply(lambda x: x.iloc[-1] - x.iloc[0],
include_groups=False))

# Enforce UTC, as otherwise rpy2 uses our locale in the output of
# OneDiveStats
Expand Down Expand Up @@ -783,7 +784,7 @@ def extract_dives(self, diveNo, **kwargs):
>>> tdrX.detect_dive_phases("unimodal", descent_crit_q=0.01,
... ascent_crit_q=0, knot_factor=20)
>>> tdrX.extract_dives(diveNo=20) # doctest: +ELLIPSIS
<xarray.Dataset>
<xarray.Dataset> ...
Dimensions: ...
"""
Expand Down
9 changes: 6 additions & 3 deletions skdiveMove/tdrphases.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ def detect_dive_phases(self, dive_model, smooth_par=0.1,
spl_list.append(spl_dict)
# Spline derivatives
spl_der = res.pop("spline_deriv")
spl_der_idx = pd.TimedeltaIndex(spl_der[:, 0], unit="s")
spl_der_idx = pd.TimedeltaIndex(
pd.to_timedelta(spl_der[:, 0], unit="s"))
spl_der = pd.DataFrame({'y': spl_der[:, 1]},
index=spl_der_idx)
spl_der_list.append(spl_der)
Expand Down Expand Up @@ -568,10 +569,12 @@ def _get_dive_spline_slot(self, diveNo, name):
"g", "a", "b", "variter"]
idata = self.get_dives_details("splines")[diveNo]
if name == "data":
x = pd.TimedeltaIndex(np.array(idata[name][0]), unit="s")
x = pd.TimedeltaIndex(
pd.to_timedelta(np.array(idata[name][0]), unit="s"))
odata = pd.Series(np.array(idata[name][1]), index=x)
elif name == "xy":
x = pd.TimedeltaIndex(np.array(idata["x"]), unit="s")
x = pd.TimedeltaIndex(
pd.to_timedelta(np.array(idata["x"]), unit="s"))
odata = pd.Series(np.array(idata["y"]), index=x)
elif name in scalars:
odata = float(idata[name][0])
Expand Down
12 changes: 6 additions & 6 deletions skdiveMove/tests/test_BoutsMLE.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ def test_plot_fit(self):
_ = xbouts.plot_fit(fit2, ax=ax)
lines = ax.get_lines()
self.assertEqual(len(lines), 2)
plt.close()
plt.close("all")
# Without Axes
_ = xbouts.plot_fit(fit2)
lines = ax.get_lines()
self.assertEqual(len(lines), 2)
plt.close()
plt.close("all")

# Three process
# -------------
Expand All @@ -219,7 +219,7 @@ def test_plot_fit(self):
_ = xbouts.plot_fit(fit2, ax=ax)
lines = ax.get_lines()
self.assertEqual(len(lines), 2)
plt.close()
plt.close("all")

def test_plot_ecdf(self):
# Two process
Expand All @@ -237,12 +237,12 @@ def test_plot_ecdf(self):
_ = xbouts.plot_ecdf(fit2, ax=ax)
lines = ax.get_lines()
self.assertEqual(len(lines), 2)
plt.close()
plt.close("all")
# Without Axes
_ = xbouts.plot_ecdf(fit2)
lines = ax.get_lines()
self.assertEqual(len(lines), 2)
plt.close()
plt.close("all")

# Three process
# -------------
Expand All @@ -259,7 +259,7 @@ def test_plot_ecdf(self):
_ = xbouts.plot_ecdf(fit2, ax=ax)
lines = ax.get_lines()
self.assertEqual(len(lines), 2)
plt.close()
plt.close("all")

def test_compare2r(self):
# Two process
Expand Down

0 comments on commit 85cb9c5

Please sign in to comment.