bertiniteam / b2

Bertini 2.0: The redevelopment of Bertini in C++.
92 stars 34 forks source link

Failed test case: b2_class_test #59

Closed davisbnag closed 7 years ago

davisbnag commented 7 years ago

make check failed for b2_class_test. Thanks!

test-suite.txt

ofloveandhate commented 7 years ago

this is surprising to me, as I just compiled and ran these test cases earlier today on a mac with Boost 1.59, gmp 6.1.1, and mpfr 3.x.x. Let's start by investigating the first failing test,

test/classes/function_tree_test.cpp:112: error: in "function_tree_class/manual_construction_num_squared": check fabs(N->Eval<mpfr>().real() - exact_mpfr.real() ) < threshold_clearance_mp has failed

my best guess is that somewhere the precision got out of alignment, and results aren't as expected. maybe on your system some initialization of the globals happened, but the order of global initialization is not well defined. so perhaps their precision is incorrect.

maybe you can check the precision of the two things being checked at line 112?

davisbnag commented 7 years ago

For: "function_tree_class/manual_construction_num_squared". Comparing the real parts I have: Test Error: 9.75782e-20 Threshold_Clearance: 1e-27

leading to the error. Here are the various precision(s):

Test Precision: 50 N->Eval<mpfr>().precision() Exact Precision: 50 exact_mpfr.precision() Test Real Precision: 50 N->Eval<mpfr>().real().precision() Exact Real Precision: 50 exact_mpfr.real().precision()

mpfr my_test_mpfr = N->Eval<mpfr>() - exact_mpfr;

Difference of Test,Exact Precision: 50 my_test_mpfr.precision() Difference of Test, Exact Real Precision: 50 my_test_mpfr.real().precision()

davisbnag commented 7 years ago

Looks like I'm using Boost 1.62.0, GMP 6.1.1, and MPFR 3.1.5 after reading from the commands: brew info boost brew info gmp brew info mpfr

ofloveandhate commented 7 years ago

the precision of the my_test_mpfr is as expected, because the first thing we do in the test is DefaultPrecision(CLASS_TEST_MPFR_DEFAULT_DIGITS), and my_test_mpfr is a new mpfr_complex object.

can you inspect the precision of the variable anum_mpfr?

davisbnag commented 7 years ago

anum_mpfr Precision: 20 anum_mpfr.real() Precision: 20

Looks like that may be the issue...

ofloveandhate commented 7 years ago

Thanks! Glad we found the culprit. Now for the solution...

I think we need to provide a function which will ensure that the precision has been set before initializing those variables. I will come up with something better than what we have going now.

ofloveandhate commented 7 years ago

Hey @davisbnag , will you please apply the attached patch to your clone, and see if it fixes the problem? change the .txt suffix to .diff. somewhat surprisingly, .diff isn't allowed as a filetype for attachments to issues presently.

apply-patch

global_fixture_cure_precision_woes.txt

davisbnag commented 7 years ago

What interface is that? I am a newb. I will try and patch is through the command line.

davisbnag commented 7 years ago

After applying the patch, it seems as though I am now getting a compile time error during make check. (Not sure about failed tests yet ...)

g++ -DHAVE_CONFIG_H -I. -I./include/bertini2  -I./include -pthread -I/usr/local/include -I/usr/local/include/eigen3 -pthread -I/usr/local/include -g -O2 -std=gnu++14 -MT test/classes/b2_class_test-function_tree_test.o -MD -MP -MF test/classes/.deps/b2_class_test-function_tree_test.Tpo -c -o test/classes/b2_class_test-function_tree_test.o `test -f 'test/classes/function_tree_test.cpp' || echo './'`test/classes/function_tree_test.cpp
test/classes/eigen_test.cpp:39:10: fatal error: 'externs.hpp' file not found
#include "externs.hpp"
         ^
1 error generated.
make[3]: *** [test/classes/b2_class_test-eigen_test.o] Error 1
make[3]: *** Waiting for unfinished jobs....
test/classes/function_tree_test.cpp:46:10: fatal error: 'externs.hpp' file not found
#include "externs.hpp"
         ^
1 error generated.
make[3]: *** [test/classes/b2_class_test-function_tree_test.o] Error 1
make[2]: *** [check-TESTS] Error 2
make[1]: *** [check-am] Error 2
make: *** [check] Error 2
davisbnag commented 7 years ago

Maybe we forgot to include externs.hpp in the patch? It seems to be in almost all of the .cpp files in /core/test/classes.

ofloveandhate commented 7 years ago

@davisbnag sorry, my bad. git reset --hard, and let's try that again a different way. for some reason the new file externs.hpp isn't being written into my patches i am making. always a little more learning to do!

i went ahead and committed to a hot fix. can you switch to the hotfix branch hotfix/fix_class_test_precision, pull, and check whether this fixes your test issues?

davisbnag commented 7 years ago

Okay I pulled that branch and it looks like all the tests have passed on my machine.. Thank you!

ofloveandhate commented 7 years ago

awesome. i'll finish the hotfix and apply it to master, etc. thanks for the help!