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

1st attempt for Python 3.11 testing #685

Merged
merged 13 commits into from
Nov 1, 2022
2 changes: 1 addition & 1 deletion .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
strategy:
matrix:
os: ['ubuntu-latest']
environment-file: [ci/310.yaml]
environment-file: [ci/311.yaml]
experimental: [false]
defaults:
run:
Expand Down
29 changes: 21 additions & 8 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,27 @@
testing:
needs: linting
env:
RUN_TEST: pytest -v -n auto spaghetti --cov spaghetti --doctest-modules --cov-config .coveragerc --cov-report xml --color yes --cov-append --cov-report term-missing --timeout 60
RUN_TEST: pytest spaghetti -v -r a -n auto --cov spaghetti --doctest-modules --cov-config .coveragerc --cov-report xml --color yes --cov-append --cov-report term-missing --timeout 60
name: ${{ matrix.os }}, ${{ matrix.environment-file }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-latest]
environment-file:
- ci/38.yaml
- ci/39.yaml
- ci/310.yaml
- ci/38-BASE.yaml
- ci/39-BASE.yaml
- ci/310-BASE.yaml
- ci/310-DEV.yaml
- ci/310-DEV_shapely_dev.yaml
- ci/311-BARE.yaml
- ci/311-BASE.yaml
- ci/311-DEV.yaml
include:
- environment-file: ci/310.yaml
- environment-file: ci/311-BASE.yaml
os: macos-latest
- environment-file: ci/310.yaml
- environment-file: ci/311-BASE.yaml
os: windows-latest
fail-fast: false

steps:
- name: checkout repo
Expand All @@ -58,13 +60,24 @@
micromamba-version: 'latest'
channel-priority: 'flexible'

- name: install bleeding edge libpysal & esda (Ubuntu / Python 3.10)
- name: install bleeding edge libpysal & esda (Ubuntu / Python 3.11)
shell: bash -l {0}
run: |
pip install git+https://github.com/pysal/libpysal.git@master
pip install git+https://github.com/pysal/esda.git@master
if: matrix.os == 'ubuntu-latest' && contains(matrix.environment-file, 'DEV')

- name: environment info
shell: bash -l {0}
run: |
micromamba info
micromamba list

- name: spatial versions (if geopandas is installed)
shell: bash -l {0}
run: 'python -c "import geopandas; geopandas.show_versions();"'
if: contains(matrix.environment-file, 'DEV') || contains(matrix.environment-file, 'BASE')

- name: run tests - bash
shell: bash -l {0}
run: ${{ env.RUN_TEST }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The following are a selection of some examples that can be launched individually

## Installation

Python [3.8](https://docs.python.org/3.8/), [3.9](https://docs.python.org/3.9/), and [3.10](https://docs.python.org/3.10/) are tested for support by `spaghetti`. Please make sure that you are operating in a Python >= 3.8 environment.
Python [3.8](https://docs.python.org/3.8/), [3.9](https://docs.python.org/3.9/), [3.10](https://docs.python.org/3.10/), and [3.11](https://docs.python.org/3.11/) are tested for support by `spaghetti`. Please make sure that you are operating in a Python >= 3.8 environment.

**Installing with `conda` via [`conda-forge`](https://github.com/conda-forge/spaghetti-feedstock) (highly recommended)**

Expand Down
2 changes: 2 additions & 0 deletions ci/310-BASE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ dependencies:
- pytest-cov
- pytest-timeout
- pytest-xdist
# optional
- geopandas>=0.7.0
21 changes: 21 additions & 0 deletions ci/311-BARE.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: test
channels:
- conda-forge
dependencies:
- python=3.11
# required
- esda
- libpysal
- numpy
- pandas>=1.0
- pip
- rtree
- scipy>=1.0
- watermark
# testing/formatting
- black
- codecov
- pytest
- pytest-cov
- pytest-timeout
- pytest-xdist
2 changes: 1 addition & 1 deletion ci/310.yaml → ci/311-BASE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test
channels:
- conda-forge
dependencies:
- python=3.10
- python=3.11
# required
- esda
- libpysal
Expand Down
2 changes: 1 addition & 1 deletion ci/310-DEV.yaml → ci/311-DEV.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test
channels:
- conda-forge
dependencies:
- python=3.10
- python=3.11
# required
- numpy
- pandas>=1.0
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. Installation

Python 3.8_, 3.9_, and 3.10_ are tested for support by `spaghetti`. Please make sure that you are operating in a Python >= 3.8 environment.
Python 3.8_, 3.9_, 3.10_, and 3.11_ are tested for support by `spaghetti`. Please make sure that you are operating in a Python >= 3.8 environment.


Installation
Expand Down Expand Up @@ -51,6 +51,7 @@ You can also fork_ the `pysal/spaghetti`_ repo and create a local clone of your
.. _3.8: https://docs.python.org/3.8/
.. _3.9: https://docs.python.org/3.9/
.. _3.10: https://docs.python.org/3.10/
.. _3.11: https://docs.python.org/3.11/
.. _spaghetti-feedstock: https://github.com/conda-forge/spaghetti-feedstock
.. _a nice example: https://geopandas.readthedocs.io/en/latest/getting_started/install.html#creating-a-new-environment
.. _conda: https://docs.conda.io/en/latest/
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: notebooks-environment
channels:
- conda-forge
dependencies:
- python=3.10
- python=3.11
- esda
- geopandas>=0.9.0
- libspatialindex
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def setup_package():
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
license="3-Clause BSD",
packages=[package],
Expand Down
29 changes: 22 additions & 7 deletions spaghetti/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,19 +1010,29 @@ def distancebandweights(self, threshold, n_processes=1, gen_tree=False):

>>> import spaghetti
>>> from libpysal import examples
>>> import warnings
>>> streets_file = examples.get_path("streets.shp")
>>> ntw = spaghetti.Network(in_data=streets_file)

Create a contiguity-based ``W`` object based on network distance, ``500``
US feet in this case.

>>> w = ntw.distancebandweights(threshold=500)
>>> with warnings.catch_warnings():
... warnings.filterwarnings(
... "ignore", "The weights matrix is not fully connected", UserWarning
... )
... w = ntw.distancebandweights(threshold=500)

Show the number of units in the ``W`` object.

>>> w.n
230

There are 7 components in the ``W`` object.

>>> w.n_components
7

There are ``8`` units with ``3`` neighbors in the ``W`` object.

>>> w.histogram[-1]
Expand Down Expand Up @@ -2329,15 +2339,15 @@ def int_coord(c):
return int(c) if (type(c) == float and c.is_integer()) else c

# catch invalid split types
split_by = split_by.lower()
_split_by = split_by.lower()
valid_split_types = ["distance", "count"]
if split_by not in valid_split_types:
if _split_by not in valid_split_types:
msg = f"'{split_by}' is not a valid value for 'split_by'. "
msg += f"Valid arguments include: {valid_split_types}."
raise ValueError(msg)

# catch invalid count params
if split_by == "count":
if _split_by == "count":
if split_param <= 1:
msg = "Splitting arcs by 1 or less is not possible. "
msg += f"Currently 'split_param' is set to {split_param}."
Expand Down Expand Up @@ -2376,7 +2386,7 @@ def int_coord(c):
length = split_network.arc_lengths[arc]

# set initial segmentation interval
if split_by == "distance":
if _split_by == "distance":
interval = split_param
else:
interval = length / float(split_param)
Expand Down Expand Up @@ -2757,8 +2767,13 @@ def extract_component(net, component_id, weightings=None):

>>> from libpysal import examples
>>> import spaghetti
>>> import warnings
>>> snow_net = examples.get_path("Soho_Network.shp")
>>> ntw = spaghetti.Network(in_data=snow_net, extractgraph=False)
>>> with warnings.catch_warnings():
... warnings.filterwarnings(
... "ignore", "The weights matrix is not fully connected", UserWarning
... )
... ntw = spaghetti.Network(in_data=snow_net, extractgraph=False)

The network is not fully connected.

Expand Down Expand Up @@ -3009,7 +3024,7 @@ def spanning_tree(net, method="sort", maximum=False, silence_warnings=True):
if method.lower() == "sort":
spanning_tree = mst_weighted_sort(net, maximum, net_kws)
else:
msg = "'%s' not a valid method for minimum spanning tree creation"
msg = "'%s' not a valid method for minimum spanning tree creation."
raise ValueError(msg % method)

# instantiate the spanning tree as a network object
Expand Down
23 changes: 0 additions & 23 deletions spaghetti/tests/test_api_network.py

This file was deleted.

29 changes: 0 additions & 29 deletions spaghetti/tests/test_dev_network.py

This file was deleted.