diff --git a/.github/workflows/run-ci.yml b/.github/workflows/run-ci.yml new file mode 100644 index 0000000..c3f6909 --- /dev/null +++ b/.github/workflows/run-ci.yml @@ -0,0 +1,25 @@ +name: Run CI + +on: [pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + make install + - name: Run tests + run: | + make test \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..14b9131 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +install: + pip install -e .[all] + +upgrade: + pip install --upgrade -e .[all] + +test: + python -m pytest \ No newline at end of file diff --git a/README.md b/README.md index 75237d6..67a5286 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,7 @@ pip install pykalman-bardo Alternatively, you can setup from source: ```bash -# pip -pip install -e . - -# poetry -poetry pyproject.toml +pip install . ``` ## Usage diff --git a/pykalman/sqrt/tests/test_unscented.py b/pykalman/sqrt/tests/test_unscented.py index 1e40acc..55cb739 100644 --- a/pykalman/sqrt/tests/test_unscented.py +++ b/pykalman/sqrt/tests/test_unscented.py @@ -3,8 +3,6 @@ from numpy.testing import assert_array_almost_equal from scipy import linalg -from nose.tools import assert_true - from pykalman.sqrt import AdditiveUnscentedKalmanFilter from pykalman.sqrt.unscented import cholupdate, qr @@ -46,8 +44,8 @@ def test_additive_sample(): kf = build_unscented_filter(AdditiveUnscentedKalmanFilter) (x, z) = kf.sample(100) - assert_true(x.shape == (100, 2)) - assert_true(z.shape == (100, 1)) + assert x.shape == (100, 2) + assert z.shape == (100, 1) def test_additive_filter(): diff --git a/pykalman/tests/test_standard.py b/pykalman/tests/test_standard.py index cedc526..76fd865 100644 --- a/pykalman/tests/test_standard.py +++ b/pykalman/tests/test_standard.py @@ -5,7 +5,6 @@ import numpy as np from numpy.testing import assert_array_almost_equal from scipy import linalg -from nose.tools import assert_true from pykalman import KalmanFilter from pykalman.datasets import load_robot @@ -29,8 +28,8 @@ def test_kalman_sampling(self): self.data.initial_state_covariance) (x, z) = kf.sample(100) - assert_true(x.shape == (100, self.data.transition_matrix.shape[0])) - assert_true(z.shape == (100, self.data.observation_matrix.shape[0])) + assert x.shape == (100, self.data.transition_matrix.shape[0]) + assert z.shape == (100, self.data.observation_matrix.shape[0]) def test_kalman_filter_update(self): kf = self.KF( @@ -128,7 +127,7 @@ def test_kalman_fit(self): loglikelihoods[i] = kf.loglikelihood(self.data.observations) kf.em(X=self.data.observations, n_iter=1) - assert_true(np.allclose(loglikelihoods, self.data.loglikelihoods[:5])) + assert (np.allclose(loglikelihoods, self.data.loglikelihoods[:5])).all() # check that EM for all parameters is working kf.em_vars = 'all' @@ -137,7 +136,7 @@ def test_kalman_fit(self): kf.em(X=self.data.observations[0:n_timesteps], n_iter=1) loglikelihoods[i] = kf.loglikelihood(self.data.observations[0:n_timesteps]) for i in range(len(loglikelihoods) - 1): - assert_true(loglikelihoods[i] < loglikelihoods[i + 1]) + assert (loglikelihoods[i] < loglikelihoods[i + 1]).all() def test_kalman_initialize_parameters(self): self.check_dims(5, 1, {'transition_matrices': np.eye(5)}) @@ -154,16 +153,14 @@ def check_dims(self, n_dim_state, n_dim_obs, kwargs): initial_state_mean, initial_state_covariance) = ( kf._initialize_parameters() ) - assert_true(transition_matrices.shape == (n_dim_state, n_dim_state)) - assert_true(transition_offsets.shape == (n_dim_state,)) - assert_true(transition_covariance.shape == (n_dim_state, n_dim_state)) - assert_true(observation_matrices.shape == (n_dim_obs, n_dim_state)) - assert_true(observation_offsets.shape == (n_dim_obs,)) - assert_true(observation_covariance.shape == (n_dim_obs, n_dim_obs)) - assert_true(initial_state_mean.shape == (n_dim_state,)) - assert_true( - initial_state_covariance.shape == (n_dim_state, n_dim_state) - ) + assert transition_matrices.shape == (n_dim_state, n_dim_state) + assert transition_offsets.shape == (n_dim_state,) + assert transition_covariance.shape == (n_dim_state, n_dim_state) + assert observation_matrices.shape == (n_dim_obs, n_dim_state) + assert observation_offsets.shape == (n_dim_obs,) + assert observation_covariance.shape == (n_dim_obs, n_dim_obs) + assert initial_state_mean.shape == (n_dim_state,) + assert initial_state_covariance.shape == (n_dim_state, n_dim_state) def test_kalman_pickle(self): kf = self.KF( diff --git a/pykalman/tests/test_unscented.py b/pykalman/tests/test_unscented.py index 8e055ad..47cf150 100644 --- a/pykalman/tests/test_unscented.py +++ b/pykalman/tests/test_unscented.py @@ -4,8 +4,6 @@ from numpy import ma from numpy.testing import assert_array_almost_equal -from nose.tools import assert_true - from pykalman import AdditiveUnscentedKalmanFilter, UnscentedKalmanFilter from pykalman.datasets import load_robot @@ -56,38 +54,32 @@ def check_dims(n_dim_state, n_dim_obs, n_func_args, kf_cls, kwargs): kf._initialize_parameters() ) - assert_true( + assert ( transition_functions.shape == (1,) if not 'transition_functions' in kwargs else (len(kwargs['transition_functions']),) ) - assert_true( - all([len(inspect.getargspec(f).args) == n_func_args + assert all([len(inspect.getargspec(f).args) == n_func_args for f in transition_functions]) - ) - assert_true(transition_covariance.shape == (n_dim_state, n_dim_state)) - assert_true( + assert transition_covariance.shape == (n_dim_state, n_dim_state) + assert ( observation_functions.shape == (1,) if not 'observation_functions' in kwargs else (len(kwargs['observation_functions']),) ) - assert_true( - all([len(inspect.getargspec(f).args) == n_func_args + assert all([len(inspect.getargspec(f).args) == n_func_args for f in observation_functions]) - ) - assert_true(observation_covariance.shape == (n_dim_obs, n_dim_obs)) - assert_true(initial_state_mean.shape == (n_dim_state,)) - assert_true( - initial_state_covariance.shape == (n_dim_state, n_dim_state) - ) + assert observation_covariance.shape == (n_dim_obs, n_dim_obs) + assert initial_state_mean.shape == (n_dim_state,) + assert initial_state_covariance.shape == (n_dim_state, n_dim_state) def test_unscented_sample(): kf = build_unscented_filter(UnscentedKalmanFilter) (x, z) = kf.sample(100) - assert_true(x.shape == (100, 2)) - assert_true(z.shape == (100, 1)) + assert x.shape == (100, 2) + assert z.shape == (100, 1) def test_unscented_filter(): @@ -157,8 +149,8 @@ def test_additive_sample(): kf = build_unscented_filter(AdditiveUnscentedKalmanFilter) (x, z) = kf.sample(100) - assert_true(x.shape == (100, 2)) - assert_true(z.shape == (100, 1)) + assert x.shape == (100, 2) + assert z.shape == (100, 1) def test_additive_filter(): diff --git a/pyproject.toml b/pyproject.toml index 80057c4..351ee77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ [project.optional-dependencies] tests = [ - "nose" + "pytest" ] docs = [ @@ -38,7 +38,7 @@ docs = [ ] all = [ - "nose", + "pytest", "Sphinx", "numpydoc" ] @@ -52,7 +52,7 @@ Documentation = "https://pykalman.github.io/" file = "COPYING" [build-system] -requires = ["setuptools", "wheel", "toml", "build"] +requires = ["setuptools", "wheel", "build"] build-backend = "setuptools.build_meta" [tool.setuptools]