From 2fab482749f1afd82236c74296a6b84813ef33c9 Mon Sep 17 00:00:00 2001 From: alephcero Date: Fri, 21 Jun 2019 16:52:54 -0300 Subject: [PATCH 01/12] change in dependencies from requirements.txt --- requirements.txt | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8bd415fe3..24ebcbc1d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,5 @@ --e git+https://github.com/synthicity/urbansim.git@286e61049ac1e67c7e7a9eec8acecea704b1a332#egg=urbansim --e git+https://github.com/synthicity/urbansim_defaults.git@8c95c2a10c5d0bcd1a470a3b636b47d8824e1254#egg=urbansim_defaults --e git+https://github.com/UDST/orca.git@f49398e2a363f8869e14b5218640d8d9c13863a4#egg=orca --e git+https://github.com/UDST/orca_test.git@02357bacc6a31e87b1476ff0f5b377a683e0c86a#egg=orca_test --e git+https://github.com/UDST/pandana.git@8f24b8a1b7539c95b51153e9954f755a7116089b#egg=pandana -# using this version of anaconda http://repo.continuum.io/archive/Anaconda2-4.0.0-Linux-x86_64.sh -# to install: -# 1) get that anaconda and install -# 2) clone master (or release) of bayarea_urbansim -# 3) pip install -r requirements.txt -# run by calling `python baus.py &` +-e git+https://github.com/UDST/urbansim.git@master#egg=urbansim +-e git+https://github.com/UDST/urbansim_defaults.git@python3#egg=urbansim_defaults +-e git+https://github.com/UDST/orca.git@master#egg=orca +-e git+https://github.com/UDST/orca_test.git@master#egg=orca_test boto From d4c199aa559c3fa08f5f344d94676d82f70293be Mon Sep 17 00:00:00 2001 From: alephcero Date: Fri, 21 Jun 2019 17:41:14 -0300 Subject: [PATCH 02/12] change in print statements. Related to #100 --- baus.py | 16 +++---- baus/datasources.py | 20 ++++----- baus/earthquake.py | 12 ++--- baus/models.py | 102 +++++++++++++++++++++--------------------- baus/preprocessing.py | 14 +++--- baus/slr.py | 8 ++-- baus/subsidies.py | 86 +++++++++++++++++------------------ baus/summaries.py | 2 +- baus/ual.py | 62 ++++++++++++------------- baus/utils.py | 12 ++--- baus/validation.py | 14 +++--- 11 files changed, 174 insertions(+), 174 deletions(-) diff --git a/baus.py b/baus.py index cd41160b5..c1ad92ed6 100644 --- a/baus.py +++ b/baus.py @@ -110,8 +110,8 @@ run_num = orca.get_injectable("run_number") if LOGS: - print '***The Standard stream is being written to /runs/run{0}.log***'\ - .format(run_num) + print('***The Standard stream is being written to /runs/run{0}.log***'\ + .format(run_num)) sys.stdout = sys.stderr = open("runs/run%d.log" % run_num, 'w') if RANDOM_SEED: @@ -373,10 +373,10 @@ def run_models(MODE, SCENARIO): raise "Invalid mode" -print "Started", time.ctime() -print "Current Branch : ", BRANCH.rstrip() -print "Current Commit : ", CURRENT_COMMIT.rstrip() -print "Current Scenario : ", orca.get_injectable('scenario').rstrip() +print("Started", time.ctime()) +print("Current Branch : ", BRANCH.rstrip()) +print("Current Commit : ", CURRENT_COMMIT.rstrip()) +print("Current Scenario : ", orca.get_injectable('scenario').rstrip()) if SLACK: @@ -390,7 +390,7 @@ def run_models(MODE, SCENARIO): run_models(MODE, SCENARIO) except Exception as e: - print traceback.print_exc() + print(traceback.print_exc()) if SLACK: slack.chat.post_message( '#sim_updates', @@ -400,7 +400,7 @@ def run_models(MODE, SCENARIO): raise e sys.exit(0) -print "Finished", time.ctime() +print("Finished", time.ctime()) if MAPS: diff --git a/baus/datasources.py b/baus/datasources.py index 110bb3447..cc879b256 100644 --- a/baus/datasources.py +++ b/baus/datasources.py @@ -50,7 +50,7 @@ def limits_settings(settings, scenario): d = settings['development_limits'] if scenario in d.keys(): - print "Using limits for scenario: %s" % scenario + print("Using limits for scenario: %s" % scenario) assert "default" in d d_scen = d[scenario] @@ -61,7 +61,7 @@ def limits_settings(settings, scenario): return d - print "Using default limits" + print("Using default limits") return d["default"] @@ -73,19 +73,19 @@ def inclusionary_housing_settings(settings, scenario): s = settings['inclusionary_housing_settings'] if scenario in s.keys(): - print "Using inclusionary settings for scenario: %s" % scenario + print("Using inclusionary settings for scenario: %s" % scenario) s = s[scenario] elif "default" in s.keys(): - print "Using default inclusionary settings" + print("Using default inclusionary settings") s = s["default"] d = {} for item in s: # this is a list of cities with an inclusionary rate that is the # same for all the cities in the list - print "Setting inclusionary rates for %d cities to %.2f" %\ - (len(item["values"]), item["amount"]) + print("Setting inclusionary rates for %d cities to %.2f" %\ + (len(item["values"]), item["amount"])) # this is a list of inclusionary rates and the cities they apply # to - need tro turn it in a map of city names to rates for juris in item["values"]: @@ -178,7 +178,7 @@ def fetch_from_s3(settings): file = os.path.join("data", file) if os.path.exists(file): continue - print "Downloading " + file + print("Downloading " + file) key = bucket.get_key(file, validate=False) key.get_contents_to_filename(file) @@ -561,7 +561,7 @@ def get_dev_projects_table(scenario, parcels): cnts = df.geom_id.isin(parcels.geom_id).value_counts() if False in cnts.index: - print "%d MISSING GEOMIDS!" % cnts.loc[False] + print("%d MISSING GEOMIDS!" % cnts.loc[False]) df = df[df.geom_id.isin(parcels.geom_id)] @@ -612,10 +612,10 @@ def development_projects(parcels, settings, scenario): df = df.dropna(subset=["year_built"]) df = df[df.action.isin(["add", "build"])] - print "Describe of development projects" + print("Describe of development projects") # this makes sure dev projects has all the same columns as buildings # which is the point of this method - print df[orca.get_table('buildings').local_columns].describe() + print(df[orca.get_table('buildings').local_columns].describe()) return df diff --git a/baus/earthquake.py b/baus/earthquake.py index ca4940da0..b0a86defb 100644 --- a/baus/earthquake.py +++ b/baus/earthquake.py @@ -259,7 +259,7 @@ def earthquake_demolish(parcels, parcels_tract, tracts_earthquake, buildings, # using the lookup table created with "parcel_tract_assignment.ipynb" census_tract = pd.Series(parcels_tract['census_tract'], parcels_tract.index) - print "Number of parcels with census tracts is: %d" % len(census_tract) + print("Number of parcels with census tracts is: %d" % len(census_tract)) orca.add_column('parcels', 'tract', census_tract) # group parcels by their census tract @@ -274,7 +274,7 @@ def earthquake_demolish(parcels, parcels_tract, tracts_earthquake, buildings, key=itemgetter(0)): tract_parcels_grp.append(list(parcels)) tracts.append(tract) - print "Number of census tract groups is: %d" % len(tract_parcels_grp) + print("Number of census tract groups is: %d" % len(tract_parcels_grp)) # for the parcels in each tract, destroy X% of parcels in that tract tracts_earthquake = tracts_earthquake.to_frame() @@ -349,8 +349,8 @@ def earthquake_demolish(parcels, parcels_tract, tracts_earthquake, buildings, fire_buildings.extend(buildings_fire) eq_buildings.extend(buildings_fire) - print "Total number of buildings being destroyed is: %d" \ - % len(eq_buildings) + print("Total number of buildings being destroyed is: %d" \ + % len(eq_buildings)) orca.add_injectable("eq_buildings", eq_buildings) orca.add_injectable("existing_buildings", existing_buildings) @@ -362,7 +362,7 @@ def earthquake_demolish(parcels, parcels_tract, tracts_earthquake, buildings, eq_demolish = buildings.local[buildings.index.isin (eq_buildings)] orca.add_table("eq_demolish", eq_demolish) - print "Demolishing %d buildings" % len(eq_demolish) + print("Demolishing %d buildings" % len(eq_demolish)) households = households.to_frame() hh_unplaced = households[households["building_id"] == -1] @@ -392,4 +392,4 @@ def earthquake_demolish(parcels, parcels_tract, tracts_earthquake, buildings, orca.add_table("buildings", buildings) buildings = orca.get_table("buildings") - print "Demolished %d buildings" % (l1 - len(buildings)) + print("Demolished %d buildings" % (l1 - len(buildings))) diff --git a/baus/models.py b/baus/models.py index ab5ae13dc..714884f0a 100644 --- a/baus/models.py +++ b/baus/models.py @@ -31,14 +31,14 @@ def elcm_simulate(jobs, buildings, aggregations, elcm_config): @orca.step() def households_transition(households, household_controls, year, settings): s = orca.get_table('households').base_income_quartile.value_counts() - print "Distribution by income before:\n", (s/s.sum()) + print("Distribution by income before:\n", (s/s.sum())) ret = utils.full_transition(households, household_controls, year, settings['households_transition'], "building_id") s = orca.get_table('households').base_income_quartile.value_counts() - print "Distribution by income after:\n", (s/s.sum()) + print("Distribution by income after:\n", (s/s.sum())) return ret @@ -84,8 +84,8 @@ def _proportional_jobs_model( available_jobs = \ jobs_df.query("empsix == '%s' and building_id == -1" % sector) - print "Need more jobs total: %d" % need_more_jobs_total - print "Available jobs: %d" % len(available_jobs) + print("Need more jobs total: %d" % need_more_jobs_total) + print("Available jobs: %d" % len(available_jobs)) if len(available_jobs) == 0: # corner case @@ -109,16 +109,16 @@ def _proportional_jobs_model( if need_more_jobs_total <= 0: return pd.Series() - print "Need more jobs\n", need_more_jobs + print("Need more jobs\n", need_more_jobs) excess = need_more_jobs.sub(locations_series.value_counts(), fill_value=0) - print "Excess demand\n", excess[excess > 0] + print("Excess demand\n", excess[excess > 0]) # there's an issue with groupby_random_choice where it can't choose from # a set of locations that don't exist - e.g. we have 2 jobs in a certain # city but not locations to put them in. we need to drop this demand drop = need_more_jobs.index.difference(locations_series.unique()) - print "We don't have any locations for these locations:\n", drop + print("We don't have any locations for these locations:\n", drop) need_more_jobs = need_more_jobs.drop(drop) # choose random locations within jurises to match need_more_jobs totals @@ -186,7 +186,7 @@ def proportional_elcm(jobs, households, buildings, parcels, location_options = building_subset.juris.repeat( building_subset.vacant_job_spaces.clip(0)) - print "Running proportional jobs model for retail" + print("Running proportional jobs model for retail") s = _proportional_jobs_model( # we now take the ratio of retail jobs to households as an input @@ -242,7 +242,7 @@ def proportional_elcm(jobs, households, buildings, parcels, target_jobs = target_jobs.astype('int') - print "Running proportional jobs model for gov/edu" + print("Running proportional jobs model for gov/edu") # location options are vacant job spaces in retail buildings - this will # overfill certain location because we don't have enough space @@ -309,7 +309,7 @@ def scheduled_development_events(buildings, development_projects, # first demolish demolish = demolish_events.to_frame().\ query("%d <= year_built < %d" % (year, year + years_per_iter)) - print "Demolishing/building %d buildings" % len(demolish) + print("Demolishing/building %d buildings" % len(demolish)) l1 = len(buildings) buildings = utils._remove_developed_buildings( buildings.to_frame(buildings.local_columns), @@ -317,8 +317,8 @@ def scheduled_development_events(buildings, development_projects, unplace_agents=["households", "jobs"]) orca.add_table("buildings", buildings) buildings = orca.get_table("buildings") - print "Demolished %d buildings" % (l1 - len(buildings)) - print " (this number is smaller when parcel has no existing buildings)" + print("Demolished %d buildings" % (l1 - len(buildings))) + print(" (this number is smaller when parcel has no existing buildings)") # then build dps = development_projects.to_frame().\ @@ -356,7 +356,7 @@ def scheduled_development_events(buildings, development_projects, def supply_and_demand_multiplier_func(demand, supply): s = demand / supply settings = orca.get_injectable('settings') - print "Number of submarkets where demand exceeds supply:", len(s[s > 1.0]) + print("Number of submarkets where demand exceeds supply:", len(s[s > 1.0])) # print "Raw relationship of supply and demand\n", s.describe() supply_correction = settings["price_equilibration"] clip_change_high = supply_correction["kwargs"]["clip_change_high"] @@ -393,8 +393,8 @@ def add_extra_columns_func(df): if "deed_restricted_units" not in df.columns: df["deed_restricted_units"] = 0 else: - print "Number of deed restricted units built = %d" %\ - df.deed_restricted_units.sum() + print("Number of deed restricted units built = %d" %\ + df.deed_restricted_units.sum()) df["redfin_sale_year"] = 2012 df["redfin_sale_price"] = np.nan @@ -503,8 +503,8 @@ def residential_developer(feasibility, households, buildings, parcels, year, for parcel_mask, target, final_target, juris in targets: - print "Running developer for %s with target of %d" % \ - (str(juris), target) + print("Running developer for %s with target of %d" % \ + (str(juris), target)) # this was a fairly heinous bug - have to get the building wrapper # again because the buildings df gets modified by the run_developer @@ -591,7 +591,7 @@ def retail_developer(jobs, buildings, parcels, nodes, feasibility, p = f1 * 1.5 + f2 p = p.clip(lower=1.0/len(p)/10) - print "Attempting to build {:,} retail sqft".format(target) + print("Attempting to build {:,} retail sqft".format(target)) # order by weighted random sample feasibility = feasibility.sample(frac=1.0, weights=p) @@ -624,10 +624,10 @@ def retail_developer(jobs, buildings, parcels, nodes, feasibility, # add the buidings and demolish old buildings, and add to debug output devs = pd.DataFrame(devs, columns=feasibility.columns) - print "Building {:,} retail sqft in {:,} projects".format( - devs.non_residential_sqft.sum(), len(devs)) + print("Building {:,} retail sqft in {:,} projects".format( + devs.non_residential_sqft.sum(), len(devs))) if target > 0: - print " WARNING: retail target not met" + print(" WARNING: retail target not met") devs["form"] = "retail" devs = add_extra_columns_func(devs) @@ -658,13 +658,13 @@ def office_developer(feasibility, jobs, buildings, parcels, year, buildings.job_spaces.sum(), dev_settings['kwargs']['target_vacancy']) - print "Total units to build = %d" % all_units + print("Total units to build = %d" % all_units) if all_units <= 0: return for typ in ["Office"]: - print "\nRunning for type: ", typ + print("\nRunning for type: ", typ) num_units = all_units * float(dev_settings['type_splits'][typ]) @@ -692,9 +692,9 @@ def office_developer(feasibility, jobs, buildings, parcels, year, target = (year - 2015 + 1) * limit - current_total if target <= 0: - print "Already met target for juris = %s" % juris - print " target = %d, current_total = %d" %\ - (target, current_total) + print("Already met target for juris = %s" % juris) + print(" target = %d, current_total = %d" %\ + (target, current_total)) continue targets.append((juris_name == juris, target, juris)) @@ -709,9 +709,9 @@ def office_developer(feasibility, jobs, buildings, parcels, year, for parcel_mask, target, juris in targets: - print "Running developer for %s with target of %d" % \ - (str(juris), target) - print "Parcels in play:\n", pd.Series(parcel_mask).value_counts() + print("Running developer for %s with target of %d" % \ + (str(juris), target)) + print("Parcels in play:\n", pd.Series(parcel_mask).value_counts()) # this was a fairly heinous bug - have to get the building wrapper # again because the buildings df gets modified by the run_developer @@ -758,11 +758,11 @@ def developer_reprocess(buildings, year, years_per_iter, jobs, to_add = res_units * .05 - job_spaces if to_add > 0: - print "Adding %d job_spaces" % to_add + print("Adding %d job_spaces" % to_add) res_units = buildings.residential_units[s] # bias selection of places to put job spaces based on res units - print res_units.describe() - print res_units[res_units < 0] + print(res_units.describe()) + print(res_units[res_units < 0]) add_indexes = np.random.choice(res_units.index.values, size=to_add, replace=True, p=(res_units/res_units.sum())) @@ -770,12 +770,12 @@ def developer_reprocess(buildings, year, years_per_iter, jobs, add_indexes = pd.Series(add_indexes).value_counts() # this is sqft per job for residential bldgs add_sizes = add_indexes * 400 - print "Job spaces in res before adjustment: ", \ - buildings.job_spaces[s].sum() + print("Job spaces in res before adjustment: ", \ + buildings.job_spaces[s].sum()) buildings.local.loc[add_sizes.index, "non_residential_sqft"] += add_sizes.values - print "Job spaces in res after adjustment: ",\ - buildings.job_spaces[s].sum() + print("Job spaces in res after adjustment: ",\ + buildings.job_spaces[s].sum()) # the second step here is to add retail to buildings that are greater than # X stories tall - presumably this is a ground floor retail policy @@ -783,12 +783,12 @@ def developer_reprocess(buildings, year, years_per_iter, jobs, new_buildings = old_buildings.query( '%d == year_built and stories >= 4' % year) - print "Attempting to add ground floor retail to %d devs" % \ - len(new_buildings) + print("Attempting to add ground floor retail to %d devs" % \ + len(new_buildings)) retail = parcel_is_allowed_func("retail") new_buildings = new_buildings[retail.loc[new_buildings.parcel_id].values] - print "Disallowing dev on these parcels:" - print " %d devs left after retail disallowed" % len(new_buildings) + print("Disallowing dev on these parcels:") + print(" %d devs left after retail disallowed" % len(new_buildings)) # this is the key point - make these new buildings' nonres sqft equal # to one story of the new buildings @@ -809,8 +809,8 @@ def developer_reprocess(buildings, year, years_per_iter, jobs, ratio = parcels.retail_ratio.loc[new_buildings.parcel_id] new_buildings = new_buildings[ratio.values > ratio.median()] - print "Adding %d sqft of ground floor retail in %d locations" % \ - (new_buildings.non_residential_sqft.sum(), len(new_buildings)) + print("Adding %d sqft of ground floor retail in %d locations" % \ + (new_buildings.non_residential_sqft.sum(), len(new_buildings))) all_buildings = dev.merge(old_buildings, new_buildings) orca.add_table("buildings", all_buildings) @@ -829,8 +829,8 @@ def developer_reprocess(buildings, year, years_per_iter, jobs, ['year_built', 'building_sqft', 'general_type']) sqft_by_gtype = buildings_df.query('year_built >= %d' % year).\ groupby('general_type').building_sqft.sum() - print "New square feet by general type in millions:\n",\ - sqft_by_gtype / 1000000.0 + print("New square feet by general type in millions:\n",\ + sqft_by_gtype / 1000000.0) def proportional_job_allocation(parcel_id): @@ -868,9 +868,9 @@ def proportional_job_allocation(parcel_id): # make sure index is incrementing new_jobs.index = new_jobs.index + 1 + np.max(all_jobs.index.values) - print "Adding {} new jobs to parcel {} with proportional model".format( - num_new_jobs, parcel_id) - print new_jobs.head() + print("Adding {} new jobs to parcel {} with proportional model".format( + num_new_jobs, parcel_id)) + print(new_jobs.head()) all_jobs = all_jobs.append(new_jobs) orca.add_table("jobs", all_jobs) @@ -951,7 +951,7 @@ def neighborhood_vars(net): nodes = nodes.replace(np.inf, np.nan) nodes = nodes.fillna(0) - print nodes.describe() + print(nodes.describe()) orca.add_table("nodes", nodes) @@ -964,7 +964,7 @@ def regional_vars(net): index_col="tmnode_id") nodes = pd.concat([nodes, nodes2], axis=1) - print nodes.describe() + print(nodes.describe()) orca.add_table("tmnodes", nodes) @@ -989,7 +989,7 @@ def regional_pois(settings, landmarks): cols[locname] = n.nearest_pois(75, "tmp", num_pois=1)[1] df = pd.DataFrame(cols) - print df.describe() + print(df.describe()) df.index.name = "tmnode_id" df.to_csv('regional_poi_distances.csv') @@ -998,7 +998,7 @@ def regional_pois(settings, landmarks): def price_vars(net): nodes2 = networks.from_yaml(net["walk"], "price_vars.yaml") nodes2 = nodes2.fillna(0) - print nodes2.describe() + print(nodes2.describe()) nodes = orca.get_table('nodes') nodes = nodes.to_frame().join(nodes2) orca.add_table("nodes", nodes) diff --git a/baus/preprocessing.py b/baus/preprocessing.py index a81346de8..40bff2622 100644 --- a/baus/preprocessing.py +++ b/baus/preprocessing.py @@ -158,14 +158,14 @@ def assign_deed_restricted_units(df, parcels): units = pd.Series(buildings_ids.index.values).value_counts() df.loc[units.index, "deed_restricted_units"] += units.values - print "Total deed restricted units after random selection: %d" % \ - df.deed_restricted_units.sum() + print("Total deed restricted units after random selection: %d" % \ + df.deed_restricted_units.sum()) df["deed_restricted_units"] = \ df[["deed_restricted_units", "residential_units"]].min(axis=1) - print "Total deed restricted units after truncating to res units: %d" % \ - df.deed_restricted_units.sum() + print("Total deed restricted units after truncating to res units: %d" % \ + df.deed_restricted_units.sum()) return df @@ -250,15 +250,15 @@ def correct_baseyear_vacancies(buildings, parcels, jobs, store): jobs_county = misc.reindex(buildings_county, jobs.building_id) - print "Vacancy rate by county:\n", \ + print("Vacancy rate by county:\n", \ buildings.job_spaces.groupby(buildings_county).sum() / \ - jobs_county.value_counts() - 1.0 + jobs_county.value_counts() - 1.0) jobs_juris = misc.reindex(buildings_juris, jobs.building_id) s = buildings.job_spaces.groupby(buildings_juris).sum() / \ jobs_juris.value_counts() - 1.0 - print "Vacancy rate by juris:\n", s.to_string() + print("Vacancy rate by juris:\n", s.to_string()) return buildings diff --git a/baus/slr.py b/baus/slr.py index e3d4ecda8..181d1803b 100644 --- a/baus/slr.py +++ b/baus/slr.py @@ -26,12 +26,12 @@ def slr_inundate(scenario, parcels, slr_progression_C, slr_progression_R, orca.add_table("slr_progression", slr_progression) inundation_yr = slr_progression.query('year==@year')['inundated'].item() - print "Inundation in model year is %d inches" % inundation_yr + print("Inundation in model year is %d inches" % inundation_yr) slr_parcel_inundation = slr_parcel_inundation.to_frame() destroy_parcels = slr_parcel_inundation.\ query('inundation<=@inundation_yr').astype('bool') orca.add_table('destroy_parcels', destroy_parcels) - print "Number of parcels destroyed: %d" % len(destroy_parcels) + print("Number of parcels destroyed: %d" % len(destroy_parcels)) slr_nodev = pd.Series(False, parcels.index) destroy = pd.Series(destroy_parcels['inundation']) @@ -55,7 +55,7 @@ def slr_remove_dev(buildings, year, parcels, households, jobs, (destroy_parcels.index)] orca.add_table("slr_demolish", slr_demolish) - print "Demolishing %d buildings" % len(slr_demolish) + print("Demolishing %d buildings" % len(slr_demolish)) households = households.to_frame() hh_unplaced = households[households["building_id"] == -1] jobs = jobs.to_frame() @@ -79,4 +79,4 @@ def slr_remove_dev(buildings, year, parcels, households, jobs, orca.add_injectable("jobs_unplaced_slr", jobs_unplaced_slr) orca.add_table("buildings", buildings) buildings = orca.get_table("buildings") - print "Demolished %d buildings" % (l1 - len(buildings)) + print("Demolished %d buildings" % (l1 - len(buildings))) diff --git a/baus/subsidies.py b/baus/subsidies.py index 557ca9a5c..f4584c3f7 100644 --- a/baus/subsidies.py +++ b/baus/subsidies.py @@ -80,7 +80,7 @@ def lump_sum_accounts(settings, year, buildings, coffer, # comments alongside the code def inclusionary_housing_revenue_reduction(feasibility, units): - print "Computing adjustments due to inclusionary housing" + print("Computing adjustments due to inclusionary housing") # AMI by jurisdiction # @@ -134,14 +134,14 @@ def value_can_afford(monthly_payment): feasibility[('residential', 'building_revenue')] / units revenue_diff_per_unit = (ave_price_per_unit - value_can_afford).fillna(0) - print "Revenue difference per unit (not zero values)" - print revenue_diff_per_unit[revenue_diff_per_unit > 0].describe() + print("Revenue difference per unit (not zero values)") + print(revenue_diff_per_unit[revenue_diff_per_unit > 0].describe()) revenue_reduction = revenue_diff_per_unit * num_affordable_units s = num_affordable_units.groupby(parcels_geography.juris_name).sum() - print "Feasibile affordable units by jurisdiction" - print s[s > 0].sort_values() + print("Feasibile affordable units by jurisdiction") + print(s[s > 0].sort_values()) return revenue_reduction, num_affordable_units @@ -151,14 +151,14 @@ def value_can_afford(monthly_payment): # is done here as well def policy_modifications_of_profit(feasibility, parcels): - print "Making policy modifications to profitability" + print("Making policy modifications to profitability") # this first section adds parcel unit-based fees units = feasibility[('residential', 'residential_sqft')] / \ parcels.ave_sqft_per_unit fees = (units * parcels.fees_per_unit).fillna(0) - print "Sum of residential fees: ", fees.sum() + print("Sum of residential fees: ", fees.sum()) feasibility[("residential", "fees")] = fees feasibility[("residential", "max_profit")] -= fees @@ -171,7 +171,7 @@ def policy_modifications_of_profit(feasibility, parcels): sqft = feasibility[(use, 'non_residential_sqft')] fees = (sqft * parcels.fees_per_sqft).fillna(0) - print "Sum of non-residential fees (%s): %.0f" % (use, fees.sum()) + print("Sum of non-residential fees (%s): %.0f" % (use, fees.sum())) feasibility[(use, "fees")] = fees feasibility[(use, "max_profit")] -= fees @@ -182,11 +182,11 @@ def policy_modifications_of_profit(feasibility, parcels): assert np.all(num_affordable_units <= units.fillna(0)) - print "Describe of inclusionary revenue reduction:\n", \ - revenue_reduction[revenue_reduction > 0].describe() + print("Describe of inclusionary revenue reduction:\n", \ + revenue_reduction[revenue_reduction > 0].describe()) - print "Describe of number of affordable units:\n", \ - num_affordable_units[num_affordable_units > 0].describe() + print("Describe of number of affordable units:\n", \ + num_affordable_units[num_affordable_units > 0].describe()) feasibility[("residential", "policy_based_revenue_reduction")] = \ revenue_reduction @@ -207,7 +207,7 @@ def policy_modifications_of_profit(feasibility, parcels): pct_modifications = feasibility[("residential", "vmt_res_cat")].\ map(sb743_settings["sb743_pcts"]) + 1 - print "Modifying profit for SB743:\n", pct_modifications.describe() + print("Modifying profit for SB743:\n", pct_modifications.describe()) feasibility[("residential", "max_profit")] *= pct_modifications @@ -231,8 +231,8 @@ def policy_modifications_of_profit(feasibility, parcels): pct_modifications = \ pct_modifications.reindex(pzc.index).fillna(1.0) - print "Modifying profit for Land Value Tax:\n", \ - pct_modifications.describe() + print("Modifying profit for Land Value Tax:\n", \ + pct_modifications.describe()) feasibility[("residential", "max_profit")] *= pct_modifications @@ -252,13 +252,13 @@ def policy_modifications_of_profit(feasibility, parcels): policy["profitability_adjustment_formula"]) pct_modifications += 1.0 - print "Modifying profit for %s:\n" % policy["name"], \ - pct_modifications.describe() + print("Modifying profit for %s:\n" % policy["name"], \ + pct_modifications.describe()) feasibility[("residential", "max_profit")] *= pct_modifications - print "There are %d affordable units if all feasible projects are built" %\ - feasibility[("residential", "deed_restricted_units")].sum() + print("There are %d affordable units if all feasible projects are built" %\ + feasibility[("residential", "deed_restricted_units")].sum()) return feasibility @@ -278,7 +278,7 @@ def calculate_vmt_fees(settings, year, buildings, vmt_fee_categories, coffer, if not len(df): return - print "%d projects pass the vmt filter" % len(df) + print("%d projects pass the vmt filter" % len(df)) total_fees = 0 @@ -287,17 +287,17 @@ def calculate_vmt_fees(settings, year, buildings, vmt_fee_categories, coffer, df["res_for_res_fees"] = df.vmt_res_cat.map( vmt_settings["res_for_res_fee_amounts"]) total_fees += (df.res_for_res_fees * df.residential_units).sum() - print "Applying vmt fees to %d units" % df.residential_units.sum() + print("Applying vmt fees to %d units" % df.residential_units.sum()) if scenario in vmt_settings["com_for_res_scenarios"]: df["com_for_res_fees"] = df.vmt_res_cat.map( vmt_settings["com_for_res_fee_amounts"]) total_fees += (df.com_for_res_fees * df.non_residential_sqft).sum() - print "Applying vmt fees to %d commerical sqft" % \ - df.non_residential_sqft.sum() + print("Applying vmt fees to %d commerical sqft" % \ + df.non_residential_sqft.sum()) - print "Adding total vmt fees for res amount of $%.2f" % total_fees + print("Adding total vmt fees for res amount of $%.2f" % total_fees) metadata = { "description": "VMT development fees", @@ -315,10 +315,10 @@ def calculate_vmt_fees(settings, year, buildings, vmt_fee_categories, coffer, df["com_for_com_fees"] = df.vmt_res_cat.map( vmt_settings["com_for_com_fee_amounts"]) total_fees += (df.com_for_com_fees * df.non_residential_sqft).sum() - print "Applying vmt fees to %d commerical sqft" % \ - df.non_residential_sqft.sum() + print("Applying vmt fees to %d commerical sqft" % \ + df.non_residential_sqft.sum()) - print "Adding total vmt fees for com amount of $%.2f" % total_fees + print("Adding total vmt fees for com amount of $%.2f" % total_fees) coffer["vmt_com_acct"].add_transaction(total_fees, subaccount="regional", metadata=metadata) @@ -355,8 +355,8 @@ def subsidized_office_developer(feasibility, coffer, acct_settings, year, # make parcel_id available feasibility = feasibility.reset_index() - print "%.0f subsidy with %d developments to choose from" % ( - total_subsidy, len(feasibility)) + print("%.0f subsidy with %d developments to choose from" % ( + total_subsidy, len(feasibility))) devs = [] @@ -403,8 +403,8 @@ def subsidized_office_developer(feasibility, coffer, acct_settings, year, # add the buidings and demolish old buildings, and add to debug output devs = pd.DataFrame(devs, columns=feasibility.columns) - print "Building {:,} subsidized office sqft in {:,} projects".format( - devs.non_residential_sqft.sum(), len(devs)) + print("Building {:,} subsidized office sqft in {:,} projects".format( + devs.non_residential_sqft.sum(), len(devs))) devs["form"] = "office" devs = add_extra_columns_func(devs) @@ -532,10 +532,10 @@ def run_subsidized_developer(feasibility, parcels, buildings, households, feasibility["subaccount"] = feasibility.eval(sending_bldgs) # step 6 for subacct, amount in account.iter_subaccounts(): - print "Subaccount: ", subacct + print("Subaccount: ", subacct) df = feasibility[feasibility.subaccount == subacct] - print "Number of feasible projects in receiving zone:", len(df) + print("Number of feasible projects in receiving zone:", len(df)) if len(df) == 0: continue @@ -546,7 +546,7 @@ def run_subsidized_developer(feasibility, parcels, buildings, households, # (orca.get_injectable("year"), account.name, subacct)) # step 8 - print "Amount in subaccount: ${:,.2f}".format(amount) + print("Amount in subaccount: ${:,.2f}".format(amount)) num_bldgs = int((-1*df.max_profit).cumsum().searchsorted(amount)) if num_bldgs == 0: @@ -629,22 +629,22 @@ def run_subsidized_developer(feasibility, parcels, buildings, households, assert np.all(buildings.local.deed_restricted_units.fillna(0) <= buildings.local.residential_units.fillna(0)) - print "Amount left after subsidy: ${:,.2f}".\ - format(account.total_transactions_by_subacct(subacct)) + print("Amount left after subsidy: ${:,.2f}".\ + format(account.total_transactions_by_subacct(subacct))) new_buildings_list.append(new_buildings) total_len = reduce(lambda x, y: x+len(y), new_buildings_list, 0) if total_len == 0: - print "No subsidized buildings" + print("No subsidized buildings") return new_buildings = pd.concat(new_buildings_list) - print "Built {} total subsidized buildings".format(len(new_buildings)) - print " Total subsidy: ${:,.2f}".format( - -1*new_buildings.max_profit.sum()) - print " Total subsidized units: {:.0f}".\ - format(new_buildings.residential_units.sum()) + print("Built {} total subsidized buildings".format(len(new_buildings))) + print(" Total subsidy: ${:,.2f}".format( + -1*new_buildings.max_profit.sum())) + print(" Total subsidized units: {:.0f}".\ + format(new_buildings.residential_units.sum())) new_buildings["subsidized"] = True new_buildings["policy_name"] = policy_name @@ -732,7 +732,7 @@ def subsidized_residential_developer_lump_sum_accts( if scenario not in acct["enable_in_scenarios"]: continue - print "Running the subsidized developer for acct: %s" % acct["name"] + print("Running the subsidized developer for acct: %s" % acct["name"]) # need to rerun the subsidized feasibility every time and get new # results - this is not ideal and is a story to fix in pivotal, but the diff --git a/baus/summaries.py b/baus/summaries.py index fdc441225..059faad9b 100644 --- a/baus/summaries.py +++ b/baus/summaries.py @@ -534,7 +534,7 @@ def diagnostic_output(households, buildings, parcels, taz, jobs, settings, # save the dropped buildings to a csv if "dropped_buildings" in orca.orca._TABLES: df = orca.get_table("dropped_buildings").to_frame() - print "Dropped buildings", df.describe() + print("Dropped buildings", df.describe()) df.to_csv( "runs/run{}_dropped_buildings.csv".format(run_number) ) diff --git a/baus/ual.py b/baus/ual.py index 3ddb60966..439564556 100644 --- a/baus/ual.py +++ b/baus/ual.py @@ -158,10 +158,10 @@ def assign_tenure_to_units(residential_units, households): units.loc[own, 'tenure'] = 'own' units.loc[rent, 'tenure'] = 'rent' - print "Init unit tenure assignment: %d%% owner occupied, %d%% unfilled" % \ + print("Init unit tenure assignment: %d%% owner occupied, %d%% unfilled" % \ (round(len(units[units.tenure == 'own'])*100 / len(units[units.tenure.notnull()])), - round(len(units[units.tenure.isnull()])*100 / len(units))) + round(len(units[units.tenure.isnull()])*100 / len(units)))) # Fill remaining units with random tenure assignment # TO DO: Make this weighted by existing allocation, rather than 50/50 @@ -301,7 +301,7 @@ def reconcile_placed_households(households, residential_units): hh = households.to_frame(['unit_id', 'building_id']) hh.index.rename('household_id', inplace=True) hh = hh.reset_index() - print "hh columns: %s" % hh.columns + print("hh columns: %s" % hh.columns) # hh.index.name='household_id' units = residential_units.to_frame(['building_id']).reset_index() @@ -314,9 +314,9 @@ def reconcile_placed_households(households, residential_units): hh = hh.drop('building_id', axis=1) hh = pd.merge(hh, units, on='unit_id', how='left').\ set_index('household_id') - print "hh index.names: %s" % hh.index.names + print("hh index.names: %s" % hh.index.names) - print "%d movers updated" % len(hh) + print("%d movers updated" % len(hh)) households.update_col_from_series('building_id', hh.building_id, cast=True) # Verify final data characteristics @@ -366,17 +366,17 @@ def reconcile_unplaced_households(households): ''' def _print_status(): - print "Households not in a unit: %d" % \ - (households.unit_id == -1).sum() - print "Househing missing a unit: %d" % \ - households.unit_id.isnull().sum() - print "Households not in a building: %d" % \ - (households.building_id == -1).sum() - print "Househing missing a building: %d" % \ - households.building_id.isnull().sum() + print("Households not in a unit: %d" % \ + (households.unit_id == -1).sum()) + print("Househing missing a unit: %d" % \ + households.unit_id.isnull().sum()) + print("Households not in a building: %d" % \ + (households.building_id == -1).sum()) + print("Househing missing a building: %d" % \ + households.building_id.isnull().sum()) _print_status() - print "Reconciling unplaced households..." + print("Reconciling unplaced households...") hh = households.to_frame(['building_id', 'unit_id']) # Get indexes of households unplaced in buildings or in units @@ -437,10 +437,10 @@ def remove_old_units(buildings, residential_units): units = residential_units.to_frame(residential_units.local_columns) current_units = units[units.building_id.isin(buildings.index)] - print "Removing %d units from %d buildings that no longer exist" % \ + print("Removing %d units from %d buildings that no longer exist" % \ ((len(units) - len(current_units)), (len(units.groupby('building_id')) - - len(current_units.groupby('building_id')))) + len(current_units.groupby('building_id'))))) orca.add_table('residential_units', current_units) @@ -503,8 +503,8 @@ def initialize_new_units(buildings, residential_units): all_units = dev.merge(old_units, new_units) all_units.index.name = 'unit_id' - print "Creating %d residential units for %d new buildings" % \ - (len(new_units), len(new_bldgs)) + print("Creating %d residential units for %d new buildings" % \ + (len(new_units), len(new_bldgs))) orca.add_table('residential_units', all_units) @@ -568,8 +568,8 @@ def assign_tenure_to_new_units(residential_units, settings): units.loc[~rental_units, 'tenure'] = 'own' units.loc[rental_units, 'tenure'] = 'rent' - print "Adding tenure assignment to %d new residential units" % len(units) - print units.describe() + print("Adding tenure assignment to %d new residential units" % len(units)) + print(units.describe()) residential_units.update_col_from_series( 'tenure', units.tenure, cast=True) @@ -630,7 +630,7 @@ def _mtc_clip(table, col_name, settings, price_scale=1): low = float(settings["rsh_simulate"]["low"]) * price_scale high = float(settings["rsh_simulate"]["high"]) * price_scale table.update_col(col_name, table[col_name].clip(low, high)) - print "Clipping produces\n", table[col_name].describe() + print("Clipping produces\n", table[col_name].describe()) @orca.step() @@ -708,9 +708,9 @@ def households_relocation(households, settings): rates = pd.DataFrame.from_dict(settings['relocation_rates']) - print "Total agents: %d" % len(households) - print "Total currently unplaced: %d" % (households.unit_id == -1).sum() - print "Assigning for relocation..." + print("Total agents: %d" % len(households)) + print("Total currently unplaced: %d" % (households.unit_id == -1).sum()) + print("Assigning for relocation...") # Initialize model, choose movers, and un-place them from buildings # and units @@ -721,7 +721,7 @@ def households_relocation(households, settings): households.update_col_from_series( 'unit_id', pd.Series(-1, index=mover_ids), cast=True) - print "Total currently unplaced: %d" % (households.unit_id == -1).sum() + print("Total currently unplaced: %d" % (households.unit_id == -1).sum()) return @@ -860,12 +860,12 @@ def balance_rental_and_ownership_hedonics(households, settings, owner_utilization = hh_rent_own.own / float(unit_rent_own.own) renter_utilization = hh_rent_own.rent / float(unit_rent_own.rent) - print "Owner utilization = %.3f" % owner_utilization - print "Renter utilization = %.3f" % renter_utilization + print("Owner utilization = %.3f" % owner_utilization) + print("Renter utilization = %.3f" % renter_utilization) utilization_ratio = renter_utilization / owner_utilization - print "Ratio of renter utilization to owner utilization = %.3f" %\ - utilization_ratio + print("Ratio of renter utilization to owner utilization = %.3f" %\ + utilization_ratio) if "original_cap_rate" not in settings: settings["original_cap_rate"] = settings["cap_rate"] @@ -876,7 +876,7 @@ def balance_rental_and_ownership_hedonics(households, settings, utilization_ratio /= factor elif utilization_ratio > 1.0: utilization_ratio *= factor - print "Modified ratio = %.3f" % utilization_ratio + print("Modified ratio = %.3f" % utilization_ratio) # adjust the cap rate based on utilization ratio - higher ratio # here means renter utilization is higher than owner utilization @@ -885,4 +885,4 @@ def balance_rental_and_ownership_hedonics(households, settings, settings["cap_rate"] = settings["original_cap_rate"] /\ utilization_ratio - print "New cap rate = %.2f" % settings["cap_rate"] + print("New cap rate = %.2f" % settings["cap_rate"]) diff --git a/baus/utils.py b/baus/utils.py index aae97ea3d..94e69dac8 100644 --- a/baus/utils.py +++ b/baus/utils.py @@ -37,7 +37,7 @@ def save_and_restore_state(in_d, outhdf="save_state.h5"): store = pd.HDFStore(outhdf) out_d = {} for table_name in store: - print "Restoring", table_name + print("Restoring", table_name) out_d[table_name[1:]] = store[table_name] return out_d @@ -49,7 +49,7 @@ def save_and_restore_state(in_d, outhdf="save_state.h5"): except: # not a dataframe wrapper continue - print "Saving", table_name + print("Saving", table_name) store[table_name] = table store.close() sys.exit(0) @@ -184,8 +184,8 @@ def constrained_normalization(marginals, constraint, total): num_constrained = len(constrained[constrained is True]) num_exceeds = len(exceeds[exceeds is True]) - print "Len constrained = %d, exceeds = %d" %\ - (num_constrained, num_exceeds) + print("Len constrained = %d, exceeds = %d" %\ + (num_constrained, num_exceeds)) if num_exceeds == 0: return marginals @@ -212,7 +212,7 @@ def simple_ipf(seed_matrix, col_marginals, row_marginals, tolerance=1, cnt=0): seed_matrix *= ratios closeness = np.absolute(row_marginals - seed_matrix.sum(axis=1)).sum() assert np.absolute(col_marginals - seed_matrix.sum(axis=0)).sum() < .01 - print "row closeness", closeness + print("row closeness", closeness) if closeness < tolerance: return seed_matrix @@ -222,7 +222,7 @@ def simple_ipf(seed_matrix, col_marginals, row_marginals, tolerance=1, cnt=0): seed_matrix = seed_matrix * ratios.reshape((ratios.size, 1)) assert np.absolute(row_marginals - seed_matrix.sum(axis=1)).sum() < .01 closeness = np.absolute(col_marginals - seed_matrix.sum(axis=0)).sum() - print "col closeness", closeness + print("col closeness", closeness) if closeness < tolerance: return seed_matrix diff --git a/baus/validation.py b/baus/validation.py index 8acfb220f..af8acb070 100644 --- a/baus/validation.py +++ b/baus/validation.py @@ -20,7 +20,7 @@ def assert_series_equal(s1, s2, head=None): # make sure the household controls are currently being matched def check_household_controls(households, household_controls, year): - print "Check household controls" + print("Check household controls") current_household_controls = household_controls.local.loc[year] current_household_controls = current_household_controls.\ set_index("base_income_quartile").total_number_of_households @@ -33,7 +33,7 @@ def check_household_controls(households, household_controls, year): # make sure the employment controls are currently being matched def check_job_controls(jobs, employment_controls, year, settings): - print "Check job controls" + print("Check job controls") current_employment_controls = employment_controls.local.loc[year] current_employment_controls = current_employment_controls.\ set_index("empsix_id").number_of_jobs @@ -48,7 +48,7 @@ def check_job_controls(jobs, employment_controls, year, settings): def check_residential_units(residential_units, buildings): - print "Check residential units" + print("Check residential units") # assert we fanned out the residential units correctly assert len(residential_units) == buildings.residential_units.sum() @@ -71,7 +71,7 @@ def check_residential_units(residential_units, buildings): # make sure everyone gets a house - this might not exist in the real world, # but due to the nature of control totals it exists here def check_no_unplaced_households(households, year): - print "Check no unplaced households" + print("Check no unplaced households") # for some reason, since we added renter/owner models, we do have # unplaced households in the first couple of years, which eventually # evens out @@ -82,13 +82,13 @@ def check_no_unplaced_households(households, year): def check_no_unplaced_jobs(jobs, year): - print "Check no unplaced jobs" + print("Check no unplaced jobs") assert -1 not in jobs.building_id.value_counts() # check not more households than units or jobs than job spaces def check_no_overfull_buildings(households, buildings): - print "Check no overfull buildings" + print("Check no overfull buildings") assert True not in (buildings.vacant_res_units < 0).value_counts() # there are overfull job spaces based on the assignment and also # proportional job model @@ -97,7 +97,7 @@ def check_no_overfull_buildings(households, buildings): # households have both unit ids and building ids - make sure they're in sync def check_unit_ids_match_building_ids(households, residential_units): - print "Check unit ids and building ids match" + print("Check unit ids and building ids match") building_ids = misc.reindex( residential_units.building_id, households.unit_id) assert_series_equal(building_ids, households.building_id, 25000) From bba7ddd010bbebd5dced622b470901f0914f28ab Mon Sep 17 00:00:00 2001 From: alephcero Date: Mon, 24 Jun 2019 10:22:07 -0300 Subject: [PATCH 03/12] changes to support NumPy 1.16 --- baus/models.py | 6 +++--- baus/utils.py | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/baus/models.py b/baus/models.py index 714884f0a..159d365a2 100644 --- a/baus/models.py +++ b/baus/models.py @@ -119,7 +119,7 @@ def _proportional_jobs_model( # city but not locations to put them in. we need to drop this demand drop = need_more_jobs.index.difference(locations_series.unique()) print("We don't have any locations for these locations:\n", drop) - need_more_jobs = need_more_jobs.drop(drop) + need_more_jobs = need_more_jobs.drop(drop).astype('int') # choose random locations within jurises to match need_more_jobs totals choices = groupby_random_choice(locations_series, need_more_jobs, @@ -523,7 +523,7 @@ def residential_developer(feasibility, households, buildings, parcels, year, year=year, form_to_btype_callback=form_to_btype_func, add_more_columns_callback=add_extra_columns_func, - num_units_to_build=target, + num_units_to_build=int(target), profit_to_prob_func=subsidies.profit_to_prob_func, **kwargs) @@ -731,7 +731,7 @@ def office_developer(feasibility, jobs, buildings, parcels, year, form_to_btype_callback=form_to_btype_func, add_more_columns_callback=add_extra_columns_func, residential=False, - num_units_to_build=target, + num_units_to_build=int(target), profit_to_prob_func=subsidies.profit_to_prob_func, **dev_settings['kwargs']) diff --git a/baus/utils.py b/baus/utils.py index 94e69dac8..47f5d4fea 100644 --- a/baus/utils.py +++ b/baus/utils.py @@ -207,8 +207,14 @@ def constrained_normalization(marginals, constraint, total): def simple_ipf(seed_matrix, col_marginals, row_marginals, tolerance=1, cnt=0): assert np.absolute(row_marginals.sum() - col_marginals.sum()) < 5.0 + # most numpy/pandas combinations will perform this conversion + # automatically, but explicit is safer - see PR #99 + if isinstance(col_marginals, pd.Series): + col_marginals = col_marginals.values + # first normalize on columns ratios = col_marginals / seed_matrix.sum(axis=0) + seed_matrix *= ratios closeness = np.absolute(row_marginals - seed_matrix.sum(axis=1)).sum() assert np.absolute(col_marginals - seed_matrix.sum(axis=0)).sum() < .01 From 030757c3e80a490c48f505d7fd07ba059696299e Mon Sep 17 00:00:00 2001 From: alephcero Date: Mon, 24 Jun 2019 13:11:03 -0300 Subject: [PATCH 04/12] change in urbansim_defaults repo branch for dependencies (change sort for sort_values) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 24ebcbc1d..53a83d7e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -e git+https://github.com/UDST/urbansim.git@master#egg=urbansim --e git+https://github.com/UDST/urbansim_defaults.git@python3#egg=urbansim_defaults +-e git+https://github.com/UDST/urbansim_defaults.git@python3-mtc#egg=urbansim_defaults -e git+https://github.com/UDST/orca.git@master#egg=orca -e git+https://github.com/UDST/orca_test.git@master#egg=orca_test boto From 64238462372a9075655ad7ded02ae054e65f1e44 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Mon, 24 Jun 2019 15:11:18 -0700 Subject: [PATCH 05/12] Revert "change in dependencies from requirements.txt " This reverts commit 2fab482749f1afd82236c74296a6b84813ef33c9. --- requirements.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 53a83d7e3..8bd415fe3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,12 @@ --e git+https://github.com/UDST/urbansim.git@master#egg=urbansim --e git+https://github.com/UDST/urbansim_defaults.git@python3-mtc#egg=urbansim_defaults --e git+https://github.com/UDST/orca.git@master#egg=orca --e git+https://github.com/UDST/orca_test.git@master#egg=orca_test +-e git+https://github.com/synthicity/urbansim.git@286e61049ac1e67c7e7a9eec8acecea704b1a332#egg=urbansim +-e git+https://github.com/synthicity/urbansim_defaults.git@8c95c2a10c5d0bcd1a470a3b636b47d8824e1254#egg=urbansim_defaults +-e git+https://github.com/UDST/orca.git@f49398e2a363f8869e14b5218640d8d9c13863a4#egg=orca +-e git+https://github.com/UDST/orca_test.git@02357bacc6a31e87b1476ff0f5b377a683e0c86a#egg=orca_test +-e git+https://github.com/UDST/pandana.git@8f24b8a1b7539c95b51153e9954f755a7116089b#egg=pandana +# using this version of anaconda http://repo.continuum.io/archive/Anaconda2-4.0.0-Linux-x86_64.sh +# to install: +# 1) get that anaconda and install +# 2) clone master (or release) of bayarea_urbansim +# 3) pip install -r requirements.txt +# run by calling `python baus.py &` boto From a5576bd2509abe3514f38e4730a6f257a72a1397 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Mon, 24 Jun 2019 15:11:41 -0700 Subject: [PATCH 06/12] Revert "changes to support NumPy 1.16" This reverts commit bba7ddd010bbebd5dced622b470901f0914f28ab. --- baus/models.py | 6 +++--- baus/utils.py | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/baus/models.py b/baus/models.py index 159d365a2..714884f0a 100644 --- a/baus/models.py +++ b/baus/models.py @@ -119,7 +119,7 @@ def _proportional_jobs_model( # city but not locations to put them in. we need to drop this demand drop = need_more_jobs.index.difference(locations_series.unique()) print("We don't have any locations for these locations:\n", drop) - need_more_jobs = need_more_jobs.drop(drop).astype('int') + need_more_jobs = need_more_jobs.drop(drop) # choose random locations within jurises to match need_more_jobs totals choices = groupby_random_choice(locations_series, need_more_jobs, @@ -523,7 +523,7 @@ def residential_developer(feasibility, households, buildings, parcels, year, year=year, form_to_btype_callback=form_to_btype_func, add_more_columns_callback=add_extra_columns_func, - num_units_to_build=int(target), + num_units_to_build=target, profit_to_prob_func=subsidies.profit_to_prob_func, **kwargs) @@ -731,7 +731,7 @@ def office_developer(feasibility, jobs, buildings, parcels, year, form_to_btype_callback=form_to_btype_func, add_more_columns_callback=add_extra_columns_func, residential=False, - num_units_to_build=int(target), + num_units_to_build=target, profit_to_prob_func=subsidies.profit_to_prob_func, **dev_settings['kwargs']) diff --git a/baus/utils.py b/baus/utils.py index 47f5d4fea..94e69dac8 100644 --- a/baus/utils.py +++ b/baus/utils.py @@ -207,14 +207,8 @@ def constrained_normalization(marginals, constraint, total): def simple_ipf(seed_matrix, col_marginals, row_marginals, tolerance=1, cnt=0): assert np.absolute(row_marginals.sum() - col_marginals.sum()) < 5.0 - # most numpy/pandas combinations will perform this conversion - # automatically, but explicit is safer - see PR #99 - if isinstance(col_marginals, pd.Series): - col_marginals = col_marginals.values - # first normalize on columns ratios = col_marginals / seed_matrix.sum(axis=0) - seed_matrix *= ratios closeness = np.absolute(row_marginals - seed_matrix.sum(axis=1)).sum() assert np.absolute(col_marginals - seed_matrix.sum(axis=0)).sum() < .01 From efbb95ff680641427cd13cf0830dce6498510038 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Mon, 24 Jun 2019 18:18:21 -0700 Subject: [PATCH 07/12] PEP8 fixes --- baus/datasources.py | 4 ++-- baus/earthquake.py | 7 ++++--- baus/models.py | 36 ++++++++++++++++++------------------ baus/preprocessing.py | 14 +++++++------- baus/subsidies.py | 43 ++++++++++++++++++++++--------------------- baus/ual.py | 40 ++++++++++++++++++++-------------------- baus/utils.py | 4 ++-- 7 files changed, 75 insertions(+), 73 deletions(-) diff --git a/baus/datasources.py b/baus/datasources.py index cc879b256..7b3a188ab 100644 --- a/baus/datasources.py +++ b/baus/datasources.py @@ -84,8 +84,8 @@ def inclusionary_housing_settings(settings, scenario): for item in s: # this is a list of cities with an inclusionary rate that is the # same for all the cities in the list - print("Setting inclusionary rates for %d cities to %.2f" %\ - (len(item["values"]), item["amount"])) + print("Setting inclusionary rates for %d cities to %.2f" % + (len(item["values"]), item["amount"])) # this is a list of inclusionary rates and the cities they apply # to - need tro turn it in a map of city names to rates for juris in item["values"]: diff --git a/baus/earthquake.py b/baus/earthquake.py index b0a86defb..3677eac37 100644 --- a/baus/earthquake.py +++ b/baus/earthquake.py @@ -259,7 +259,8 @@ def earthquake_demolish(parcels, parcels_tract, tracts_earthquake, buildings, # using the lookup table created with "parcel_tract_assignment.ipynb" census_tract = pd.Series(parcels_tract['census_tract'], parcels_tract.index) - print("Number of parcels with census tracts is: %d" % len(census_tract)) + print("Number of parcels with census tracts is: %d" % + len(census_tract)) orca.add_column('parcels', 'tract', census_tract) # group parcels by their census tract @@ -349,8 +350,8 @@ def earthquake_demolish(parcels, parcels_tract, tracts_earthquake, buildings, fire_buildings.extend(buildings_fire) eq_buildings.extend(buildings_fire) - print("Total number of buildings being destroyed is: %d" \ - % len(eq_buildings)) + print("Total number of buildings being destroyed is: %d" % + len(eq_buildings)) orca.add_injectable("eq_buildings", eq_buildings) orca.add_injectable("existing_buildings", existing_buildings) diff --git a/baus/models.py b/baus/models.py index 159d365a2..d910092ab 100644 --- a/baus/models.py +++ b/baus/models.py @@ -393,8 +393,8 @@ def add_extra_columns_func(df): if "deed_restricted_units" not in df.columns: df["deed_restricted_units"] = 0 else: - print("Number of deed restricted units built = %d" %\ - df.deed_restricted_units.sum()) + print("Number of deed restricted units built = %d" % + df.deed_restricted_units.sum()) df["redfin_sale_year"] = 2012 df["redfin_sale_price"] = np.nan @@ -503,8 +503,8 @@ def residential_developer(feasibility, households, buildings, parcels, year, for parcel_mask, target, final_target, juris in targets: - print("Running developer for %s with target of %d" % \ - (str(juris), target)) + print("Running developer for %s with target of %d" % + (str(juris), target)) # this was a fairly heinous bug - have to get the building wrapper # again because the buildings df gets modified by the run_developer @@ -693,8 +693,8 @@ def office_developer(feasibility, jobs, buildings, parcels, year, if target <= 0: print("Already met target for juris = %s" % juris) - print(" target = %d, current_total = %d" %\ - (target, current_total)) + print(" target = %d, current_total = %d" % + (target, current_total)) continue targets.append((juris_name == juris, target, juris)) @@ -709,8 +709,8 @@ def office_developer(feasibility, jobs, buildings, parcels, year, for parcel_mask, target, juris in targets: - print("Running developer for %s with target of %d" % \ - (str(juris), target)) + print("Running developer for %s with target of %d" % + (str(juris), target)) print("Parcels in play:\n", pd.Series(parcel_mask).value_counts()) # this was a fairly heinous bug - have to get the building wrapper @@ -770,12 +770,12 @@ def developer_reprocess(buildings, year, years_per_iter, jobs, add_indexes = pd.Series(add_indexes).value_counts() # this is sqft per job for residential bldgs add_sizes = add_indexes * 400 - print("Job spaces in res before adjustment: ", \ - buildings.job_spaces[s].sum()) + print("Job spaces in res before adjustment: ", + buildings.job_spaces[s].sum()) buildings.local.loc[add_sizes.index, "non_residential_sqft"] += add_sizes.values - print("Job spaces in res after adjustment: ",\ - buildings.job_spaces[s].sum()) + print("Job spaces in res after adjustment: ", + buildings.job_spaces[s].sum()) # the second step here is to add retail to buildings that are greater than # X stories tall - presumably this is a ground floor retail policy @@ -783,8 +783,8 @@ def developer_reprocess(buildings, year, years_per_iter, jobs, new_buildings = old_buildings.query( '%d == year_built and stories >= 4' % year) - print("Attempting to add ground floor retail to %d devs" % \ - len(new_buildings)) + print("Attempting to add ground floor retail to %d devs" % + len(new_buildings)) retail = parcel_is_allowed_func("retail") new_buildings = new_buildings[retail.loc[new_buildings.parcel_id].values] print("Disallowing dev on these parcels:") @@ -809,8 +809,8 @@ def developer_reprocess(buildings, year, years_per_iter, jobs, ratio = parcels.retail_ratio.loc[new_buildings.parcel_id] new_buildings = new_buildings[ratio.values > ratio.median()] - print("Adding %d sqft of ground floor retail in %d locations" % \ - (new_buildings.non_residential_sqft.sum(), len(new_buildings))) + print("Adding %d sqft of ground floor retail in %d locations" % + (new_buildings.non_residential_sqft.sum(), len(new_buildings))) all_buildings = dev.merge(old_buildings, new_buildings) orca.add_table("buildings", all_buildings) @@ -829,8 +829,8 @@ def developer_reprocess(buildings, year, years_per_iter, jobs, ['year_built', 'building_sqft', 'general_type']) sqft_by_gtype = buildings_df.query('year_built >= %d' % year).\ groupby('general_type').building_sqft.sum() - print("New square feet by general type in millions:\n",\ - sqft_by_gtype / 1000000.0) + print("New square feet by general type in millions:\n", + sqft_by_gtype / 1000000.0) def proportional_job_allocation(parcel_id): diff --git a/baus/preprocessing.py b/baus/preprocessing.py index 40bff2622..79bacb60e 100644 --- a/baus/preprocessing.py +++ b/baus/preprocessing.py @@ -158,14 +158,14 @@ def assign_deed_restricted_units(df, parcels): units = pd.Series(buildings_ids.index.values).value_counts() df.loc[units.index, "deed_restricted_units"] += units.values - print("Total deed restricted units after random selection: %d" % \ - df.deed_restricted_units.sum()) + print("Total deed restricted units after random selection: %d" % + df.deed_restricted_units.sum()) df["deed_restricted_units"] = \ df[["deed_restricted_units", "residential_units"]].min(axis=1) - print("Total deed restricted units after truncating to res units: %d" % \ - df.deed_restricted_units.sum()) + print("Total deed restricted units after truncating to res units: %d" % + df.deed_restricted_units.sum()) return df @@ -250,9 +250,9 @@ def correct_baseyear_vacancies(buildings, parcels, jobs, store): jobs_county = misc.reindex(buildings_county, jobs.building_id) - print("Vacancy rate by county:\n", \ - buildings.job_spaces.groupby(buildings_county).sum() / \ - jobs_county.value_counts() - 1.0) + print("Vacancy rate by county:\n", + buildings.job_spaces.groupby(buildings_county).sum() / + jobs_county.value_counts() - 1.0) jobs_juris = misc.reindex(buildings_juris, jobs.building_id) diff --git a/baus/subsidies.py b/baus/subsidies.py index f4584c3f7..bd9f0ff04 100644 --- a/baus/subsidies.py +++ b/baus/subsidies.py @@ -182,11 +182,11 @@ def policy_modifications_of_profit(feasibility, parcels): assert np.all(num_affordable_units <= units.fillna(0)) - print("Describe of inclusionary revenue reduction:\n", \ - revenue_reduction[revenue_reduction > 0].describe()) + print("Describe of inclusionary revenue reduction:\n", + revenue_reduction[revenue_reduction > 0].describe()) - print("Describe of number of affordable units:\n", \ - num_affordable_units[num_affordable_units > 0].describe()) + print("Describe of number of affordable units:\n", + num_affordable_units[num_affordable_units > 0].describe()) feasibility[("residential", "policy_based_revenue_reduction")] = \ revenue_reduction @@ -207,7 +207,8 @@ def policy_modifications_of_profit(feasibility, parcels): pct_modifications = feasibility[("residential", "vmt_res_cat")].\ map(sb743_settings["sb743_pcts"]) + 1 - print("Modifying profit for SB743:\n", pct_modifications.describe()) + print("Modifying profit for SB743:\n", + pct_modifications.describe()) feasibility[("residential", "max_profit")] *= pct_modifications @@ -231,8 +232,8 @@ def policy_modifications_of_profit(feasibility, parcels): pct_modifications = \ pct_modifications.reindex(pzc.index).fillna(1.0) - print("Modifying profit for Land Value Tax:\n", \ - pct_modifications.describe()) + print("Modifying profit for Land Value Tax:\n", + pct_modifications.describe()) feasibility[("residential", "max_profit")] *= pct_modifications @@ -252,13 +253,13 @@ def policy_modifications_of_profit(feasibility, parcels): policy["profitability_adjustment_formula"]) pct_modifications += 1.0 - print("Modifying profit for %s:\n" % policy["name"], \ - pct_modifications.describe()) + print("Modifying profit for %s:\n" % policy["name"], + pct_modifications.describe()) feasibility[("residential", "max_profit")] *= pct_modifications - print("There are %d affordable units if all feasible projects are built" %\ - feasibility[("residential", "deed_restricted_units")].sum()) + print("There are %d affordable units if all feasible projects are built" % + feasibility[("residential", "deed_restricted_units")].sum()) return feasibility @@ -294,8 +295,8 @@ def calculate_vmt_fees(settings, year, buildings, vmt_fee_categories, coffer, df["com_for_res_fees"] = df.vmt_res_cat.map( vmt_settings["com_for_res_fee_amounts"]) total_fees += (df.com_for_res_fees * df.non_residential_sqft).sum() - print("Applying vmt fees to %d commerical sqft" % \ - df.non_residential_sqft.sum()) + print("Applying vmt fees to %d commerical sqft" % + df.non_residential_sqft.sum()) print("Adding total vmt fees for res amount of $%.2f" % total_fees) @@ -315,8 +316,8 @@ def calculate_vmt_fees(settings, year, buildings, vmt_fee_categories, coffer, df["com_for_com_fees"] = df.vmt_res_cat.map( vmt_settings["com_for_com_fee_amounts"]) total_fees += (df.com_for_com_fees * df.non_residential_sqft).sum() - print("Applying vmt fees to %d commerical sqft" % \ - df.non_residential_sqft.sum()) + print("Applying vmt fees to %d commerical sqft" % + df.non_residential_sqft.sum()) print("Adding total vmt fees for com amount of $%.2f" % total_fees) @@ -629,8 +630,8 @@ def run_subsidized_developer(feasibility, parcels, buildings, households, assert np.all(buildings.local.deed_restricted_units.fillna(0) <= buildings.local.residential_units.fillna(0)) - print("Amount left after subsidy: ${:,.2f}".\ - format(account.total_transactions_by_subacct(subacct))) + print("Amount left after subsidy: ${:,.2f}". + format(account.total_transactions_by_subacct(subacct))) new_buildings_list.append(new_buildings) @@ -641,10 +642,10 @@ def run_subsidized_developer(feasibility, parcels, buildings, households, new_buildings = pd.concat(new_buildings_list) print("Built {} total subsidized buildings".format(len(new_buildings))) - print(" Total subsidy: ${:,.2f}".format( - -1*new_buildings.max_profit.sum())) - print(" Total subsidized units: {:.0f}".\ - format(new_buildings.residential_units.sum())) + print(" Total subsidy: ${:,.2f}". + format(-1*new_buildings.max_profit.sum())) + print(" Total subsidized units: {:.0f}". + format(new_buildings.residential_units.sum())) new_buildings["subsidized"] = True new_buildings["policy_name"] = policy_name diff --git a/baus/ual.py b/baus/ual.py index 439564556..a9f28c988 100644 --- a/baus/ual.py +++ b/baus/ual.py @@ -158,10 +158,10 @@ def assign_tenure_to_units(residential_units, households): units.loc[own, 'tenure'] = 'own' units.loc[rent, 'tenure'] = 'rent' - print("Init unit tenure assignment: %d%% owner occupied, %d%% unfilled" % \ - (round(len(units[units.tenure == 'own'])*100 / - len(units[units.tenure.notnull()])), - round(len(units[units.tenure.isnull()])*100 / len(units)))) + print("Init unit tenure assignment: %d%% owner occupied, %d%% unfilled" % + (round(len(units[units.tenure == 'own'])*100 / + len(units[units.tenure.notnull()])), + round(len(units[units.tenure.isnull()])*100 / len(units)))) # Fill remaining units with random tenure assignment # TO DO: Make this weighted by existing allocation, rather than 50/50 @@ -366,14 +366,14 @@ def reconcile_unplaced_households(households): ''' def _print_status(): - print("Households not in a unit: %d" % \ - (households.unit_id == -1).sum()) - print("Househing missing a unit: %d" % \ - households.unit_id.isnull().sum()) - print("Households not in a building: %d" % \ - (households.building_id == -1).sum()) - print("Househing missing a building: %d" % \ - households.building_id.isnull().sum()) + print("Households not in a unit: %d" % + (households.unit_id == -1).sum()) + print("Househing missing a unit: %d" % + households.unit_id.isnull().sum()) + print("Households not in a building: %d" % + (households.building_id == -1).sum()) + print("Househing missing a building: %d" % + households.building_id.isnull().sum()) _print_status() print("Reconciling unplaced households...") @@ -437,10 +437,10 @@ def remove_old_units(buildings, residential_units): units = residential_units.to_frame(residential_units.local_columns) current_units = units[units.building_id.isin(buildings.index)] - print("Removing %d units from %d buildings that no longer exist" % \ - ((len(units) - len(current_units)), - (len(units.groupby('building_id')) - - len(current_units.groupby('building_id'))))) + print("Removing %d units from %d buildings that no longer exist" % + ((len(units) - len(current_units)), + (len(units.groupby('building_id')) - + len(current_units.groupby('building_id'))))) orca.add_table('residential_units', current_units) @@ -503,8 +503,8 @@ def initialize_new_units(buildings, residential_units): all_units = dev.merge(old_units, new_units) all_units.index.name = 'unit_id' - print("Creating %d residential units for %d new buildings" % \ - (len(new_units), len(new_bldgs))) + print("Creating %d residential units for %d new buildings" % + (len(new_units), len(new_bldgs))) orca.add_table('residential_units', all_units) @@ -864,8 +864,8 @@ def balance_rental_and_ownership_hedonics(households, settings, print("Renter utilization = %.3f" % renter_utilization) utilization_ratio = renter_utilization / owner_utilization - print("Ratio of renter utilization to owner utilization = %.3f" %\ - utilization_ratio) + print("Ratio of renter utilization to owner utilization = %.3f" % + utilization_ratio) if "original_cap_rate" not in settings: settings["original_cap_rate"] = settings["cap_rate"] diff --git a/baus/utils.py b/baus/utils.py index e8d93c50b..27cf4034e 100644 --- a/baus/utils.py +++ b/baus/utils.py @@ -184,8 +184,8 @@ def constrained_normalization(marginals, constraint, total): num_constrained = len(constrained[constrained is True]) num_exceeds = len(exceeds[exceeds is True]) - print("Len constrained = %d, exceeds = %d" %\ - (num_constrained, num_exceeds)) + print("Len constrained = %d, exceeds = %d" % + (num_constrained, num_exceeds)) if num_exceeds == 0: return marginals From 2c865dd3c13f84636a342be1c61c73a7097da403 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Mon, 24 Jun 2019 18:34:15 -0700 Subject: [PATCH 08/12] __future__ imports --- baus/datasources.py | 2 ++ baus/earthquake.py | 2 ++ baus/models.py | 2 ++ baus/preprocessing.py | 2 ++ baus/slr.py | 2 ++ baus/subsidies.py | 4 +++- baus/ual.py | 2 ++ baus/utils.py | 2 ++ baus/validation.py | 2 ++ 9 files changed, 19 insertions(+), 1 deletion(-) diff --git a/baus/datasources.py b/baus/datasources.py index 7b3a188ab..48ca436eb 100644 --- a/baus/datasources.py +++ b/baus/datasources.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import numpy as np import pandas as pd import os diff --git a/baus/earthquake.py b/baus/earthquake.py index 3677eac37..70bc14ac8 100644 --- a/baus/earthquake.py +++ b/baus/earthquake.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import orca import numpy as np import pandas as pd diff --git a/baus/models.py b/baus/models.py index d910092ab..96e793f49 100644 --- a/baus/models.py +++ b/baus/models.py @@ -1,3 +1,5 @@ +from __future__ import print_function + from urbansim.utils import misc import os import sys diff --git a/baus/preprocessing.py b/baus/preprocessing.py index 79bacb60e..01aaf34f3 100644 --- a/baus/preprocessing.py +++ b/baus/preprocessing.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import orca import pandas as pd from urbansim.utils import misc diff --git a/baus/slr.py b/baus/slr.py index 181d1803b..d96e98645 100644 --- a/baus/slr.py +++ b/baus/slr.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import orca import numpy as np import pandas as pd diff --git a/baus/subsidies.py b/baus/subsidies.py index bd9f0ff04..5db439d9b 100644 --- a/baus/subsidies.py +++ b/baus/subsidies.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import sys import time import orca @@ -207,7 +209,7 @@ def policy_modifications_of_profit(feasibility, parcels): pct_modifications = feasibility[("residential", "vmt_res_cat")].\ map(sb743_settings["sb743_pcts"]) + 1 - print("Modifying profit for SB743:\n", + print("Modifying profit for SB743:\n", pct_modifications.describe()) feasibility[("residential", "max_profit")] *= pct_modifications diff --git a/baus/ual.py b/baus/ual.py index a9f28c988..6eb6477e4 100644 --- a/baus/ual.py +++ b/baus/ual.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import os import math import yaml diff --git a/baus/utils.py b/baus/utils.py index 27cf4034e..aa592757d 100644 --- a/baus/utils.py +++ b/baus/utils.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import pandas as pd import numpy as np import orca diff --git a/baus/validation.py b/baus/validation.py index af8acb070..1220aed6b 100644 --- a/baus/validation.py +++ b/baus/validation.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import sys import os import orca From f2f48aaac6803ed5b4c5599659777f660291c13d Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Mon, 24 Jun 2019 20:00:27 -0700 Subject: [PATCH 09/12] PEP8 fix for baus.py --- baus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/baus.py b/baus.py index c1ad92ed6..bbd9bb3ac 100644 --- a/baus.py +++ b/baus.py @@ -110,8 +110,8 @@ run_num = orca.get_injectable("run_number") if LOGS: - print('***The Standard stream is being written to /runs/run{0}.log***'\ - .format(run_num)) + print('***The Standard stream is being written to /runs/run{0}.log***' + .format(run_num)) sys.stdout = sys.stderr = open("runs/run%d.log" % run_num, 'w') if RANDOM_SEED: From 8899c865a98f1343126339e69dc637922bc8d632 Mon Sep 17 00:00:00 2001 From: Elizabeth Theocharides Date: Mon, 23 Sep 2019 12:23:45 -0700 Subject: [PATCH 10/12] remove white space --- baus/slr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baus/slr.py b/baus/slr.py index da22d238b..2c201f440 100644 --- a/baus/slr.py +++ b/baus/slr.py @@ -31,7 +31,7 @@ def slr_inundate(scenario, parcels, slr_progression_C, slr_progression_R, inundation_yr = slr_progression.query('year==@year')['inundated'].item() print("Inundation in model year is %d inches" % inundation_yr) - + if scenario in settings["slr_scenarios"]["mitigation_full"]: slr_parcel_inundation = slr_parcel_inundation_mf.to_frame() orca.add_injectable("slr_mitigation", 'full mitigation') From 7d82626087fbf74d329116eedbb6c8da153ab1fd Mon Sep 17 00:00:00 2001 From: Elizabeth Theocharides Date: Mon, 23 Sep 2019 12:27:49 -0700 Subject: [PATCH 11/12] add python 2 print compatibility --- baus.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/baus.py b/baus.py index 6c9160b27..4bdb732f8 100644 --- a/baus.py +++ b/baus.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import os import sys import time From 9f4fefdb1cbc6cd8e158bc13e73f51a03bab33c1 Mon Sep 17 00:00:00 2001 From: Elizabeth Theocharides Date: Mon, 23 Sep 2019 12:55:37 -0700 Subject: [PATCH 12/12] import python 2 compatibility --- baus/summaries.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/baus/summaries.py b/baus/summaries.py index f3269b1f8..c888b1755 100644 --- a/baus/summaries.py +++ b/baus/summaries.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import sys import os import orca