Giter Site home page Giter Site logo

Comments (15)

gwater avatar gwater commented on July 4, 2024

An alternative would be extending:

import Base: ismissing
ismissing(::Indeterminate) = true

That would, in most cases, allow Base methods to promote Indeterminate() to missing. However I'm very concerned about weird interactions when a type claims to be something it isn't. (See the whole Number/Real debate in IntevalArithmetic.jl).

from numberintervals.jl.

gwater avatar gwater commented on July 4, 2024

Oh, and of course this proposal would break the exception catching concept (for TypeError). Although it might be ok to treat missing information more generally rather than specializing for missing data due to interval arithmetic?

from numberintervals.jl.

oschulz avatar oschulz commented on July 4, 2024

Hmm, I have to admit I'm unsure about this myself. Using Base.missing seems nice and simple. But on the other hand, it really makes things a bit unspecific, and there may be other things besides ifelse that one may want to specialize in the future. And then, semantically, it's not really "missing" information - semantically, it's actually more like three-valued logic, resp. a [false, true] interval.

from numberintervals.jl.

gwater avatar gwater commented on July 4, 2024

And then, semantically, it's not really "missing" information

I would say it is missing information: we simply don't know which two numbers we are comparing (for example). And Base documentation suggests that missing was added explicitly to implement three valued logic.

Consider for example Base.==(::AbstractArray, ::AbstractArray) it would be very annoying to reimplement that for the Indeterminate type because it would be 100% the same function

from numberintervals.jl.

gwater avatar gwater commented on July 4, 2024

And as long as we don't add methods to Missing, it's not type piracy

from numberintervals.jl.

oschulz avatar oschulz commented on July 4, 2024

Sure - but then, you did get kind of positive replies to you suggestion to make ifelse a non-builtin again. :-)

from numberintervals.jl.

gwater avatar gwater commented on July 4, 2024

True, I think there are three methods we could implement without type piracy

ifelse(::Missing, ::NumberInterval, ::NumberInterval)
ifelse(::Missing, ::NumberInterval, ::Number)
ifelse(::Missing, ::Number, ::NumberInterval)

the only one that would be problematic imho, is ifelse(::Missing, ::Number, ::Number)

from numberintervals.jl.

oschulz avatar oschulz commented on July 4, 2024

True. Alas, ifelse(::Missing, ::Number, ::Number) may be quite relevant.

How about using a specialized type like TrueOrFalse for now. It can always be turned into an alias for Missing later on, if we find it unnecessary. However, moving in the other direction, from Missing to a specialized type, is bound to break user code.

from numberintervals.jl.

gwater avatar gwater commented on July 4, 2024

True. Alas, ifelse(::Missing, ::Number, ::Number) may be quite relevant.

I'm not sure intervals are even the right result for that operation. The set of solutions isnt the interval [a, b] (for ifelse(::Missing, a::Number, b::Number), assuming a<b) it's really the set {a,b}.

from numberintervals.jl.

oschulz avatar oschulz commented on July 4, 2024

Hm, yes. Ok, assuming we'll go with missing - we could propose ifelse(::Missing, a, b) = missing.

from numberintervals.jl.

gwater avatar gwater commented on July 4, 2024

Yes, I think that would make sense in a Base context.

I guess in the future one could also propose a generalized "set arithmetic" which is able to compose arbitrary sets of numbers, not just intervals. Then, taking in two sets of single numbers, {a} and {b}, one could reasonably return their union {a, b} (without any type piracy). It's beyond the scope here, but I think it's worth considering for a future package…

from numberintervals.jl.

oschulz avatar oschulz commented on July 4, 2024

Yes, I agree.

from numberintervals.jl.

gwater avatar gwater commented on July 4, 2024

Ok, so I think I will move forward with #17 .

Would you like to add ifelse(::Missing, a, b) = missing to JuliaLang/julia/issues/32844 ? I think it would make sense to combine the proposal to make ifelse generic with that extending it in Base.

from numberintervals.jl.

oschulz avatar oschulz commented on July 4, 2024

Good idea - done.

from numberintervals.jl.

gwater avatar gwater commented on July 4, 2024

ok, thanks

from numberintervals.jl.

Related Issues (14)

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.