Skip to content

Commit 3b70dfc

Browse files
bstablerClint DanielsBlakeBlake Rosenthaltoliwaga
authored
publish v0.9.5 (#340)
* 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 <[email protected]> Co-authored-by: Blake <[email protected]> Co-authored-by: Blake Rosenthal <[email protected]> Co-authored-by: Jeff Doyle <[email protected]> Co-authored-by: Jeffrey Doyle <[email protected]> Co-authored-by: Jeffrey Newman <[email protected]>
1 parent a3dca1f commit 3b70dfc

File tree

496 files changed

+463490
-293638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

496 files changed

+463490
-293638
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
sandbox/
2-
example/data/*
32
.idea
43
.ipynb_checkpoints
54
.coverage*

.travis.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
language: python
22
sudo: false
33
python:
4-
- '2.7'
4+
- '3.6'
55
- '3.7'
6+
- '3.8'
67
install:
7-
- wget http://repo.continuum.io/miniconda/Miniconda-3.7.0-Linux-x86_64.sh -O miniconda.sh
8+
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
89
- bash miniconda.sh -b -p $HOME/miniconda
9-
- export PATH="$HOME/miniconda/bin:$PATH"
10+
- source "$HOME/miniconda/etc/profile.d/conda.sh"
1011
- hash -r
1112
- conda config --set always_yes yes --set changeps1 no
1213
- conda update -q conda
1314
- conda info -a
14-
- |
15-
conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION future
16-
- source activate test-environment
15+
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION
16+
- conda activate test-environment
1717
- conda install pytest pytest-cov coveralls pycodestyle
1818
- pip install .
1919
- pip freeze
@@ -40,6 +40,8 @@ deploy:
4040

4141
notifications:
4242
slack:
43+
on_success: never # default: change
44+
on_failure: always # default: always
4345
secure: Dpp+zBrnPGBHXrYWjwHy/bnHvhINfepSIiViwKfBZizBvTDvzSJfu6gCH+/lQ3squF3D4qTWwxB+LQ9V6KTYhuma8vQVisyneI6ARjUI/qgX6aJjuvmDDGPk6DVeDow7+aCLZ8VEHRhSjwy+dv0Ij0rxI6I94xPVwXUkk7ZjcK0=
4446
env:
4547
global:

LICENSE.txt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
ActivitySim
2-
Contributions prior to March 2016 Copyright (C) by UrbanSim Inc.
3-
Contributions subsequent to March 2016 Copyright (C) by the contributing authors
1+
BSD 3-Clause License
2+
3+
Copyright (c) After March 2016, Contributing Authors
4+
Copyright (c) Before March 2016, UrbanSim Inc
5+
All rights reserved.
46

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

8-
* Redistributions of source code must retain the above copyright notice, this
9-
list of conditions and the following disclaimer.
10+
1. Redistributions of source code must retain the above copyright notice, this
11+
list of conditions and the following disclaimer.
1012

11-
* Redistributions in binary form must reproduce the above copyright notice,
12-
this list of conditions and the following disclaimer in the documentation
13-
and/or other materials provided with the distribution.
13+
2. Redistributions in binary form must reproduce the above copyright notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
1416

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

1921
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2022
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -25,4 +27,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2527
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2628
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2729
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
include ez_setup.py
22
include README.rst
3+
graft notebooks
4+
graft activitysim/examples
5+
6+
# required for test system
7+
38
include activitysim\abm\test\data\mtc_asim.h5
49
include activitysim\abm\test\data\skims.omx
510
include activitysim\abm\test\data\households.csv

activitysim/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# ActivitySim
22
# See full license in LICENSE.txt.
3+
4+
__version__ = '0.9.5'
5+
__doc__ = 'Activity-Based Travel Modeling'

activitysim/abm/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# ActivitySim
22
# See full license in LICENSE.txt.
3-
4-
from __future__ import absolute_import
5-
63
from . import misc
74
from . import tables
85
from . import models

activitysim/abm/misc.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# ActivitySim
22
# See full license in LICENSE.txt.
3-
4-
from __future__ import (absolute_import, division, print_function, )
5-
from future.standard_library import install_aliases
6-
install_aliases() # noqa: E402
7-
83
import logging
94

105
import pandas as pd

activitysim/abm/models/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# ActivitySim
22
# See full license in LICENSE.txt.
3-
4-
from __future__ import absolute_import
5-
63
from . import accessibility
74
from . import atwork_subtour_destination
85
from . import atwork_subtour_frequency
@@ -30,3 +27,4 @@
3027
from . import trip_purpose
3128
from . import trip_purpose_and_destination
3229
from . import trip_scheduling
30+
from . import trip_matrices

activitysim/abm/models/accessibility.py

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# ActivitySim
22
# See full license in LICENSE.txt.
3-
4-
from __future__ import (absolute_import, division, print_function, )
5-
from future.standard_library import install_aliases
6-
install_aliases() # noqa: E402
7-
83
import logging
94

105
import pandas as pd
@@ -51,25 +46,29 @@ def __init__(self, skim_dict, orig_zones, dest_zones, transpose=False):
5146
self.skim_dict = skim_dict
5247
self.transpose = transpose
5348

54-
if omx_shape[0] == len(orig_zones):
55-
# no slicing required
56-
self.slice_map = None
49+
if omx_shape[0] == len(orig_zones) and skim_dict.offset_mapper.offset_series is None:
50+
# no slicing required because whatever the offset_int, the skim data aligns with zone list
51+
self.map_data = False
5752
else:
58-
# 2-d boolean slicing in numpy is a bit tricky
59-
# data = data[orig_map, dest_map] # <- WRONG!
60-
# data = data[orig_map, :][:, dest_map] # <- RIGHT
61-
# data = data[np.ix_(orig_map, dest_map)] # <- ALSO RIGHT
53+
54+
if omx_shape[0] == len(orig_zones):
55+
logger.debug("AccessibilitySkims - applying offset_mapper")
6256

6357
skim_index = list(range(omx_shape[0]))
64-
orig_map = np.isin(skim_index, skim_dict.offset_mapper.map(orig_zones))
65-
dest_map = np.isin(skim_index, skim_dict.offset_mapper.map(dest_zones))
58+
orig_map = skim_dict.offset_mapper.map(orig_zones)
59+
dest_map = skim_dict.offset_mapper.map(dest_zones)
60+
61+
# (we might be sliced multiprocessing)
62+
# assert np.isin(skim_index, orig_map).all()
6663

67-
if not dest_map.all():
64+
if np.isin(skim_index, dest_map).all():
6865
# not using the whole skim matrix
6966
logger.info("%s skim zones not in dest_map: %s" %
7067
((~dest_map).sum(), np.ix_(~dest_map)))
7168

72-
self.slice_map = np.ix_(orig_map, dest_map)
69+
self.map_data = True
70+
self.orig_map = orig_map
71+
self.dest_map = dest_map
7372

7473
def __getitem__(self, key):
7574
"""
@@ -85,10 +84,15 @@ def __getitem__(self, key):
8584
if self.transpose:
8685
data = data.transpose()
8786

88-
if self.slice_map is not None:
87+
if self.map_data:
88+
8989
# slice skim to include only orig rows and dest columns
90-
# 2-d boolean slicing in numpy is a bit tricky - see explanation in __init__
91-
data = data[self.slice_map]
90+
# 2-d boolean slicing in numpy is a bit tricky
91+
# data = data[orig_map, dest_map] # <- WRONG!
92+
# data = data[orig_map, :][:, dest_map] # <- RIGHT
93+
# data = data[np.ix_(orig_map, dest_map)] # <- ALSO RIGHT
94+
95+
data = data[self.orig_map, :][:, self.dest_map]
9296

9397
return data.flatten()
9498

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

123127
constants = config.get_model_constants(model_settings)
124-
land_use_columns = model_settings.get('land_use_columns', [])
125128

129+
land_use_columns = model_settings.get('land_use_columns', [])
126130
land_use_df = land_use.to_frame()
131+
land_use_df = land_use_df[land_use_columns]
127132

128-
# #bug
129-
#
130-
# land_use_df = land_use_df[land_use_df.index % 2 == 1]
131-
# accessibility_df = accessibility_df[accessibility_df.index.isin(land_use_df.index)].head(5)
132-
#
133-
# print "land_use_df", land_use_df.index
134-
# print "accessibility_df", accessibility_df.index
135-
# #bug
136-
133+
# don't assume they are the same: accessibility may be sliced if we are multiprocessing
137134
orig_zones = accessibility_df.index.values
138135
dest_zones = land_use_df.index.values
139136

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

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

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

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

181177
# - write table to pipeline

0 commit comments

Comments
 (0)