nan

How can I plot NaN values as a special color with imshow in matplotlib?

I am trying to use imshow in matplotlib to plot data as a heatmap, but some of the values are NaNs. I'd like the NaNs to be rendered as a special color not found in the colormap. example: import numpy as np import matplotlib.pyplot as plt f = plt.figure() ax = f.add_subplot(111) a = np.arange(25).reshape((5,5)).astype(float) a[3,:] = n...

In Java what does NaN mean.

I have a program that more or less tries to widdle a double down to a desired number. The output i get though, instead of being that final double is NaN What does this mean? ...

How to interpret situations where Math.Acos() reports invalid input?

Hey all. I'm computing the angle between two vectors, and sometimes Math.Acos() returns NaN when it's input is out of bounds (-1 > input && input > 1) for a cosine. What does that mean, exactly? Would someone be able to explain what's happening? Any help is appreciated! Here's my method: public double AngleBetween(vector b) { ...

How does Double.isNaN() work?

The sun jdk implementation looks like this: return v != v; Can anyone explain how that works? ...

Is there a better way of making numpy.argmin() ignore NaN values

Hello Everybody, I want to get the index of the min value of a numpy array that contains NaNs and I want them ignored >>> a = array([ nan, 2.5, 3., nan, 4., 5.]) >>> a array([ NaN, 2.5, 3. , NaN, 4. , 5. ]) if I run argmin, it returns the index of the first NaN >>> a.argmin() 0 I substitute NaNs with Infs a...

"isnotnan" functionality in numpy, can this be more pythonic?

Hello Everybody, I need a function that returns non-NaN values from an array. Currently I am doing it this way: >>> a = np.array([np.nan, 1, 2]) >>> a array([ NaN, 1., 2.]) >>> np.invert(np.isnan(a)) array([False, True, True], dtype=bool) >>> a[np.invert(np.isnan(a))] array([ 1., 2.]) Python: 2.6.4 numpy: 1.3.0 Please share...

When can Java produce a NaN (with specific code question)

I'm a bit perplexed by some code I'm currently writing. I am trying to preform a specific gradient descent (main loop included below) and depending on the initial conditions I will alternatively get good looking results (perhaps 20% of the time) or everything becomes NaN (the other 80% of the time). However it seems to me that none of ...

I get NaN when I try to insert some HTML into a DIV element with jQuery

I am tring to display a text box when a element of class numObj is clicked. For some reason I get NaNNaNaNaNNaNNaNaNaN where I expect to the see the result of the searchForm variable in the code below. I know that NaN stands for Not a Number. What I don't understand is why is Javascript expecting a number? I can't understand why it care...

No warning from gcc when function definition in linked source different from function prototype in header

Hi, I had a problem with a part of my code, which after some iterations seemed to read NaN as value of a double of a struct. I think I found the error, but am still wondering why gcc (version 3.2.3 on a embedded Linux with busybox) did not warn me. Here are the important parts of the code: A c file and its header for functions to acqui...

reading floating-point numbers with 1.#QNAN values in python

Hello, Does anyone know of a python string-to-float parser that can cope with MSVC nan numbers (1.#QNAN)? Currently I'm just using float(str) which at least copes with "nan". I'm using a python script to read the output of a C++ program (runs under linux/mac/win platforms) and the script barfs up when reading these values. (I did alread...

Why does this code sometimes return NaN?

This often returns NAN ("Not A Number") depending on input: #define PI 3.1415f GLfloat sineEaseIn(GLfloat ratio) { return 1.0f-cosf(ratio * (PI / 2.0f)); } I tried making PI a few digits smaller to see if that would help. No dice. Then I thought it might be a datatype mismatch, but float and glfloat seem to be equivalent: gl.h t...

Why JavaScript says that a number is not a number?

Hi, I have a piece of JavaScript code which is expected to set an integer value to a variable. Something is broken, so when I try to do alert(A);, it returns NaN. isNaN(A); returns true. But if I alert(typeof(A));, it says number. So how can a variable be a number and not a number at the same time? Maybe I misunderstood what NaN reall...

How to deal with NaN's when reading in a csv file in C++

Hi, I'm reading in a csv file of time-series data into a C++ program. My data however contains some NaN's. For example: 1-Jul-2010, 1.0 2-Jul-2010, 2.0 3-Jul-2010, NaN 4-Jul-2010, 3.0 To deal with this I wrote a short script in Matlab which replaces all the NaN's with 0.0 - I then read in the new file without the NaN's. I...

c# nullable double to actionscript NaN through fluorine gateway

Hi, Is there a way in fluorine to force a nullable double to be passed to flex as NaN? (and vice versa) By default these values are passed as null, but a Number in actionscript is not nullable, so it is converted to 0 by default. I need server side nullable doubles to be NaN in flex, and NaN values from flex to be nullable doubles on t...

Negative NaN is not a NaN?

While writing some test cases, and some of the tests check for the result of a NaN. I tried using std::isnan but the assert failes: Assertion `std::isnan(x)' failed. After printing the value of x, it turned out it's negative NaN (-nan) which is totally acceptable in my case. After trying to use the fact that NaN != NaN and using ass...

How slow is NaN arithmetic in the Intel x64 FPU?

Hints and allegations abound that arithmetic with NaNs can be 'slow' in hardware FPUs. Specifically in the modern x64 FPU, e.g on a Nehalem i7, is that still true? Do FPU multiplies get churned out at the same speed regardless of the values of the operands? I have some interpolation code that can wander off the edge of our defined data...

Can someone explain to me NaN in Ruby ?

I just found a bug in some number manipulations in my program and I'm getting a FloatDomainError (NaN) So I started logging the number passed in with: if(metric.is_a?(Numeric)) self.metric = metric else LOGGER.warn("metric #{metric} is not a number") self.metric=0 end But the number being passed in is NaN which apparently is_a?...

MATLAB: Using interpolation to replace missing values (NaN)

Hello, I have cell array each containing a sequence of values as a row vector. The sequences contain some missing values represented by NaN. I would like to replace all NaNs using some sort of interpolation method, how can I can do this in MATLAB? I am also open to other suggestions on how to deal with these missing values. Consider t...

jqGrid not displaying a single row

Our jqGrid is working well - if we return > 1 row everything works. But.. if we return just one row, the grid does not display any data and the nav bar says 1 of NaN. Very weird - any ideas?? This is the JSON being returned for the single row: {"records":"1","page":"1","total":"1","rows":{"cell":["ECS","D","201009","","0","ABCD","0"...

matlab: quick function that can produce NaN if x > 1

I am looking for a one-line function f = @(x) {something} that produces NaN if x >= 1, and either 0 or 1 if x < 1. Any suggestions? ...