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
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
python -m pip install .[full,test]
- name: Lint with flake8
run: |
# stop the build if there are any warnings or errors.
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change log

## 2.0.0

### Major changes

- Make [OpenCV](https://pypi.org/project/opencv-python/) an optional dependency, simplifying installation requirements for forecasting from an existing model. This change requires users to specify the "full" package version at installation to get support for model fitting. [#4](https://github.com/blab/popcast/pull/4) (@huddlej)

## 1.1.0

### Features
Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ See the methods of [Huddleston et al. 2020](https://doi.org/10.7554/eLife.60067)

## Install

For a full installation with the OpenCV package that's required for model fitting, specify the "full" package dependencies.

``` bash
python -m pip install 'popcast[full]'
```

For a smaller installation that only supports forecasting with an existing model, omit the optional package dependency.

``` bash
python3 -m pip install popcast
python -m pip install popcast
```

## Usage
Expand All @@ -30,7 +38,7 @@ popcast fit \
### Install locally

``` bash
python3 -m pip install ".[test]"
python -m pip install '.[full,test]'
```

### Lint and run tests
Expand All @@ -52,17 +60,17 @@ cram --shell=/bin/bash tests/
Install or upgrade publishing tools.

``` bash
python3 -m pip install --upgrade build twine
python -m pip install --upgrade build twine
```

Build the distribution packages.

``` bash
python3 -m build
python -m build
```

Upload the distribution packages.

``` bash
python3 -m twine upload dist/*
python -m twine upload dist/*
```
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"

[project]
name = "popcast"
version = "1.1.0"
version = "2.0.0"
authors = [
{ name="John Huddleston", email="huddlej@gmail.com" },
]
Expand All @@ -20,13 +20,15 @@ classifiers = [

dependencies = [
"jellyfish >=0.8.2, ==0.*",
"opencv-python >=4.5, ==4.*",
"numpy >=1.17.0, ==1.*",
"pandas >=1.2.0, ==1.*",
"scipy >=1.5.4, ==1.*",
]

[project.optional-dependencies]
full = [
"opencv-python >=4.5, ==4.*",
]
test = [
"coverage[toml] >=5.2.1, ==5.*",
"cram >=0.7, ==0.*",
Expand Down
2 changes: 1 addition & 1 deletion src/popcast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """John Huddleston"""
__email__ = 'huddlej@gmail.com'
__version__ = '1.1.0'
__version__ = '2.0.0'
7 changes: 6 additions & 1 deletion src/popcast/fit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Fit a model for the given data using the requested predictors and evaluate the model by time series cross-validation.
"""
import cv2
import json
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -418,6 +417,12 @@ def _fit(self, coefficients, X, y, use_l1_penalty=True, calculate_optimal_distan
error between estimated values using the given coefficients and
input data and the observed values
"""
try:
import cv2
except ImportError:
print("Failed to import cv2 package required for model fitting. Install popcast with OpenCV using \"python -m pip install 'popcast[full]'\".", file=sys.stderr)
sys.exit(1)

# Estimate target values.
y_hat = self.predict(X, coefficients)

Expand Down