Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
display_name: "2020"
deps: "numpy==1.19.* scipy==1.5.* matplotlib==3.3.* pandas==1.1.* tables==3.6.* scikit-learn==0.24.* numba==0.53.* llvmlite==0.36.*"
- python: "3.10"
display_name: "2021"
deps: "numpy==1.22.* scipy==1.7.* matplotlib==3.5.* pandas==1.3.* tables==3.7.* scikit-learn==1.0.* numba==0.55.* llvmlite==0.38.*"
display_name: "2021ish"
deps: "numpy==1.22.* scipy==1.7.* matplotlib==3.5.* pandas==1.4.* tables==3.7.* scikit-learn==1.0.* numba==0.55.* llvmlite==0.38.*"
- python: "3.11"
display_name: "2022"
deps: "numpy==1.24.* scipy==1.9.* matplotlib==3.6.* pandas==2.0.* tables==3.8.* scikit-learn==1.1.* numba==0.57.* llvmlite==0.40.*"
Expand All @@ -39,7 +39,7 @@ jobs:
python-version: ${{ matrix.python }}

- name: Install HDF5 library
run: sudo apt-get install libhdf5-dev
run: sudo apt-get update && sudo apt-get install -y libhdf5-dev

- name: Install python dependencies
shell: bash
Expand Down
3 changes: 2 additions & 1 deletion trackpy/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging

import numpy as np
from .utils import pandas_map

try:
from pims import plot_to_frame, plots_to_frame, normalize
Expand Down Expand Up @@ -640,7 +641,7 @@ def subpx_bias(f, pos_columns=None):
pos_columns = ['x', 'y', 'z']
else:
pos_columns = ['x', 'y']
axlist = f[pos_columns].applymap(lambda x: x % 1).hist()
axlist = pandas_map(f[pos_columns], lambda x: x % 1).hist()
return axlist

@make_axes
Expand Down
14 changes: 14 additions & 0 deletions trackpy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
is_pandas_since_023 = True


try:
is_pandas_since_210 = (LooseVersion(pd.__version__) >=
LooseVersion('2.1.0'))
except ValueError: # Probably a development version
is_pandas_since_210 = True

try:
is_pandas_since_220 = (LooseVersion(pd.__version__) >=
LooseVersion('2.2.0'))
Expand Down Expand Up @@ -308,6 +314,14 @@ def _pandas_concat_post_023(*args, **kwargs):
pandas_concat = pd.concat


def pandas_map(df, func):
"""Apply func element-wise to a DataFrame (compat for pandas < 2.1)."""
if is_pandas_since_210:
return df.map(func)
else:
return df.applymap(func)


def guess_pos_columns(f):
""" Guess the position columns from a given feature DataFrame """
if 'z' in f:
Expand Down
Loading