Beispiel #1
0
def test_convertallfields():
    """py.test convertallfields"""
    data = (
        ("version, 8.1;", 'VERSION', [u'version', u'8.1']),
        # idfstr, objkey, expected
        ("WINDOWMATERIAL:SIMPLEGLAZINGSYSTEM, simple, 0.45;",
         'WINDOWMATERIAL:SIMPLEGLAZINGSYSTEM',
         [u'WINDOWMATERIAL:SIMPLEGLAZINGSYSTEM', 'simple', 0.45]),
        # idfstr, objkey, expected
        ("HVACTEMPLATE:ZONE:FANCOIL, gumby1, gumby2, 0.45;",
         'HVACTEMPLATE:ZONE:FANCOIL',
         [u'HVACTEMPLATE:ZONE:FANCOIL', 'gumby1', 'gumby2', 0.45]),
        # idfstr, objkey, expected
        ("HVACTEMPLATE:ZONE:FANCOIL, gumby1, gumby2, autosize;",
         'HVACTEMPLATE:ZONE:FANCOIL',
         [u'HVACTEMPLATE:ZONE:FANCOIL', 'gumby1', 'gumby2', 'autosize']),
        # idfstr, objkey, expected
    )
    commdct = None
    block = None
    for idfstr, objkey, expected in data:
        idfhandle = StringIO(idfstr)
        block, data, commdct, idd_index = readidf.readdatacommdct1(
            idfhandle, iddfile=iddfhandle, commdct=commdct, block=block)
        idfreader.convertallfields(data, commdct, block)
        result = data.dt[objkey][0]
        assert result == expected
Beispiel #2
0
def test_convertallfields():
    """py.test convertallfields"""
    data = (
        ("version, 8.1;", "VERSION", ["version", "8.1"]),
        # idfstr, objkey, expected
        (
            "WINDOWMATERIAL:SIMPLEGLAZINGSYSTEM, simple, 0.45;",
            "WINDOWMATERIAL:SIMPLEGLAZINGSYSTEM",
            ["WINDOWMATERIAL:SIMPLEGLAZINGSYSTEM", "simple", 0.45],
        ),
        # idfstr, objkey, expected
        (
            "HVACTEMPLATE:ZONE:FANCOIL, gumby1, gumby2, 0.45;",
            "HVACTEMPLATE:ZONE:FANCOIL",
            ["HVACTEMPLATE:ZONE:FANCOIL", "gumby1", "gumby2", 0.45],
        ),
        # idfstr, objkey, expected
        (
            "HVACTEMPLATE:ZONE:FANCOIL, gumby1, gumby2, autosize;",
            "HVACTEMPLATE:ZONE:FANCOIL",
            ["HVACTEMPLATE:ZONE:FANCOIL", "gumby1", "gumby2", "autosize"],
        ),
        # idfstr, objkey, expected
    )
    commdct = None
    block = None
    for idfstr, objkey, expected in data:
        idfhandle = StringIO(idfstr)
        block, data, commdct, idd_index = readidf.readdatacommdct1(
            idfhandle, iddfile=iddfhandle, commdct=commdct, block=block)
        idfreader.convertallfields(data, commdct, block)
        result = data.dt[objkey][0]
        assert result == expected
Beispiel #3
0
def idfreader1(
        fname,  # type: str
        iddfile,  # type: str
        theidf,  # type: IDF
        conv=True,  # type: Optional[bool]
        commdct=None,  # type: List[List[Dict[str, Any]]]
        block=None,  # type: Optional[List]
):
    # type: (...) -> Tuple[Dict[str, Any], Optional[List[Any]], Any, List[List[Dict[str, Any]]], Any, Any]
    """Read idf file and return bunches.

    :param fname: Name of the IDF file to read.
    :param iddfile: Name of the IDD file to use to interpret the IDF.
    :param conv: If True, convert strings to floats and integers where marked in the IDD. Defaults to None.
    :param commdct: Descriptions of IDF fields from the IDD. Defaults to None.
    :param block: EnergyPlus field ID names of the IDF from the IDD. Defaults to None.
    :returns: bunchdt Dict of lists of idf_MSequence objects in the IDF.
    :returns: block EnergyPlus field ID names of the IDF from the IDD.
    :returns data: Eplusdata object containing representions of IDF objects.
    :returns: commdct List of names of IDF objects.
    :returns: idd_index A pair of dicts used for fast lookups of names of groups of objects.
    :returns: versiontuple Version of EnergyPlus from the IDD.

    """
    versiontuple = iddversiontuple(iddfile)
    block, data, commdct, idd_index = readdatacommdct1(fname,
                                                       iddfile=iddfile,
                                                       commdct=commdct,
                                                       block=block)
    if conv:
        convertallfields(data, commdct)
    # fill gaps in idd
    if versiontuple < (8, ):
        skiplist = ["TABLE:MULTIVARIABLELOOKUP"]  # type: Optional[List[str]]
    else:
        skiplist = None
    nofirstfields = iddgaps.missingkeys_standard(commdct,
                                                 data.dtls,
                                                 skiplist=skiplist)
    iddgaps.missingkeys_nonstandard(block, commdct, data.dtls, nofirstfields)
    bunchdt = makebunches(data, commdct, theidf)

    return bunchdt, block, data, commdct, idd_index, versiontuple
Beispiel #4
0
def idfreader1(fname, iddfile, theidf, conv=True, commdct=None, block=None):
    """read idf file and return bunches"""
    versiontuple = iddversiontuple(iddfile)
    block, data, commdct, idd_index = readidf.readdatacommdct1(fname,
                                                               iddfile=iddfile,
                                                               commdct=commdct,
                                                               block=block)
    if conv:
        convertallfields(data, commdct)
    # fill gaps in idd
    ddtt, dtls = data.dt, data.dtls
    if versiontuple < (8, ):
        skiplist = ["TABLE:MULTIVARIABLELOOKUP"]
    else:
        skiplist = None
    nofirstfields = iddgaps.missingkeys_standard(commdct,
                                                 dtls,
                                                 skiplist=skiplist)
    iddgaps.missingkeys_nonstandard(commdct, dtls, nofirstfields)
    # bunchdt = makebunches(data, commdct)
    bunchdt = makebunches(data, commdct, theidf)

    return bunchdt, block, data, commdct, idd_index