From 5281b63de214f13d537b411c086a2b792d319031 Mon Sep 17 00:00:00 2001 From: guille Date: Tue, 29 Mar 2022 07:33:04 -0400 Subject: [PATCH] Remove unneeded files and wrong unittest, partial usage factory test correction --- .../iot/concordia_energy_sensor.py | 45 -------------- .../iot/concordia_gas_flow_sensor.py | 45 -------------- .../iot/concordia_temperature_sensor.py | 45 -------------- unittests/test_sensors_factory.py | 58 ------------------- unittests/test_usage_factory.py | 2 +- 5 files changed, 1 insertion(+), 194 deletions(-) delete mode 100644 city_model_structure/iot/concordia_energy_sensor.py delete mode 100644 city_model_structure/iot/concordia_gas_flow_sensor.py delete mode 100644 city_model_structure/iot/concordia_temperature_sensor.py delete mode 100644 unittests/test_sensors_factory.py diff --git a/city_model_structure/iot/concordia_energy_sensor.py b/city_model_structure/iot/concordia_energy_sensor.py deleted file mode 100644 index afc7b930..00000000 --- a/city_model_structure/iot/concordia_energy_sensor.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -Energy Sensor module -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca -""" - -import pandas as pd -from city_model_structure.iot.sensor import Sensor - - -class ConcordiaEnergySensor(Sensor): - """ - Concordia energy sensor. - """ - - def __init__(self, name): - super().__init__() - self._name = name - self._interval = 5 - self._interval_units = 'minutes' - self._type = 'ConcordiaEnergySensor' - self._units = 'kW' - self._measures = pd.DataFrame(columns=["Date time", "Energy consumption"]) - - @property - def measures(self) -> pd.DataFrame: - """ - Get sensor measures [yyyy-mm-dd, hh:mm:ss kW] - :return: DataFrame["Date time", "Energy consumption"] - """ - return self._measures - - @measures.deleter - def measures(self): - """ - Delete sensor measures - """ - self._measures.drop = None - - def add_period(self, measures): - """ - Add or update a period measures to the dataframe - """ - measures = self._measures.append(measures, ignore_index=True) - self._measures = measures.drop_duplicates('Date time', keep='last') diff --git a/city_model_structure/iot/concordia_gas_flow_sensor.py b/city_model_structure/iot/concordia_gas_flow_sensor.py deleted file mode 100644 index 86da31bd..00000000 --- a/city_model_structure/iot/concordia_gas_flow_sensor.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -Gas Flow Sensor module -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca -""" - -import pandas as pd -from city_model_structure.iot.sensor import Sensor - - -class ConcordiaGasFlowSensor(Sensor): - """ - Concordia gas flow sensor. - """ - - def __init__(self, name): - super().__init__() - self._name = name - self._interval = 5 - self._interval_units = 'minutes' - self._type = 'ConcordiaGasFlowSensor' - self._units = 'm3' - self._measures = pd.DataFrame(columns=["Date time", "Gas Flow Cumulative Monthly"]) - - @property - def measures(self) -> pd.DataFrame: - """ - Get sensor measures [yyyy-mm-dd, hh:mm:ss m3] - :return: DataFrame["Date time", "Gas Flow Cumulative Monthly"] - """ - return self._measures - - @measures.deleter - def measures(self): - """ - Delete sensor measures - """ - self._measures.drop = None - - def add_period(self, measures): - """ - Add or update a period measures to the dataframe - """ - measures = self._measures.append(measures, ignore_index=True) - self._measures = measures.drop_duplicates('Date time', keep='last') diff --git a/city_model_structure/iot/concordia_temperature_sensor.py b/city_model_structure/iot/concordia_temperature_sensor.py deleted file mode 100644 index 9ae6079c..00000000 --- a/city_model_structure/iot/concordia_temperature_sensor.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -Temperature Sensor module -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca -""" - -import pandas as pd -from city_model_structure.iot.sensor import Sensor - - -class ConcordiaTemperatureSensor(Sensor): - """ - Concordia temperature sensor. - """ - - def __init__(self, name): - super().__init__() - self._name = name - self._interval = 5 - self._interval_units = 'minutes' - self._type = 'ConcordiaTemperatureSensor' - self._units = 'Celsius' - self._measures = pd.DataFrame(columns=["Date time", "Temperature"]) - - @property - def measures(self) -> pd.DataFrame: - """ - Get sensor measures [yyyy-mm-dd, hh:mm:ss Celsius] - :return: DataFrame["Date time", "Temperature"] - """ - return self._measures - - @measures.deleter - def measures(self): - """ - Delete sensor measures - """ - self._measures.drop = None - - def add_period(self, measures): - """ - Add or update a period measures to the dataframe - """ - measures = self._measures.append(measures, ignore_index=True) - self._measures = measures.drop_duplicates('Date time', keep='last') diff --git a/unittests/test_sensors_factory.py b/unittests/test_sensors_factory.py deleted file mode 100644 index 55b13e01..00000000 --- a/unittests/test_sensors_factory.py +++ /dev/null @@ -1,58 +0,0 @@ -""" -TestSensorsFactory test and validate the city model structure schedules -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2021 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca -""" -from pathlib import Path -from unittest import TestCase -from city_model_structure.building import Building -from city_model_structure.buildings_cluster import BuildingsCluster -from city_model_structure.city import City -from imports.sensors_factory import SensorsFactory - - -class TestSensorsFactory(TestCase): - """ - TestSchedulesFactory TestCase - """ - - def setUp(self) -> None: - """ - Configure test environment - :return: - """ - self._city = TestSensorsFactory._mockup_city() - self._end_point = (Path(__file__).parent / - 'tests_data/EV-GM energy demand weekly report_01-26-20_04-30.csv').resolve() - - @staticmethod - def _mockup_city(): - lower_corner = [0, 0, 0] - upper_corner = [10, 10, 10] - srs_name = 'Mockup_city' - buildings = [] - lod = 2 - surfaces = [] - year_of_construction = 2021 - function = "office" - city = City(lower_corner, upper_corner, srs_name) - buildings.append(Building("EV", lod, surfaces, year_of_construction, function, lower_corner)) - buildings.append(Building("GM", lod, surfaces, year_of_construction, function, lower_corner)) - buildings.append(Building("MB", lod, surfaces, year_of_construction, function, lower_corner)) - for building in buildings: - city.add_city_object(building) - buildings_cluster = BuildingsCluster("GM_MB_EV", buildings) - city.add_city_objects_cluster(buildings_cluster) - return city - - def test_city_with_sensors(self): - """ - Load concordia sensors and verify it - """ - SensorsFactory('cec', self._city, self._end_point).enrich() - SensorsFactory('cgf', self._city, self._end_point).enrich() - SensorsFactory('ct', self._city, self._end_point).enrich() - for city_object in self._city.city_objects: - print(city_object.name, len(city_object.sensors)) - for sensor in city_object.sensors: - print(sensor.name) diff --git a/unittests/test_usage_factory.py b/unittests/test_usage_factory.py index 269457be..2bcb6ceb 100644 --- a/unittests/test_usage_factory.py +++ b/unittests/test_usage_factory.py @@ -72,7 +72,7 @@ class TestUsageFactory(TestCase): def _check_usage_zone(self, usage_zone): self.assertIsNotNone(usage_zone.usage, 'usage is none') self.assertIsNotNone(usage_zone.percentage, 'usage percentage is none') - self.assertIsNotNone(usage_zone.get_internal_gains, 'internal gains is none') + self.assertIsNotNone(usage_zone.internal_gains, 'internal gains is none') self.assertIsNotNone(usage_zone.hours_day, 'hours per day is none') self.assertIsNotNone(usage_zone.days_year, 'days per year is none') self.assertIsNotNone(usage_zone.thermal_control, 'thermal control is none')