Skip to content

Commit

Permalink
publish v0.9.5 (#340)
Browse files Browse the repository at this point in the history
* update docs, drop scripts no longer needed, include example files in package

* Pandas 1.0 fixes

* Location and mode choice logsums (#298)

* Tncs (#14)

* write trip matrices (#311)

* small fixes for semcog deployment (#319)

* improved validation diagnostics in trip_purpose and various windows-related int32/int64 conversions

* fix bug in handling of no viable trips case in choose_trip_destination

* major work on phase 5 (#325)

* estimation through atwork_subtour_mode_choice

* Tnc updates and notebooks (#18)

* move other resources into folder since examples now part of package as well

* add example zone shapefile

* estimation notebooks for larch (#19)

* multiprocessing related logging and error checking

* trip_destination handle all trips fail

* skim caching with numpy memmap to speed skim loading

* better chunking in vectorize_tour_scheduling

* Cli (#22)

* use activitysim_resources

Fixed auto sufficiency conditions in tour_mode_choice.csv. (Issue #324)

* correct write trip matrices sampling expansion and add vehicle occupancy to the expression file

* additional updates for estimation integration  (#328)

* improve LICENSE (#30)

* correct univ coeff template lookup (#28)

Co-authored-by: Clint Daniels <clint.daniels@wsp.com>
Co-authored-by: Blake <brosenthalpdx@gmail.com>
Co-authored-by: Blake Rosenthal <blake.rosenthal@rsginc.com>
Co-authored-by: Jeff Doyle <toliwaga@gmail.com>
Co-authored-by: Jeffrey Doyle <jeff.doyle@rsginc.com>
Co-authored-by: Jeffrey Newman <jeff@newman.me>
  • Loading branch information
7 people authored Sep 4, 2020
1 parent a3dca1f commit 3b70dfc
Show file tree
Hide file tree
Showing 496 changed files with 463,490 additions and 293,638 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
sandbox/
example/data/*
.idea
.ipynb_checkpoints
.coverage*
Expand Down
14 changes: 8 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
language: python
sudo: false
python:
- '2.7'
- '3.6'
- '3.7'
- '3.8'
install:
- wget http://repo.continuum.io/miniconda/Miniconda-3.7.0-Linux-x86_64.sh -O miniconda.sh
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- |
conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION future
- source activate test-environment
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION
- conda activate test-environment
- conda install pytest pytest-cov coveralls pycodestyle
- pip install .
- pip freeze
Expand All @@ -40,6 +40,8 @@ deploy:

notifications:
slack:
on_success: never # default: change
on_failure: always # default: always
secure: Dpp+zBrnPGBHXrYWjwHy/bnHvhINfepSIiViwKfBZizBvTDvzSJfu6gCH+/lQ3squF3D4qTWwxB+LQ9V6KTYhuma8vQVisyneI6ARjUI/qgX6aJjuvmDDGPk6DVeDow7+aCLZ8VEHRhSjwy+dv0Ij0rxI6I94xPVwXUkk7ZjcK0=
env:
global:
Expand Down
26 changes: 14 additions & 12 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
ActivitySim
Contributions prior to March 2016 Copyright (C) by UrbanSim Inc.
Contributions subsequent to March 2016 Copyright (C) by the contributing authors
BSD 3-Clause License

Copyright (c) After March 2016, Contributing Authors
Copyright (c) Before March 2016, UrbanSim Inc
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of [project] nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Expand All @@ -25,4 +27,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
include ez_setup.py
include README.rst
graft notebooks
graft activitysim/examples

# required for test system

include activitysim\abm\test\data\mtc_asim.h5
include activitysim\abm\test\data\skims.omx
include activitysim\abm\test\data\households.csv
Expand Down
3 changes: 3 additions & 0 deletions activitysim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# ActivitySim
# See full license in LICENSE.txt.

__version__ = '0.9.5'
__doc__ = 'Activity-Based Travel Modeling'
3 changes: 0 additions & 3 deletions activitysim/abm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# ActivitySim
# See full license in LICENSE.txt.

from __future__ import absolute_import

from . import misc
from . import tables
from . import models
5 changes: 0 additions & 5 deletions activitysim/abm/misc.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# ActivitySim
# See full license in LICENSE.txt.

from __future__ import (absolute_import, division, print_function, )
from future.standard_library import install_aliases
install_aliases() # noqa: E402

import logging

import pandas as pd
Expand Down
4 changes: 1 addition & 3 deletions activitysim/abm/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# ActivitySim
# See full license in LICENSE.txt.

from __future__ import absolute_import

from . import accessibility
from . import atwork_subtour_destination
from . import atwork_subtour_frequency
Expand Down Expand Up @@ -30,3 +27,4 @@
from . import trip_purpose
from . import trip_purpose_and_destination
from . import trip_scheduling
from . import trip_matrices
58 changes: 27 additions & 31 deletions activitysim/abm/models/accessibility.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# ActivitySim
# See full license in LICENSE.txt.

from __future__ import (absolute_import, division, print_function, )
from future.standard_library import install_aliases
install_aliases() # noqa: E402

import logging

import pandas as pd
Expand Down Expand Up @@ -51,25 +46,29 @@ def __init__(self, skim_dict, orig_zones, dest_zones, transpose=False):
self.skim_dict = skim_dict
self.transpose = transpose

if omx_shape[0] == len(orig_zones):
# no slicing required
self.slice_map = None
if omx_shape[0] == len(orig_zones) and skim_dict.offset_mapper.offset_series is None:
# no slicing required because whatever the offset_int, the skim data aligns with zone list
self.map_data = False
else:
# 2-d boolean slicing in numpy is a bit tricky
# data = data[orig_map, dest_map] # <- WRONG!
# data = data[orig_map, :][:, dest_map] # <- RIGHT
# data = data[np.ix_(orig_map, dest_map)] # <- ALSO RIGHT

if omx_shape[0] == len(orig_zones):
logger.debug("AccessibilitySkims - applying offset_mapper")

skim_index = list(range(omx_shape[0]))
orig_map = np.isin(skim_index, skim_dict.offset_mapper.map(orig_zones))
dest_map = np.isin(skim_index, skim_dict.offset_mapper.map(dest_zones))
orig_map = skim_dict.offset_mapper.map(orig_zones)
dest_map = skim_dict.offset_mapper.map(dest_zones)

# (we might be sliced multiprocessing)
# assert np.isin(skim_index, orig_map).all()

if not dest_map.all():
if np.isin(skim_index, dest_map).all():
# not using the whole skim matrix
logger.info("%s skim zones not in dest_map: %s" %
((~dest_map).sum(), np.ix_(~dest_map)))

self.slice_map = np.ix_(orig_map, dest_map)
self.map_data = True
self.orig_map = orig_map
self.dest_map = dest_map

def __getitem__(self, key):
"""
Expand All @@ -85,10 +84,15 @@ def __getitem__(self, key):
if self.transpose:
data = data.transpose()

if self.slice_map is not None:
if self.map_data:

# slice skim to include only orig rows and dest columns
# 2-d boolean slicing in numpy is a bit tricky - see explanation in __init__
data = data[self.slice_map]
# 2-d boolean slicing in numpy is a bit tricky
# data = data[orig_map, dest_map] # <- WRONG!
# data = data[orig_map, :][:, dest_map] # <- RIGHT
# data = data[np.ix_(orig_map, dest_map)] # <- ALSO RIGHT

data = data[self.orig_map, :][:, self.dest_map]

return data.flatten()

Expand Down Expand Up @@ -121,19 +125,12 @@ def compute_accessibility(accessibility, skim_dict, land_use, trace_od):
logger.info("Running %s with %d dest zones" % (trace_label, len(accessibility_df)))

constants = config.get_model_constants(model_settings)
land_use_columns = model_settings.get('land_use_columns', [])

land_use_columns = model_settings.get('land_use_columns', [])
land_use_df = land_use.to_frame()
land_use_df = land_use_df[land_use_columns]

# #bug
#
# land_use_df = land_use_df[land_use_df.index % 2 == 1]
# accessibility_df = accessibility_df[accessibility_df.index.isin(land_use_df.index)].head(5)
#
# print "land_use_df", land_use_df.index
# print "accessibility_df", accessibility_df.index
# #bug

# don't assume they are the same: accessibility may be sliced if we are multiprocessing
orig_zones = accessibility_df.index.values
dest_zones = land_use_df.index.values

Expand All @@ -158,7 +155,6 @@ def compute_accessibility(accessibility, skim_dict, land_use, trace_od):
trace_od_rows = None

# merge land_use_columns into od_df
land_use_df = land_use_df[land_use_columns]
od_df = pd.merge(od_df, land_use_df, left_on='dest', right_index=True).sort_index()

locals_d = {
Expand All @@ -175,7 +171,7 @@ def compute_accessibility(accessibility, skim_dict, land_use, trace_od):

for column in results.columns:
data = np.asanyarray(results[column])
data.shape = (orig_zone_count, dest_zone_count)
data.shape = (orig_zone_count, dest_zone_count) # (o,d)
accessibility_df[column] = np.log(np.sum(data, axis=1) + 1)

# - write table to pipeline
Expand Down
Loading

0 comments on commit 3b70dfc

Please sign in to comment.