Skip to content

Commit

Permalink
Merge pull request #125 from UDST/develop
Browse files Browse the repository at this point in the history
v0.4.4 release
  • Loading branch information
smmaurer authored Sep 4, 2019
2 parents 947b440 + 460a132 commit a187e6d
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 73 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.4.4
======

2019/9/4

* Restores support for pre-C++11 compilers.

v0.4.3
======

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[![Build Status](https://travis-ci.org/UDST/pandana.svg?branch=master)](https://travis-ci.org/UDST/pandana)
![Version](https://img.shields.io/badge/version-0.4.4-blue.svg)
[![Travis build status](https://travis-ci.org/UDST/pandana.svg?branch=master)](https://travis-ci.org/UDST/pandana)
[![Appveyor build status](https://ci.appveyor.com/api/projects/status/a90kvns7qe56kg57?svg=true)](https://ci.appveyor.com/project/smmaurer/pandana)
[![Coverage Status](https://coveralls.io/repos/github/UDST/pandana/badge.svg?branch=master)](https://coveralls.io/github/UDST/pandana?branch=master)

# Pandana
Expand Down
24 changes: 24 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
# built documents.
#
# The short X.Y version.
version = '0.4.3'
version = '0.4.4'
# The full version, including alpha/beta/rc tags.
release = '0.4.3'
release = '0.4.4'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
29 changes: 17 additions & 12 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Pandana is hosted on Conda Forge::
conda install pandana --channel conda-forge


.. _pip:

Pip (requires local compilation)
--------------------------------

Expand All @@ -25,6 +27,10 @@ Pandana is also hosted on PyPI::

Pandana's C/C++ extension will compile automatically if the right tools are present. See below for troubleshooting.

Pip can have trouble installing Pandana's requirements in Windows Python 2.7; try Conda instead.


.. _github:

GitHub source code
------------------
Expand All @@ -35,6 +41,8 @@ If you'll be modifying the code, you can install Pandana from the `GitHub source
cd pandana
python setup.py develop

You'll need to have Cython and NumPy installed before running :code:`setup.py`.

Pandana's C/C++ extension will compile automatically if the right tools are present. See below for troubleshooting.


Expand All @@ -43,16 +51,10 @@ Compiling locally

Building Pandana from source requires C/C++ compilers. On Linux and Mac these are usually already present, but read on for more information.

.. note::
Pandana's C/C++ code references some libraries from NumPy, so you'll need to have NumPy fully installed before running Pandana's setup script.

.. note::
Pandana uses OpenMP to parallelize computations --- compiling without OpenMP support will still work but won't allow multi-threading.

Compiling Pandana in Linux
~~~~~~~~~~~~~~~~~~~~~~~~~~

Pandana's setup script expects a version of the GCC compiler with support for the C++11 standard and 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::
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

Expand All @@ -66,16 +68,19 @@ Certain older machines may need the `Microsoft Visual C++ 2008 SP1 Redistributab
Compiling Pandana in OS X
~~~~~~~~~~~~~~~~~~~~~~~~~

The default OS X compilers don't support OpenMP multi-threading. Use these commands to confirm that Xcode Command Line Tools are present and to install some newer compilers from Anaconda::
The default OS X compilers don't support OpenMP, which Pandana uses for multi-threading.

To allow multi-threading, use these commands to confirm that Xcode Command Line Tools are present and to install some newer compilers from Anaconda::

xcode-select --install
conda install llvm-openmp clang

After installing Pandana, running :code:`examples/simple_example.py` will display the number of threads that Pandana is using.
Then follow the :ref:`Pip <pip>` or :ref:`GitHub source code <github>` instructions above.

.. note::
If you get a compilation error like ``'wchar.h' file not found``, you can resolve it in macOS 10.14 by installing some additional header files::
If you get a compilation error like ``'wchar.h' file not found``, you can resolve it in macOS 10.14 by installing some additional header files::

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

After installing Pandana, running :code:`examples/simple_example.py` will display the number of threads that Pandana is using.

.. _Anaconda: https://www.anaconda.com/distribution/
2 changes: 1 addition & 1 deletion pandana/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .network import Network

version = __version__ = '0.4.3'
version = __version__ = '0.4.4'
12 changes: 6 additions & 6 deletions pandana/tests/test_cyaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def net(nodes_and_edges):

net = cyaccess(
nodes.index.values,
nodes.as_matrix(),
edges.as_matrix(),
edge_weights.transpose().as_matrix(),
nodes.values,
edges.values,
edge_weights.transpose().values,
True
)

Expand Down Expand Up @@ -109,9 +109,9 @@ def test_memory_leak(nodes_and_edges):
print i
net = cyaccess(
nodes.index.values,
nodes.as_matrix(),
edges.as_matrix(),
edge_weights.transpose().as_matrix(),
nodes.values,
edges.values,
edge_weights.transpose().values,
True
)
'''
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def run(self):
## Standard setup
###############################################

version = '0.4.3'
version = '0.4.4'

packages = find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"])

Expand Down
31 changes: 22 additions & 9 deletions src/accessibility.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "accessibility.h"
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include "graphalg.h"

Expand All @@ -18,6 +17,23 @@ bool distance_node_pair_comparator(const distance_node_pair& l,
const distance_node_pair& r)
{ 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<long>> edges,
Expand Down Expand Up @@ -350,17 +366,14 @@ Accessibility::aggregateAccessibilityVariable(
double sum = 0.0;
double sumsq = 0.0;

std::function<double(const double &, const float &, const float &)> sum_function;
double (*sum_function_ptr)(const double &, const float &, const float &);

if(decay == "exp")
sum_function = [](const double &distance, const float &radius, const float &var)
{ return exp(-1*distance/radius) * var; };
sum_function_ptr = &exp_decay;
if(decay == "linear")
sum_function = [](const double &distance, const float &radius, const float &var)
{ return (1.0-distance/radius) * var; };
sum_function_ptr = &linear_decay;
if(decay == "flat")
sum_function = [](const double &distance, const float &radius, const float &var)
{ return var; };
sum_function_ptr = &flat_decay;

for (int i = 0 ; i < distances.size() ; i++) {
int nodeid = distances[i].first;
Expand All @@ -371,7 +384,7 @@ Accessibility::aggregateAccessibilityVariable(

for (int j = 0 ; j < vars[nodeid].size() ; j++) {
cnt++; // count items
sum += sum_function(distance, radius, vars[nodeid][j]);
sum += (*sum_function_ptr)(distance, radius, vars[nodeid][j]);

// stddev is always flat
sumsq += vars[nodeid][j] * vars[nodeid][j];
Expand Down
41 changes: 0 additions & 41 deletions tmp.py

This file was deleted.

0 comments on commit a187e6d

Please sign in to comment.