digitalmars.D.learn - problem with isnan
- Charles Hixson via Digitalmars-d-learn (10/10) Nov 10 2016 The line:
- Adam D. Ruppe (6/9) Nov 10 2016 How did you set it? There are like billions of different NaNs.
- Charles Hixson via Digitalmars-d-learn (10/18) Nov 10 2016 It was default initialized by the class instance:
- Edwin van Leeuwen (4/15) Nov 11 2016 std.math.isNaN should work for the default initialization (at
- pineapple (7/16) Nov 11 2016 Incidentally, I just recently submitted a PR to fix this.
- Charles Hixson via Digitalmars-d-learn (20/36) Nov 11 2016 Thank you. Unfortunately:
- John C (2/10) Nov 11 2016 It should be isNaN.
- Charles Hixson via Digitalmars-d-learn (7/18) Nov 11 2016 Ok, now it seems the same as std.math.isnan, (i.e., it works properly). ...
The line: assert (isnan (c.curActivation), "cell has unexpected curActivation: %s".format(c.curActivation)); throws the exception: core.exception.AssertError cell.d(285): cell has unexpected curActivation: nan and I've looked at it backwards and forwards and don't understand why. It's *supposed* to be nan, and the assert message reports that it is, but it should pass the assert test, not throw an assertion. What am I doing wrong?
Nov 10 2016
On Thursday, 10 November 2016 at 16:41:56 UTC, Charles Hixson wrote:It's *supposed* to be nan, and the assert message reports that it is, but it should pass the assert test, not throw an assertion. What am I doing wrong?How did you set it? There are like billions of different NaNs. I'm not sure if isnan checks for all of them. (I'm also not sure that it doesn't, the docs don't specify.) you might try using std.math.isNaN instead and see what it does.
Nov 10 2016
On 11/10/2016 08:47 AM, Adam D. Ruppe via Digitalmars-d-learn wrote:On Thursday, 10 November 2016 at 16:41:56 UTC, Charles Hixson wrote:It was default initialized by the class instance: class Cell ... float curActivation; ... The this method doesn't have any mention of a few variables that are supposed to be default initialized, or which curActivation is one. I suppose I could set it to be -2.0 or something, but that doesn't really tell me what's going on.It's *supposed* to be nan, and the assert message reports that it is, but it should pass the assert test, not throw an assertion. What am I doing wrong?How did you set it? There are like billions of different NaNs. I'm not sure if isnan checks for all of them. (I'm also not sure that it doesn't, the docs don't specify.) you might try using std.math.isNaN instead and see what it does.
Nov 10 2016
On Thursday, 10 November 2016 at 23:45:01 UTC, Charles Hixson wrote:std.math.isNaN should work for the default initialization (at least it does for doubles)you might try using std.math.isNaN instead and see what it does.It was default initialized by the class instance: class Cell ... float curActivation; ... The this method doesn't have any mention of a few variables that are supposed to be default initialized, or which curActivation is one.
Nov 11 2016
On Thursday, 10 November 2016 at 16:47:30 UTC, Adam D. Ruppe wrote:On Thursday, 10 November 2016 at 16:41:56 UTC, Charles Hixson wrote:Incidentally, I just recently submitted a PR to fix this. What probably happened is that you're referring to a limited `isnan` method defined as a unittest utility method in object.d that should have been private but wasn't. You want to use `isNan` instead.It's *supposed* to be nan, and the assert message reports that it is, but it should pass the assert test, not throw an assertion. What am I doing wrong?How did you set it? There are like billions of different NaNs. I'm not sure if isnan checks for all of them. (I'm also not sure that it doesn't, the docs don't specify.) you might try using std.math.isNaN instead and see what it does.
Nov 11 2016
On 11/11/2016 10:31 AM, pineapple via Digitalmars-d-learn wrote:On Thursday, 10 November 2016 at 16:47:30 UTC, Adam D. Ruppe wrote:Thank you. Unfortunately: import std.math; ... assert (isNan (c.curActivation), "cell has unexpected curActivation: %s".format(c.curActivation)); yields: cell.d(292): Error: undefined identifier 'isNan', did you mean overloadset 'isnan'? while: import std.math; ... assert (std.math.isnan (c.curActivation), "cell has unexpected curActivation: %s".format(c.curActivation)); yields: core.exception.AssertError cell.d(310): cell has unexpected idno: 636144943519357244 That is, indeed, an unexpected value, unless it's some representation of Nan, in which case it should have passed the assert. I notice that it doesn't appear to be a float, which puzzles me.On Thursday, 10 November 2016 at 16:41:56 UTC, Charles Hixson wrote:Incidentally, I just recently submitted a PR to fix this. What probably happened is that you're referring to a limited `isnan` method defined as a unittest utility method in object.d that should have been private but wasn't. You want to use `isNan` instead.It's *supposed* to be nan, and the assert message reports that it is, but it should pass the assert test, not throw an assertion. What am I doing wrong?How did you set it? There are like billions of different NaNs. I'm not sure if isnan checks for all of them. (I'm also not sure that it doesn't, the docs don't specify.) you might try using std.math.isNaN instead and see what it does.
Nov 11 2016
On Friday, 11 November 2016 at 20:55:52 UTC, Charles Hixson wrote:Thank you. Unfortunately: import std.math; ... assert (isNan (c.curActivation), "cell has unexpected curActivation: %s".format(c.curActivation)); yields: cell.d(292): Error: undefined identifier 'isNan', did you mean overloadset 'isnan'?It should be isNaN.
Nov 11 2016
On 11/11/2016 01:34 PM, John C via Digitalmars-d-learn wrote:On Friday, 11 November 2016 at 20:55:52 UTC, Charles Hixson wrote:Ok, now it seems the same as std.math.isnan, (i.e., it works properly). On looking over the error messages more closely (just now) I noticed that the line number had now changed. Whoops! It just *LOOKED* like the error hadn't been fixed, where it had actually moved onto the next one. The hint should have been that it was printing an integer value...I mean besides the changed line number.Thank you. Unfortunately: import std.math; ... assert (isNan (c.curActivation), "cell has unexpected curActivation: %s".format(c.curActivation)); yields: cell.d(292): Error: undefined identifier 'isNan', did you mean overloadset 'isnan'?It should be isNaN.
Nov 11 2016