Skip to content

Commit

Permalink
Merge pull request #353 from freemansw1/add_matrix_testing
Browse files Browse the repository at this point in the history
Add matrix CI Tests on multiple Python versions and OS versions
  • Loading branch information
freemansw1 authored Nov 13, 2023
2 parents 5f096e3 + b7739d5 commit d639db3
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 8 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/matrix_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Matrix Testing CI
# this is similar to the pyart CI action
on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# This job installs dependencies and runs tests across a matrix of python and OS versions.
#Add if: github.repository == 'tobac-project/tobac' to limit runs to tobac repo

jobs:
build:
name: ${{ matrix.os }}-${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
if: github.repository == 'tobac-project/tobac'
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [macos, ubuntu, windows]

steps:
- uses: actions/checkout@v2

# Install micromamba and dependencies
- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment-ci.yml
activate-environment: pyart-dev
cache-downloads: true
channels: conda-forge
channel-priority: strict
python-version: ${{ matrix.python-version }}

- name: Fetch all history for all tags and branches
run: |
git fetch --prune --unshallow
- name: Install tobac
shell: bash -l {0}
run: |
python -m pip install -e . --no-deps --force-reinstall
- name: Run Tests
id: run_tests
shell: bash -l {0}
run: |
python -m pytest -v
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ trackpy
pre-commit
black
pytest

typing_extensions
16 changes: 16 additions & 0 deletions environment-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pyart-dev
channels:
- conda-forge
dependencies:
- numpy
- scipy
- scikit-image
- scikit-learn
- pandas
- matplotlib
- iris
- xarray
- cartopy
- trackpy
- pytest
- typing_extensions
3 changes: 2 additions & 1 deletion example_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ notebook
pytables
s3fs
arm_pyart
h5netcdf
h5netcdf
typing_extensions
8 changes: 4 additions & 4 deletions tobac/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def make_simple_sample_data_2D(data_type="iris"):
) * np.exp(-np.power(yy - y_i, 2.0) / (2 * np.power(10e3, 2.0)))

t_start = datetime.datetime(1970, 1, 1, 0, 0)
t_points = (t - t_start).astype("timedelta64[ms]").astype(int) / 1000
t_points = (t - t_start).astype("timedelta64[ms]").astype(int) // 1000
t_coord = DimCoord(
t_points,
standard_name="time",
Expand Down Expand Up @@ -176,7 +176,7 @@ def make_sample_data_2D_3blobs(data_type="iris"):
-np.power(xx - x_i, 2.0) / (2 * np.power(10e3, 2.0))
) * np.exp(-np.power(yy - y_i, 2.0) / (2 * np.power(10e3, 2.0)))
t_start = datetime.datetime(1970, 1, 1, 0, 0)
t_points = (t - t_start).astype("timedelta64[ms]").astype(int) / 1000
t_points = (t - t_start).astype("timedelta64[ms]").astype(int) // 1000
t_coord = DimCoord(
t_points,
standard_name="time",
Expand Down Expand Up @@ -286,7 +286,7 @@ def make_sample_data_2D_3blobs_inv(data_type="iris"):
) * np.exp(-np.power(yy - y_i, 2.0) / (2 * np.power(10e3, 2.0)))

t_start = datetime.datetime(1970, 1, 1, 0, 0)
t_points = (t - t_start).astype("timedelta64[ms]").astype(int) / 1000
t_points = (t - t_start).astype("timedelta64[ms]").astype(int) // 1000

t_coord = DimCoord(
t_points,
Expand Down Expand Up @@ -432,7 +432,7 @@ def make_sample_data_3D_3blobs(data_type="iris", invert_xy=False):
)

t_start = datetime.datetime(1970, 1, 1, 0, 0)
t_points = (t - t_start).astype("timedelta64[ms]").astype(int) / 1000
t_points = (t - t_start).astype("timedelta64[ms]").astype(int) // 1000
t_coord = DimCoord(
t_points,
standard_name="time",
Expand Down
10 changes: 8 additions & 2 deletions tobac/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,16 @@ def combine_feature_dataframes(
if old_feature_column_name is not None:
combined_df[old_feature_column_name] = combined_df["feature"]
# count_per_time = combined_feats.groupby('time')['index'].count()
combined_df["frame"] = combined_df["time"].rank(method="dense").astype(int) - 1
original_frame_dtype = combined_df["frame"].dtype
combined_df["frame"] = (
combined_df["time"].rank(method="dense").astype(original_frame_dtype) - 1
)
combined_sorted = combined_df.sort_values(sort_features_by, ignore_index=True)
if renumber_features:
combined_sorted["feature"] = np.arange(1, len(combined_sorted) + 1)
original_feature_dtype = combined_df["feature"].dtype
combined_sorted["feature"] = np.arange(
1, len(combined_sorted) + 1, dtype=original_feature_dtype
)
combined_sorted = combined_sorted.reset_index(drop=True)
return combined_sorted

Expand Down

0 comments on commit d639db3

Please sign in to comment.