GithubHelp home page GithubHelp logo

Comments (5)

dmey avatar dmey commented on July 28, 2024 1

@milankl great, thanks. Will add this to my current PRs. Feel free to close.

from speedyweather.jl.

milankl avatar milankl commented on July 28, 2024

Does it matter, it will be overwritten anyway? To initialise arrays as with NaNs we would need to do

julia> fill(convert(NF,NaN),2,3)
2×3 Matrix{Float16}:
 NaN  NaN  NaN
 NaN  NaN  NaN

for example, such that for ever NF<:AbstractFloat there needs to a conversion from NaN to whatever NaN corresponds to in NF.

from speedyweather.jl.

dmey avatar dmey commented on July 28, 2024

Sometime is hard to distinguish unset or improperly used variables down at the bottom of the stack and for debugging and assertions having NaNs helps... If there is no difference in terms of performance etc, I think it would be safer to use NaNs where possible.

from speedyweather.jl.

milankl avatar milankl commented on July 28, 2024

No it's not a performance issue. In both cases memory is allocated and filled with bits. Doesn't matter what those are.

julia> using BenchmarkTools
julia> c = NaN
julia> @btime fill($c,1000,1000);
  1.160 ms (2 allocations: 7.63 MiB)

julia> c = 0.0
julia> @btime fill($c,1000,1000);
  1.163 ms (2 allocations: 7.63 MiB)

Note that in the dynamics we allocate with zeros, and I never had a debugging-related issue with this. Happy for you to convert the initialisation for ColumnVariables to init with NaN, if people prefer that. I would suggest to define

function nans(::Type{T},dims...) where T
     return fill(convert(T,NaN),dims...)
end

in utility_functions.jl such that zeros(NF,...) works as nans(NF,...)

julia> nans(Float16,2)
2-element Vector{Float16}:
 NaN
 NaN

julia> nans(Float32,2)
2-element Vector{Float32}:
 NaN
 NaN

from speedyweather.jl.

milankl avatar milankl commented on July 28, 2024

nans has been added now ☝🏼

from speedyweather.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.