Commit 2f3a8bac authored by shinde's avatar shinde
Browse files

Conducted black check

parent c12c6142
Pipeline #27674 failed with stage
in 5 minutes and 17 seconds
......@@ -355,9 +355,13 @@ class JapanDatabase(SpatialiteDatabase):
"""
sql_statement = "INSERT INTO HouseholdData "
sql_statement += "(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
sql_statement += (
"(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
)
sql_statement += "number_dwelling, number_household, number_household_member, "
sql_statement += "rooms_per_dwelling, tatami_per_dwelling, floorspace_per_dwelling, "
sql_statement += (
"rooms_per_dwelling, tatami_per_dwelling, floorspace_per_dwelling, "
)
sql_statement += "tatami_per_person, person_per_room) "
sql_statement += "VALUES (%d, %d, %d, %d, %f, %f, %f, %f, %f, %f, %f, %f)" % (
district_id,
......@@ -403,7 +407,9 @@ class JapanDatabase(SpatialiteDatabase):
"""
sql_statement = "INSERT INTO DwellingFloorspace "
sql_statement += "(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
sql_statement += (
"(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
)
sql_statement += "construction_material_id, floorspace) "
sql_statement += "VALUES (%d, %d, %d, %d, %d, %f)" % (
district_id,
......@@ -446,8 +452,12 @@ class JapanDatabase(SpatialiteDatabase):
"""
sql_statement = "INSERT INTO DwellingDistribution "
sql_statement += "(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
sql_statement += "construction_material_id, dwelling_size_type_id, number_dwelling) "
sql_statement += (
"(district_id, building_type_id, dwelling_type_id, tenure_type_id, "
)
sql_statement += (
"construction_material_id, dwelling_size_type_id, number_dwelling) "
)
sql_statement += "VALUES (%d, %d, %d, %d, %d, %d, %f)" % (
district_id,
building_type_id,
......@@ -594,7 +604,9 @@ class JapanDatabase(SpatialiteDatabase):
File path to the boundary file
"""
boundary_db = SpatialiteDatabase(district_boundary_filepath, self.spatialite_filepath)
boundary_db = SpatialiteDatabase(
district_boundary_filepath, self.spatialite_filepath
)
boundary_db.connect(init_spatial_metadata=False)
sql_statement = "SELECT key_code_ward, "
......@@ -606,7 +618,8 @@ class JapanDatabase(SpatialiteDatabase):
self.insert_district(
row[0],
row[1],
"ST_Transform(CastToMultiPolygon(GeomFromText('%s', 4612)), 4326)" % row[2],
"ST_Transform(CastToMultiPolygon(GeomFromText('%s', 4612)), 4326)"
% row[2],
)
logger.debug("District %d with boundary added" % row[0])
self.connection.commit()
......@@ -662,7 +675,9 @@ class JapanDatabase(SpatialiteDatabase):
# Read numbers of dwellings
dwelling_numbers_input = pandas.read_excel(
dwelling_numbers_filepath, header=10, usecols=[4, 5, 7, 9, 10, 11, 12, 13, 14]
dwelling_numbers_filepath,
header=10,
usecols=[4, 5, 7, 9, 10, 11, 12, 13, 14],
)
for index, row in dwelling_numbers_input.iterrows():
admin_id = int((row["Area classification"].split("_"))[0])
......@@ -692,7 +707,7 @@ class JapanDatabase(SpatialiteDatabase):
building_type_id,
material_id,
story_number_id,
dwelling_number
dwelling_number,
)
logger.debug(
"Dwelling number for district %s, type %s, %s added"
......@@ -739,7 +754,7 @@ class JapanDatabase(SpatialiteDatabase):
building_type_id,
material_id,
story_number_id,
building_number
building_number,
)
logger.debug(
"Building number for district %s, type %s, %s added"
......@@ -871,7 +886,9 @@ class JapanDatabase(SpatialiteDatabase):
# Prepare and insert the data to the DwellingDistribution table
for dwelling_size_type_id in range(7):
number_dwelling = float(str(row[6 + dwelling_size_type_id]).replace("-", "0"))
number_dwelling = float(
str(row[6 + dwelling_size_type_id]).replace("-", "0")
)
self.insert_dwelling_distribution(
district_id,
building_type_id,
......@@ -894,7 +911,9 @@ class JapanDatabase(SpatialiteDatabase):
logger.info("Number and sizes of dwellings added")
# Read Population
population_input = pandas.read_csv(population_filepath, usecols=[2, 9, 10, 11, 12])
population_input = pandas.read_csv(
population_filepath, usecols=[2, 9, 10, 11, 12]
)
for index, row in population_input.iterrows():
admin_id = int(row["KEY_CODE"])
......@@ -940,11 +959,15 @@ class JapanDatabase(SpatialiteDatabase):
for construction_material_id, construction_material in enumerate(
construction_material_list
):
self.insert_construction_material(construction_material_id, construction_material)
self.insert_construction_material(
construction_material_id, construction_material
)
logger.info("Construction-material types added")
# Add the types of dwelling sizes to the database
for dwelling_size_type_id, dwelling_size_type in enumerate(dwelling_size_type_list):
for dwelling_size_type_id, dwelling_size_type in enumerate(
dwelling_size_type_list
):
self.insert_dwelling_size_type(dwelling_size_type_id, dwelling_size_type)
logger.info("Dwelling-size types added")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment