# \#nan

**URL:** https://discourse.julialang.org/tag/nan/376.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [\[ANN\] MathChecker.jl: Find problems in floating-point calculations](https://discourse.julialang.org/t/ann-mathchecker-jl-find-problems-in-floating-point-calculations/139261)

<div class="topic-metadata">

**Author:** [@moble](https://discourse.julialang.org/u/moble)\
**Replies:** 6\
**Last updated:** [September 10, 2026, 4:01pm UTC](https://discourse.julialang.org/t/ann-mathchecker-jl-find-problems-in-floating-point-calculations/139261 "2026-09-10T16:01:50Z")

</div>

I’m always surprised this isn’t a bigger topic of conversation among Julia users: how to find where problems are coming from in numerics. The gap between our pretty equations and algorithms on one hand, and practical …

---

## [How to ignore minibatches with NaN gradients optimizing a hybrid LUX model using Optimization.jl](https://discourse.julialang.org/t/how-to-ignore-minibatches-with-nan-gradients-optimizing-a-hybrid-lux-model-using-optimization-jl/132615)

<div class="topic-metadata">

**Author:** [@progtw1](https://discourse.julialang.org/u/progtw1)\
**Replies:** 1\
**Last updated:** [October 24, 2025, 1:17pm UTC](https://discourse.julialang.org/t/how-to-ignore-minibatches-with-nan-gradients-optimizing-a-hybrid-lux-model-using-optimization-jl/132615 "2025-10-24T13:17:45Z")

</div>

I try following the LUX tutorial on fitting an ML model using Optimization.jl for fitting a hybrid model, where the LUX model predicts some parameters of a process-based model, the LUX model application is just a call in…

---

## [Support for signaling NaNs?](https://discourse.julialang.org/t/support-for-signaling-nans/75571)

<div class="topic-metadata">

**Author:** [@stephancb](https://discourse.julialang.org/u/stephancb)\
**Replies:** 1\
**Last updated:** [November 19, 2024, 3:47pm UTC](https://discourse.julialang.org/t/support-for-signaling-nans/75571 "2024-11-19T15:47:08Z")

</div>

In Julia generally missing is favored over NaN, among other because NaN work only for floating point types, and because the origin of NaNs can be hard to trace once they have infected the data. However, IEEE745 has als…

---

## [Treating NaN as error: Helping debugging](https://discourse.julialang.org/t/treating-nan-as-error-helping-debugging/36933)

<div class="topic-metadata">

**Author:** [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Replies:** 19\
**Last updated:** [October 29, 2024, 3:08pm UTC](https://discourse.julialang.org/t/treating-nan-as-error-helping-debugging/36933 "2024-10-29T15:08:49Z")

</div>

I am writing a large hydrological model, and for some sets of parameters I get a NaN value, but I do not know which first function is giving me NaN. Therefore, I would like to stop my program at the first NaN. A dirty …

---

## [How to efficiently parse null as NaN in JSON?](https://discourse.julialang.org/t/how-to-efficiently-parse-null-as-nan-in-json/121561)

<div class="topic-metadata">

**Author:** [@berjine](https://discourse.julialang.org/u/berjine)\
**Replies:** 1\
**Last updated:** [October 22, 2024, 12:00am UTC](https://discourse.julialang.org/t/how-to-efficiently-parse-null-as-nan-in-json/121561 "2024-10-22T00:00:10Z")

</div>

Hi I want to parse lines of JSON containing among other things a vector of signed ints with some values being “null”, like that : {"data":\[98,null,-51,null\]} The way I do it currently is by using a conversion function…

---

## [Ignoring NaNs when calculating means of columns of a dataframe](https://discourse.julialang.org/t/ignoring-nans-when-calculating-means-of-columns-of-a-dataframe/110326)

<div class="topic-metadata">

**Author:** [@PeX](https://discourse.julialang.org/u/PeX)\
**Replies:** 1\
**Last updated:** [February 17, 2024, 12:07am UTC](https://discourse.julialang.org/t/ignoring-nans-when-calculating-means-of-columns-of-a-dataframe/110326 "2024-02-17T00:07:48Z")

</div>

Hi all, I have a dataframe with rows as dates and columns as data points. I need to calculate the mean of each column, but the problem is that some of the columns have “NaN” values. Is there an efficient way to achieve…

---

## [StackOverflowError() with ModellingToolkit.jl and NaNMath.jl](https://discourse.julialang.org/t/stackoverflowerror-with-modellingtoolkit-jl-and-nanmath-jl/104364)

<div class="topic-metadata">

**Author:** [@dleather](https://discourse.julialang.org/u/dleather)\
**Replies:** 6\
**Last updated:** [September 28, 2023, 9:04pm UTC](https://discourse.julialang.org/t/stackoverflowerror-with-modellingtoolkit-jl-and-nanmath-jl/104364 "2023-09-28T21:04:36Z")

</div>

The following code results in a StackOverflowError() in Julia 1.9. Is this expected behavior? using ModelingToolkit using NaNMath #Define Problem @variables t g(t) π(t) r(t) @parameters α\_g α\_π α\_r κ\_g κ\_π κ\_r ϕ\_g ϕ\_π…

---

## [Julia NaN check for NamedTuple](https://discourse.julialang.org/t/julia-nan-check-for-namedtuple/102583)

<div class="topic-metadata">

**Author:** [@iHany](https://discourse.julialang.org/u/iHany)\
**Replies:** 4\
**Last updated:** [August 8, 2023, 7:00am UTC](https://discourse.julialang.org/t/julia-nan-check-for-namedtuple/102583 "2023-08-08T07:00:39Z")

</div>

How to check if NaN is in a given NamedTuple? For example, julia\> myarray = \[0, 1, 2, NaN\] 4-element Vector{Float64}: 0.0 1.0 2.0 NaN julia\> isnan.(myarray) 4-element BitVector: 0 0 0 1 julia\> mynt = (;…

---

## [How to replace all values in an array with missing values?](https://discourse.julialang.org/t/how-to-replace-all-values-in-an-array-with-missing-values/75467)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 43\
**Last updated:** [April 15, 2023, 12:24pm UTC](https://discourse.julialang.org/t/how-to-replace-all-values-in-an-array-with-missing-values/75467 "2023-04-15T12:24:26Z")

</div>

I have an array A with the size of 360 x 180 x 100. The current missing value indicator is NaN. My goal is to replace all NaN values with missing values. Below is my code: A\[isnan.(A)\] .= missing; Unfortunately, I got…

---

## [Does anybody anywhere care about NaN payloads?](https://discourse.julialang.org/t/does-anybody-anywhere-care-about-nan-payloads/94152)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 2\
**Last updated:** [February 6, 2023, 7:21pm UTC](https://discourse.julialang.org/t/does-anybody-anywhere-care-about-nan-payloads/94152 "2023-02-06T19:21:05Z")

</div>

There are a bunch of different NaN values. NaN and anotherNaN = reinterpret(Float64, reinterpret(UInt64, NaN) + 1) and NaN are two examples. There is a proposal to explicitly disclaim any garuntees about which NaN you re…

---

## [min(NaN,5) = NaN (why no @fastmath?)](https://discourse.julialang.org/t/min-nan-5-nan-why-no-fastmath/93736)

<div class="topic-metadata">

**Author:** [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Replies:** 47\
**Last updated:** [February 2, 2023, 9:03pm UTC](https://discourse.julialang.org/t/min-nan-5-nan-why-no-fastmath/93736 "2023-02-02T21:03:44Z")

</div>

Hey Julianners, I just want to ask, as I ran into this problem 4th times even after that I know what causes this problem. Shouldn’t we make it happen to be correct as it is expected like in other languages? So basic…

---

## [Isusefulnumber()](https://discourse.julialang.org/t/isusefulnumber/93795)

<div class="topic-metadata">

**Author:** [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Replies:** 2\
**Last updated:** [January 30, 2023, 10:24pm UTC](https://discourse.julialang.org/t/isusefulnumber/93795 "2023-01-30T22:24:45Z")

</div>

Is there a function available to check in a large vector, if one of the following occurs in a vector: missing nothing Inf NaN ? Here is my snippet to investigate a vector for such elements: a = \[1.3, NaN, Inf, missi…

---

## [Best practices for dealing with NaNs in multiple data set using Turing](https://discourse.julialang.org/t/best-practices-for-dealing-with-nans-in-multiple-data-set-using-turing/70423)

<div class="topic-metadata">

**Author:** [@99dB](https://discourse.julialang.org/u/99dB)\
**Replies:** 2\
**Last updated:** [February 23, 2022, 3:44pm UTC](https://discourse.julialang.org/t/best-practices-for-dealing-with-nans-in-multiple-data-set-using-turing/70423 "2022-02-23T15:44:01Z")

</div>

What is the best way to deal with NaNs in multiple data treatments when using Turing? For example, for this example tutorial from https://github.com/TuringLang/TuringTutorials/blob/master/tutorials/10-bayesian-different…

---

## [(boxplot, StatsPlots.jl) how to plot \`boxplot\` with different number of data for each label?](https://discourse.julialang.org/t/boxplot-statsplots-jl-how-to-plot-boxplot-with-different-number-of-data-for-each-label/72649)

<div class="topic-metadata">

**Author:** [@iHany](https://discourse.julialang.org/u/iHany)\
**Replies:** 1\
**Last updated:** [December 6, 2021, 11:43am UTC](https://discourse.julialang.org/t/boxplot-statsplots-jl-how-to-plot-boxplot-with-different-number-of-data-for-each-label/72649 "2021-12-06T11:43:03Z")

</div>

Hi, I’d like to plot a boxplot with different number of data for each label. For example, using StatsPlots labels = \["hi", "hello"\] data = \[1.0 missing 3.0; 4.0 5.0 6.0\] boxplot(labels, data) results in the error: j…

---

## [Problem standardizing data with MLJ + NaN predictions in Flux](https://discourse.julialang.org/t/problem-standardizing-data-with-mlj-nan-predictions-in-flux/70923)

<div class="topic-metadata">

**Author:** [@lfenzo](https://discourse.julialang.org/u/lfenzo)\
**Replies:** 3\
**Last updated:** [November 8, 2021, 2:58am UTC](https://discourse.julialang.org/t/problem-standardizing-data-with-mlj-nan-predictions-in-flux/70923 "2021-11-08T02:58:36Z")

</div>

I’m new to Julia and Flux so I suspect this may be something dumb that I may be missing… I was trying to do some pre-processing in order to train a NN using Flux and ended up stuck with two problems: The predictions …

---

## [A few questions on Julia's missing values, and how they compare to Python and R](https://discourse.julialang.org/t/a-few-questions-on-julias-missing-values-and-how-they-compare-to-python-and-r/56007)

<div class="topic-metadata">

**Author:** [@yet\_another\_pythonis](https://discourse.julialang.org/u/yet_another_pythonis)\
**Replies:** 3\
**Last updated:** [February 25, 2021, 1:46pm UTC](https://discourse.julialang.org/t/a-few-questions-on-julias-missing-values-and-how-they-compare-to-python-and-r/56007 "2021-02-25T13:46:28Z")

</div>

I have read a lot about how Julia handles missing values: https://docs.julialang.org/en/v1/manual/missing/ but what’s still not clear to me is the differences (and pros and cons) vs how Python and R treat them. Could …

---

## [NaN Detector](https://discourse.julialang.org/t/nan-detector/55024)

<div class="topic-metadata">

**Author:** [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Replies:** 10\
**Last updated:** [February 25, 2021, 2:23am UTC](https://discourse.julialang.org/t/nan-detector/55024 "2021-02-25T02:23:39Z")

</div>

I’m trying to find my NaN generator. I think it is due to an uninitialized input variable without proper protection in the code. I know the debugger doesn’t have a nan break and it is very difficult for me to get to th…

---

## [DifferentialEquations.jl: ODE returns "retcode: success" but interpolation gives "NaN"](https://discourse.julialang.org/t/differentialequations-jl-ode-returns-retcode-success-but-interpolation-gives-nan/52942)

<div class="topic-metadata">

**Author:** [@Paio](https://discourse.julialang.org/u/Paio)\
**Replies:** 2\
**Last updated:** [January 6, 2021, 3:55pm UTC](https://discourse.julialang.org/t/differentialequations-jl-ode-returns-retcode-success-but-interpolation-gives-nan/52942 "2021-01-06T15:55:47Z")

</div>

Hello Julia community, I am currently going through a toy-problem trying to solve the heat PDE using the FFT (I’m following this series by Steve Brunton Solving PDEs with the FFT \[Matlab\] - YouTube). This is the code I …

---

## [Ignoring \`NaN\` with \`findmax()\`](https://discourse.julialang.org/t/ignoring-nan-with-findmax/39891)

<div class="topic-metadata">

**Author:** [@sergevic](https://discourse.julialang.org/u/sergevic)\
**Replies:** 9\
**Last updated:** [May 25, 2020, 12:22am UTC](https://discourse.julialang.org/t/ignoring-nan-with-findmax/39891 "2020-05-25T00:22:53Z")

</div>

Suppose I have the following array: a=\[NaN, 1,2,3\] If I use findmax(a), I obtain (NaN, 1). How can I use findmax() ignoring all NaN values? I tried findmax(filter(!isnan, a)) but it returns (3.0,3) when I want (3.0,4).…
