diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 7e870c24..dfbcda4d 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -13,31 +13,63 @@ jobs: build: runs-on: ubuntu-latest + + defaults: + run: + shell: bash -l {0} + strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [3.9] 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 system dependencies - run: | - sudo apt-get update && sudo apt-get install -y libproj-dev proj-data proj-bin libgeos-dev - - name: Install python dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest - python -m pip install cython numpy - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest + + - uses: actions/checkout@v2 + + - uses: conda-incubator/setup-miniconda@v2 + with: + miniconda-version: "latest" + channels: bioconda, conda-forge, defaults + use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! + auto-update-conda: true + auto-activate-base: true + + - name: Install system dependencies + run: | + sudo apt-get update && sudo apt-get install -y libproj-dev proj-data proj-bin libgeos-dev + + - name: Create conda environment + run: | + conda init bash + conda create -n myenv python=${{ matrix.python-version }} + + - name: Activate conda environment + run: | + conda activate myenv + conda config --set always_yes yes --set changeps1 no + + - name: Update conda environment + run: | + conda update --name base -q conda + + - name: Install Python dependencies with Conda + run: | + conda install cartopy + + - name: Install python dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + python -m pip install cython numpy + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Test with pytest + run: | + pytest diff --git a/requirements.txt b/requirements.txt index 2dc19bb9..d0c9d155 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ scipy Shapely seaborn setuptools -cartopy<0.20.0 +cartopy typing_extensions tables pydantic diff --git a/test/test_model.py b/test/test_model.py index b3c1b8b8..7892c94a 100644 --- a/test/test_model.py +++ b/test/test_model.py @@ -140,7 +140,7 @@ def test_minimal_example(self): p_global = np.full(shape=(1, n_features, n_states), fill_value=0.5) source = np.zeros((n_objects, n_features, 2), dtype=bool) sample = Sample.from_numpy_arrays( - clusters=np.ones((1, n_objects), dtype=np.bool), + clusters=np.ones((1, n_objects), dtype=bool), weights=broadcast_weights([0.5, 0.5], n_features), cluster_effect=p_cluster, confounding_effects={"universal": p_global},