Test driven partial corrections

This commit is contained in:
Guille Gutierrez 2021-11-16 07:57:47 -05:00
parent 155daa47b7
commit a692f9c22a
8 changed files with 10 additions and 9 deletions

View File

@ -21,8 +21,8 @@ class Obj:
with open(path, 'r') as file: with open(path, 'r') as file:
self._scene = trimesh.exchange.load.load(file, file_type='obj', force='scene') self._scene = trimesh.exchange.load.load(file, file_type='obj', force='scene')
self._corners = self._scene.bounds_corners self._corners = self._scene.bounds_corners
_bound_corner_min = [] _bound_corner_min = None
_bound_corner_max = [] _bound_corner_max = None
for corner in self._corners: for corner in self._corners:
if _bound_corner_min is None: if _bound_corner_min is None:
_bound_corner_min = corner _bound_corner_min = corner

View File

@ -19,6 +19,6 @@ class LcaFuel:
with open(path) as xml: with open(path) as xml:
self._lca = xmltodict.parse(xml.read()) 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'], self._city.fuels.append(Fuel(fuel['@id'], fuel['@name'], fuel['carbon_emission_factor']['#text'],
fuel['carbon_emission_factor']['@unit'])) fuel['carbon_emission_factor']['@unit']))

View File

@ -19,7 +19,7 @@ class LcaMachine:
with open(path) as xml: with open(path) as xml:
self._lca = xmltodict.parse(xml.read()) 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'], self._city.machines.append(Machine(machine['@id'], machine['@name'], machine['work_efficiency']['#text'],
machine['work_efficiency']['@unit'], machine['energy_consumption_rate']['#text'], machine['work_efficiency']['@unit'], machine['energy_consumption_rate']['#text'],
machine['energy_consumption_rate']['@unit'], machine['carbon_emission_factor']['#text'], machine['energy_consumption_rate']['@unit'], machine['carbon_emission_factor']['#text'],

View File

@ -19,7 +19,7 @@ class LcaVehicle:
with open(path) as xml: with open(path) as xml:
self._lca = xmltodict.parse(xml.read()) 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'], 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['fuel_consumption_rate']['@unit'], vehicle['carbon_emission_factor']['#text'],
vehicle['carbon_emission_factor']['@unit'])) vehicle['carbon_emission_factor']['@unit']))

View File

@ -8,7 +8,7 @@ from pathlib import Path
from imports.life_cycle_assessment.lca_fuel import LcaFuel from imports.life_cycle_assessment.lca_fuel import LcaFuel
from imports.life_cycle_assessment.lca_vehicle import LcaVehicle from imports.life_cycle_assessment.lca_vehicle import LcaVehicle
from imports.life_cycle_assessment.lca_machine import LcaMachine 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: class LifeCycleAssessment:

View File

@ -45,7 +45,7 @@ class TestExports(TestCase):
else: else:
file_path = (self._example_path / 'one_building_in_kelowna.gml').resolve() file_path = (self._example_path / 'one_building_in_kelowna.gml').resolve()
self._complete_city = self._get_citygml(file_path) 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() UsageFactory('ca', self._complete_city).enrich()
SchedulesFactory('comnet', self._complete_city).enrich() SchedulesFactory('comnet', self._complete_city).enrich()
cli = 'C:\\Users\\Pilar\\PycharmProjects\\monthlyenergybalance\\tests_data\\weather\\inseldb_Summerland.cli' cli = 'C:\\Users\\Pilar\\PycharmProjects\\monthlyenergybalance\\tests_data\\weather\\inseldb_Summerland.cli'

View File

@ -9,6 +9,7 @@ from unittest import TestCase
from imports.geometry_factory import GeometryFactory from imports.geometry_factory import GeometryFactory
from imports.usage_factory import UsageFactory from imports.usage_factory import UsageFactory
from imports.geometry.helpers.geometry_helper import GeometryHelper from imports.geometry.helpers.geometry_helper import GeometryHelper
from imports.construction_factory import ConstructionFactory
class TestUsageFactory(TestCase): class TestUsageFactory(TestCase):
@ -38,7 +39,7 @@ class TestUsageFactory(TestCase):
city = self._get_citygml(file) city = self._get_citygml(file)
for building in city.buildings: for building in city.buildings:
building.function = GeometryHelper.pluto_to_function[building.function] building.function = GeometryHelper.pluto_to_function[building.function]
ConstructionFactory('nrel', city).enrich()
UsageFactory('hft', city).enrich() UsageFactory('hft', city).enrich()
for building in city.buildings: for building in city.buildings:
self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined') self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined')
@ -61,7 +62,7 @@ class TestUsageFactory(TestCase):
# case 2: CA # case 2: CA
file = 'one_building_in_kelowna.gml' file = 'one_building_in_kelowna.gml'
city = self._get_citygml(file) city = self._get_citygml(file)
ConstructionFactory('nrel', city).enrich()
UsageFactory('ca', city).enrich() UsageFactory('ca', city).enrich()
for building in city.buildings: for building in city.buildings:
self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined') self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined')