nan

Serialize NaN values into JSON as nulls in JSON.NET

浪子不回头ぞ 提交于 2019-12-04 20:33:02
问题 Most Json parsers don't serialize NaN, because in Javascript, NaN is not a constant. Json.Net, however, does serialize NaN values into NaN, which means it outputs invalid Json; attempting to deserialize this Json will fail with most parsers. (We're deserializing in WebKit.) We have hacked the Json.Net code to output null values when passed NaN, but this seems like a poor solution. Douglas Crockford (once) recommended using nulls in place of NaNs: http://www.json.org/json.ppt (Look at slide 16

Filter image that contains NaNs in Matlab?

安稳与你 提交于 2019-12-04 20:09:02
问题 I have a 2d array ( doubles ) representing some data, and it has a bunch of NaNs in it. The contour plot of the data looks like this: All of the white spaces are NaNs , the gray diamond is there for reference, and the filled contour shows the shape of my data. When I filter the data with imfilt , the NaNs significantly chew into the data, so we end up with something like this: You can see that the support set is significantly contracted. I can't use this, as it has chewed into some of the

Image Processing Issue: Fill NaNs in image, which mostly consists of NaNs

大兔子大兔子 提交于 2019-12-04 17:25:16
I have a dataset / image DD like the one in this image: (by the way: is there a way of uploading small data sets here, so that you can actually work with the same data I use, without having to put them in the code?) Colored pixels in the image represent height/depth ranging from 0 to about 400 meters. Blue pixels are NaN . Now what I need to do is to interpolate the pixel values WITHIN the displayed object, but without interpolating the whole image. I tried using the function inpaint_nans from the file-exchange, which has helped me quite often and again, it did a decent job: imagesc(inpaint

Android NDK: ARMv6 + VFP devices. wrong calculations, NaN, denormal numbers, VFP11 bug

浪尽此生 提交于 2019-12-04 16:43:36
I wish to target ARMv6 with VFP Android device. I have following line in my Android.mk file to enable VFP LOCAL_CFLAGS := -marm -mfloat-abi=softfp -mfpu=vfp -Wmultichar I believe I target ARMv5 with VFP . I edited android-ndk-r8b\toolchains\arm-linux-androideabi-4.6\setup.mk to remove -msoft-float . I also tried with original setup.mk My code works fine 99.99% of time but some times goes crazy on ARMv6 devices. I have special code to detect when it goes crazy. Code glm::vec3 D = P1 - P2; float f1 = sqrtf(D.x*D.x + D.y*D.y + D.z*D.z); if(!(f1 < 5)){ // f1 is bigger then 5 or NaN mylog_fmt(

Best way to detect NaN's in OpenGL shaders

和自甴很熟 提交于 2019-12-04 16:09:07
问题 I ran into what seemed a mysterious bug this morning that I feel very lucky to have stumbled upon a solution for quite quickly. I was dividing by a counter to produce an average inside of a fragment shader, and of course when the counter is zero, the resulting color value became NaN. During blending, NVidia gracefully treats a NaN as a 0 value, but Intel does not and appears to cascade the NaN, resulting in black fragments. And so this bug persisted until I tested the code on an Intel machine

Replace NaN's in NumPy array with closest non-NaN value

瘦欲@ 提交于 2019-12-04 15:54:35
问题 I have a NumPy array a like the following: >>> str(a) '[ nan nan nan 1.44955726 1.44628034 1.44409573\n 1.4408188 1.43657094 1.43171624 1.42649744 1.42200684 1.42117704\n 1.42040255 1.41922908 nan nan nan nan\n nan nan]' I want to replace each NaN with the closest non-NaN value, so that all of the NaN's at the beginning get set to 1.449... and all of the NaN's at the end get set to 1.419... . I can see how to do this for specific cases like this, but I need to be able to do it generally for

NaN Values in a float field in MSSQL Database

*爱你&永不变心* 提交于 2019-12-04 11:36:30
I am working on an old database I inherited from my predecessors. In it, some float fields contains NaN where there should be a null. The following SQL doesn't work because it doesn't recognize NaN. UPDATE xxx SET column= null WHERE column=NaN How can I do this? Try UPDATE xxx SET column= null WHERE IsNumeric(column)=0 Then run your select again. 来源: https://stackoverflow.com/questions/450618/nan-values-in-a-float-field-in-mssql-database

zero values of an array to be converted to nan values

流过昼夜 提交于 2019-12-04 11:26:31
I have an array 1200*1200. Some of its values are zero. I want to convert the zero values to numpy.nan values. This is my solution: import numpy for i in range(1200): for j in range(1200): if data_a[i, j] == 0: data_a[i, j] = numpy.nan But I got this error: data_a[i,j] = numpy.nan ValueError: cannot convert float NaN to integer I don't understand the error. Any alternatives or solutions? That error message is because your array is for storing integers: >>> import numpy as np >>> a = np.arange(3) >>> a array([0, 1, 2]) >>> a.dtype dtype('int32') >>> a[0] = np.nan Traceback (most recent call

How do I find: Is the first non-NaN value in each column the maximum for that column in a DataFrame?

若如初见. 提交于 2019-12-04 10:15:54
For example: 0 1 0 87.0 NaN 1 NaN 99.0 2 NaN NaN 3 NaN NaN 4 NaN 66.0 5 NaN NaN 6 NaN 77.0 7 NaN NaN 8 NaN NaN 9 88.0 NaN My expected output is: [False, True] since 87 is the first !NaN value but not the maximum in column 0 . 99 however is the first !NaN value and is indeed the max in that column. Option a) : Just do groupby with first (May not be 100% reliable ) df.groupby([1]*len(df)).first()==df.max() Out[89]: 0 1 1 False True Option b) : bfill Or using bfill (Fill any NaN value by the backward value in the column , then the first row after bfill is the first not NaN value ) df.bfill().iloc

Why are floating point infinities, unlike NaNs, equal?

这一生的挚爱 提交于 2019-12-04 09:50:21
问题 Why doesn't infinity comparison follow the logic applied to NaNs? This code prints out false three times: double a = Double.NaN; double b = Double.NaN; System.out.println(a == b); // false System.out.println(a < b); // false System.out.println(a > b); // false However, if I change Double.NaN to Double.POSITIVE_INFINITY , I get true for equality, but false for the greater-than and less-than comparisons: double a = Double.POSITIVE_INFINITY; double b = Double.POSITIVE_INFINITY; System.out