Skip to content

Commit

Permalink
Keeps the defaultvalues kwarg, and passes it through to newrawobject
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Bull committed Nov 16, 2022
1 parent 2867b97 commit df51682
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 6 additions & 4 deletions geomeppy/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,12 @@ def read(self):
)
self.__class__.setidd(idd_info, idd_index, block, versiontuple)

def newidfobject(self, key, aname="", **kwargs):
# type: (str, str, **Any) -> EpBunch
def newidfobject(self, key, aname="", defaultvalues=True, **kwargs):
# type: (str, str, bool, **Any) -> EpBunch
"""Add a new idfobject to the model.
If you don't specify a value for a field, the default value will be set.
If you don't specify a value for a field, the default value will be set, unless
defaultvalues is set to False.
For example ::
Expand All @@ -280,10 +281,11 @@ def newidfobject(self, key, aname="", **kwargs):
:param key: The type of IDF object. This must be in ALL_CAPS.
:param aname: This parameter is not used. It is left there for backward compatibility.
:param defaultvalues: Specifies whether to set default values when creating IDF objects.
:param kwargs: Keyword arguments in the format `field=value` used to set fields in the EnergyPlus object.
:returns: EpBunch object.
"""
obj = newrawobject(self.model, self.idd_info, key)
obj = newrawobject(self.model, self.idd_info, key, defaultvalues=defaultvalues)
abunch = obj2bunch(self.model, self.idd_info, obj)
if aname:
warnings.warn(
Expand Down
5 changes: 5 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,8 @@ def test_shadow_intersecting(new_idf, shadow_matching):
new_idf.intersect()
shadows = [Polygon3D(s.coords) for s in new_idf.getshadingsurfaces()]
assert len(shadows) == 23


def test_defaultvalues_in_newidfobject(new_idf):
obj = new_idf.newidfobject("ZONE", Name="O-Zone", defaultvalues=True)
assert obj.Name == "O-Zone"

0 comments on commit df51682

Please sign in to comment.