예제 #1
0
def swmm_report_compare(path_test, path_ref, rtol, atol):
    '''
    Compares results in two report files ignoring contents of header and footer.
    
    Arguments: 
        path_test - path to result file being tested
        path_ref  - path to reference result file
        rtol - ignored
        atol - ignored
    
    Returns: 
        True or False
        
    Raises: 
        HeaderError()
        FooterError()
        RunTimeError()
        ...
    '''
    HEADER = 4
    FOOTER = 4
    
    with open(path_test ,'r') as ftest, open(path_ref, 'r') as fref:
        
        for (test_line, ref_line) in it.izip(hdf.parse(ftest, HEADER, FOOTER)[1], 
                                             hdf.parse(fref, HEADER, FOOTER)[1]): 
        
            if test_line != ref_line: 
                return False

    return True 
def swmm_report_compare(path_test, path_ref, rtol, atol):
    '''
    Compares results in two report files ignoring contents of header and footer.
    
    Arguments: 
        path_test - path to result file being tested
        path_ref  - path to reference result file
        rtol - ignored
        atol - ignored
    
    Returns: 
        True or False
        
    Raises: 
        HeaderError()
        FooterError()
        RunTimeError()
        ...
    '''
    HEADER = 4
    FOOTER = 4

    with open(path_test, 'r') as ftest, open(path_ref, 'r') as fref:

        for (test_line, ref_line) in it.izip(
                hdf.parse(ftest, HEADER, FOOTER)[1],
                hdf.parse(fref, HEADER, FOOTER)[1]):

            if test_line != ref_line:
                return False

    return True
예제 #3
0
def epanet_report_compare(path_test, path_ref, rtol, atol):
    '''
    Compares results in two report files ignoring contents of header and footer.
    
    Note: Header is 11 lines with report summary turned off. This test will fail 
    if the report summary is turned on because a time stamp is being written 
    immediately after it.  
    
    Arguments: 
        path_test - path to result file being tested
        path_ref  - path to reference result file
        rtol - ignored
        atol - ignored
    
    Returns: 
        True or False
        
    Raises: 
        HeaderError()
        FooterError()
        RunTimeError()
        ...
    '''
    HEADER = 10
    FOOTER = 2

    with open(path_test, 'r') as ftest, open(path_ref, 'r') as fref:

        for (test_line, ref_line) in it.izip(
                hdf.parse(ftest, HEADER, FOOTER)[1],
                hdf.parse(fref, HEADER, FOOTER)[1]):

            if test_line != ref_line:
                return False

    return True
예제 #4
0
        print('%d differences found\n' % notclose)
        isclose = False

    return isclose

def array_zero(test, ref):
    if not test.any() and not ref.any():
        return True
    return False

def report_compare(path_test, path_ref, (comp_args)):
    '''
    Compares results in two report files ignoring contents of header and footer. 
    '''
    with open(path_test ,'r') as ftest, open(path_ref, 'r') as fref:
        for (test_line, ref_line) in it.izip(hdf.parse(ftest, 4, 4)[1], hdf.parse(fref, 4, 4)[1]): 
            if test_line != ref_line: 
                return False

    return True 


import logging    
from os import listdir
from os.path import exists, isfile, isdir, join

from nrtest.testsuite import TestSuite
from nrtest.compare import compare_testsuite, validate_testsuite
from nrtest.execute import execute_testsuite
    
def nrtest_compare(path_test, path_ref, rtol, atol): 
예제 #5
0
파일: main.py 프로젝트: karosc/swmm-python
def result_compare(path_test, path_ref, comp_args):

    isclose = True
    close = 0
    notclose = 0
    equal = 0
    total = 0
    output = cStringIO.StringIO()
    eps =  np.finfo(float).eps

    start = time.time()

    test_reader = ordr.output_generator(path_test)
    ref_reader = ordr.output_generator(path_ref)

    for test, ref in _zip(test_reader, ref_reader):
        total += 1
        if total%100000 == 0:
        print(total)

        if len(test) != len(ref):
            raise ValueError('Inconsistent lengths')

        # Skip results if they are zero or equal
        if np.array_equal(test, ref):
            equal += 1
            continue
        else:
            try:
                np.testing.assert_allclose(test, ref, comp_args[0], comp_args[1])
                close += 1

            except AssertionError as ae:
                notclose += 1
                output.write(str(ae))
                output.write('\n\n')
                continue

    stop = time.time()

    print(output.getvalue())
    output.close()

    print('equal: %d  close: %d  notclose: %d  total: %d  in %f (sec)\n' %
          (equal, close, notclose, total, (stop - start)))

    if notclose > 0:
        print('%d differences found\n' % notclose)
        isclose = False

    return isclose

def array_zero(test, ref):
    if not test.any() and not ref.any():
        return True
    return False

def report_compare(path_test, path_ref, (comp_args)):
    '''
    Compares results in two report files ignoring contents of header and footer.
    '''
    with open(path_test ,'r') as ftest, open(path_ref, 'r') as fref:
        for (test_line, ref_line) in zip(hdf.parse(ftest, 4, 4)[1],
                                         hdf.parse(fref, 4, 4)[1]):
            if test_line != ref_line:
                return False

    return True
예제 #6
0
    return isclose


def array_zero(test, ref):
    if not test.any() and not ref.any():
        return True
    return False


def report_compare(path_test, path_ref, (comp_args)):
    '''
    Compares results in two report files ignoring contents of header and footer. 
    '''
    with open(path_test, 'r') as ftest, open(path_ref, 'r') as fref:
        for (test_line, ref_line) in it.izip(
                hdf.parse(ftest, 4, 4)[1],
                hdf.parse(fref, 4, 4)[1]):
            if test_line != ref_line:
                return False

    return True


import logging
from os import listdir
from os.path import exists, isfile, isdir, join

from nrtest.testsuite import TestSuite
from nrtest.compare import compare_testsuite, validate_testsuite
from nrtest.execute import execute_testsuite