Skip to content

Commit

Permalink
Merge 94ecdff into 0f838aa
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelduchesne committed Aug 9, 2019
2 parents 0f838aa + 94ecdff commit a4497ed
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 148 deletions.
1 change: 0 additions & 1 deletion archetypal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@
from .trnsys import *
from .template import *
from .core import *
from .building import *
from .umi_template import *
from .cli import *
102 changes: 0 additions & 102 deletions archetypal/building.py

This file was deleted.

2 changes: 1 addition & 1 deletion archetypal/idfclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ def run_eplus(
version (bool, optional): Display version information (default: False)
Returns:
tuple: a 1-tuple or a 2-tuple
2-tuple: a 1-tuple or a 2-tuple
- dict: dict of [(title, table), .....]
- IDF: The IDF object. Only provided if return_idf is True.
"""
Expand Down
2 changes: 1 addition & 1 deletion archetypal/template/building_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(
self.Windows = Windows

def __hash__(self):
return hash((self.Name, self.idf.name))
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, BuildingTemplate):
Expand Down
2 changes: 1 addition & 1 deletion archetypal/template/conditioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def __add__(self, other):
return self.combine(other)

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, ZoneConditioning):
Expand Down
2 changes: 1 addition & 1 deletion archetypal/template/dhw.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __add__(self, other):
return self.combine(other)

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, DomesticHotWaterSetting):
Expand Down
2 changes: 1 addition & 1 deletion archetypal/template/gas_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, *args, Category="Gases", Type="Gas", **kwargs):
self.Type = Type

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, GasMaterial):
Expand Down
2 changes: 1 addition & 1 deletion archetypal/template/glazing_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __add__(self, other):
return self.combine(other)

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, GlazingMaterial):
Expand Down
2 changes: 1 addition & 1 deletion archetypal/template/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __add__(self, other):
return self.combine(other)

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, ZoneLoad):
Expand Down
2 changes: 1 addition & 1 deletion archetypal/template/opaque_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __add__(self, other):
return self.combine(other)

def __hash__(self):
return hash((self.Name))
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, OpaqueConstruction):
Expand Down
2 changes: 1 addition & 1 deletion archetypal/template/opaque_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __add__(self, other):
return self.combine(other)

def __hash__(self):
return hash((self.Name))
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, OpaqueMaterial):
Expand Down
6 changes: 3 additions & 3 deletions archetypal/template/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __str__(self):
return repr(self)

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, UmiSchedule):
Expand Down Expand Up @@ -387,7 +387,7 @@ def get_days(self, epbunch):
]
for day in dayname:
week_day_schedule_name = epbunch["{}_ScheduleDay_Name".format(day)]
blocks.append(self.all_objects[("DaySchedule", week_day_schedule_name)])
blocks.append(self.all_objects[hash(("DaySchedule", week_day_schedule_name))])

return blocks

Expand Down Expand Up @@ -478,7 +478,7 @@ def get_parts(self, epbunch):
FromMonth,
ToDay,
ToMonth,
self.all_objects[("WeekSchedule", week_day_schedule_name)],
self.all_objects[hash(("WeekSchedule", week_day_schedule_name))],
)
)
return parts
Expand Down
2 changes: 1 addition & 1 deletion archetypal/template/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(
self.MassRatios = MassRatios

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, StructureDefinition):
Expand Down
17 changes: 9 additions & 8 deletions archetypal/template/umi_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __call__(cls, *args, **kwargs):
*args:
**kwargs:
"""
key = (cls.mro()[0].__name__, kwargs["Name"])
key = hash((cls.mro()[0].__name__, kwargs["Name"]))
if key not in CREATED_OBJECTS:
self = cls.__new__(cls, *args, **kwargs)
cls.__init__(self, *args, **kwargs)
Expand Down Expand Up @@ -149,12 +149,12 @@ def _get_predecessors_meta(self, other):

def rename(self, name):
"""renames self as well as the cached object"""
key = (self.__class__.mro()[0].__name__, self.Name)
key = hash((self.__class__.mro()[0].__name__, self.Name))
self._cache.pop(key)
CREATED_OBJECTS.pop(key)

self.Name = name
newkey = (self.__class__.mro()[0].__name__, name)
newkey = hash((self.__class__.mro()[0].__name__, name))
self._cache[newkey] = self
CREATED_OBJECTS[newkey] = self

Expand Down Expand Up @@ -185,7 +185,7 @@ def get_random_schedule(self):
)

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.mro()[0].__name__, self.Name))

def to_dict(self):
return {"$ref": str(self.id)}
Expand Down Expand Up @@ -275,13 +275,14 @@ def extend(self, other):
Returns:
UmiBase: self
"""
self.all_objects.pop(self.__hash__(), None)
id = self.id
new_obj = self + other
new_obj = self.combine(other)
new_obj.__dict__.pop("id")
new_obj.id = id
name = new_obj.__dict__.pop("Name")
self.__dict__.update(**new_obj.__dict__)
self.all_objects.pop((self.__class__.__name__, name))
self.__dict__.update(Name=name, **new_obj.__dict__)
self.all_objects[self.__hash__()] = self
return self


Expand Down Expand Up @@ -357,7 +358,7 @@ def __init__(
self.TransportEnergy = TransportEnergy

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, MaterialBase):
Expand Down
2 changes: 1 addition & 1 deletion archetypal/template/ventilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __add__(self, other):
return self.combine(other)

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, VentilationSetting):
Expand Down
4 changes: 2 additions & 2 deletions archetypal/template/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
self.Layers = None

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, WindowConstruction):
Expand Down Expand Up @@ -310,7 +310,7 @@ def __str__(self):
return repr(self)

def __hash__(self):
return hash(self.Name)
return hash((self.__class__.__name__, self.Name))

def __eq__(self, other):
if not isinstance(other, WindowSetting):
Expand Down

0 comments on commit a4497ed

Please sign in to comment.