output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
return fan power in bhp given the fan IDF object
Make a summary of the following Python 3 code def fanpower_bhp(ddtt): from eppy.bunch_subclass import BadEPFieldError # here to prevent circular dependency try: fan_tot_eff = ddtt.Fan_Total_Efficiency # from V+ V8.7.0 onwards except BadEPFieldError as e: fan_tot_eff = ddtt.Fan_Efficiency ...
As a Python code analyst, you investigate and solve complex coding mysteries
def fanpower_watts(ddtt): """return fan power in bhp given the fan IDF object""" from eppy.bunch_subclass import BadEPFieldError # here to prevent circular dependency try: fan_tot_eff = ddtt.Fan_Total_Efficiency # from V+ V8.7.0 onwards except BadEPFieldError as e: fan_tot_eff = ddtt.Fan...
Create a Python 3 function for returning the fan power in bhp given the fan IDF object
As a python code expert, you are capable of creating scripts from specifications.
return the fan max cfm
Make a summary of the following Python 3 code def fan_maxcfm(ddtt): if str(ddtt.Maximum_Flow_Rate).lower() == 'autosize': # str can fail with unicode chars :-( return 'autosize' else: m3s = float(ddtt.Maximum_Flow_Rate) return m3s2cfm(m3s)
As a Python code translator, you convert algorithms and pseudocode into Python.
def install_paths(version=None, iddname=None): """Get the install paths for EnergyPlus executable and weather files. We prefer to get the install path from the IDD name but fall back to getting it from the version number for backwards compatibility and to simplify tests. Parameters ---------- ...
How would you implement a function in Python 3 that gets the install paths for EnergyPlus executable and weather files.
As a Python code analyst, you investigate and solve complex coding mysteries
def paths_from_iddname(iddname): """Get the EnergyPlus install directory and executable path. Parameters ---------- iddname : str, optional File path to the IDD. Returns ------- eplus_exe : str Full path to the EnergyPlus executable. eplus_home : str Full path t...
Write a Python 3 script for getting the EnergyPlus install directory and executable path from an IDD.
You are a Python code architect, reviewing and designing scalable and efficient code
def paths_from_version(version): """Get the EnergyPlus install directory and executable path. Parameters ---------- version : str, optional EnergyPlus version in the format "X-X-X", e.g. "8-7-0". Returns ------- eplus_exe : str Full path to the EnergyPlus executable. ep...
How would you code a function in Python 3 to get the EnergyPlus install directory and executable path.
As a Python code composer, you craft elegant and concise scripts.
Wrapper for run() to be used when running IDF5 runs in parallel.
Can you generate the documentation for the following Python 3 function def runIDFs(jobs, processors=1): if processors <= 0: processors = max(1, mp.cpu_count() - processors) shutil.rmtree("multi_runs", ignore_errors=True) os.mkdir("multi_runs") prepared_runs = (prepare_run(run_id, run_data) for...
You are a Python code architect, reviewing and designing scalable and efficient code
Prepare run inputs for one of multiple EnergyPlus runs.
How would you explain what the following Python 3 function does def prepare_run(run_id, run_data): idf, kwargs = run_data epw = idf.epw idf_dir = os.path.join('multi_runs', 'idf_%i' % run_id) os.mkdir(idf_dir) idf_path = os.path.join(idf_dir, 'in.idf') idf.saveas(idf_path) return (idf_path, ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Wrapper around the EnergyPlus command line interface.
Here you have a function in Python 3, explain what it does def run(idf=None, weather=None, output_directory='', annual=False, design_day=False, idd=None, epmacro=False, expandobjects=False, readvars=False, output_prefix=None, output_suffix=None, version=False, verbose='v', ep_version=None): ...
You are a Python code architect, reviewing and designing scalable and efficient code
Parse the error file and put it in the exception message.
Here you have a function in Python 3, explain what it does def parse_error(output_dir): sys.stderr.seek(0) std_err = sys.stderr.read().decode('utf-8') err_file = os.path.join(output_dir, "eplusout.err") if os.path.isfile(err_file): with open(err_file, "r") as f: ep_err = f.read() ...
As a Python code analyst, you investigate and solve complex coding mysteries
def rvalue(ddtt): """ R value (W/K) of a construction or material. thickness (m) / conductivity (W/m-K) """ object_type = ddtt.obj[0] if object_type == 'Construction': rvalue = INSIDE_FILM_R + OUTSIDE_FILM_R layers = ddtt.obj[2:] field_idd = ddtt.getfieldidd('Outside_Laye...
Write a Python 3 script to get the rvalue of a single object in IDF
You are a Python code generator, capable of creating scripts from specifications.
def heatcapacity(ddtt): """ Heat capacity (kJ/m2-K) of a construction or material. thickness (m) * density (kg/m3) * specific heat (J/kg-K) * 0.001 """ object_type = ddtt.obj[0] if object_type == 'Construction': heatcapacity = 0 layers = ddtt.obj[2:] field_idd = ddtt.getf...
Can you create a Python 3 function that gets the heat capacity of a single object in IDF
As a Python code translator, you convert algorithms and pseudocode into Python.
def almostequal(first, second, places=7, printit=True): """ Test if two values are equal to a given number of places. This is based on python's unittest so may be covered by Python's license. """ if first == second: return True if round(abs(second - first), places) != 0: if...
Implement a Python 3 function for testing if two values are equal to a given number of places.
As a Python code composer, you craft elegant and concise scripts.
def newrawobject(data, commdct, key, block=None, defaultvalues=True): """Make a new object for the given key. Parameters ---------- data : Eplusdata object Data dictionary and list of objects for the entire model. commdct : list of dicts Comments from the IDD file describing each it...
Write a Python 3 function that can make a new object for the given key.
You are a Python code generator, capable of creating scripts from specifications.
add a bunch to the bunchdt
Make a summary of the following Python 3 code def addthisbunch(bunchdt, data, commdct, thisbunch, theidf): key = thisbunch.key.upper() obj = copy.copy(thisbunch.obj) abunch = obj2bunch(data, commdct, obj) bunchdt[key].append(abunch) return abunch
As a Python code analyst, you investigate and solve complex coding mysteries
def obj2bunch(data, commdct, obj): """make a new bunch object using the data object""" dtls = data.dtls key = obj[0].upper() key_i = dtls.index(key) abunch = makeabunch(commdct, obj, key_i) return abunch
Write a Python 3 script for making a bunch object using the data object
You are a Python code analyst, evaluating scripts for potential improvements.
def addobject(bunchdt, data, commdct, key, theidf, aname=None, **kwargs): """add an object to the eplus model""" obj = newrawobject(data, commdct, key) abunch = obj2bunch(data, commdct, obj) if aname: namebunch(abunch, aname) data.dt[key].append(obj) bunchdt[key].append(abunch) for k...
Write a Python 3 script to add an object to the bunchdt
You are a Python code analyst, evaluating scripts for potential improvements.
allows you to pass a dict and named args Taxonomy so you can pass a dict and named kwargs Taxonomy so you can pass a dict and named args Taxonomy so you can pass a dict and get dict
How would you explain what the following Python 3 function does def getnamedargs(*args, **kwargs): adict = {} for arg in args: if isinstance(arg, dict): adict.update(arg) adict.update(kwargs) return adict
You are a Python code generator, capable of creating scripts from specifications.
add an object to the eplus model
How would you explain what the following Python 3 function does def addobject1(bunchdt, data, commdct, key, **kwargs): obj = newrawobject(data, commdct, key) abunch = obj2bunch(data, commdct, obj) data.dt[key].append(obj) bunchdt[key].append(abunch) # adict = getnamedargs(*args, **kwargs) for kk...
As a Python code translator, you convert algorithms and pseudocode into Python.
get the object if you have the key and the name returns a list of objects
Make a summary of the following Python 3 code def getobject(bunchdt, key, name): # TODO : throw exception if more than one object, or return more objects idfobjects = bunchdt[key] if idfobjects: # second item in list is a unique ID unique_id = idfobjects[0].objls[1] theobjs = [idfobj for...
As a Python code analyst, you investigate and solve complex coding mysteries
def __objecthasfields(bunchdt, data, commdct, idfobject, places=7, **kwargs): """test if the idf object has the field values in kwargs""" for key, value in list(kwargs.items()): if not isfieldvalue( bunchdt, data, commdct, idfobject, key, value, places=places): ...
Write a Python 3 function that can test if the idf object has the fields in kwargs
As a Python code translator, you convert algorithms and pseudocode into Python.
get all the objects of the given key that match the fields in kwargs
How would you explain what the following Python 3 function does def getobjects(bunchdt, data, commdct, key, places=7, **kwargs): idfobjects = bunchdt[key] allobjs = [] for obj in idfobjects: if __objecthasfields( bunchdt, data, commdct, obj, places=places, **kwargs): ...
You are a Python code analyst, evaluating scripts for potential improvements.
def getextensibleindex(bunchdt, data, commdct, key, objname): """get the index of the first extensible item""" theobject = getobject(bunchdt, key, objname) if theobject == None: return None theidd = iddofobject(data, commdct, key) extensible_i = [ i for i in range(len(theidd)) if 'be...
Write a Python 3 script to get the index of the first extensible item
As a python code expert, you are capable of creating scripts from specifications.
def removeextensibles(bunchdt, data, commdct, key, objname): """remove the extensible items in the object""" theobject = getobject(bunchdt, key, objname) if theobject == None: return theobject theidd = iddofobject(data, commdct, key) extensible_i = [ i for i in range(len(theidd)) if ...
Write a Python 3 script to remove the extensible items in the object
As a Python code analyst, you investigate and solve complex coding mysteries
def getfieldcomm(bunchdt, data, commdct, idfobject, fieldname): """get the idd comment for the field""" key = idfobject.obj[0].upper() keyi = data.dtls.index(key) fieldi = idfobject.objls.index(fieldname) thiscommdct = commdct[keyi][fieldi] return thiscommdct
Write a Python 3 function for getting the idd comment for the field
You are a Python code architect, reviewing and designing scalable and efficient code
def is_retaincase(bunchdt, data, commdct, idfobject, fieldname): """test if case has to be retained for that field""" thiscommdct = getfieldcomm(bunchdt, data, commdct, idfobject, fieldname) return 'retaincase' in thiscommdct
Implement a Python 3 function for testing if case has to be retained for that field
As a Python code composer, you craft elegant and concise scripts.
test if idfobj. field == value
Given the following Python 3 function, write the documentation def isfieldvalue(bunchdt, data, commdct, idfobj, fieldname, value, places=7): # do a quick type check # if type(idfobj[fieldname]) != type(value): # return False # takes care of autocalculate and real # check float thiscommdct = getfield...
As a Python code translator, you convert algorithms and pseudocode into Python.
returns true if the two fields are equal
Can you generate a brief explanation for the following Python 3 code def equalfield(bunchdt, data, commdct, idfobj1, idfobj2, fieldname, places=7): # TODO test if both objects are of same type key1 = idfobj1.obj[0].upper() key2 = idfobj2.obj[0].upper() if key1 != key2: raise NotSameObjectError ...
As a Python code composer, you craft elegant and concise scripts.
def getrefnames(idf, objname): """get the reference names for this object""" iddinfo = idf.idd_info dtls = idf.model.dtls index = dtls.index(objname) fieldidds = iddinfo[index] for fieldidd in fieldidds: if 'field' in fieldidd: if fieldidd['field'][0].endswith('Name'): ...
Write a Python 3 function for getting the reference names for this object
You are a Python code architect, reviewing and designing scalable and efficient code
rename all the refrences to this objname
Can you tell what is the following Python 3 function doing def rename(idf, objkey, objname, newname): refnames = getrefnames(idf, objkey) for refname in refnames: objlists = getallobjlists(idf, refname) # [('OBJKEY', refname, fieldindexlist), ...] for refname in refnames: # TODO ...
As a Python code analyst, you investigate and solve complex coding mysteries
zone height min - max
Can you generate a brief explanation for the following Python 3 code def zone_height_min2max(idf, zonename, debug=False): zone = idf.getobject('ZONE', zonename) surfs = idf.idfobjects['BuildingSurface:Detailed'.upper()] zone_surfs = [s for s in surfs if s.Zone_Name == zone.Name] surf_xyzs = [eppy.functi...
You are a Python code generator, capable of creating scripts from specifications.
def zoneheight(idf, zonename, debug=False): """zone height""" zone = idf.getobject('ZONE', zonename) surfs = idf.idfobjects['BuildingSurface:Detailed'.upper()] zone_surfs = [s for s in surfs if s.Zone_Name == zone.Name] floors = [s for s in zone_surfs if s.Surface_Type.upper() == 'FLOOR'] roofs ...
Write a Python 3 script for getting the height of a zone
You are a Python code generator, capable of creating scripts from specifications.
def zone_floor2roofheight(idf, zonename, debug=False): """zone floor to roof height""" zone = idf.getobject('ZONE', zonename) surfs = idf.idfobjects['BuildingSurface:Detailed'.upper()] zone_surfs = [s for s in surfs if s.Zone_Name == zone.Name] floors = [s for s in zone_surfs if s.Surface_Type.upper...
How would you implement a function in Python 3 that zones floor to roof height
As a Python code composer, you craft elegant and concise scripts.
Set the path to the EnergyPlus IDD file which is used by eppy.
Make a summary of the following Python 3 code def setiddname(cls, iddname, testing=False): if cls.iddname == None: cls.iddname = iddname cls.idd_info = None cls.block = None elif cls.iddname == iddname: pass else: if testing == False: ...
As a Python code translator, you convert algorithms and pseudocode into Python.
def setidd(cls, iddinfo, iddindex, block, idd_version): """Set the IDD to be used by eppy. Parameters ---------- iddinfo : list Comments and metadata about fields in the IDD. block : list Field names in the IDD. """ cls.idd_info = iddinfo...
Write a Python 3 function that can set the IDD to be used by eppy.
As a Python code composer, you craft elegant and concise scripts.
Initialize the IDD with the contents of the IDF file.
How would you explain what the following Python 3 function does def initread(self, idfname): with open(idfname, 'r') as _: # raise nonexistent file error early if idfname doesn't exist pass iddfhandle = StringIO(iddcurrent.iddtxt) if self.getiddname() == None: ...
As a python code expert, you are capable of creating scripts from specifications.
Initialize the IDD and read an IDF from text data.
Can you tell what is the following Python 3 function doing def initreadtxt(self, idftxt): iddfhandle = StringIO(iddcurrent.iddtxt) if self.getiddname() == None: self.setiddname(iddfhandle) idfhandle = StringIO(idftxt) self.idfname = idfhandle self.read()
You are a Python code architect, reviewing and designing scalable and efficient code
def read(self): """ Read the IDF file and the IDD file. If the IDD file had already been read, it will not be read again. Read populates the following data structures: - idfobjects : list - model : list - idd_info : list - idd_index : dict """ ...
Can you implement a function in Python 3 that reads the IDF file and the IDD file.
As a python code expert, you are capable of creating scripts from specifications.
Initialize the current IDD and create a new empty IDF.
Can you generate the documentation for the following Python 3 function def initnew(self, fname): iddfhandle = StringIO(iddcurrent.iddtxt) if self.getiddname() == None: self.setiddname(iddfhandle) idfhandle = StringIO('') self.idfname = idfhandle self.read() if...
You are a Python code architect, reviewing and designing scalable and efficient code
def newidfobject(self, key, aname='', defaultvalues=True, **kwargs): """ Add a new idfobject to the model. If you don't specify a value for a field, the default value will be set. For example :: newidfobject("CONSTRUCTION") newidfobject("CONSTRUCTION", ...
Write a Python 3 function that can add a new IDF object to the model.
As a python code expert, you are capable of creating scripts from specifications.
Removes an IDF object from the IDF.
How would you explain what the following Python 3 function does def removeidfobject(self, idfobject): key = idfobject.key.upper() self.idfobjects[key].remove(idfobject)
As a Python code analyst, you investigate and solve complex coding mysteries
Add an IDF object to the IDF.
Explain what the following Python 3 code does def copyidfobject(self, idfobject): return addthisbunch(self.idfobjects, self.model, self.idd_info, idfobject, self)
As a python code expert, you are capable of creating scripts from specifications.
def getextensibleindex(self, key, name): """ Get the index of the first extensible item. Only for internal use. # TODO : hide this Parameters ---------- key : str The type of IDF object. This must be in ALL_CAPS. name : str The name of th...
Write a Python 3 function that can return the index of the first extensible item in the list of items in the IDF table.
You are a Python code generator, capable of creating scripts from specifications.
Remove extensible items in the object of key and name.
Here you have a function in Python 3, explain what it does def removeextensibles(self, key, name): return removeextensibles( self.idfobjects, self.model, self.idd_info, key, name)
As a python code expert, you are capable of creating scripts from specifications.
def idfstr(self): """String representation of the IDF. Returns ------- str """ if self.outputtype == 'standard': astr = '' else: astr = self.model.__repr__() if self.outputtype == 'standard': astr = '' dtl...
Implement a function in Python 3 to return the string representation of the IDF.
As a Python code composer, you craft elegant and concise scripts.
def save(self, filename=None, lineendings='default', encoding='latin-1'): """ Save the IDF as a text file with the optional filename passed, or with the current idfname of the IDF. Parameters ---------- filename : str, optional Filepath to save the file. If N...
Can you create a Python 3 function that saves the IDF as a text file with the optional filename passed or with the current idfname of the IDF.
As a Python code composer, you craft elegant and concise scripts.
Save the IDF as a text file with the filename passed.
Can you generate a brief explanation for the following Python 3 code def saveas(self, filename, lineendings='default', encoding='latin-1'): self.idfname = filename self.save(filename, lineendings, encoding)
You are a Python code analyst, evaluating scripts for potential improvements.
def savecopy(self, filename, lineendings='default', encoding='latin-1'): """Save a copy of the file with the filename passed. Parameters ---------- filename : str Filepath to save the file. lineendings : str, optional Line endings to use in the saved fil...
How would you code a function in Python 3 to save a copy of the file with the filename passed.
You are a Python code generator, capable of creating scripts from specifications.
This is the main entry point for the EnergyPlus command line interface.
Can you generate a brief explanation for the following Python 3 code def run(self, **kwargs): # write the IDF to the current directory self.saveas('in.idf') # if `idd` is not passed explicitly, use the IDF.iddname idd = kwargs.pop('idd', self.iddname) epw = kwargs.pop('weather', ...
As a Python code translator, you convert algorithms and pseudocode into Python.
printdict - prints the dictionary adict
Here you have a function in Python 3, explain what it does def printdict(adict): dlist = list(adict.keys()) dlist.sort() for i in range(0, len(dlist)): print(dlist[i], adict[dlist[i]])
As a Python code composer, you craft elegant and concise scripts.
def tabstr2list(data): """tabstr2list""" alist = data.split(os.linesep) blist = alist[1].split('\t') clist = [] for num in range(0, len(alist)): ilist = alist[num].split('\t') clist = clist+[ilist] cclist = clist[:-1] #the last element is turning out to be empty #thi...
Implement a Python 3 function for converting a tabstr to a list of unique ids
As a Python code translator, you convert algorithms and pseudocode into Python.
converts a list of tables to a single table of tables
Can you tell what is the following Python 3 function doing def list2doe(alist): theequal = '' astr = '' lenj = len(alist) leni = len(alist[0]) for i in range(0, leni-1): for j in range(0, lenj): if j == 0: astr = astr + alist[j][i + 1] + theequal + alist[j][0] + R...
You are a Python code architect, reviewing and designing scalable and efficient code
convert tabfile to doefile
Explain what the following Python 3 code does def tabfile2doefile(tabfile, doefile): alist = tabfile2list(tabfile) astr = list2doe(alist) mylib1.write_str2file(doefile, astr)
You are a Python code architect, reviewing and designing scalable and efficient code
make a new dict that contains all of the keys in ddict and bdict that are not in bdict
Explain what the following Python 3 code does def makedoetree(ddict, bdict): dlist = list(ddict.keys()) blist = list(bdict.keys()) dlist.sort() blist.sort() #make space dict doesnot = 'DOES NOT' lst = [] for num in range(0, len(blist)): if bdict[blist[num]] == doesnot:#belong ...
As a Python code composer, you craft elegant and concise scripts.
tree2doe - converts a string into a single DOE
Given the following Python 3 function, write the documentation def tree2doe(str1): retstuff = makedoedict(str1) ddict = makedoetree(retstuff[0], retstuff[1]) ddict = retstuff[0] retstuff[1] = {}# don't need it anymore str1 = ''#just re-using it l1list = list(ddict.keys()) l1list.sort() ...
You are a Python code generator, capable of creating scripts from specifications.
mtabstr2doestr - convert a string to a tree
Can you generate the documentation for the following Python 3 function def mtabstr2doestr(st1): seperator = '$ ==============' alist = st1.split(seperator) #this removes all the tabs that excel #puts after the seperator and before the next line for num in range(0, len(alist)): alist[num] = ...
You are a Python code architect, reviewing and designing scalable and efficient code
def getoneblock(astr, start, end): """get the block bounded by start and end doesn't work for multiple blocks""" alist = astr.split(start) astr = alist[-1] alist = astr.split(end) astr = alist[0] return astr
Write a Python 3 function that can get the block bounded by start and end doesn t work for multiple blocks
You are a Python code generator, capable of creating scripts from specifications.
converts a DOS string to a TAB string
Make a summary of the following Python 3 code def doestr2tabstr(astr, kword): alist = astr.split('..') del astr #strip junk put .. back for num in range(0, len(alist)): alist[num] = alist[num].strip() alist[num] = alist[num] + os.linesep + '..' + os.linesep alist.pop() lblock = ...
You are a Python code generator, capable of creating scripts from specifications.
in string astr replace all occurences of thefind with thereplace
Can you generate the documentation for the following Python 3 function def myreplace(astr, thefind, thereplace): alist = astr.split(thefind) new_s = alist.split(thereplace) return new_s
As a python code expert, you are capable of creating scripts from specifications.
def fsliceafter(astr, sub): """Return the slice after at sub in string astr""" findex = astr.find(sub) return astr[findex + len(sub):]
Can you write a function in Python 3 where it returns the slice after at sub in string astr
As a Python code translator, you convert algorithms and pseudocode into Python.
same as pickle. dump
How would you explain what the following Python 3 function does def pickledump(theobject, fname): fhandle = open(fname, 'wb') pickle.dump(theobject, fhandle)
You are a Python code architect, reviewing and designing scalable and efficient code
writes a string to file
How would you explain what the following Python 3 function does def write_str2file(pathname, astr): fname = pathname fhandle = open(fname, 'wb') fhandle.write(astr) fhandle.close()
You are a Python code generator, capable of creating scripts from specifications.
volume of a irregular tetrahedron
How would you explain what the following Python 3 function does def vol_tehrahedron(poly): a_pnt = np.array(poly[0]) b_pnt = np.array(poly[1]) c_pnt = np.array(poly[2]) d_pnt = np.array(poly[3]) return abs(np.dot( (a_pnt-d_pnt), np.cross((b_pnt-d_pnt), (c_pnt-d_pnt))) / 6)
As a Python code composer, you craft elegant and concise scripts.
volume of a zone defined by two polygon bases
Can you generate the documentation for the following Python 3 function def vol_zone(poly1, poly2): c_point = central_p(poly1, poly2) c_point = (c_point[0], c_point[1], c_point[2]) vol_therah = 0 num = len(poly1) for i in range(num-2): # the upper part tehrahedron = [c_point, poly1[0]...
As a Python code translator, you convert algorithms and pseudocode into Python.
open a new idf file for particular version
Make a summary of the following Python 3 code def newidf(version=None): if not version: version = "8.9" import eppy.easyopen as easyopen idfstring = " Version,{};".format(str(version)) fhandle = StringIO(idfstring) return easyopen.easyopen(fhandle)
You are a Python code analyst, evaluating scripts for potential improvements.
automatically set idd and open idf file. Uses version from idf to set correct idd
Given the following Python 3 function, write the documentation def openidf(fname, idd=None, epw=None): import eppy.easyopen as easyopen return easyopen.easyopen(fname, idd=idd, epw=epw)
You are a Python code generator, capable of creating scripts from specifications.
def wallinterzone(idf, bsdobject, deletebsd=True, setto000=False): """return an wall:interzone object if the bsd (buildingsurface:detailed) is an interaone wall""" # ('WALL:INTERZONE', Wall, Surface OR Zone OR OtherSideCoefficients) # test if it is an exterior wall if bsdobject.Surface_Type.upper()...
Write a Python 3 function for returning an interaone wall if the bsd object is an interaone wall
You are a Python code generator, capable of creating scripts from specifications.
return an door object if the fsd ( fenestrationsurface : detailed ) is a door object if the fsd ( fenestrationsurface : detailed ) is a door object if the fsd ( fenestrationsurface : detailed ) is a door object if the fsd ( fenestrationsurface : detailed ) is a door object if the fsd ( f
Given the following Python 3 function, write the documentation def door(idf, fsdobject, deletebsd=True, setto000=False): # ('DOOR', Door, None) # test if it is aroof if fsdobject.Surface_Type.upper() == 'DOOR': # Surface_Type == w simpleobject = idf.newidfobject('DOOR') simpleobject.Name = f...
You are a Python code analyst, evaluating scripts for potential improvements.
convert a bsd into a simple surface
Here you have a function in Python 3, explain what it does def simplesurface(idf, bsd, deletebsd=True, setto000=False): funcs = (wallexterior, walladiabatic, wallunderground, wallinterzone, roof, ceilingadiabatic, ceilinginterzone, floorgroundcontact, ...
As a Python code composer, you craft elegant and concise scripts.
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...
Can you write a function in Python 3 where it converts a bsd ( fenestrationsurface : detailed into a simple
As a Python code analyst, you investigate and solve complex coding mysteries
convert the br in td into line ending
Make a summary of the following Python 3 code def tdbr2EOL(td): 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 BeautifulSoup ntxt =...
As a Python code composer, you craft elegant and concise scripts.
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...
Can you write a function in Python 3 where it tests if the table has only strings in the cells
You are a Python code analyst, evaluating scripts for potential improvements.
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...
Write a Python 3 script to convert a table to a list of lists - a 2D matrix
As a Python code composer, you craft elegant and concise scripts.
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'): ...
How would you code a function in Python 3 to convert a table to a list of lists - a 2D matrix
As a Python code composer, you craft elegant and concise scripts.
return a list of tuples of title table...
Given the following Python 3 function, write the documentation def titletable(html_doc, tofloat=True): soup = BeautifulSoup(html_doc, "html.parser") btables = soup.find_all(['b', 'table']) # find all the <b> and <table> titletables = [] for i, item in enumerate(btables): if item.name == 'table':...
As a Python code analyst, you investigate and solve complex coding mysteries
checks if soup_obj is really a soup object or just a string
How would you explain what the following Python 3 function does def _has_name(soup_obj): try: name = soup_obj.name if name == None: return False return True except AttributeError: return False
As a python code expert, you are capable of creating scripts from specifications.
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...
Can you implement a function in Python 3 that returns a list of lines between this table and the previous table
As a Python code analyst, you investigate and solve complex coding mysteries
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, ...
Implement a Python 3 function for making a named tuple grid
As a python code expert, you are capable of creating scripts from specifications.
return only legal chars
Here you have a function in Python 3, explain what it does def onlylegalchar(name): legalchar = ascii_letters + digits + ' ' return ''.join([s for s in name[:] if s in legalchar])
As a Python code translator, you convert algorithms and pseudocode into Python.
Check if two strings are equal ignoring case and spaces / underscore.
Make a summary of the following Python 3 code def matchfieldnames(field_a, field_b): normalised_a = field_a.replace(' ', '_').lower() normalised_b = field_b.replace(' ', '_').lower() return normalised_a == normalised_b
As a python code expert, you are capable of creating scripts from specifications.
test if int in list
Can you generate a brief explanation for the following Python 3 code def intinlist(lst): for item in lst: try: item = int(item) return True except ValueError: pass return False
As a Python code translator, you convert algorithms and pseudocode into Python.
replace int in lst
Can you generate the documentation for the following Python 3 function def replaceint(fname, replacewith='%s'): words = fname.split() for i, word in enumerate(words): try: word = int(word) words[i] = replacewith except ValueError: pass return ' '.join(word...
You are a Python code generator, capable of creating scripts from specifications.
make all the keys lower case
Make a summary of the following Python 3 code def cleaniddfield(acomm): 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
As a python code expert, you are capable of creating scripts from specifications.
return the csv to be displayed
Can you generate the documentation for the following Python 3 function def makecsvdiffs(thediffs, dtls, n1, n2): def ishere(val): if val == None: return "not here" else: return "is here" rows = [] rows.append(['file1 = %s' % (n1, )]) rows.append(['file2 = %s' % (n...
As a python code expert, you are capable of creating scripts from specifications.
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...
Implement a Python 3 function for returning the diffs between two idfs
You are a Python code architect, reviewing and designing scalable and efficient code
add heading row to table
Given the following Python 3 function, write the documentation def heading2table(soup, table, row): tr = Tag(soup, name="tr") table.append(tr) for attr in row: th = Tag(soup, name="th") tr.append(th) th.append(attr)
You are a Python code architect, reviewing and designing scalable and efficient code
ad a row to the table
Can you generate a brief explanation for the following Python 3 code def row2table(soup, table, row): tr = Tag(soup, name="tr") table.append(tr) for attr in row: td = Tag(soup, name="td") tr.append(td) td.append(attr)
You are a Python code analyst, evaluating scripts for potential improvements.
extend the list so that you have i - th value
Given the following Python 3 function, write the documentation def extendlist(lst, i, value=''): if i < len(lst): pass else: lst.extend([value, ] * (i - len(lst) + 1))
As a python code expert, you are capable of creating scripts from specifications.
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...
Write a Python 3 script to add functions to the epbunch
You are a Python code architect, reviewing and designing scalable and efficient code
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] = ...
Write a Python 3 script for getting the ranges for this field
As a Python code translator, you convert algorithms and pseudocode into Python.
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...
Create a Python 3 function for checking if the value of the fieldname is in the range of the idd dict
As a Python code analyst, you investigate and solve complex coding mysteries
get the idd dict for this fieldname Will return {} if the fieldname does not exist
Can you generate a brief explanation for the following Python 3 code def getfieldidd(bch, fieldname): # print(bch) try: fieldindex = bch.objls.index(fieldname) except ValueError as e: return {} # the fieldname does not exist # so there is no idd fieldidd = bch.objidd...
As a Python code composer, you craft elegant and concise scripts.
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: ...
Can you implement a function in Python 3 that returns an item from the fieldidd given the iddkey
As a python code expert, you are capable of creating scripts from specifications.
return True if the field is equal to value
Make a summary of the following Python 3 code def isequal(bch, fieldname, value, places=7): def equalalphanumeric(bch, fieldname, value): if bch.get_retaincase(fieldname): return bch[fieldname] == value else: return bch[fieldname].upper() == value.upper() fieldidd = bch....
As a Python code composer, you craft elegant and concise scripts.
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] ...
Create a Python 3 function for getting a list of objects that refer to this object
As a Python code composer, you craft elegant and concise scripts.
Get an object that is referenced by a field in another object.
Here you have a function in Python 3, explain what it does def get_referenced_object(referring_object, fieldname): idf = referring_object.theidf object_list = referring_object.getfieldidd_item(fieldname, u'object-list') for obj_type in idf.idfobjects: for obj in idf.idfobjects[obj_type]: ...
You are a Python code generator, capable of creating scripts from specifications.
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)
Implement a function in Python 3 to return True if the field == value
You are a Python code architect, reviewing and designing scalable and efficient code
Get a list of objects that refer to this object
Can you generate a brief explanation for the following Python 3 code def getreferingobjs(self, iddgroups=None, fields=None): return getreferingobjs(self, iddgroups=iddgroups, fields=fields)
You are a Python code analyst, evaluating scripts for potential improvements.
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...
Implement a Python 3 function for voluming of a irregular tetrahedron
As a python code expert, you are capable of creating scripts from specifications.
volume of a zone defined by two polygon bases
Can you generate a brief explanation for the following Python 3 code def vol(poly1, poly2): 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 up...
You are a Python code architect, reviewing and designing scalable and efficient code