Re: problem with isnan

2016-11-11 Thread Charles Hixson via Digitalmars-d-learn



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:

Thank you.  Unfortunately:
importstd.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.

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.


Re: problem with isnan

2016-11-11 Thread John C via Digitalmars-d-learn

On Friday, 11 November 2016 at 20:55:52 UTC, Charles Hixson wrote:

Thank you.  Unfortunately:
importstd.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.


Re: problem with isnan

2016-11-11 Thread Charles Hixson via Digitalmars-d-learn

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:

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.


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.



Thank you.  Unfortunately:
importstd.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:
importstd.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.


Re: problem with isnan

2016-11-11 Thread pineapple via Digitalmars-d-learn
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:
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.


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.



Re: problem with isnan

2016-11-11 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 10 November 2016 at 23:45:01 UTC, Charles Hixson 
wrote:
you might try using std.math.isNaN instead and see what it 
does.



It was default initialized by the class instance:

classCell
...
floatcurActivation;
...

The this method doesn't have any mention of a few variables 
that are supposed to be default initialized, or which 
curActivation is one.



std.math.isNaN should work for the default initialization (at 
least it does for doubles)




Re: problem with isnan

2016-11-10 Thread Daniel Kozak via Digitalmars-d-learn

Dne 10.11.2016 v 17:41 Charles Hixson via Digitalmars-d-learn napsal(a):


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?

You need to use https://dlang.org/library/std/math/is_nan.html



Re: problem with isnan

2016-11-10 Thread Charles Hixson via Digitalmars-d-learn

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'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.


It was default initialized by the class instance:

classCell
...
floatcurActivation;
...

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.


Re: problem with isnan

2016-11-10 Thread Adam D. Ruppe via Digitalmars-d-learn
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.


problem with isnan

2016-11-10 Thread Charles Hixson via Digitalmars-d-learn

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?