New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes issue #1888 #1896
Fixes issue #1888 #1896
Conversation
@@ -187,7 +187,9 @@ class CMath : public CSGObject | |||
else | |||
return -a; | |||
} | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the whitespace here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was going to put the 'CMath::fequals(..)' function there, forgot to erase the whitespace...
@dhruv13J This already looks good. Have a look at travis, one unit test fails, it is TParameter.equals_scalar_different2 and TParameter.equals_vector_different1 See https://travis-ci.org/shogun-toolbox/shogun/jobs/19696129 In fact, could you add all the unit tests in http://floating-point-gui.de/errors/NearlyEqualsTest.java This would be extremely helpful, and is only copy paste work and some minor adjustments |
good work btw :) |
I'm working on it :-) |
@@ -212,3 +213,53 @@ | |||
EXPECT_TRUE(CMath::strtold("1.234567890123", &long_double_result)); | |||
EXPECT_DOUBLE_EQ(1.234567890123, long_double_result); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all unit tests added yet; will add the rest soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice those strtold tests!
Hi. One possible mistake I came across was the representation of negative infinity (just added a '-' to positive infinity and that failed. According to the test, +inf==-inf is true). |
Travis fails because of JSON Serialization, weird... |
@pranet: what is the value of epsilon you are using? some tests depend on it, use 0.00001f |
It is 0.00001l not 0.00001f. Will that make a difference? |
@@ -3237,7 +3237,7 @@ bool TParameter::equals(TParameter* other, float64_t accuracy) | |||
|
|||
for (index_t i=0; i<length; ++i) | |||
{ | |||
SG_SDEBUG("comparing element %d which is %d byes from start\n", | |||
SG_SDEBUG("comparing element %d which is %d bytes from start\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha nice, thanks! :)
Nice, these are already very helpful. However, the most interesting ones are the other ones from this website. Travis: The python tests fail here: Your help is really appreciated. We also realise that this is a highly complicated task which touches lots of Shogun's internals. Keep on going! :) |
Still working on the JSON tests... will try and finish soon! |
looking forward! :) |
@@ -3133,7 +3133,7 @@ void TParameter::copy_data(const TParameter* source) | |||
SG_SDEBUG("leaving TParameter::copy_data for %s\n", m_name) | |||
} | |||
|
|||
bool TParameter::equals(TParameter* other, float64_t accuracy) | |||
bool TParameter::equals(TParameter* other, float64_t accuracy, bool tolerant) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the tolerant parameter allows less strict check for equality, based on the epsilon value given to the function. it has been added to all methods which can call TParameter::equals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about a default parameter value?
@@ -89,7 +89,7 @@ TEST(SerializationJSON,{{class}}_{{type}}) | |||
|
|||
// check whether they are equal, up to accuracy since json is lossy | |||
float64_t accuracy=1e-6; | |||
ASSERT(object->equals(deserializedObject, accuracy)); | |||
ASSERT(object->equals(deserializedObject, accuracy, true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont know why this is assert ,but should be expect
ok, lets wait for travis, do all tests pass locally on your machine? |
@karlnapf: yeah, all tests passed locally, before i added the last commit; made a stupid typo |
any progress here? :) |
@karlnapf: my latest pr should fix it; I'm having problems because I can't reproduce the build error locally... |
@karlnapf: Ready for merge i think! |
Conflicts: src/shogun/mathematics/Math.h
Created a templated function CMath::fequals() in Math.h and called this function in TParameter::compare_ptype() for floating point types.