pyne / pyne

PyNE: The Nuclear Engineering Toolkit
http://pyne.io/
Other
261 stars 176 forks source link

Reference output files are mismatched with the generated output files while testing `ensdf_processing` #1536

Open ahnaf-tahmid-chowdhury opened 4 weeks ago

ahnaf-tahmid-chowdhury commented 4 weeks ago

Description

When testing ensdf_processing, the reference output files are mismatched with the generated output files.

I believe the issue is occurring because we have updated our dependencies. We need to consider updating our reference files accordingly. However, I'm not sure how to proceed with this.

Input

import numpy, os, io
from pyne import ensdf_processing

# path to folder for temporary test files.
tmp_path = "ensdf_processing/tmp"

def create_tmp():
    if not os.path.exists(tmp_path):
        os.makedirs(tmp_path, exist_ok=True)

def file_comp(file_out, file_ref, exceptions):
    f_out = io.open(file_out, "r", encoding="latin-1")
    f_ref = io.open(file_ref, "r", encoding="latin-1")
    diff_lines = numpy.array([])
    line_num = 0
    for line_out in f_out:
        line_ref = f_ref.readline()
        print("line_ref: " + line_ref)
        print("line_out: " + line_out)
        if line_ref != line_out:
            ignore = False
            for i in range(0, len(exceptions)):
                if exceptions[i][0] == 1:
                    if line_out[0 : len(exceptions[i][1])] == exceptions[i][1]:
                        ignore = True
                elif exceptions[i][0] == 2:
                    if exceptions[i][1] in line_out:
                        ignore = True
                elif exceptions[i][0] == 3:
                    # ignores select lines to allow for tolerable differences
                    # in output precision
                    if exceptions[i][1] == line_num:
                        ignore = True
                elif exceptions[i][0] == 4:
                    if len(line_ref[:-1]) == len(line_out):
                        # special exception for lines with possible carriage return
                        # instead of standard line feed return
                        if line_ref[:-2] == line_out[:-1]:
                            ignore = True
            if not ignore:
                raise Exception(
                    "ENSDF Processing: Incorrect output generated, file: " + file_ref
                )
        line_num = line_num + 1
    f_out.close()
    f_ref.close()
    diff_dict = {}
    diff_dict["differences_lines"] = diff_lines
    return diff_dict

create_tmp()
input_dict = {}
input_dict["input_file"] = "ensdf_processing/bldhst/ref_bldhst_iccseq.dat"
input_dict["output_table_file"] = tmp_path + "/tmp_bldhst_icctbl.dat"
input_dict["output_index_file"] = tmp_path + "/tmp_bldhst_iccndx.dat"
output_dict = ensdf_processing.bldhst(input_dict)
ref_table = "ensdf_processing/bldhst/ref_icctbl.dat"
ref_index = "ensdf_processing/bldhst/ref_iccndx.dat"
d_table = file_comp(input_dict["output_table_file"], ref_table, [])
d_index = file_comp(input_dict["output_index_file"], ref_index, [])

Output

line_ref: K1pAÝ$=ÍÌ´@ÍCÝFÇ:;î|?>HA@QDK1AÅ 0=\R@TC KFÖ¨;ÙÎ÷=

line_out: K1.@øS㥰?@ y@£Û@Ô+eâXg?V-²@K11@j¼t¦?R¸
ëQ

Traceback (most recent call last):
  File "/mnt/Data/Projects/pyne/tests/test_ensdf_processing.py", line 59, in <module>
    d_table = file_comp(input_dict["output_table_file"], ref_table, [])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/Data/Projects/pyne/tests/test_ensdf_processing.py", line 41, in file_comp
    raise Exception(
Exception: ENSDF Processing: Incorrect output generated, file: ensdf_processing/bldhst/ref_icctbl.dat

pytest log

------------------------------------------ Captured stderr call -------------------------------------------
Note: The following floating-point exceptions are signalling: IEEE_UNDERFLOW_FLAG IEEE_DENORMAL
========================================= short test summary info =========================================
FAILED test_ensdf_processing.py::test_bldhst - Exception: ENSDF Processing: Incorrect output generated, file: ensdf_processing/bldhst/ref_icctbl.dat
FAILED test_ensdf_processing.py::test_delta - Exception: ENSDF Processing: Incorrect output generated, file: ensdf_processing/delta/ref_delta.rpt
FAILED test_ensdf_processing.py::test_logft - Exception: ENSDF Processing: Incorrect output generated, file: ensdf_processing/logft/ref_logft.new
================================= 3 failed, 6 passed, 1 skipped in 0.43s ==================================

Expected behavior

For example, in ensdf_processing.bldhst, the output files (tmp_bldhst_icctbl.dat and tmp_bldhst_iccndx.dat) should match the reference files (ref_icctbl.dat and ref_iccndx.dat) respectively.

Additional information