Skip to content

Commit

Permalink
black and isort (#578)
Browse files Browse the repository at this point in the history
* black and isort
  • Loading branch information
jpn-- authored Aug 4, 2022
1 parent f79341d commit 3b7e551
Show file tree
Hide file tree
Showing 210 changed files with 15,775 additions and 10,536 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ script:
- python activitysim/examples/placeholder_multiple_zone/scripts/three_zone_example_data.py
- python /home/travis/miniconda/envs/asimtest/lib/python$TRAVIS_PYTHON_VERSION/site-packages/activitysim/examples/placeholder_multiple_zone/scripts/two_zone_example_data.py
- python /home/travis/miniconda/envs/asimtest/lib/python$TRAVIS_PYTHON_VERSION/site-packages/activitysim/examples/placeholder_multiple_zone/scripts/three_zone_example_data.py
# pycodestyle
- pycodestyle activitysim
- black --check --diff activitysim
# run specific TEST_SUITE job on travis to avoid job max time
- travis_wait 50 py.test $TEST_SUITE --cov activitysim --cov-report term-missing --durations=0
# coveralls # disable coveralls service, which errors frequently
4 changes: 2 additions & 2 deletions activitysim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# See full license in LICENSE.txt.


__version__ = '1.0.4'
__doc__ = 'Activity-Based Travel Modeling'
__version__ = "1.0.4"
__doc__ = "Activity-Based Travel Modeling"
4 changes: 1 addition & 3 deletions activitysim/abm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# ActivitySim
# See full license in LICENSE.txt.
from . import misc
from . import tables
from . import models
from . import misc, models, tables
37 changes: 22 additions & 15 deletions activitysim/abm/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import pandas as pd

from activitysim.core import config
from activitysim.core import inject
from activitysim.core import config, inject

# FIXME
# warnings.filterwarnings('ignore', category=pd.io.pytables.PerformanceWarning)
Expand All @@ -18,26 +17,28 @@
def households_sample_size(settings, override_hh_ids):

if override_hh_ids is None:
return settings.get('households_sample_size', 0)
return settings.get("households_sample_size", 0)
else:
return 0 if override_hh_ids is None else len(override_hh_ids)


@inject.injectable(cache=True)
def override_hh_ids(settings):

hh_ids_filename = settings.get('hh_ids', None)
hh_ids_filename = settings.get("hh_ids", None)
if hh_ids_filename is None:
return None

file_path = config.data_file_path(hh_ids_filename, mandatory=False)
if not file_path:
logger.error("hh_ids file name '%s' specified in settings not found" % hh_ids_filename)
logger.error(
"hh_ids file name '%s' specified in settings not found" % hh_ids_filename
)
return None

df = pd.read_csv(file_path, comment='#')
df = pd.read_csv(file_path, comment="#")

if 'household_id' not in df.columns:
if "household_id" not in df.columns:
logger.error("No 'household_id' column in hh_ids file %s" % hh_ids_filename)
return None

Expand All @@ -47,19 +48,23 @@ def override_hh_ids(settings):
logger.error("No households in hh_ids file %s" % hh_ids_filename)
return None

logger.info("Using hh_ids list with %s households from file %s" %
(len(household_ids), hh_ids_filename))
logger.info(
"Using hh_ids list with %s households from file %s"
% (len(household_ids), hh_ids_filename)
)

return household_ids


@inject.injectable(cache=True)
def trace_hh_id(settings):

id = settings.get('trace_hh_id', None)
id = settings.get("trace_hh_id", None)

if id and not isinstance(id, int):
logger.warning("setting trace_hh_id is wrong type, should be an int, but was %s" % type(id))
logger.warning(
"setting trace_hh_id is wrong type, should be an int, but was %s" % type(id)
)
id = None

return id
Expand All @@ -68,9 +73,11 @@ def trace_hh_id(settings):
@inject.injectable(cache=True)
def trace_od(settings):

od = settings.get('trace_od', None)
od = settings.get("trace_od", None)

if od and not (isinstance(od, list) and len(od) == 2 and all(isinstance(x, int) for x in od)):
if od and not (
isinstance(od, list) and len(od) == 2 and all(isinstance(x, int) for x in od)
):
logger.warning("setting trace_od should be a list of length 2, but was %s" % od)
od = None

Expand All @@ -79,11 +86,11 @@ def trace_od(settings):

@inject.injectable(cache=True)
def chunk_size(settings):
_chunk_size = int(settings.get('chunk_size', 0) or 0)
_chunk_size = int(settings.get("chunk_size", 0) or 0)

return _chunk_size


@inject.injectable(cache=True)
def check_for_variability(settings):
return bool(settings.get('check_for_variability', False))
return bool(settings.get("check_for_variability", False))
78 changes: 40 additions & 38 deletions activitysim/abm/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
# ActivitySim
# See full license in LICENSE.txt.
from . import accessibility
from . import atwork_subtour_destination
from . import atwork_subtour_frequency
from . import atwork_subtour_mode_choice
from . import atwork_subtour_scheduling
from . import auto_ownership
from . import cdap
from . import free_parking
from . import initialize
from . import initialize_tours
from . import initialize_los
from . import joint_tour_composition
from . import joint_tour_destination
from . import joint_tour_frequency
from . import joint_tour_participation
from . import joint_tour_scheduling
from . import location_choice
from . import mandatory_scheduling
from . import mandatory_tour_frequency
from . import non_mandatory_destination
from . import non_mandatory_scheduling
from . import non_mandatory_tour_frequency
from . import parking_location_choice
from . import stop_frequency
from . import tour_mode_choice
from . import tour_od_choice
from . import tour_scheduling_probabilistic
from . import trip_destination
from . import trip_mode_choice
from . import trip_purpose
from . import trip_purpose_and_destination
from . import trip_scheduling
from . import trip_departure_choice
from . import trip_scheduling_choice
from . import trip_matrices
from . import summarize
from . import vehicle_allocation
from . import vehicle_type_choice
from . import (
accessibility,
atwork_subtour_destination,
atwork_subtour_frequency,
atwork_subtour_mode_choice,
atwork_subtour_scheduling,
auto_ownership,
cdap,
free_parking,
initialize,
initialize_los,
initialize_tours,
joint_tour_composition,
joint_tour_destination,
joint_tour_frequency,
joint_tour_participation,
joint_tour_scheduling,
location_choice,
mandatory_scheduling,
mandatory_tour_frequency,
non_mandatory_destination,
non_mandatory_scheduling,
non_mandatory_tour_frequency,
parking_location_choice,
stop_frequency,
summarize,
tour_mode_choice,
tour_od_choice,
tour_scheduling_probabilistic,
trip_departure_choice,
trip_destination,
trip_matrices,
trip_mode_choice,
trip_purpose,
trip_purpose_and_destination,
trip_scheduling,
trip_scheduling_choice,
vehicle_allocation,
vehicle_type_choice,
)
Loading

0 comments on commit 3b7e551

Please sign in to comment.