sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def tag_and_stem(self, text, cache=None): """ Given some text, return a sequence of (stem, pos, text) triples as appropriate for the reader. `pos` can be as general or specific as necessary (for example, it might label all parts of speech, or it might only distinguish function wo...
Given some text, return a sequence of (stem, pos, text) triples as appropriate for the reader. `pos` can be as general or specific as necessary (for example, it might label all parts of speech, or it might only distinguish function words from others). Twitter-style hashtags and at-menti...
entailment
def extract_phrases(self, text): """ Given some text, extract phrases of up to 2 content words, and map their normalized form to the complete phrase. """ analysis = self.analyze(text) for pos1 in range(len(analysis)): rec1 = analysis[pos1] if not s...
Given some text, extract phrases of up to 2 content words, and map their normalized form to the complete phrase.
entailment
def to_kana(text): """ Use MeCab to turn any text into its phonetic spelling, as katakana separated by spaces. """ records = MECAB.analyze(text) kana = [] for record in records: if record.pronunciation: kana.append(record.pronunciation) elif record.reading: ...
Use MeCab to turn any text into its phonetic spelling, as katakana separated by spaces.
entailment
def get_kana_info(char): """ Return two things about each character: - Its transliterated value (in Roman characters, if it's a kana) - A class of characters indicating how it affects the romanization """ try: name = unicodedata.name(char) except ValueError: return char, NOT...
Return two things about each character: - Its transliterated value (in Roman characters, if it's a kana) - A class of characters indicating how it affects the romanization
entailment
def analyze(self, text): """ Runs a line of text through MeCab, and returns the results as a list of lists ("records") that contain the MeCab analysis of each word. """ try: self.process # make sure things are loaded text = render_safe(text).repla...
Runs a line of text through MeCab, and returns the results as a list of lists ("records") that contain the MeCab analysis of each word.
entailment
def is_stopword_record(self, record): """ Determine whether a single MeCab record represents a stopword. This mostly determines words to strip based on their parts of speech. If common_words is set to True (default), it will also strip common verbs and nouns such as くる and よう. I...
Determine whether a single MeCab record represents a stopword. This mostly determines words to strip based on their parts of speech. If common_words is set to True (default), it will also strip common verbs and nouns such as くる and よう. If more_stopwords is True, it will look at the sub-...
entailment
def get_record_pos(self, record): """ Given a record, get the word's part of speech. Here we're going to return MeCab's part of speech (written in Japanese), though if it's a stopword we prefix the part of speech with '~'. """ if self.is_stopword_record(record): ...
Given a record, get the word's part of speech. Here we're going to return MeCab's part of speech (written in Japanese), though if it's a stopword we prefix the part of speech with '~'.
entailment
def analyze(self, text): """ Run text through the external process, and get a list of lists ("records") that contain the analysis of each word. """ try: text = render_safe(text).strip() if not text: return [] chunks = text.split...
Run text through the external process, and get a list of lists ("records") that contain the analysis of each word.
entailment
def untokenize(words): """ Untokenizing a text undoes the tokenizing operation, restoring punctuation and spaces to the places that people expect them to be. Ideally, `untokenize(tokenize(text))` should be identical to `text`, except for line breaks. """ text = ' '.join(words) step1 = t...
Untokenizing a text undoes the tokenizing operation, restoring punctuation and spaces to the places that people expect them to be. Ideally, `untokenize(tokenize(text))` should be identical to `text`, except for line breaks.
entailment
def un_camel_case(text): r""" Splits apart words that are written in CamelCase. Bugs: - Non-ASCII characters are treated as lowercase letters, even if they are actually capital letters. Examples: >>> un_camel_case('1984ZXSpectrumGames') '1984 ZX Spectrum Games' >>> un_camel_ca...
r""" Splits apart words that are written in CamelCase. Bugs: - Non-ASCII characters are treated as lowercase letters, even if they are actually capital letters. Examples: >>> un_camel_case('1984ZXSpectrumGames') '1984 ZX Spectrum Games' >>> un_camel_case('aaAa aaAaA 0aA AAAa!AAA'...
entailment
def string_pieces(s, maxlen=1024): """ Takes a (unicode) string and yields pieces of it that are at most `maxlen` characters, trying to break it at punctuation/whitespace. This is an important step before using a tokenizer with a maximum buffer size. """ if not s: return i = 0 wh...
Takes a (unicode) string and yields pieces of it that are at most `maxlen` characters, trying to break it at punctuation/whitespace. This is an important step before using a tokenizer with a maximum buffer size.
entailment
def _word_badness(word): """ Assign a heuristic to possible outputs from Morphy. Minimizing this heuristic avoids incorrect stems. """ if word.endswith('e'): return len(word) - 2 elif word.endswith('ess'): return len(word) - 10 elif word.endswith('ss'): return len(wor...
Assign a heuristic to possible outputs from Morphy. Minimizing this heuristic avoids incorrect stems.
entailment
def _morphy_best(word, pos=None): """ Get the most likely stem for a word using Morphy, once the input has been pre-processed by morphy_stem(). """ results = [] if pos is None: pos = 'nvar' for pos_item in pos: results.extend(morphy(word, pos_item)) if not results: ...
Get the most likely stem for a word using Morphy, once the input has been pre-processed by morphy_stem().
entailment
def morphy_stem(word, pos=None): """ Get the most likely stem for a word. If a part of speech is supplied, the stem will be more accurate. Valid parts of speech are: - 'n' or 'NN' for nouns - 'v' or 'VB' for verbs - 'a' or 'JJ' for adjectives - 'r' or 'RB' for adverbs Any other pa...
Get the most likely stem for a word. If a part of speech is supplied, the stem will be more accurate. Valid parts of speech are: - 'n' or 'NN' for nouns - 'v' or 'VB' for verbs - 'a' or 'JJ' for adjectives - 'r' or 'RB' for adverbs Any other part of speech will be treated as unknown.
entailment
def tag_and_stem(text): """ Returns a list of (stem, tag, token) triples: - stem: the word's uninflected form - tag: the word's part of speech - token: the original word, so we can reconstruct it later """ tokens = tokenize(text) tagged = nltk.pos_tag(tokens) out = [] for token,...
Returns a list of (stem, tag, token) triples: - stem: the word's uninflected form - tag: the word's part of speech - token: the original word, so we can reconstruct it later
entailment
def normalize_list(text): """ Get a list of word stems that appear in the text. Stopwords and an initial 'to' will be stripped, unless this leaves nothing in the stem. >>> normalize_list('the dog') ['dog'] >>> normalize_list('big dogs') ['big', 'dog'] >>> normalize_list('the') ['the...
Get a list of word stems that appear in the text. Stopwords and an initial 'to' will be stripped, unless this leaves nothing in the stem. >>> normalize_list('the dog') ['dog'] >>> normalize_list('big dogs') ['big', 'dog'] >>> normalize_list('the') ['the']
entailment
def normalize_topic(topic): """ Get a canonical representation of a Wikipedia topic, which may include a disambiguation string in parentheses. Returns (name, disambig), where "name" is the normalized topic name, and "disambig" is a string corresponding to the disambiguation text or None. ""...
Get a canonical representation of a Wikipedia topic, which may include a disambiguation string in parentheses. Returns (name, disambig), where "name" is the normalized topic name, and "disambig" is a string corresponding to the disambiguation text or None.
entailment
def key2elements(key): """split key to elements""" # words = key.split('.') # if len(words) == 4: # return words # # there is a dot in object name # fieldword = words.pop(-1) # nameword = '.'.join(words[-2:]) # if nameword[-1] in ('"', "'"): # # The object name is in quotes ...
split key to elements
entailment
def updateidf(idf, dct): """update idf using dct""" for key in list(dct.keys()): if key.startswith('idf.'): idftag, objkey, objname, field = key2elements(key) if objname == '': try: idfobj = idf.idfobjects[objkey.upper()][0] exc...
update idf using dct
entailment
def fan_bhp(fan_tot_eff, pascal, m3s): """return the fan power in bhp given fan efficiency, Pressure rise (Pa) and flow (m3/s)""" # from discussion in # http://energy-models.com/forum/baseline-fan-power-calculation inh2o = pascal2inh2o(pascal) cfm = m3s2cfm(m3s) return (cfm * inh2o * 1.0) / (635...
return the fan power in bhp given fan efficiency, Pressure rise (Pa) and flow (m3/s)
entailment
def bhp2pascal(bhp, cfm, fan_tot_eff): """return inputs for E+ in pascal and m3/s""" inh2o = bhp * 6356.0 * fan_tot_eff / cfm pascal = inh2o2pascal(inh2o) m3s = cfm2m3s(cfm) return pascal, m3s
return inputs for E+ in pascal and m3/s
entailment
def fan_watts(fan_tot_eff, pascal, m3s): """return the fan power in watts given fan efficiency, Pressure rise (Pa) and flow (m3/s)""" # got this from a google search bhp = fan_bhp(fan_tot_eff, pascal, m3s) return bhp2watts(bhp)
return the fan power in watts given fan efficiency, Pressure rise (Pa) and flow (m3/s)
entailment
def watts2pascal(watts, cfm, fan_tot_eff): """convert and return inputs for E+ in pascal and m3/s""" bhp = watts2bhp(watts) return bhp2pascal(bhp, cfm, fan_tot_eff)
convert and return inputs for E+ in pascal and m3/s
entailment
def fanpower_bhp(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_E...
return fan power in bhp given the fan IDF object
entailment
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...
return fan power in bhp given the fan IDF object
entailment
def fan_maxcfm(ddtt): """return the fan max cfm""" 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)
return the fan max cfm
entailment
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 ---------- ...
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 ---------- version : str, optional EnergyPlus version...
entailment
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...
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 to the EnergyPlus install directory. ...
entailment
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...
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. eplus_home : str Full path to the ...
entailment
def wrapped_help_text(wrapped_func): """Decorator to pass through the documentation from a wrapped function. """ def decorator(wrapper_func): """The decorator. Parameters ---------- f : callable The wrapped function. """ wrapper_func.__doc__ = ('...
Decorator to pass through the documentation from a wrapped function.
entailment
def runIDFs(jobs, processors=1): """Wrapper for run() to be used when running IDF5 runs in parallel. Parameters ---------- jobs : iterable A list or generator made up of an IDF5 object and a kwargs dict (see `run_functions.run` for valid keywords). processors : int, optional ...
Wrapper for run() to be used when running IDF5 runs in parallel. Parameters ---------- jobs : iterable A list or generator made up of an IDF5 object and a kwargs dict (see `run_functions.run` for valid keywords). processors : int, optional Number of processors to run on (default...
entailment
def prepare_run(run_id, run_data): """Prepare run inputs for one of multiple EnergyPlus runs. :param run_id: An ID number for naming the IDF. :param run_data: Tuple of the IDF and keyword args to pass to EnergyPlus executable. :return: Tuple of the IDF path and EPW, and the keyword args. """ id...
Prepare run inputs for one of multiple EnergyPlus runs. :param run_id: An ID number for naming the IDF. :param run_data: Tuple of the IDF and keyword args to pass to EnergyPlus executable. :return: Tuple of the IDF path and EPW, and the keyword args.
entailment
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): """ Wrapper around the EnergyPlus command line interfac...
Wrapper around the EnergyPlus command line interface. Parameters ---------- idf : str Full or relative path to the IDF file to be run, or an IDF object. weather : str Full or relative path to the weather file. output_directory : str, optional Full or relative path to an ou...
entailment
def parse_error(output_dir): """Add contents of stderr and eplusout.err and put it in the exception message. :param output_dir: str :return: str """ 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_f...
Add contents of stderr and eplusout.err and put it in the exception message. :param output_dir: str :return: str
entailment
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...
R value (W/K) of a construction or material. thickness (m) / conductivity (W/m-K)
entailment
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...
Heat capacity (kJ/m2-K) of a construction or material. thickness (m) * density (kg/m3) * specific heat (J/kg-K) * 0.001
entailment
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...
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.
entailment
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...
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 item type in `data`. key : str Object type of the object to add (in...
entailment
def addthisbunch(bunchdt, data, commdct, thisbunch, theidf): """add a bunch to model. abunch usually comes from another idf file or it can be used to copy within the idf file""" key = thisbunch.key.upper() obj = copy.copy(thisbunch.obj) abunch = obj2bunch(data, commdct, obj) bunchdt[key].app...
add a bunch to model. abunch usually comes from another idf file or it can be used to copy within the idf file
entailment
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
make a new bunch object using the data object
entailment
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...
add an object to the eplus model
entailment
def getnamedargs(*args, **kwargs): """allows you to pass a dict and named args so you can pass ({'a':5, 'b':3}, c=8) and get dict(a=5, b=3, c=8)""" adict = {} for arg in args: if isinstance(arg, dict): adict.update(arg) adict.update(kwargs) return adict
allows you to pass a dict and named args so you can pass ({'a':5, 'b':3}, c=8) and get dict(a=5, b=3, c=8)
entailment
def addobject1(bunchdt, data, commdct, key, **kwargs): """add an object to the eplus model""" obj = newrawobject(data, commdct, key) abunch = obj2bunch(data, commdct, obj) data.dt[key].append(obj) bunchdt[key].append(abunch) # adict = getnamedargs(*args, **kwargs) for kkey, value in iteritem...
add an object to the eplus model
entailment
def getobject(bunchdt, key, name): """get the object if you have the key and the name returns a list of objects, in case you have more than one You should not have more than one""" # TODO : throw exception if more than one object, or return more objects idfobjects = bunchdt[key] if idfobjects: ...
get the object if you have the key and the name returns a list of objects, in case you have more than one You should not have more than one
entailment
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): ...
test if the idf object has the field values in kwargs
entailment
def getobjects(bunchdt, data, commdct, key, places=7, **kwargs): """get all the objects of key that matches the fields in **kwargs""" idfobjects = bunchdt[key] allobjs = [] for obj in idfobjects: if __objecthasfields( bunchdt, data, commdct, obj, places=places, **...
get all the objects of key that matches the fields in **kwargs
entailment
def iddofobject(data, commdct, key): """from commdct, return the idd of the object key""" dtls = data.dtls i = dtls.index(key) return commdct[i]
from commdct, return the idd of the object key
entailment
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...
get the index of the first extensible item
entailment
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 ...
remove the extensible items in the object
entailment
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
get the idd comment for the field
entailment
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
test if case has to be retained for that field
entailment
def isfieldvalue(bunchdt, data, commdct, idfobj, fieldname, value, places=7): """test if idfobj.field == value""" # do a quick type check # if type(idfobj[fieldname]) != type(value): # return False # takes care of autocalculate and real # check float thiscommdct = getfieldcomm(bunchdt, data, com...
test if idfobj.field == value
entailment
def equalfield(bunchdt, data, commdct, idfobj1, idfobj2, fieldname, places=7): """returns true if the two fields are equal will test for retaincase places is used if the field is float/real""" # TODO test if both objects are of same type key1 = idfobj1.obj[0].upper() key2 = idfobj2.obj[0].upper(...
returns true if the two fields are equal will test for retaincase places is used if the field is float/real
entailment
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'): ...
get the reference names for this object
entailment
def getallobjlists(idf, refname): """get all object-list fields for refname return a list: [('OBJKEY', refname, fieldindexlist), ...] where fieldindexlist = index of the field where the object-list = refname """ dtls = idf.model.dtls objlists = [] for i, fieldidds in enumerate(idf.idd_in...
get all object-list fields for refname return a list: [('OBJKEY', refname, fieldindexlist), ...] where fieldindexlist = index of the field where the object-list = refname
entailment
def rename(idf, objkey, objname, newname): """rename all the refrences to this objname""" refnames = getrefnames(idf, objkey) for refname in refnames: objlists = getallobjlists(idf, refname) # [('OBJKEY', refname, fieldindexlist), ...] for refname in refnames: # TODO : there ...
rename all the refrences to this objname
entailment
def zonearea(idf, zonename, debug=False): """zone area""" 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'] if debug: ...
zone area
entailment
def zone_height_min2max(idf, zonename, debug=False): """zone height = max-min""" 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.function_helpers.getcoords(s) for s in zone...
zone height = max-min
entailment
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 ...
zone height
entailment
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...
zone floor to roof height
entailment
def zonevolume(idf, zonename): """zone volume""" area = zonearea(idf, zonename) height = zoneheight(idf, zonename) volume = area * height return volume
zone volume
entailment
def setiddname(cls, iddname, testing=False): """ Set the path to the EnergyPlus IDD for the version of EnergyPlus which is to be used by eppy. Parameters ---------- iddname : str Path to the IDD file. testing : bool Flag to use if running ...
Set the path to the EnergyPlus IDD for the version of EnergyPlus which is to be used by eppy. Parameters ---------- iddname : str Path to the IDD file. testing : bool Flag to use if running tests since we may want to ignore the `IDDAlreadySetE...
entailment
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...
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.
entailment
def initread(self, idfname): """ Use the current IDD and read an IDF from file. If the IDD has not yet been initialised then this is done first. Parameters ---------- idf_name : str Path to an IDF file. """ with open(idfname, 'r') as _: ...
Use the current IDD and read an IDF from file. If the IDD has not yet been initialised then this is done first. Parameters ---------- idf_name : str Path to an IDF file.
entailment
def initreadtxt(self, idftxt): """ Use the current IDD and read an IDF from text data. If the IDD has not yet been initialised then this is done first. Parameters ---------- idftxt : str Text representing an IDF file. """ iddfhandle = StringI...
Use the current IDD and read an IDF from text data. If the IDD has not yet been initialised then this is done first. Parameters ---------- idftxt : str Text representing an IDF file.
entailment
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 """ ...
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
entailment
def initnew(self, fname): """ Use the current IDD and create a new empty IDF. If the IDD has not yet been initialised then this is done first. Parameters ---------- fname : str, optional Path to an IDF. This does not need to be set at this point. """...
Use the current IDD and create a new empty IDF. If the IDD has not yet been initialised then this is done first. Parameters ---------- fname : str, optional Path to an IDF. This does not need to be set at this point.
entailment
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", ...
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", Name='Interior Ceiling_class', Outside_Layer='LW Concrete', ...
entailment
def removeidfobject(self, idfobject): """Remove an IDF object from the IDF. Parameters ---------- idfobject : EpBunch object The IDF object to remove. """ key = idfobject.key.upper() self.idfobjects[key].remove(idfobject)
Remove an IDF object from the IDF. Parameters ---------- idfobject : EpBunch object The IDF object to remove.
entailment
def copyidfobject(self, idfobject): """Add an IDF object to the IDF. Parameters ---------- idfobject : EpBunch object The IDF object to remove. This usually comes from another idf file, or it can be used to copy within this idf file. """ return a...
Add an IDF object to the IDF. Parameters ---------- idfobject : EpBunch object The IDF object to remove. This usually comes from another idf file, or it can be used to copy within this idf file.
entailment
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...
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 the object to fetch. Returns ------- i...
entailment
def removeextensibles(self, key, name): """ Remove extensible items in the object of key and name. Only for internal use. # TODO : hide this Parameters ---------- key : str The type of IDF object. This must be in ALL_CAPS. name : str The ...
Remove extensible items in the object of key and name. 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 the object to fetch. Returns ------...
entailment
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...
String representation of the IDF. Returns ------- str
entailment
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...
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 None then use the IDF.idfname parameter. Also accepts a file handle. linee...
entailment
def saveas(self, filename, lineendings='default', encoding='latin-1'): """ Save the IDF as a text file with the filename passed. Parameters ---------- filename : str Filepath to to set the idfname attribute to and save the file as. lineendings : str, optional ...
Save the IDF as a text file with the filename passed. Parameters ---------- filename : str Filepath to to set the idfname attribute to and save the file as. lineendings : str, optional Line endings to use in the saved file. Options are 'default', 'wi...
entailment
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...
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 file. Options are 'default', 'windows' and 'unix' the default is 'default' ...
entailment
def run(self, **kwargs): """ Run an IDF file with a given EnergyPlus weather file. This is a wrapper for the EnergyPlus command line interface. Parameters ---------- **kwargs See eppy.runner.functions.run() """ # write the IDF to the current ...
Run an IDF file with a given EnergyPlus weather file. This is a wrapper for the EnergyPlus command line interface. Parameters ---------- **kwargs See eppy.runner.functions.run()
entailment
def readfile(filename): """readfile""" fhandle = open(filename, 'rb') data = fhandle.read() try: data = data.decode('ISO-8859-2') except AttributeError: pass fhandle.close() return data
readfile
entailment
def printdict(adict): """printdict""" dlist = list(adict.keys()) dlist.sort() for i in range(0, len(dlist)): print(dlist[i], adict[dlist[i]])
printdict
entailment
def tabfile2list(fname): "tabfile2list" #dat = mylib1.readfileasmac(fname) #data = string.strip(dat) data = mylib1.readfileasmac(fname) #data = data[:-2]#remove the last return alist = data.split('\r')#since I read it as a mac file blist = alist[1].split('\t') clist = [] for num in ...
tabfile2list
entailment
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...
tabstr2list
entailment
def list2doe(alist): """list2doe""" 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] + RET else: ast...
list2doe
entailment
def tabfile2doefile(tabfile, doefile): """tabfile2doefile""" alist = tabfile2list(tabfile) astr = list2doe(alist) mylib1.write_str2file(doefile, astr)
tabfile2doefile
entailment
def makedoedict(str1): """makedoedict""" blocklist = str1.split('..') blocklist = blocklist[:-1]#remove empty item after last '..' blockdict = {} belongsdict = {} for num in range(0, len(blocklist)): blocklist[num] = blocklist[num].strip() linelist = blocklist[num].split(os.lines...
makedoedict
entailment
def makedoetree(ddict, bdict): """makedoetree""" 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 lst = lst + [bl...
makedoetree
entailment
def tree2doe(str1): """tree2doe""" 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() for i in range(0, len(l1list)): str1...
tree2doe
entailment
def mtabstr2doestr(st1): """mtabstr2doestr""" 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] = alist[num].lstrip() st2 = '' for num i...
mtabstr2doestr
entailment
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
get the block bounded by start and end doesn't work for multiple blocks
entailment
def doestr2tabstr(astr, kword): """doestr2tabstr""" 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 = [] for num in rang...
doestr2tabstr
entailment
def myreplace(astr, thefind, thereplace): """in string astr replace all occurences of thefind with thereplace""" alist = astr.split(thefind) new_s = alist.split(thereplace) return new_s
in string astr replace all occurences of thefind with thereplace
entailment
def fsliceafter(astr, sub): """Return the slice after at sub in string astr""" findex = astr.find(sub) return astr[findex + len(sub):]
Return the slice after at sub in string astr
entailment
def pickledump(theobject, fname): """same as pickle.dump(theobject, fhandle).takes filename as parameter""" fhandle = open(fname, 'wb') pickle.dump(theobject, fhandle)
same as pickle.dump(theobject, fhandle).takes filename as parameter
entailment
def write_str2file(pathname, astr): """writes a string to file""" fname = pathname fhandle = open(fname, 'wb') fhandle.write(astr) fhandle.close()
writes a string to file
entailment
def vol_tehrahedron(poly): """volume of a irregular tetrahedron""" 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)
volume of a irregular tetrahedron
entailment
def vol_zone(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) for i in range(num-2): # the upper part tehrahedron = [c_point, poly1[0], poly1[i+1],...
volume of a zone defined by two polygon bases
entailment
def newidf(version=None): """open a new idf file easy way to open a new idf file for particular version. Works only id Energyplus of that version is installed. Parameters ---------- version: string version of the new file you want to create. Will work only if this version of Energ...
open a new idf file easy way to open a new idf file for particular version. Works only id Energyplus of that version is installed. Parameters ---------- version: string version of the new file you want to create. Will work only if this version of Energyplus has been installed. R...
entailment
def openidf(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 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()...
return an wall:interzone object if the bsd (buildingsurface:detailed) is an interaone wall
entailment
def door(idf, fsdobject, deletebsd=True, setto000=False): """return an door object if the fsd (fenestrationsurface:detailed) is a door""" # ('DOOR', Door, None) # test if it is aroof if fsdobject.Surface_Type.upper() == 'DOOR': # Surface_Type == w simpleobject = idf.newidfobject('DOOR') ...
return an door object if the fsd (fenestrationsurface:detailed) is a door
entailment
def simplesurface(idf, bsd, deletebsd=True, setto000=False): """convert a bsd (buildingsurface:detailed) into a simple surface""" funcs = (wallexterior, walladiabatic, wallunderground, wallinterzone, roof, ceilingadiabatic, ceilinginterzone, floorgroundcon...
convert a bsd (buildingsurface:detailed) into a simple surface
entailment