From a692f9c22a933f62149bf506ca704d16a946360d Mon Sep 17 00:00:00 2001 From: guille Date: Tue, 16 Nov 2021 07:57:47 -0500 Subject: [PATCH] Test driven partial corrections --- .../lca_data.xml | 0 imports/geometry/obj.py | 4 ++-- imports/life_cycle_assessment/lca_fuel.py | 2 +- imports/life_cycle_assessment/lca_machine.py | 2 +- imports/life_cycle_assessment/lca_vehicle.py | 2 +- imports/life_cycle_assessment_factory.py | 2 +- unittests/test_exports.py | 2 +- unittests/test_usage_factory.py | 5 +++-- 8 files changed, 10 insertions(+), 9 deletions(-) rename data/{life_cicle_analize => life_cycle_assessment}/lca_data.xml (100%) diff --git a/data/life_cicle_analize/lca_data.xml b/data/life_cycle_assessment/lca_data.xml similarity index 100% rename from data/life_cicle_analize/lca_data.xml rename to data/life_cycle_assessment/lca_data.xml diff --git a/imports/geometry/obj.py b/imports/geometry/obj.py index 5c7fdd5b..6349921b 100644 --- a/imports/geometry/obj.py +++ b/imports/geometry/obj.py @@ -21,8 +21,8 @@ class Obj: with open(path, 'r') as file: self._scene = trimesh.exchange.load.load(file, file_type='obj', force='scene') self._corners = self._scene.bounds_corners - _bound_corner_min = [] - _bound_corner_max = [] + _bound_corner_min = None + _bound_corner_max = None for corner in self._corners: if _bound_corner_min is None: _bound_corner_min = corner diff --git a/imports/life_cycle_assessment/lca_fuel.py b/imports/life_cycle_assessment/lca_fuel.py index 2ffbcb37..c35e0749 100644 --- a/imports/life_cycle_assessment/lca_fuel.py +++ b/imports/life_cycle_assessment/lca_fuel.py @@ -19,6 +19,6 @@ class LcaFuel: with open(path) as xml: self._lca = xmltodict.parse(xml.read()) - for fuel in self._lca["library"]["fuels"]['fuel']: + for fuel in self._lca["library"]["Fuels"]['fuel']: self._city.fuels.append(Fuel(fuel['@id'], fuel['@name'], fuel['carbon_emission_factor']['#text'], fuel['carbon_emission_factor']['@unit'])) diff --git a/imports/life_cycle_assessment/lca_machine.py b/imports/life_cycle_assessment/lca_machine.py index ae90c03c..0ecae0c8 100644 --- a/imports/life_cycle_assessment/lca_machine.py +++ b/imports/life_cycle_assessment/lca_machine.py @@ -19,7 +19,7 @@ class LcaMachine: with open(path) as xml: self._lca = xmltodict.parse(xml.read()) - for machine in self._lca["library"]["machines"]['machine']: + for machine in self._lca["library"]["Machines"]['machine']: self._city.machines.append(Machine(machine['@id'], machine['@name'], machine['work_efficiency']['#text'], machine['work_efficiency']['@unit'], machine['energy_consumption_rate']['#text'], machine['energy_consumption_rate']['@unit'], machine['carbon_emission_factor']['#text'], diff --git a/imports/life_cycle_assessment/lca_vehicle.py b/imports/life_cycle_assessment/lca_vehicle.py index 79da498f..55cef922 100644 --- a/imports/life_cycle_assessment/lca_vehicle.py +++ b/imports/life_cycle_assessment/lca_vehicle.py @@ -19,7 +19,7 @@ class LcaVehicle: with open(path) as xml: self._lca = xmltodict.parse(xml.read()) - for vehicle in self._lca["library"]["vehicles"]['vehicle']: + for vehicle in self._lca["library"]["Vehicles"]['vehicle']: self._city.vehicles.append(Vehicle(vehicle['@id'], vehicle['@name'], vehicle['fuel_consumption_rate']['#text'], vehicle['fuel_consumption_rate']['@unit'], vehicle['carbon_emission_factor']['#text'], vehicle['carbon_emission_factor']['@unit'])) diff --git a/imports/life_cycle_assessment_factory.py b/imports/life_cycle_assessment_factory.py index cb99b981..66e1f609 100644 --- a/imports/life_cycle_assessment_factory.py +++ b/imports/life_cycle_assessment_factory.py @@ -8,7 +8,7 @@ from pathlib import Path from imports.life_cycle_assessment.lca_fuel import LcaFuel from imports.life_cycle_assessment.lca_vehicle import LcaVehicle from imports.life_cycle_assessment.lca_machine import LcaMachine -from imports.life_cycle_assessment.lca_material import LcaMaterial +# from imports.life_cycle_assessment.lca_material import LcaMaterial class LifeCycleAssessment: diff --git a/unittests/test_exports.py b/unittests/test_exports.py index 5b25b4e1..b4c38be1 100644 --- a/unittests/test_exports.py +++ b/unittests/test_exports.py @@ -45,7 +45,7 @@ class TestExports(TestCase): else: file_path = (self._example_path / 'one_building_in_kelowna.gml').resolve() self._complete_city = self._get_citygml(file_path) - ConstructionFactory('ca', self._complete_city).enrich() + ConstructionFactory('nrel', self._complete_city).enrich() UsageFactory('ca', self._complete_city).enrich() SchedulesFactory('comnet', self._complete_city).enrich() cli = 'C:\\Users\\Pilar\\PycharmProjects\\monthlyenergybalance\\tests_data\\weather\\inseldb_Summerland.cli' diff --git a/unittests/test_usage_factory.py b/unittests/test_usage_factory.py index 82c692a1..7281f86d 100644 --- a/unittests/test_usage_factory.py +++ b/unittests/test_usage_factory.py @@ -9,6 +9,7 @@ from unittest import TestCase from imports.geometry_factory import GeometryFactory from imports.usage_factory import UsageFactory from imports.geometry.helpers.geometry_helper import GeometryHelper +from imports.construction_factory import ConstructionFactory class TestUsageFactory(TestCase): @@ -38,7 +39,7 @@ class TestUsageFactory(TestCase): city = self._get_citygml(file) for building in city.buildings: building.function = GeometryHelper.pluto_to_function[building.function] - + ConstructionFactory('nrel', city).enrich() UsageFactory('hft', city).enrich() for building in city.buildings: self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined') @@ -61,7 +62,7 @@ class TestUsageFactory(TestCase): # case 2: CA file = 'one_building_in_kelowna.gml' city = self._get_citygml(file) - + ConstructionFactory('nrel', city).enrich() UsageFactory('ca', city).enrich() for building in city.buildings: self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined')