Skip to content

Commit

Permalink
update python, tests, and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahmish committed Mar 14, 2024
1 parent bd4c473 commit e709e0a
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 31 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-20.04, macos-latest]
steps:
- uses: actions/checkout@v1
Expand All @@ -20,15 +20,17 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: pip install .[dev]
run: |
pip install --upgrade pip setuptools wheel
pip install .[dev]
- name: make test-devel
run: make test-devel

readme:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-20.04, macos-latest]
steps:
- uses: actions/checkout@v1
Expand All @@ -37,15 +39,17 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install package and dependencies
run: pip install rundoc .
run: |
pip install --upgrade pip setuptools wheel
pip install rundoc .
- name: make test-readme
run: make test-readme

unit:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-20.04, macos-latest]
steps:
- uses: actions/checkout@v1
Expand All @@ -54,6 +58,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install package and dependencies
run: pip install .[test]
run: |
pip install --upgrade pip setuptools wheel
pip install .[test]
- name: make test-unit
run: make test-unit
6 changes: 3 additions & 3 deletions mlprimitives/adapters/statsmodels.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from statsmodels.tsa import arima_model
from statsmodels.tsa.arima import model


class ARIMA(object):
Expand Down Expand Up @@ -45,8 +45,8 @@ def predict(self, X):

num_sequences = len(X)
for sequence in range(num_sequences):
arima = arima_model.ARIMA(X[sequence], order=(self.p, self.d, self.q))
arima_fit = arima.fit(disp=0)
arima = model.ARIMA(X[sequence], order=(self.p, self.d, self.q))
arima_fit = arima.fit()
arima_results.append(arima_fit.forecast(self.steps)[0])

arima_results = np.asarray(arima_results)
Expand Down
6 changes: 5 additions & 1 deletion mlprimitives/custom/timeseries_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,8 @@ def cutoff_window_sequences(X, timeseries, window_size, cutoff_time=None, time_i

output.append(selected.values)

return np.array(output)
output = np.array(output, dtype=object)
if output.ndim >= 2:
output = output.astype(float)

return output
1 change: 0 additions & 1 deletion mlprimitives/primitives/xgboost.XGBClassifier.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"args": [
{
"name": "X",
"keyword": "data",
"type": "ndarray"
}
],
Expand Down
1 change: 0 additions & 1 deletion mlprimitives/primitives/xgboost.XGBRegressor.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"args": [
{
"name": "X",
"keyword": "data",
"type": "ndarray"
}
],
Expand Down
28 changes: 19 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
history = history_file.read()

install_requires = [
'Keras>=2.4,<2.5',
'Keras>=2.4,<2.15',
'featuretools>=0.6.1,<0.23',
'iso639>=0.1.4,<0.2',
'langdetect>=1.0.7,<2',
'lightfm>=1.15,<2',
'mlblocks>=0.4.0.dev0,<0.7',
'mlblocks>=0.6,<0.7',
'networkx>=2.0,<3',
'nltk>=3.3,<4',
'numpy<1.21.0,>=1.16.0',
'numpy>=1.16.0,<2',
'opencv-python>=3.4.0.12,<4.7',
'pandas>=1,<2',
'python-louvain>=0.10,<0.14', # community
'scikit-image>=0.15',
'scikit-learn>=0.21',
'scipy>=1.1.0,<2',
'statsmodels>=0.9.0,<0.13',
'tensorflow>=2,<2.5',
'xgboost>=0.72.1,<1',
'statsmodels>=0.9.0,<0.15',
'tensorflow>=2,<2.15',
'xgboost>=0.72.1,<2',
'protobuf<4',
]

Expand Down Expand Up @@ -59,6 +59,15 @@
'mistune>=0.7,<2',
'Jinja2>=2,<3.1',

# fails on Sphinx < v3.4
'alabaster<=0.7.12',
# fails on Sphins < v5.0
'sphinxcontrib-applehelp<1.0.8',
'sphinxcontrib-devhelp<1.0.6',
'sphinxcontrib-htmlhelp<2.0.5',
'sphinxcontrib-serializinghtml<1.1.10',
'sphinxcontrib-qthelp<1.0.7',

# style check
'flake8>=3.7.7,<4',
'isort>=4.3.4,<5',
Expand Down Expand Up @@ -91,9 +100,10 @@
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
description='Pipelines and primitives for machine learning and data science.',
entry_points = {
Expand All @@ -117,7 +127,7 @@
long_description_content_type='text/markdown',
name='mlprimitives',
packages=find_packages(include=['mlprimitives', 'mlprimitives.*']),
python_requires='>=3.6,<3.9',
python_requires='>=3.8,<3.12',
setup_requires=setup_requires,
test_suite='tests',
tests_require=tests_require,
Expand Down
8 changes: 4 additions & 4 deletions tests/adapters/test_statsmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mlprimitives.adapters.statsmodels import ARIMA


@patch('statsmodels.tsa.arima_model.ARIMA')
@patch('statsmodels.tsa.arima.model.ARIMA')
def test_arima_1d(arima_mock):
arima = ARIMA(1, 0, 0, 3)
X = np.array([1, 2, 3, 4, 5])
Expand All @@ -15,7 +15,7 @@ def test_arima_1d(arima_mock):
assert arima_mock.call_args[1] == {'order': (1, 0, 0)}


@patch('statsmodels.tsa.arima_model.ARMAResults.forecast')
@patch('statsmodels.tsa.arima.model.ARIMAResultsWrapper.forecast')
def test_predict_1d(arima_mock):
arima_mock.return_value = [[1, 2, 3]]

Expand All @@ -29,7 +29,7 @@ def test_predict_1d(arima_mock):
arima_mock.assert_called_once_with(3)


@patch('statsmodels.tsa.arima_model.ARIMA')
@patch('statsmodels.tsa.arima.model.ARIMA')
def test_arima_2d(arima_mock):
arima = ARIMA(1, 0, 0, 3)
X = np.array([
Expand All @@ -46,7 +46,7 @@ def test_arima_2d(arima_mock):
assert arima_mock.call_args_list[2][1] == {'order': (1, 0, 0)}


@patch('statsmodels.tsa.arima_model.ARMAResults.forecast')
@patch('statsmodels.tsa.arima.model.ARIMAResultsWrapper.forecast')
def test_predict_2d(arima_mock):
arima_mock.side_effect = [
[[1, 2, 3]],
Expand Down
2 changes: 1 addition & 1 deletion tests/custom/test_timeseries_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def test_not_enough_data(self):
[15, 35],
[16, 36]
])
])
], dtype=object)

assert_allclose(
array[0],
Expand Down
12 changes: 7 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
[tox]
envlist = py3{6,7,8}, test-devel
envlist = py3{8,9,10,11}, test-devel

[travis]
python =
3.8: py38, test-devel
3.7: py37
3.6: py36
3.9: py39
3.10: py310
3.11: py311

[gh-actions]
python =
3.8: py38, test-devel
3.7: py37
3.6: py36
3.9: py39
3.10: py310
3.11: py311

[testenv]
passenv = CI TRAVIS TRAVIS_*
Expand Down

0 comments on commit e709e0a

Please sign in to comment.