-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates the patches with the eppy.ext_field_functions.increaseIDDfields #252
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
from eppy.EPlusInterfaceFunctions.eplusdata import Eplusdata # noqa | ||
from eppy.bunch_subclass import EpBunch as BaseBunch | ||
from eppy.idf_msequence import Idf_MSequence | ||
from eppy.idfreader import convertallfields, iddversiontuple | ||
from eppy.idfreader import convertallfields, iddversiontuple, convertfields | ||
from eppy.modeleditor import IDF as BaseIDF | ||
from eppy.modeleditor import IDDNotSetError, namebunch, newrawobject | ||
|
||
|
@@ -161,7 +161,7 @@ def addthisbunch( | |
""" | ||
key = thisbunch.key.upper() | ||
obj = copy.copy(thisbunch.obj) | ||
abunch = obj2bunch(data, commdct, obj) | ||
abunch = obj2bunch(data, commdct, obj, thisbunch.theidf.block) | ||
bunchdt[key].append(abunch) | ||
return abunch | ||
|
||
|
@@ -191,39 +191,65 @@ def makebunches( | |
|
||
|
||
def obj2bunch( | ||
data, commdct, obj | ||
data, commdct, obj, block=None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
): # type: (Eplusdata, List[List[Dict[str, Any]]], List[str]) -> EpBunch | ||
"""Make a new bunch object using the data object. | ||
|
||
:param data: Eplusdata object containing representions of IDF objects. | ||
:param commdct: Descriptions of IDF fields from the IDD. | ||
:param obj: List of field values in an object. | ||
:param block: EnergyPlus field ID names of the IDF from the IDD. Defaults to None. | ||
:returns: EpBunch object. | ||
|
||
""" | ||
dtls = data.dtls | ||
key = obj[0].upper() | ||
key_i = dtls.index(key) | ||
abunch = makeabunch(commdct, obj, key_i) | ||
abunch = makeabunch(commdct, obj, key_i, block) | ||
return abunch | ||
|
||
|
||
def makeabunch( | ||
commdct, # type: List[List[Dict[str, Any]]] | ||
obj, # type: Union[List[Union[float, str]], List[str]] | ||
obj_i, # type: int | ||
block=None, # type: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing type |
||
debugidd=True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing type |
||
): | ||
# type: (...) -> EpBunch | ||
"""Make a bunch from the object. | ||
|
||
:param commdct: Descriptions of IDF fields from the IDD. | ||
:param obj: List of field values in an object. | ||
:param obj_i: Index of the object in commdct. | ||
:param block: EnergyPlus field ID names of the IDF from the IDD. Defaults to None. | ||
:returns: EpBunch object. | ||
|
||
""" | ||
objidd = commdct[obj_i] | ||
objfields = [comm.get("field") for comm in commdct[obj_i]] # type: List | ||
objfields = [comm.get("field") for comm in commdct[obj_i]] | ||
if debugidd: | ||
import eppy.ext_field_functions as extff | ||
|
||
if len(obj) > len(objfields): | ||
# there are not enough fields in the IDD to match the IDF | ||
# -- increase the number of fields in the IDD (in block and commdct) | ||
# -- start | ||
n = len(obj) - len(objfields) | ||
key_txt = obj[0] | ||
objfields = extff.increaseIDDfields(block, commdct, obj_i, key_txt, n) | ||
# -- increase the number of fields in the IDD (in block and commdct) | ||
# -- end | ||
# | ||
# -- convertfields for added fields - start | ||
key_i = obj_i | ||
key_comm = commdct[obj_i] | ||
try: | ||
inblock = block[obj_i] | ||
except TypeError as e: | ||
inblock = None | ||
obj = convertfields(key_comm, obj, inblock) | ||
# -- convertfields for added fields - end | ||
Comment on lines
+235
to
+252
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Appreciate this is probably taken directly from eppy, but I'd prefer it to be split out as a function with all those inline comments turned into a docstring. |
||
objfields[0] = ["key"] | ||
objfields = [field[0] for field in objfields] | ||
obj_fields = [bunchhelpers.makefieldname(field) for field in objfields] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imports in alphabetical order please