sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def simplefenestration(idf, fsd, deletebsd=True, setto000=False):
"""convert a bsd (fenestrationsurface:detailed) into a simple
fenestrations"""
funcs = (window,
door,
glazeddoor,)
for func in funcs:
fenestration = func(idf, fsd, deletebsd=deletebsd, setto000=setto000)
i... | convert a bsd (fenestrationsurface:detailed) into a simple
fenestrations | entailment |
def tdbr2EOL(td):
"""convert the <br/> in <td> block into line ending (EOL = \n)"""
for br in td.find_all("br"):
br.replace_with("\n")
txt = six.text_type(td) # make it back into test
# would be unicode(id) in python2
soup = BeautifulSoup(txt, 'lxml') # read it as a ... | convert the <br/> in <td> block into line ending (EOL = \n) | entailment |
def is_simpletable(table):
"""test if the table has only strings in the cells"""
tds = table('td')
for td in tds:
if td.contents != []:
td = tdbr2EOL(td)
if len(td.contents) == 1:
thecontents = td.contents[0]
if not isinstance(thecontents, Navi... | test if the table has only strings in the cells | entailment |
def table2matrix(table):
"""convert a table to a list of lists - a 2D matrix"""
if not is_simpletable(table):
raise NotSimpleTable("Not able read a cell in the table as a string")
rows = []
for tr in table('tr'):
row = []
for td in tr('td'):
td = tdbr2EOL(td) # conve... | convert a table to a list of lists - a 2D matrix | entailment |
def table2val_matrix(table):
"""convert a table to a list of lists - a 2D matrix
Converts numbers to float"""
if not is_simpletable(table):
raise NotSimpleTable("Not able read a cell in the table as a string")
rows = []
for tr in table('tr'):
row = []
for td in tr('td'):
... | convert a table to a list of lists - a 2D matrix
Converts numbers to float | entailment |
def titletable(html_doc, tofloat=True):
"""return a list of [(title, table), .....]
title = previous item with a <b> tag
table = rows -> [[cell1, cell2, ..], [cell1, cell2, ..], ..]"""
soup = BeautifulSoup(html_doc, "html.parser")
btables = soup.find_all(['b', 'table']) # find all the <b> and <tabl... | return a list of [(title, table), .....]
title = previous item with a <b> tag
table = rows -> [[cell1, cell2, ..], [cell1, cell2, ..], ..] | entailment |
def _has_name(soup_obj):
"""checks if soup_obj is really a soup object or just a string
If it has a name it is a soup object"""
try:
name = soup_obj.name
if name == None:
return False
return True
except AttributeError:
return False | checks if soup_obj is really a soup object or just a string
If it has a name it is a soup object | entailment |
def lines_table(html_doc, tofloat=True):
"""return a list of [(lines, table), .....]
lines = all the significant lines before the table.
These are lines between this table and
the previous table or 'hr' tag
table = rows -> [[cell1, cell2, ..], [cell1, cell2, ..], ..]
The lines act as a... | return a list of [(lines, table), .....]
lines = all the significant lines before the table.
These are lines between this table and
the previous table or 'hr' tag
table = rows -> [[cell1, cell2, ..], [cell1, cell2, ..], ..]
The lines act as a description for what is in the table | entailment |
def _make_ntgrid(grid):
"""make a named tuple grid
[["", "a b", "b c", "c d"],
["x y", 1, 2, 3 ],
["y z", 4, 5, 6 ],
["z z", 7, 8, 9 ],]
will return
ntcol(x_y=ntrow(a_b=1, b_c=2, c_d=3),
y_z=ntrow(a_b=4, b_c=5, c_d=6),
z_z=ntrow(a_b=7, b_c=8, ... | make a named tuple grid
[["", "a b", "b c", "c d"],
["x y", 1, 2, 3 ],
["y z", 4, 5, 6 ],
["z z", 7, 8, 9 ],]
will return
ntcol(x_y=ntrow(a_b=1, b_c=2, c_d=3),
y_z=ntrow(a_b=4, b_c=5, c_d=6),
z_z=ntrow(a_b=7, b_c=8, c_d=9)) | entailment |
def onlylegalchar(name):
"""return only legal chars"""
legalchar = ascii_letters + digits + ' '
return ''.join([s for s in name[:] if s in legalchar]) | return only legal chars | entailment |
def matchfieldnames(field_a, field_b):
"""Check match between two strings, ignoring case and spaces/underscores.
Parameters
----------
a : str
b : str
Returns
-------
bool
"""
normalised_a = field_a.replace(' ', '_').lower()
normalised_b = field_b.replace(' ', ... | Check match between two strings, ignoring case and spaces/underscores.
Parameters
----------
a : str
b : str
Returns
-------
bool | entailment |
def intinlist(lst):
"""test if int in list"""
for item in lst:
try:
item = int(item)
return True
except ValueError:
pass
return False | test if int in list | entailment |
def replaceint(fname, replacewith='%s'):
"""replace int in lst"""
words = fname.split()
for i, word in enumerate(words):
try:
word = int(word)
words[i] = replacewith
except ValueError:
pass
return ' '.join(words) | replace int in lst | entailment |
def cleaniddfield(acomm):
"""make all the keys lower case"""
for key in list(acomm.keys()):
val = acomm[key]
acomm[key.lower()] = val
for key in list(acomm.keys()):
val = acomm[key]
if key != key.lower():
acomm.pop(key)
return acomm | make all the keys lower case | entailment |
def makecsvdiffs(thediffs, dtls, n1, n2):
"""return the csv to be displayed"""
def ishere(val):
if val == None:
return "not here"
else:
return "is here"
rows = []
rows.append(['file1 = %s' % (n1, )])
rows.append(['file2 = %s' % (n2, )])
rows.append('')
... | return the csv to be displayed | entailment |
def idfdiffs(idf1, idf2):
"""return the diffs between the two idfs"""
# for any object type, it is sorted by name
thediffs = {}
keys = idf1.model.dtls # undocumented variable
for akey in keys:
idfobjs1 = idf1.idfobjects[akey]
idfobjs2 = idf2.idfobjects[akey]
names = set([get... | return the diffs between the two idfs | entailment |
def printcsv(csvdiffs):
"""print the csv"""
for row in csvdiffs:
print(','.join([str(cell) for cell in row])) | print the csv | entailment |
def heading2table(soup, table, row):
"""add heading row to table"""
tr = Tag(soup, name="tr")
table.append(tr)
for attr in row:
th = Tag(soup, name="th")
tr.append(th)
th.append(attr) | add heading row to table | entailment |
def row2table(soup, table, row):
"""ad a row to the table"""
tr = Tag(soup, name="tr")
table.append(tr)
for attr in row:
td = Tag(soup, name="td")
tr.append(td)
td.append(attr) | ad a row to the table | entailment |
def printhtml(csvdiffs):
"""print the html"""
soup = BeautifulSoup()
html = Tag(soup, name="html")
para1 = Tag(soup, name="p")
para1.append(csvdiffs[0][0])
para2 = Tag(soup, name="p")
para2.append(csvdiffs[1][0])
table = Tag(soup, name="table")
table.attrs.update(dict(border="1"))
... | print the html | entailment |
def extendlist(lst, i, value=''):
"""extend the list so that you have i-th value"""
if i < len(lst):
pass
else:
lst.extend([value, ] * (i - len(lst) + 1)) | extend the list so that you have i-th value | entailment |
def addfunctions(abunch):
"""add functions to epbunch"""
key = abunch.obj[0].upper()
#-----------------
# TODO : alternate strategy to avoid listing the objkeys in snames
# check if epbunch has field "Zone_Name" or "Building_Surface_Name"
# and is in group u'Thermal Zones and Surfaces'
# t... | add functions to epbunch | entailment |
def getrange(bch, fieldname):
"""get the ranges for this field"""
keys = ['maximum', 'minimum', 'maximum<', 'minimum>', 'type']
index = bch.objls.index(fieldname)
fielddct_orig = bch.objidd[index]
fielddct = copy.deepcopy(fielddct_orig)
therange = {}
for key in keys:
therange[key] = ... | get the ranges for this field | entailment |
def checkrange(bch, fieldname):
"""throw exception if the out of range"""
fieldvalue = bch[fieldname]
therange = bch.getrange(fieldname)
if therange['maximum'] != None:
if fieldvalue > therange['maximum']:
astr = "Value %s is not less or equal to the 'maximum' of %s"
astr... | throw exception if the out of range | entailment |
def getfieldidd(bch, fieldname):
"""get the idd dict for this field
Will return {} if the fieldname does not exist"""
# print(bch)
try:
fieldindex = bch.objls.index(fieldname)
except ValueError as e:
return {} # the fieldname does not exist
# so there is no idd
... | get the idd dict for this field
Will return {} if the fieldname does not exist | entailment |
def getfieldidd_item(bch, fieldname, iddkey):
"""return an item from the fieldidd, given the iddkey
will return and empty list if it does not have the iddkey
or if the fieldname does not exist"""
fieldidd = getfieldidd(bch, fieldname)
try:
return fieldidd[iddkey]
except KeyError as e:
... | return an item from the fieldidd, given the iddkey
will return and empty list if it does not have the iddkey
or if the fieldname does not exist | entailment |
def isequal(bch, fieldname, value, places=7):
"""return True if the field is equal to value"""
def equalalphanumeric(bch, fieldname, value):
if bch.get_retaincase(fieldname):
return bch[fieldname] == value
else:
return bch[fieldname].upper() == value.upper()
fieldidd... | return True if the field is equal to value | entailment |
def getreferingobjs(referedobj, iddgroups=None, fields=None):
"""Get a list of objects that refer to this object"""
# pseudocode for code below
# referringobjs = []
# referedobj has: -> Name
# -> reference
# for each obj in idf:
# [optional filter -> objects in iddgroup]
... | Get a list of objects that refer to this object | entailment |
def get_referenced_object(referring_object, fieldname):
"""
Get an object referred to by a field in another object.
For example an object of type Construction has fields for each layer, each
of which refers to a Material. This functions allows the object
representing a Material to be fetched using ... | Get an object referred to by a field in another object.
For example an object of type Construction has fields for each layer, each
of which refers to a Material. This functions allows the object
representing a Material to be fetched using the name of the layer.
Returns the first item found since if th... | entailment |
def isequal(self, fieldname, value, places=7):
"""return True if the field == value
Will retain case if get_retaincase == True
for real value will compare to decimal 'places'
"""
return isequal(self, fieldname, value, places=places) | return True if the field == value
Will retain case if get_retaincase == True
for real value will compare to decimal 'places' | entailment |
def getreferingobjs(self, iddgroups=None, fields=None):
"""Get a list of objects that refer to this object"""
return getreferingobjs(self, iddgroups=iddgroups, fields=fields) | Get a list of objects that refer to this object | entailment |
def vol_tehrahedron(poly):
"""volume of a irregular tetrahedron"""
p_a = np.array(poly[0])
p_b = np.array(poly[1])
p_c = np.array(poly[2])
p_d = np.array(poly[3])
return abs(np.dot(
np.subtract(p_a, p_d),
np.cross(
np.subtract(p_b, p_d),
np.subtract(p_c, p... | volume of a irregular tetrahedron | entailment |
def vol(poly1, poly2):
""""volume of a zone defined by two polygon bases """
c_point = central_p(poly1, poly2)
c_point = (c_point[0], c_point[1], c_point[2])
vol_therah = 0
num = len(poly1)
poly1.append(poly1[0])
poly2.append(poly2[0])
for i in range(num - 2):
# the upper part
... | volume of a zone defined by two polygon bases | entailment |
def makename2refdct(commdct):
"""make the name2refs dict in the idd_index"""
refdct = {}
for comm in commdct: # commdct is a list of dict
try:
idfobj = comm[0]['idfobj'].upper()
field1 = comm[1]
if 'Name' in field1['field']:
references = field1['re... | make the name2refs dict in the idd_index | entailment |
def makeref2namesdct(name2refdct):
"""make the ref2namesdct in the idd_index"""
ref2namesdct = {}
for key, values in name2refdct.items():
for value in values:
ref2namesdct.setdefault(value, set()).add(key)
return ref2namesdct | make the ref2namesdct in the idd_index | entailment |
def ref2names2commdct(ref2names, commdct):
"""embed ref2names into commdct"""
for comm in commdct:
for cdct in comm:
try:
refs = cdct['object-list'][0]
validobjects = ref2names[refs]
cdct.update({'validobjects':validobjects})
except... | embed ref2names into commdct | entailment |
def area(poly):
"""Calculation of zone area"""
poly_xy = []
num = len(poly)
for i in range(num):
poly[i] = poly[i][0:2] + (0,)
poly_xy.append(poly[i])
return surface.area(poly) | Calculation of zone area | entailment |
def prevnode(edges, component):
"""get the pervious component in the loop"""
e = edges
c = component
n2c = [(a, b) for a, b in e if type(a) == tuple]
c2n = [(a, b) for a, b in e if type(b) == tuple]
node2cs = [(a, b) for a, b in e if b == c]
c2nodes = []
for node2c in node2cs:
c2... | get the pervious component in the loop | entailment |
def height(poly):
"""height"""
num = len(poly)
hgt = 0.0
for i in range(num):
hgt += (poly[i][2])
return hgt/num | height | entailment |
def unit_normal(apnt, bpnt, cpnt):
"""unit normal"""
xvar = np.tinylinalg.det([
[1, apnt[1], apnt[2]], [1, bpnt[1], bpnt[2]], [1, cpnt[1], cpnt[2]]])
yvar = np.tinylinalg.det([
[apnt[0], 1, apnt[2]], [bpnt[0], 1, bpnt[2]], [cpnt[0], 1, cpnt[2]]])
zvar = np.tinylinalg.det([
[apnt[... | unit normal | entailment |
def insert(self, i, v):
"""Insert an idfobject (bunch) to list1 and its object to list2."""
self.list1.insert(i, v)
self.list2.insert(i, v.obj)
if isinstance(v, EpBunch):
v.theidf = self.theidf | Insert an idfobject (bunch) to list1 and its object to list2. | entailment |
def grouper(num, iterable, fillvalue=None):
"Collect data into fixed-length chunks or blocks"
# grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx
args = [iter(iterable)] * num
return zip_longest(fillvalue=fillvalue, *args) | Collect data into fixed-length chunks or blocks | entailment |
def getcoords(ddtt):
"""return the coordinates of the surface"""
n_vertices_index = ddtt.objls.index('Number_of_Vertices')
first_x = n_vertices_index + 1 # X of first coordinate
pts = ddtt.obj[first_x:]
return list(grouper(3, pts)) | return the coordinates of the surface | entailment |
def buildingname(ddtt):
"""return building name"""
idf = ddtt.theidf
building = idf.idfobjects['building'.upper()][0]
return building.Name | return building name | entailment |
def cleanupversion(ver):
"""massage the version number so it matches the format of install folder"""
lst = ver.split(".")
if len(lst) == 1:
lst.extend(['0', '0'])
elif len(lst) == 2:
lst.extend(['0'])
elif len(lst) > 2:
lst = lst[:3]
lst[2] = '0' # ensure the 3rd number i... | massage the version number so it matches the format of install folder | entailment |
def getiddfile(versionid):
"""find the IDD file of the E+ installation"""
vlist = versionid.split('.')
if len(vlist) == 1:
vlist = vlist + ['0', '0']
elif len(vlist) == 2:
vlist = vlist + ['0']
ver_str = '-'.join(vlist)
eplus_exe, _ = eppy.runner.run_functions.install_paths(ver... | find the IDD file of the E+ installation | entailment |
def easyopen(fname, idd=None, epw=None):
"""automatically set idd and open idf file. Uses version from idf to set correct idd
It will work under the following circumstances:
- the IDF file should have the VERSION object.
- Needs the version of EnergyPlus installed that matches the IDF version.
... | automatically set idd and open idf file. Uses version from idf to set correct idd
It will work under the following circumstances:
- the IDF file should have the VERSION object.
- Needs the version of EnergyPlus installed that matches the IDF version.
- Energyplus should be installed in the default... | entailment |
def removecomment(astr, cphrase):
"""
the comment is similar to that in python.
any charachter after the # is treated as a comment
until the end of the line
astr is the string to be de-commented
cphrase is the comment phrase"""
# linesep = mylib3.getlinesep(astr)
alist = astr.splitlines(... | the comment is similar to that in python.
any charachter after the # is treated as a comment
until the end of the line
astr is the string to be de-commented
cphrase is the comment phrase | entailment |
def initdict2(self, dictfile):
"""initdict2"""
dt = {}
dtls = []
adict = dictfile
for element in adict:
dt[element[0].upper()] = [] # dict keys for objects always in caps
dtls.append(element[0].upper())
return dt, dtls | initdict2 | entailment |
def initdict(self, fname):
"""create a blank dictionary"""
if isinstance(fname, Idd):
self.dt, self.dtls = fname.dt, fname.dtls
return self.dt, self.dtls
astr = mylib2.readfile(fname)
nocom = removecomment(astr, '!')
idfst = nocom
alist = idfst.sp... | create a blank dictionary | entailment |
def makedict(self, dictfile, fnamefobject):
"""stuff file data into the blank dictionary"""
#fname = './exapmlefiles/5ZoneDD.idf'
#fname = './1ZoneUncontrolled.idf'
if isinstance(dictfile, Idd):
localidd = copy.deepcopy(dictfile)
dt, dtls = localidd.dt, localidd.d... | stuff file data into the blank dictionary | entailment |
def replacenode(self, othereplus, node):
"""replace the node here with the node from othereplus"""
node = node.upper()
self.dt[node.upper()] = othereplus.dt[node.upper()] | replace the node here with the node from othereplus | entailment |
def add2node(self, othereplus, node):
"""add the node here with the node from othereplus
this will potentially have duplicates"""
node = node.upper()
self.dt[node.upper()] = self.dt[node.upper()] + \
othereplus.dt[node.upper()] | add the node here with the node from othereplus
this will potentially have duplicates | entailment |
def addinnode(self, otherplus, node, objectname):
"""add an item to the node.
example: add a new zone to the element 'ZONE' """
# do a test for unique object here
newelement = otherplus.dt[node.upper()] | add an item to the node.
example: add a new zone to the element 'ZONE' | entailment |
def getrefs(self, reflist):
"""
reflist is got from getobjectref in parse_idd.py
getobjectref returns a dictionary.
reflist is an item in the dictionary
getrefs gathers all the fields refered by reflist
"""
alist = []
for element in reflist:
if... | reflist is got from getobjectref in parse_idd.py
getobjectref returns a dictionary.
reflist is an item in the dictionary
getrefs gathers all the fields refered by reflist | entailment |
def dropnodes(edges):
"""draw a graph without the nodes"""
newedges = []
added = False
for edge in edges:
if bothnodes(edge):
newtup = (edge[0][0], edge[1][0])
newedges.append(newtup)
added = True
elif firstisnode(edge):
for edge1 in edges:... | draw a graph without the nodes | entailment |
def edges2nodes(edges):
"""gather the nodes from the edges"""
nodes = []
for e1, e2 in edges:
nodes.append(e1)
nodes.append(e2)
nodedict = dict([(n, None) for n in nodes])
justnodes = list(nodedict.keys())
# justnodes.sort()
justnodes = sorted(justnodes, key=lambda x: str(x[0... | gather the nodes from the edges | entailment |
def makediagram(edges):
"""make the diagram with the edges"""
graph = pydot.Dot(graph_type='digraph')
nodes = edges2nodes(edges)
epnodes = [(node,
makeanode(node[0])) for node in nodes if nodetype(node)=="epnode"]
endnodes = [(node,
makeendnode(node[0])) for node in nodes if nodety... | make the diagram with the edges | entailment |
def makebranchcomponents(data, commdct, anode="epnode"):
"""return the edges jointing the components of a branch"""
alledges = []
objkey = 'BRANCH'
cnamefield = "Component %s Name"
inletfield = "Component %s Inlet Node Name"
outletfield = "Component %s Outlet Node Name"
numobjects = len(da... | return the edges jointing the components of a branch | entailment |
def makeairplantloop(data, commdct):
"""make the edges for the airloop and the plantloop"""
anode = "epnode"
endnode = "EndNode"
# in plantloop get:
# demand inlet, outlet, branchlist
# supply inlet, outlet, branchlist
plantloops = loops.plantloopfields(data, commdct)
# splitter... | make the edges for the airloop and the plantloop | entailment |
def getedges(fname, iddfile):
"""return the edges of the idf file fname"""
data, commdct, _idd_index = readidf.readdatacommdct(fname, iddfile=iddfile)
edges = makeairplantloop(data, commdct)
return edges | return the edges of the idf file fname | entailment |
def get_nocom_vars(astr):
"""
input 'astr' which is the Energy+.idd file as a string
returns (st1, st2, lss)
st1 = with all the ! comments striped
st2 = strips all comments - both the '!' and '\\'
lss = nested list of all the variables in Energy+.idd file
"""
nocom = nocomment(astr, '!')... | input 'astr' which is the Energy+.idd file as a string
returns (st1, st2, lss)
st1 = with all the ! comments striped
st2 = strips all comments - both the '!' and '\\'
lss = nested list of all the variables in Energy+.idd file | entailment |
def removeblanklines(astr):
"""remove the blank lines in astr"""
lines = astr.splitlines()
lines = [line for line in lines if line.strip() != ""]
return "\n".join(lines) | remove the blank lines in astr | entailment |
def _readfname(fname):
"""copied from extractidddata below.
It deals with all the types of fnames"""
try:
if isinstance(fname, (file, StringIO)):
astr = fname.read()
else:
astr = open(fname, 'rb').read()
except NameError:
if isinstance(fname, (FileIO, Str... | copied from extractidddata below.
It deals with all the types of fnames | entailment |
def make_idd_index(extract_func, fname, debug):
"""generate the iddindex"""
astr = _readfname(fname)
# fname is exhausted by the above read
# reconstitute fname as a StringIO
fname = StringIO(astr)
# glist = iddgroups.iddtxt2grouplist(astr.decode('ISO-8859-2'))
blocklst, commlst,... | generate the iddindex | entailment |
def embedgroupdata(extract_func, fname, debug):
"""insert group info into extracted idd"""
astr = _readfname(fname)
# fname is exhausted by the above read
# reconstitute fname as a StringIO
fname = StringIO(astr)
try:
astr = astr.decode('ISO-8859-2')
except Exception as e:... | insert group info into extracted idd | entailment |
def extractidddata(fname, debug=False):
"""
extracts all the needed information out of the idd file
if debug is True, it generates a series of text files.
Each text file is incrementally different. You can do a diff
see what the change is
-
this code is from 2004.
it works.
I am try... | extracts all the needed information out of the idd file
if debug is True, it generates a series of text files.
Each text file is incrementally different. You can do a diff
see what the change is
-
this code is from 2004.
it works.
I am trying not to change it (until I rewrite the whole thin... | entailment |
def getobjectref(blocklst, commdct):
"""
makes a dictionary of object-lists
each item in the dictionary points to a list of tuples
the tuple is (objectname, fieldindex)
"""
objlst_dct = {}
for eli in commdct:
for elj in eli:
if 'object-list' in elj:
objli... | makes a dictionary of object-lists
each item in the dictionary points to a list of tuples
the tuple is (objectname, fieldindex) | entailment |
def readdatacommlst(idfname):
"""read the idf file"""
# iddfile = sys.path[0] + '/EplusCode/Energy+.idd'
iddfile = 'Energy+.idd'
# iddfile = './EPlusInterfaceFunctions/E1.idd' # TODO : can the path name be not hard coded
iddtxt = open(iddfile, 'r').read()
block, commlst, commdct = parse_idd.extr... | read the idf file | entailment |
def readdatacommdct(idfname, iddfile='Energy+.idd', commdct=None):
"""read the idf file"""
if not commdct:
block, commlst, commdct, idd_index = parse_idd.extractidddata(iddfile)
theidd = eplusdata.Idd(block, 2)
else:
theidd = iddfile
data = eplusdata.Eplusdata(theidd, idfname)
... | read the idf file | entailment |
def extractfields(data, commdct, objkey, fieldlists):
"""get all the objects of objkey.
fieldlists will have a fieldlist for each of those objects.
return the contents of those fields"""
# TODO : this assumes that the field list identical for
# each instance of the object. This is not true.
# So... | get all the objects of objkey.
fieldlists will have a fieldlist for each of those objects.
return the contents of those fields | entailment |
def plantloopfieldlists(data):
"""return the plantloopfield list"""
objkey = 'plantloop'.upper()
numobjects = len(data.dt[objkey])
return [[
'Name',
'Plant Side Inlet Node Name',
'Plant Side Outlet Node Name',
'Plant Side Branch List Name',
'Demand Side Inlet Node... | return the plantloopfield list | entailment |
def plantloopfields(data, commdct):
"""get plantloop fields to diagram it"""
fieldlists = plantloopfieldlists(data)
objkey = 'plantloop'.upper()
return extractfields(data, commdct, objkey, fieldlists) | get plantloop fields to diagram it | entailment |
def branchlist2branches(data, commdct, branchlist):
"""get branches from the branchlist"""
objkey = 'BranchList'.upper()
theobjects = data.dt[objkey]
fieldlists = []
objnames = [obj[1] for obj in theobjects]
for theobject in theobjects:
fieldlists.append(list(range(2, len(theobject))))
... | get branches from the branchlist | entailment |
def branch_inlet_outlet(data, commdct, branchname):
"""return the inlet and outlet of a branch"""
objkey = 'Branch'.upper()
theobjects = data.dt[objkey]
theobject = [obj for obj in theobjects if obj[1] == branchname]
theobject = theobject[0]
inletindex = 6
outletindex = len(theobject) - 2
... | return the inlet and outlet of a branch | entailment |
def splittermixerfieldlists(data, commdct, objkey):
"""docstring for splittermixerfieldlists"""
objkey = objkey.upper()
objindex = data.dtls.index(objkey)
objcomms = commdct[objindex]
theobjects = data.dt[objkey]
fieldlists = []
for theobject in theobjects:
fieldlist = list(range(1, ... | docstring for splittermixerfieldlists | entailment |
def splitterfields(data, commdct):
"""get splitter fields to diagram it"""
objkey = "Connector:Splitter".upper()
fieldlists = splittermixerfieldlists(data, commdct, objkey)
return extractfields(data, commdct, objkey, fieldlists) | get splitter fields to diagram it | entailment |
def mixerfields(data, commdct):
"""get mixer fields to diagram it"""
objkey = "Connector:Mixer".upper()
fieldlists = splittermixerfieldlists(data, commdct, objkey)
return extractfields(data, commdct, objkey, fieldlists) | get mixer fields to diagram it | entailment |
def repeatingfields(theidd, commdct, objkey, flds):
"""return a list of repeating fields
fld is in format 'Component %s Name'
so flds = [fld % (i, ) for i in range(n)]
does not work for 'fields as indicated' """
# TODO : make it work for 'fields as indicated'
if type(flds) != list:
flds ... | return a list of repeating fields
fld is in format 'Component %s Name'
so flds = [fld % (i, ) for i in range(n)]
does not work for 'fields as indicated' | entailment |
def objectcount(data, key):
"""return the count of objects of key"""
objkey = key.upper()
return len(data.dt[objkey]) | return the count of objects of key | entailment |
def getfieldindex(data, commdct, objkey, fname):
"""given objkey and fieldname, return its index"""
objindex = data.dtls.index(objkey)
objcomm = commdct[objindex]
for i_index, item in enumerate(objcomm):
try:
if item['field'] == [fname]:
break
except KeyError ... | given objkey and fieldname, return its index | entailment |
def getadistus(data, commdct):
"""docstring for fname"""
objkey = "ZoneHVAC:AirDistributionUnit".upper()
objindex = data.dtls.index(objkey)
objcomm = commdct[objindex]
adistutypefield = "Air Terminal Object Type"
ifield = getfieldindex(data, commdct, objkey, adistutypefield)
adistus = objcom... | docstring for fname | entailment |
def makeadistu_inlets(data, commdct):
"""make the dict adistu_inlets"""
adistus = getadistus(data, commdct)
# assume that the inlet node has the words "Air Inlet Node Name"
airinletnode = "Air Inlet Node Name"
adistu_inlets = {}
for adistu in adistus:
objkey = adistu.upper()
obji... | make the dict adistu_inlets | entailment |
def folder2ver(folder):
"""get the version number from the E+ install folder"""
ver = folder.split('EnergyPlus')[-1]
ver = ver[1:]
splitapp = ver.split('-')
ver = '.'.join(splitapp)
return ver | get the version number from the E+ install folder | entailment |
def nocomment(astr, com='!'):
"""
just like the comment in python.
removes any text after the phrase 'com'
"""
alist = astr.splitlines()
for i in range(len(alist)):
element = alist[i]
pnt = element.find(com)
if pnt != -1:
alist[i] = element[:pnt]
return '\... | just like the comment in python.
removes any text after the phrase 'com' | entailment |
def idf2txt(txt):
"""convert the idf text to a simple text"""
astr = nocomment(txt)
objs = astr.split(';')
objs = [obj.split(',') for obj in objs]
objs = [[line.strip() for line in obj] for obj in objs]
objs = [[_tofloat(line) for line in obj] for obj in objs]
objs = [tuple(obj) for obj in o... | convert the idf text to a simple text | entailment |
def iddversiontuple(afile):
"""given the idd file or filehandle, return the version handle"""
def versiontuple(vers):
"""version tuple"""
return tuple([int(num) for num in vers.split(".")])
try:
fhandle = open(afile, 'rb')
except TypeError:
fhandle = afile
line1 = fha... | given the idd file or filehandle, return the version handle | entailment |
def makeabunch(commdct, obj, obj_i):
"""make a bunch from the object"""
objidd = commdct[obj_i]
objfields = [comm.get('field') for comm in commdct[obj_i]]
objfields[0] = ['key']
objfields = [field[0] for field in objfields]
obj_fields = [bunchhelpers.makefieldname(field) for field in objfields]
... | make a bunch from the object | entailment |
def makebunches(data, commdct):
"""make bunches with data"""
bunchdt = {}
ddtt, dtls = data.dt, data.dtls
for obj_i, key in enumerate(dtls):
key = key.upper()
bunchdt[key] = []
objs = ddtt[key]
for obj in objs:
bobj = makeabunch(commdct, obj, obj_i)
... | make bunches with data | entailment |
def makebunches_alter(data, commdct, theidf):
"""make bunches with data"""
bunchdt = {}
dt, dtls = data.dt, data.dtls
for obj_i, key in enumerate(dtls):
key = key.upper()
objs = dt[key]
list1 = []
for obj in objs:
bobj = makeabunch(commdct, obj, obj_i)
... | make bunches with data | entailment |
def convertfields_old(key_comm, obj, inblock=None):
"""convert the float and interger fields"""
convinidd = ConvInIDD()
typefunc = dict(integer=convinidd.integer, real=convinidd.real)
types = []
for comm in key_comm:
types.append(comm.get('type', [None])[0])
convs = [typefunc.get(typ, co... | convert the float and interger fields | entailment |
def convertafield(field_comm, field_val, field_iddname):
"""convert field based on field info in IDD"""
convinidd = ConvInIDD()
field_typ = field_comm.get('type', [None])[0]
conv = convinidd.conv_dict().get(field_typ, convinidd.no_type)
return conv(field_val, field_iddname) | convert field based on field info in IDD | entailment |
def convertfields(key_comm, obj, inblock=None):
"""convert based on float, integer, and A1, N1"""
# f_ stands for field_
convinidd = ConvInIDD()
if not inblock:
inblock = ['does not start with N'] * len(obj)
for i, (f_comm, f_val, f_iddname) in enumerate(zip(key_comm, obj, inblock)):
... | convert based on float, integer, and A1, N1 | entailment |
def convertallfields(data, commdct, block=None):
"""docstring for convertallfields"""
# import pdbdb; pdb.set_trace()
for key in list(data.dt.keys()):
objs = data.dt[key]
for i, obj in enumerate(objs):
key_i = data.dtls.index(key)
key_comm = commdct[key_i]
... | docstring for convertallfields | entailment |
def addfunctions(dtls, bunchdt):
"""add functions to the objects"""
snames = [
"BuildingSurface:Detailed",
"Wall:Detailed",
"RoofCeiling:Detailed",
"Floor:Detailed",
"FenestrationSurface:Detailed",
"Shading:Site:Detailed",
"Shading:Building:Detailed",
... | add functions to the objects | entailment |
def addfunctions2new(abunch, key):
"""add functions to a new bunch/munch object"""
snames = [
"BuildingSurface:Detailed",
"Wall:Detailed",
"RoofCeiling:Detailed",
"Floor:Detailed",
"FenestrationSurface:Detailed",
"Shading:Site:Detailed",
"Shading:Building:... | add functions to a new bunch/munch object | entailment |
def idfreader(fname, iddfile, conv=True):
"""read idf file and return bunches"""
data, commdct, idd_index = readidf.readdatacommdct(fname, iddfile=iddfile)
if conv:
convertallfields(data, commdct)
# fill gaps in idd
ddtt, dtls = data.dt, data.dtls
# skiplist = ["TABLE:MULTIVARIABLELOOKUP... | read idf file and return bunches | entailment |
def idfreader1(fname, iddfile, theidf, conv=True, commdct=None, block=None):
"""read idf file and return bunches"""
versiontuple = iddversiontuple(iddfile)
# import pdb; pdb.set_trace()
block, data, commdct, idd_index = readidf.readdatacommdct1(
fname,
iddfile=iddfile,
commdct=co... | read idf file and return bunches | entailment |
def conv_dict(self):
"""dictionary of conversion"""
return dict(integer=self.integer, real=self.real, no_type=self.no_type) | dictionary of conversion | entailment |
def getanymentions(idf, anidfobject):
"""Find out if idjobject is mentioned an any object anywhere"""
name = anidfobject.obj[1]
foundobjs = []
keys = idfobjectkeys(idf)
idfkeyobjects = [idf.idfobjects[key.upper()] for key in keys]
for idfobjects in idfkeyobjects:
for idfobject in idfobje... | Find out if idjobject is mentioned an any object anywhere | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.