humann/tests/utils.py
def files_almost_equal(file1, file2, precision=None):
    """ Check that the files have data that is almost equal to allow for rounding """
    
    if not precision:
        precision=7
        
    # read the files
    columns1, rows1, data1 = read_table_rows(file1)
    columns2, rows2, data2 = read_table_rows(file2)    
    
    # check the headers are the same
    if not columns1 == columns2:
        return False, "Column names in files differ"
    
    # check the row names are the same
    if not rows1 == rows2:
        return False, "Row names in files differ"
    
    # check the data is almost the same to allow for rounding
    for row1_data, row2_data in zip(data1, data2):
        for data1_point, data2_point in zip(row1_data, row2_data):
            if not round(float(data1_point),precision) == round(float(data2_point),precision):
                return False, "Data points in files differ"
    
    return True, "NA"
 Check that the files have data that is almost equal to allow for rounding 
Check that the files have data that is almost equal to allow for rounding
Check that the files have data that is almost equal to allow for rounding
def files_almost_equal(file1, file2, precision=None):
    if not precision:
        precision=7
    columns1, rows1, data1 = read_table_rows(file1)
    columns2, rows2, data2 = read_table_rows(file2)    
    if not columns1 == columns2:
        return False, "Column names in files differ"
    if not rows1 == rows2:
        return False, "Row names in files differ"
    for row1_data, row2_data in zip(data1, data2):
        for data1_point, data2_point in zip(row1_data, row2_data):
            if not round(float(data1_point),precision) == round(float(data2_point),precision):
                return False, "Data points in files differ"
    return True, "NA"
def files_almost_equal ( file1 , file2 , precision = None ) : if not precision : precision = 7 columns1 , rows1 , data1 = read_table_rows ( file1 ) columns2 , rows2 , data2 = read_table_rows ( file2 ) if not columns1 == columns2 : return False , "Column names in files differ" if not rows1 == rows2 : return False , "Row names in files differ" for row1_data , row2_data in zip ( data1 , data2 ) : for data1_point , data2_point in zip ( row1_data , row2_data ) : if not round ( float ( data1_point ) , precision ) == round ( float ( data2_point ) , precision ) : return False , "Data points in files differ" return True , "NA"
Check that the files have data that is almost equal to allow for rounding
Check that the files have data that is almost equal to allow for rounding
""" Check that the files have data that is almost equal to allow for rounding """ # read the files # check the headers are the same # check the row names are the same # check the data is almost the same to allow for rounding
file1
file2
precision