compare_objects()
- endf_parserpy.compare_objects(obj1, obj2, atol=1e-08, rtol=1e-06, strlen_only=False, do_rstrip=False, rstrcut=None, fail_on_diff=True, diff_log=None)[source]
Compare recursively two objects.
This function enables the recursive comparison of two objects possible being or containing objects of type
dictor iterable array-like objects. For example, this class can be used to confirm or reject the equality of two nested dictionaries resulting from the parsing of ENDF-6 files via theparsefile()method of theEndfParserclass. The function can print out meaningful information where the discrepancies are present in the objects with a nested structure.- Parameters:
obj1 (object) – Any kind of object but usually it will be a nested
dict-like structure.obj2 (object) – Any kind of object but usually it will be a nested
dict-like structure.atol (float) – The absolute tolerance for the comparison of two
floatvariables.rtol (float) – The relative tolerance for the comparison of two
floatvariables.strlen_only (bool) – If
True, only compare the lengths of strings, otherwise also the content of the strings is considered in the comparison.do_rstrip (bool) – If
True, strip whitespace characters at the end of the strings before comparison.rstrcut (Union[None, int]) – If an integer is provided, only retain the first
rstrcutcharacters of the strings in the comparison. IfNone, strings are compared as they are.fail_on_diff (bool) – If
True, this function will raise an exception at the first encounter of a difference. Otherwise, the function will fully compare the objects and returnTrueif the two objects are equal andFalseif they exhibit differences. The second option is mostly useful in combination withdiff_log=True.diff_log (Union[None, List]) – A
listobject can be passed which will be filled with strings that indicate the differences found. This option is only useful in combination withfail_on_diff=false.