From 5021e003ff5777b62401438316edd05edc30dab8 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Fri, 19 Mar 2021 11:31:27 -0700 Subject: [PATCH] v0.6.1 (#161) --- .github/workflows/build-wheels.yml | 66 ++++++++++++++ .github/workflows/code-style.yml | 21 +++++ .github/workflows/coverage.yml | 35 ++++++++ .github/workflows/cross-compatibility.yml | 62 +++++++++++++ .github/workflows/installation.yml | 58 ++++++++++++ .github/workflows/unit-tests.yml | 28 ++++++ .travis.yml | 22 ----- CHANGELOG.md | 9 ++ CONTRIBUTING.md | 8 +- README.md | 10 +-- appveyor.yml | 24 ----- docs/source/changelog.rst | 9 ++ docs/source/conf.py | 2 +- docs/source/index.rst | 2 +- docs/source/installation.rst | 88 ++++++------------- examples/Pandana-demo.ipynb | 4 +- pandana/__init__.py | 2 +- pandana/loaders/tests/test_osm.py | 4 +- pandana/loaders/tests/test_pandash5.py | 14 +-- pandana/testing.py | 4 +- pandana/tests/test_cyaccess.py | 4 +- pandana/tests/test_pandana.py | 2 +- setup.py | 17 ++-- src/accessibility.cpp | 30 ++----- .../src/POIIndex/POIIndex.h | 13 +-- src/contraction_hierarchies/src/libch.cpp | 2 +- 26 files changed, 364 insertions(+), 176 deletions(-) create mode 100644 .github/workflows/build-wheels.yml create mode 100644 .github/workflows/code-style.yml create mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/cross-compatibility.yml create mode 100644 .github/workflows/installation.yml create mode 100644 .github/workflows/unit-tests.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml new file mode 100644 index 00000000..48eca7cb --- /dev/null +++ b/.github/workflows/build-wheels.yml @@ -0,0 +1,66 @@ +name: Build-wheels + +# This workflow builds "wheels", which are the binary package installers hosted on PyPI. +# GitHub Actions is super helpful here because each one needs to be compiled in its own +# target environment. The wheel files are saved as artifacts, which you can download from +# the GitHub website. Wheels should be uploaded manually to PyPI -- see CONTRIBUTING.md. + +# The Linux wheels cannot be generated using `ubuntu-latest` because they require a +# special Docker image to ensure cross-Linux compatibility. There are at least a couple +# of third-party actions set up using the official image; we could switch to another if +# this ever breaks. + +on: + # push: + pull_request: + release: + workflow_dispatch: + +jobs: + + build-manylinux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 +# with: +# ref: 'v0.6' # enable to check out prior version of codebase + - name: Build wheels + uses: RalfG/python-wheels-manylinux-build@v0.3.3 + with: + python-versions: 'cp35-cp35m cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39' + build-requirements: 'cython numpy' + - name: Save artifacts + uses: actions/upload-artifact@v2 + with: + name: wheels + path: dist/*-manylinux*.whl + + build: + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -l {0} # needed for conda persistence + strategy: + matrix: + os: [macos-latest, windows-latest] + python-version: [3.6, 3.7, 3.8, 3.9] + steps: + - uses: actions/checkout@v2 +# with: +# ref: 'v0.6' # enable to check out prior version of codebase + - name: Set up Python ${{ matrix.python-version }} + uses: conda-incubator/setup-miniconda@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Set up environment + run: | + conda config --append channels conda-forge + conda install cython numpy clang llvm-openmp + - name: Build wheel + run: | + python setup.py bdist_wheel + - name: Save artifacts + uses: actions/upload-artifact@v2 + with: + name: wheels + path: dist/*.whl diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml new file mode 100644 index 00000000..5c44e43e --- /dev/null +++ b/.github/workflows/code-style.yml @@ -0,0 +1,21 @@ +name: Code style + +# This workflow runs code style checks. + +on: + push: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Check code style + run: | + pip install pycodestyle + pycodestyle pandana diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..35be4c67 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,35 @@ +name: Coverage + +# This workflow generates a coverage report (how much of the codebase is covered by the +# unit tests) and posts headline metrics to the PR thread. + +on: + # push: + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install Pandana + run: | + pip install . + pip install osmnet + - name: Generate coverage report + run: | + pip install 'pytest<4.0' 'pytest-cov<2.10' coverage + python setup.py test --pytest-args "--cov pandana --cov-report term-missing" + echo "coverage=$(coverage report | grep '^TOTAL' | grep -oE '[^ ]+$')" >> $GITHUB_ENV + - name: Post comment on PR + uses: unsplash/comment-on-pr@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "Test coverage is ${{ env.coverage }}" + check_for_duplicate_msg: true diff --git a/.github/workflows/cross-compatibility.yml b/.github/workflows/cross-compatibility.yml new file mode 100644 index 00000000..f7c3e096 --- /dev/null +++ b/.github/workflows/cross-compatibility.yml @@ -0,0 +1,62 @@ +name: Cross-compatibility + +# This workflow runs the Pandana unit tests across a comprehensive range of Python +# versions and operating systems. Windows needs conda in order to install geospatial +# dependencies. + +on: + # push: + pull_request: + workflow_dispatch: + +jobs: + build-pip: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + python-version: [3.6, 3.7, 3.8] + 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 Pandana + run: | + pip install . + pip install osmnet + - name: Run demo + run: | + python examples/simple_example.py + - name: Run unit tests + run: | + pip install 'pytest<4.0' + python setup.py test + + build-conda: + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -l {0} # needed for conda persistence + strategy: + matrix: + os: [windows-latest] + python-version: [3.6, 3.7, 3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: conda-incubator/setup-miniconda@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Pandana + run: | + pip install . + conda install osmnet --channel conda-forge + - name: Run demo + run: | + python examples/simple_example.py + - name: Run unit tests + run: | + pip install 'pytest<4.0' + python setup.py test diff --git a/.github/workflows/installation.yml b/.github/workflows/installation.yml new file mode 100644 index 00000000..31c59a7c --- /dev/null +++ b/.github/workflows/installation.yml @@ -0,0 +1,58 @@ +name: Installation + +# This workflow installs Pandana from Pip and Conda across a range of Python versions and +# operating systems. You can run this manually after a new release is posted to confirm +# that it installs smoothly. This workflow also runs periodically in the background to +# catch dependency updates that break Pandana. + +on: + # push: + # pull_request: + workflow_dispatch: + schedule: + - cron: '0 3 * * 1' # every Monday at 3am UTC (Sunday evening Calif time) + +jobs: + build-pip: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + # Pip installation for Windows is not supported. Pip installation for Mac is + # broken in the GitHub Actions environment with Pandana v0.6 but should be fixed + # in the next Pandana release. + python-version: [3.6, 3.7, 3.8] + 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 Pandana + run: | + pip install pandana + - name: Run demo + run: | + python examples/simple_example.py + + build-conda: + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -l {0} # needed for conda persistence + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.6, 3.7, 3.8, 3.9] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: conda-incubator/setup-miniconda@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Pandana + run: | + conda install pandana --channel conda-forge + - name: Run demo + run: | + python examples/simple_example.py diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 00000000..d0643707 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,28 @@ +name: Unit tests + +# This workflow runs the Pandana unit tests in a single generic environment (recent but +# stable Python version on recent but stable Ubuntu). The cross-compatibility.yml +# workflow runs the same tests across multiple platforms. + +on: + push: + # pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install Pandana + run: | + pip install . + pip install osmnet + - name: Run unit tests + run: | + pip install 'pytest<4.0' + python setup.py test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e491936a..00000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: python - -python: - - '2.7' - - '3.5' - - '3.6' - - '3.7' - - '3.8' - -install: - - pip install . - - pip install -r requirements-dev.txt - - pip install -r requirements-extras.txt - - pip list - - pip show pandana - -script: - - pycodestyle pandana - - python setup.py test --pytest-args "--cov pandana --cov-report term-missing" - -after_success: - - coveralls diff --git a/CHANGELOG.md b/CHANGELOG.md index 3180894c..4fbd5287 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +v0.6.1 +====== + +2021/03/17 + +* Adds support for non-x86 CPUs, including ARM-based Macs +* Removes accommodations for pre-C++11 compilers +* Formally ends support for Python 2.7 + v0.6 ==== diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ffc153b..9fba74e7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,11 +68,17 @@ You can contact Sam Maurer, the lead maintainer, at `maurer@urbansim.com`. - Check https://pypi.org/project/pandana/ for the new version +The binary package installers or "wheels" are built using a GitHub Actions workflow, because each one needs to be compiled in its own target environment. This should run automatically when a PR is opened, to confirm nothing is broken, and again when a release is tagged in GitHub. You can download the resulting wheel files from the Action status page and then upload them to PyPI using the same command as above. + ## Distributing a release on Conda Forge (for conda installation): -- The [conda-forge/pandana-feedstock](https://github.com/conda-forge/pandana-feedstock) repository controls the Conda Forge release +- The [conda-forge/pandana-feedstock](https://github.com/conda-forge/pandana-feedstock) repository controls the Conda Forge release, including which GitHub users have maintainer status for the repo - Conda Forge bots usually detect new releases on PyPI and set in motion the appropriate feedstock updates, which a current maintainer will need to approve and merge +- Maintainers can add on additional changes before merging the PR, for example to update the requirements or edit the list of maintainers + +- You can also fork the feedstock and open a PR manually. It seems like this must be done from a personal account (not a group account like UDST) so that the bots can be granted permission for automated cleanup + - Check https://anaconda.org/conda-forge/pandana for the new version (may take a few minutes for it to appear) diff --git a/README.md b/README.md index 19be6f79..a49cabfc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Coverage Status](https://coveralls.io/repos/github/UDST/pandana/badge.svg?branch=master)](https://coveralls.io/github/UDST/pandana?branch=master) +![Coverage Status](https://img.shields.io/badge/coverage-90%25-green) # Pandana @@ -11,11 +11,12 @@ Documentation: http://udst.github.io/pandana ### Installation -Pandana runs on Mac, Linux, and Windows with Python 2.7, 3.6, 3.7, and 3.8. +As of March 2021, binary installers are provided for Mac, Linux, and Windows through both PyPI and Conda Forge. -The easiest way to install Pandana is using the [Anaconda](https://www.anaconda.com/distribution/) package manager. Pandana's Anaconda distributions are pre-compiled and include multi-threading support on all platforms. +- `pip install pandana` +- `conda install pandana --channel conda-forge` -`conda install pandana --channel conda-forge` +Pandana is easiest to install in Python 3.6 to 3.9. The last version of Pandana with Python 2.7 binaries is v0.4.4 on Conda Forge. The last version with Python 3.5 binaries is v0.6 on Pip. See the documentation for information about other [installation options](http://udst.github.io/pandana/installation.html). @@ -25,7 +26,6 @@ See the documentation for information about other [installation options](http:// [Pandana-demo.ipynb](examples/Pandana-demo.ipynb) - ### Acknowledgments Pandana was created by [Fletcher Foti](https://github.com/fscottfoti), with subsequent contributions from [Matt Davis](https://github.com/jiffyclub), [Federico Fernandez](https://github.com/federicofernandez), [Sam Maurer](https://github.com/smmaurer), and others. Sam Maurer is currently the lead maintainer. Pandana relies on contraction hierarchy code from [Dennis Luxen](https://github.com/DennisOSRM) and his [OSRM project](https://github.com/DennisOSRM/Project-OSRM). diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 666884c8..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,24 +0,0 @@ -build: false - -environment: - matrix: - - PYTHON: 2.7 - - PYTHON: 3.6 - -init: - - "ECHO %PYTHON%" - -# The goal here is mainly to confirm that Pandana compiles in Windows; we're not -# running any of the CI tests - -# Cython and NumPy need to be present before building Pandana. Some other -# runtime requirements aren't installing well with Pip in win-py27, so I'm just -# putting all of them into the Conda environment - -install: - - "set PATH=C:\\Miniconda3;C:\\Miniconda3\\Scripts;%PATH%" - - conda config --append channels conda-forge - - "conda create --name test-env python=%PYTHON% pip cython matplotlib numpy osmnet pandas requests scikit-learn pytables --yes --quiet" - - activate test-env - - python setup.py install - - conda list diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 826e550e..b291c52b 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,6 +1,15 @@ Change log ========== +v0.6.1 +------ + +2021/03/17 + +* Adds support for non-x86 CPUs, including ARM-based Macs +* Removes accommodations for pre-C++11 compilers +* Formally ends support for Python 2.7 + v0.6 ---- diff --git a/docs/source/conf.py b/docs/source/conf.py index e915973f..543ab7dd 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -50,7 +50,7 @@ # General information about the project. project = 'pandana' -copyright = '2020, UrbanSim Inc.' +copyright = '2021, UrbanSim Inc.' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/docs/source/index.rst b/docs/source/index.rst index 4b893394..85337b78 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -8,7 +8,7 @@ Pandana Pandana is a Python library for network analysis that uses `contraction hierarchies `_ to calculate super-fast travel accessibility metrics and shortest paths. The numerical code is in C++. -v0.6, released November 11, 2020 +v0.6.1, released March 17, 2021. Acknowledgments diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 1aa7d7ff..9029d6a9 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -1,95 +1,65 @@ Installation ============ -Pandana is a Python package that includes a C++ extension for numerical operations. Pandana is tested on Mac, Linux, and Windows with Python 2.7, 3.6, 3.7, and 3.8. +Pandana is a Python package that includes a C++ extension for numerical operations. -The easiest way to install Pandana is using the `Anaconda`_ package manager. Pandana's Anaconda distributions are pre-compiled and include multi-threading support on all platforms. -If you install Pandana from Pip or from the source code on GitHub, you'll need to compile the C++ components locally. This is automatic, but won't work unless the right build tools are in place. See full instructions below. - - -Anaconda (recommended!) +Standard installation ------------------------------ -Pandana is hosted on Conda Forge:: - - conda install pandana --channel conda-forge - - -.. _pip: +As of March 2021, binary installers are provided for Mac, Linux, and Windows through both PyPI and Conda Forge. -Pip (requires local compilation) --------------------------------- - -Pandana is also hosted on PyPI:: +You can install Pandana using Pip:: pip install pandana -Pandana's C++ components will compile automatically if the right tools are present. See instructions below for individual operating systems. +Or Conda:: + conda install pandana --channel conda-forge -.. _github: +Pandana is easiest to install in Python 3.6 to 3.9. The last version of Pandana with Python 2.7 binaries is v0.4.4 on Conda Forge. The last version with Python 3.5 binaries is v0.6 on Pip. -GitHub (requires local compilation) ------------------------------------ -If you'll be modifying the code, you can install Pandana from the `GitHub source `_:: +ARM-based Macs +------------------------------ - git clone https://github.com/udst/pandana.git - cd pandana - pip install cython numpy - python setup.py develop +Native binary installers for ARM-based Macs are available on Conda Forge, but to use these your full Python stack needs to be optimized for ARM. -Pandana's C++ components will compile automatically if the right tools are present. See instructions below for individual operating systems. +If you're running Python through Rosetta translation (which is the default), older Mac installers will continue to work fine. See `issue #152 `_ for tips and further discussion. -Tips for local compilation --------------------------- +Compiling from source code +------------------------------ -If you cannot install using Conda, Pandana's C++ code will need to be compiled locally on your machine. +You may want to compile Pandana locally if you're modifying the source code or need to use a version that's missing binary installers for your platform. -Compiling in MacOS -~~~~~~~~~~~~~~~~~~ +Mac users should start by running ``xcode-select --install`` to make sure you have Apple's Xcode command line tools, which are needed behind the scenes. Windows users will need the `Microsoft Visual C++ Build Tools `_. -MacOS comes with C++ compilers, but the built-in ones don't allow multi-threading in Pandana. So, run this if possible before installing Pandana from source code:: +Pandana's build-time requirements are ``cython``, ``numpy``, and a C++ compiler that supports the C++11 standard. Additionally, the compiler needs to support OpenMP to allow Pandana to use multithreading. - xcode-select --install - conda install cython numpy llvm-openmp clang +The smoothest route is to get the compilers from Conda Forge -- you want the ``clang`` and ``llvm-openmp`` packages. Running Pandana's setup script will trigger compilation:: -Pandana will automatically detect that these are installed, and compile itself with multi-threading enabled. + conda install cython numpy clang llvm-openmp + python setup.py develop -If you prefer to use a different compiler, provide a path in the ``CC`` environment variable and we'll use that one instead. See writeup in `PR #137 `_ for some more discussion of this. +You'll see a lot of status messages go by, but hopefully no errors. -If you get a compilation error like ``'wchar.h' file not found`` in MacOS 10.14, you can resolve it by installing some additional header files:: +MacOS 10.14 (but not newer versions) often needs additional header files installed. If you see a compilation error like ``'wchar.h' file not found`` in MacOS 10.14, you can resolve it by running this command:: open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -Compiling in Linux -~~~~~~~~~~~~~~~~~~ - -Pandana's setup script expects a version of the GCC compiler with support for OpenMP. This appears to be GCC 4.8+, but we haven't done extensive testing. If you run into problems, try doing a fresh install of the core build tools:: - - sudo apt-get install --reinstall build-essential - -Compiling in Windows -~~~~~~~~~~~~~~~~~~~~ - -Compilation is automatic but requires that `Microsoft Visual C++ Build Tools `_ are installed. -Certain older machines may need the `Microsoft Visual C++ 2008 SP1 Redistributable Package (x64) `_ or something similar in order to use Pandana. This provides runtime components of the Visual C++ libraries. - - -Multi-threading ---------------- - -After installing Pandana, running :code:`examples/simple_example.py` will display the number of threads that Pandana is using. +Advanced compilation tips +------------------------------ -If you're installing from source code on a Mac, see "Compiling in MacOS" above for more information about enabling multi-threading. +If you prefer not to use Conda, you can skip the ``clang`` and ``llvm-openmp`` packages. Compilation will likely work fine with your system's built-in toolchain. -.. note:: - The multi-threading status indicator may be incorrect in certain Windows environments. See GitHub `issue #138 `_ for the latest information on this. +The default C++ compiler on Macs doesn't support OpenMP, though, meaning that Pandana won't be able to use multithreading. +You can set the ``CC`` environment variable to specify a compiler of your choice. See writeup in `PR #137 `_ for discussion of this. If you need to make additional modifications, you can edit the compilation script in your local copy of ``setup.py``. +Multithreading +------------------------------ -.. _Anaconda: https://www.anaconda.com/distribution/ +You can check how many threads Pandana is able to use on your machine by running the ``examples/simple_example.py`` script. diff --git a/examples/Pandana-demo.ipynb b/examples/Pandana-demo.ipynb index f70409f9..17b72956 100644 --- a/examples/Pandana-demo.ipynb +++ b/examples/Pandana-demo.ipynb @@ -586,9 +586,7 @@ "Then get the routing between the nodes.\n", "- [network.shortest_path()](http://udst.github.io/pandana/network.html#pandana.network.Network.shortest_path)\n", "- [network.shortest_path_length()](http://udst.github.io/pandana/network.html#pandana.network.Network.shortest_path_length)\n", - "- [network.shortest_path_lengths()](http://udst.github.io/pandana/network.html#pandana.network.Network.shortest_path_lengths)\n", - "\n", - "Note that these are only *approximately* the shortest path. Pandana uses a heuristic called [contraction hierarchies](https://en.wikipedia.org/wiki/Contraction_hierarchies) to prioritize trunk routes, similar to e.g. Google Maps. This dramatically improves routing performance." + "- [network.shortest_path_lengths()](http://udst.github.io/pandana/network.html#pandana.network.Network.shortest_path_lengths)\n" ] }, { diff --git a/pandana/__init__.py b/pandana/__init__.py index f50d2441..602e1d4c 100644 --- a/pandana/__init__.py +++ b/pandana/__init__.py @@ -1,3 +1,3 @@ from .network import Network -version = __version__ = '0.6' +version = __version__ = '0.6.1' diff --git a/pandana/loaders/tests/test_osm.py b/pandana/loaders/tests/test_osm.py index 14cd62b2..c3d04a39 100644 --- a/pandana/loaders/tests/test_osm.py +++ b/pandana/loaders/tests/test_osm.py @@ -2,7 +2,7 @@ import pandana from pandana.loaders import osm -from pandana.testing import skipiftravis +from pandana.testing import skipifci @pytest.fixture(scope='module') @@ -41,7 +41,7 @@ def test_process_node(): assert osm.process_node(test_node) == expected -@skipiftravis +@skipifci def test_network_from_bbox(bbox2): net = osm.pdna_network_from_bbox(*bbox2) assert isinstance(net, pandana.Network) diff --git a/pandana/loaders/tests/test_pandash5.py b/pandana/loaders/tests/test_pandash5.py index 140c00e8..e1206e1c 100644 --- a/pandana/loaders/tests/test_pandash5.py +++ b/pandana/loaders/tests/test_pandash5.py @@ -6,7 +6,7 @@ import pandas.util.testing as pdt from pandana import Network -from pandana.testing import skipiftravis +from pandana.testing import skipifci from pandana.loaders import pandash5 as ph5 @@ -71,7 +71,7 @@ def cleanup(): return fname -@skipiftravis +@skipifci def test_remove_nodes(network, rm_nodes): # node 0 is connected to node 4, which is in turn connected to node 5 # node 7 is connected to node 11, which has no other connections @@ -96,7 +96,7 @@ def test_remove_nodes(network, rm_nodes): pdt.assert_frame_equal(edges, exp_edges) -@skipiftravis +@skipifci def test_network_to_pandas_hdf5( tmpfile, network, nodes, edges_df, impedance_names, two_way): ph5.network_to_pandas_hdf5(network, tmpfile) @@ -110,7 +110,7 @@ def test_network_to_pandas_hdf5( store['impedance_names'], pd.Series(impedance_names)) -@skipiftravis +@skipifci def test_network_to_pandas_hdf5_removal( tmpfile, network, impedance_names, two_way, rm_nodes): nodes, edges = ph5.remove_nodes(network, rm_nodes) @@ -125,7 +125,7 @@ def test_network_to_pandas_hdf5_removal( store['impedance_names'], pd.Series(impedance_names)) -@skipiftravis +@skipifci def test_network_from_pandas_hdf5( tmpfile, network, nodes, edges_df, impedance_names, two_way): ph5.network_to_pandas_hdf5(network, tmpfile) @@ -137,7 +137,7 @@ def test_network_from_pandas_hdf5( assert new_net.impedance_names == impedance_names -@skipiftravis +@skipifci def test_network_save_load_hdf5( tmpfile, network, impedance_names, two_way, rm_nodes): network.save_hdf5(tmpfile, rm_nodes) @@ -153,7 +153,7 @@ def test_network_save_load_hdf5( # this is an odd place for this test because it's not related to HDF5, # but my test Network is perfect. -@skipiftravis +@skipifci def test_network_low_connectivity_nodes(network, impedance_names): nodes = network.low_connectivity_nodes(10, 3, imp_name=impedance_names[0]) assert list(nodes) == [7, 11] diff --git a/pandana/testing.py b/pandana/testing.py index 01c25fa8..77f8ba3c 100644 --- a/pandana/testing.py +++ b/pandana/testing.py @@ -2,5 +2,5 @@ import pytest -skipiftravis = pytest.mark.skipif( - os.environ.get('TRAVIS') == 'true', reason='skip on Travis-CI') +skipifci = pytest.mark.skipif( + os.environ.get('CI') == 'true', reason='skip on CI') diff --git a/pandana/tests/test_cyaccess.py b/pandana/tests/test_cyaccess.py index 7d67924d..5eed36da 100644 --- a/pandana/tests/test_cyaccess.py +++ b/pandana/tests/test_cyaccess.py @@ -33,9 +33,9 @@ def net(nodes_and_edges): edges["to"] = node_locations.loc[edges["to"]].values net = cyaccess( - nodes.index.values, + nodes.index.values.astype('int_'), nodes.values, - edges.values, + edges.values.astype('int_'), edge_weights.transpose().values, True ) diff --git a/pandana/tests/test_pandana.py b/pandana/tests/test_pandana.py index 68e277bd..4278ef65 100644 --- a/pandana/tests/test_pandana.py +++ b/pandana/tests/test_pandana.py @@ -5,7 +5,7 @@ import pandas as pd import pytest from pandas.util import testing as pdt -from pandana.testing import skipiftravis +from pandana.testing import skipifci import pandana.network as pdna diff --git a/setup.py b/setup.py index 23c4f06a..35d6d506 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,7 @@ import sys import sysconfig -from setuptools import find_packages -from distutils.core import setup, Extension +from setuptools import find_packages, setup, Extension from setuptools.command.test import test as TestCommand from setuptools.command.build_ext import build_ext @@ -58,13 +57,8 @@ def run(self): # versions of Xcode Command Line Tools, or newer versions installed separately if sys.platform.startswith('darwin'): # Mac - - # This environment variable sets the earliest OS version that the compiled - # code will be compatible with. In certain contexts the default is too old - # to allow using libc++; supporting OS X 10.9 and later seems reasonable - os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9' - - extra_compile_args += ['-D NO_TR1_MEMORY', '-stdlib=libc++'] + + extra_compile_args += ['-stdlib=libc++'] extra_link_args += ['-stdlib=libc++'] # The default compiler that ships with Macs doesn't support OpenMP multi- @@ -131,7 +125,7 @@ def run(self): ## Standard setup ############################################### -version = '0.6' +version = '0.6.1' packages = find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]) @@ -149,6 +143,7 @@ def run(self): 'code is in C++.'), url='https://udst.github.io/pandana/', ext_modules=[cyaccess], + python_requires = '>=3.5', install_requires=[ 'cython >=0.25.2', 'numpy >=1.8', @@ -165,11 +160,11 @@ def run(self): }, classifiers=[ 'Development Status :: 4 - Beta', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'License :: OSI Approved :: GNU Affero General Public License v3' ], ) diff --git a/src/accessibility.cpp b/src/accessibility.cpp index cedb588a..5c3ec2bd 100644 --- a/src/accessibility.cpp +++ b/src/accessibility.cpp @@ -1,6 +1,7 @@ #include "accessibility.h" #include #include +#include #include #include "graphalg.h" @@ -18,22 +19,6 @@ bool distance_node_pair_comparator(const distance_node_pair& l, { return l.first < r.first; } -double exp_decay(const double &distance, const float &radius, const float &var) -{ - return exp(-1*distance/radius) * var; -} - -double linear_decay(const double &distance, const float &radius, const float &var) -{ - return (1.0-distance/radius) * var; -} - -double flat_decay(const double &distance, const float &radius, const float &var) -{ - return var; -} - - Accessibility::Accessibility( int numnodes, vector< vector> edges, @@ -401,14 +386,17 @@ Accessibility::aggregateAccessibilityVariable( double sum = 0.0; double sumsq = 0.0; - double (*sum_function_ptr)(const double &, const float &, const float &); + std::function sum_function; if(decay == "exp") - sum_function_ptr = &exp_decay; + sum_function = [](const double &distance, const float &radius, const float &var) + { return exp(-1*distance/radius) * var; }; if(decay == "linear") - sum_function_ptr = &linear_decay; + sum_function = [](const double &distance, const float &radius, const float &var) + { return (1.0-distance/radius) * var; }; if(decay == "flat") - sum_function_ptr = &flat_decay; + sum_function = [](const double &distance, const float &radius, const float &var) + { return var; }; for (int i = 0 ; i < distances.size() ; i++) { int nodeid = distances[i].first; @@ -419,7 +407,7 @@ Accessibility::aggregateAccessibilityVariable( for (int j = 0 ; j < vars[nodeid].size() ; j++) { cnt++; // count items - sum += (*sum_function_ptr)(distance, radius, vars[nodeid][j]); + sum += sum_function(distance, radius, vars[nodeid][j]); // stddev is always flat sumsq += vars[nodeid][j] * vars[nodeid][j]; diff --git a/src/contraction_hierarchies/src/POIIndex/POIIndex.h b/src/contraction_hierarchies/src/POIIndex/POIIndex.h index 5d442fa0..bd699403 100644 --- a/src/contraction_hierarchies/src/POIIndex/POIIndex.h +++ b/src/contraction_hierarchies/src/POIIndex/POIIndex.h @@ -22,18 +22,7 @@ #include -#if defined _WIN32 || defined NO_TR1_MEMORY -#include -#else -// can we get rid of this tr1 stuff and use c++11 now? -#include -#endif - -#ifdef NO_TR1_MEMORY - using std::shared_ptr; -#else -#define shared_ptr tr1::shared_ptr -#endif +using std::shared_ptr; #include "../BasicDefinitions.h" #include "../DataStructures/BinaryHeap.h" diff --git a/src/contraction_hierarchies/src/libch.cpp b/src/contraction_hierarchies/src/libch.cpp index 8dad3b88..d591c055 100644 --- a/src/contraction_hierarchies/src/libch.cpp +++ b/src/contraction_hierarchies/src/libch.cpp @@ -20,7 +20,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "libch.h" #include "POIIndex/POIIndex.h" -#ifdef _OPENMP +#if defined(_OPENMP) && (defined(__amd64__) || defined(__i386__)) #include "Util/HyperThreading.h" #endif namespace CH {