Commit ebea4eea authored by shinde's avatar shinde
Browse files

Applied black check

parent d93a5946
Pipeline #27741 passed with stage
in 5 minutes and 11 seconds
......@@ -355,13 +355,9 @@ 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,
......@@ -407,9 +403,7 @@ 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,
......@@ -452,12 +446,8 @@ 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,
......@@ -604,9 +594,7 @@ 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, "
......@@ -618,8 +606,7 @@ 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()
......@@ -675,9 +662,7 @@ 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])
......@@ -703,11 +688,7 @@ class JapanDatabase(SpatialiteDatabase):
for material_id in range(5):
dwelling_number = float(str(row[4 + material_id]).replace("-", "0"))
self.insert_dwelling_number(
district_id,
building_type_id,
material_id,
story_number_id,
dwelling_number,
district_id, building_type_id, material_id, story_number_id, dwelling_number
)
logger.debug(
"Dwelling number for district %s, type %s, %s added"
......@@ -750,11 +731,7 @@ class JapanDatabase(SpatialiteDatabase):
if material_id == 2:
material_id = 4
self.insert_building_number(
district_id,
building_type_id,
material_id,
story_number_id,
building_number,
district_id, building_type_id, material_id, story_number_id, building_number
)
logger.debug(
"Building number for district %s, type %s, %s added"
......@@ -886,9 +863,7 @@ 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,
......@@ -911,9 +886,7 @@ 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"])
......@@ -959,15 +932,11 @@ 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