Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically find requirements in setup.py, add new dev and example requirement files and update check_formatting action to use conda instead of pip #288

Merged
merged 7 commits into from
May 31, 2023
Merged
20 changes: 14 additions & 6 deletions .github/workflows/check_formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Set up conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: '3.8'
- run: pip install .
- run: pip install black==22.6.0
- run: black tobac --check

miniforge-version: latest
miniforge-variant: mambaforge
channel-priority: strict
channels: conda-forge
show-channel-urls: true
use-only-tar-bz2: true

- name: Install dependencies and check formatting
shell: bash -l {0}
run:
mamba install --quiet --yes --file requirements.txt black &&
black tobac --check
15 changes: 15 additions & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Python dependencies
numpy
scipy
scikit-image
scikit-learn
pandas
matplotlib
iris
xarray
cartopy
trackpy
pre-commit
black
pytest

1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# allow dropdowns
collapse_navigation = False


# Include our custom CSS (currently for special table config)
def setup(app):
app.add_css_file("theme_overrides.css")
Expand Down
15 changes: 15 additions & 0 deletions example_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Python dependencies
numpy
scipy
scikit-image
scikit-learn
pandas
matplotlib
iris
xarray
cartopy
trackpy
jupyter
notebook
pytables
pyart
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ iris
xarray
cartopy
trackpy
pre-commit
31 changes: 17 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ def get_version(pkg_name):
raise RuntimeError("Unable to find version string.")


def get_requirements(requirements_filename):
requirements_file = Path(__file__).parent / requirements_filename
assert requirements_file.exists()
with open(requirements_file) as f:
requirements = [
line.strip() for line in f.readlines() if not line.startswith("#")
]
# Iris has a different name on PyPI...
if "iris" in requirements:
requirements.remove("iris")
requirements.append("scitools-iris")
return requirements


PACKAGE_NAME = "tobac"

# See classifiers list at: https://pypi.org/classifiers/
Expand Down Expand Up @@ -67,24 +81,13 @@ def get_version(pkg_name):
"max.heikenfeld@physics.ox.ac.uk",
"william.jones@physics.ox.ac.uk",
"senf@tropos.de",
"sean.freeman@colostate.edu",
"sean.freeman@uah.edu",
freemansw1 marked this conversation as resolved.
Show resolved Hide resolved
"julia.kukulies@gu.se",
"peter.marinescu@colostate.edu",
],
license="BSD-3-Clause License",
packages=[PACKAGE_NAME, PACKAGE_NAME + ".utils"],
install_requires=[
"numpy",
"scipy",
"scikit-image",
"scikit-learn",
"pandas",
"matplotlib",
"xarray",
"trackpy",
],
test_requires=[
"pytest",
],
install_requires=get_requirements("requirements.txt"),
test_requires=["pytest"],
zip_safe=False,
)
1 change: 0 additions & 1 deletion tobac/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ def cell_statistics(
cube_masked = mask_cube_cell(cube, mask_cell_i, cell, track_i)
coords_remove = []
for coordinate in cube_masked.coords(dim_coords=False):

if coordinate.name() not in dimensions:
for dim in dimensions:
if set(cube_masked.coord_dims(coordinate)).intersection(
Expand Down
10 changes: 0 additions & 10 deletions tobac/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ def plot_tracks_mask_field(
if np.any(
~np.isnan(field.data)
): # check if field to plot is not only nan, which causes error:

plot_field = iplt.contourf(
field,
coords=["longitude", "latitude"],
Expand Down Expand Up @@ -584,7 +583,6 @@ def plot_mask_cell_track_follow(

track_cell = track[track["cell"] == cell]
for i_row, row in track_cell.iterrows():

constraint_time = Constraint(time=row["time"])
constraint_x = Constraint(
projection_x_coordinate=lambda cell: row["projection_x_coordinate"] - width
Expand Down Expand Up @@ -838,7 +836,6 @@ def plot_mask_cell_individual_follow(
)

if cog is not None:

for i_row, row in cog.iterrows():
cell = row["cell"]

Expand All @@ -857,7 +854,6 @@ def plot_mask_cell_individual_follow(
)

if features is not None:

for i_row, row in features.iterrows():
color = "purple"
axes.plot(
Expand Down Expand Up @@ -934,7 +930,6 @@ def plot_mask_cell_track_static(
)
time_cell = time[slice(i_start, i_end)]
for time_i in time_cell:

# for i_row,row in track_cell.iterrows():
# time_i=row['time']
# constraint_time = Constraint(time=row['time'])
Expand Down Expand Up @@ -1208,7 +1203,6 @@ def plot_mask_cell_individual_static(
linewidth=1,
)
if cog is not None:

for i_row, row in cog.iterrows():
cell = row["cell"]

Expand All @@ -1227,7 +1221,6 @@ def plot_mask_cell_individual_static(
)

if features is not None:

for i_row, row in features.iterrows():
color = "purple"
axes.plot(
Expand Down Expand Up @@ -1307,7 +1300,6 @@ def plot_mask_cell_track_2D3Dstatic(
)
time_cell = time[slice(i_start, i_end)]
for time_i in time_cell:

# for i_row,row in track_cell.iterrows():
# time_i=row['time']
# constraint_time = Constraint(time=row['time'])
Expand Down Expand Up @@ -1485,7 +1477,6 @@ def plot_mask_cell_track_3Dstatic(
)
time_cell = time[slice(i_start, i_end)]
for time_i in time_cell:

# for i_row,row in track_cell.iterrows():
# time_i=row['time']
# constraint_time = Constraint(time=row['time'])
Expand Down Expand Up @@ -1857,7 +1848,6 @@ def plot_mask_cell_track_static_timeseries(
)
time_cell = time[slice(i_start, i_end)]
for time_i in time_cell:

constraint_time = Constraint(time=time_i)
constraint_x = Constraint(
projection_x_coordinate=lambda cell: x_min < cell < x_max
Expand Down
1 change: 0 additions & 1 deletion tobac/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def tracking_wrapper(
parameters_tracking=None,
parameters_segmentation=None,
):

from .feature_detection import feature_detection_multithreshold
from .tracking import linking_trackpy
from .segmentation import segmentation_3D, segmentation_2D
Expand Down