Comments (15)
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.
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.
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.
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.
And as long as we don't add methods to Missing, it's not type piracy
from numberintervals.jl.
Sure - but then, you did get kind of positive replies to you suggestion to make ifelse
a non-builtin again. :-)
from numberintervals.jl.
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.
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.
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.
Hm, yes. Ok, assuming we'll go with missing
- we could propose ifelse(::Missing, a, b) = missing
.
from numberintervals.jl.
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.
Yes, I agree.
from numberintervals.jl.
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.
Good idea - done.
from numberintervals.jl.
ok, thanks
from numberintervals.jl.
Related Issues (14)
- min, max HOT 1
- Three-valued logic instead of exception on comparisons? HOT 19
- implement logical operations for indeterminate HOT 1
- implement ifelse() as union of results HOT 11
- infinite `promote_rule` loop when combining with `IntervalArithmetic.jl` HOT 8
- mig, mag, inf, sup HOT 1
- sign HOT 1
- round HOT 1
- isinteger HOT 1
- redefine isfinite HOT 1
- isinteger can return false for certain cases HOT 1
- provide more detailed error messages in indeterminate cases HOT 1
- cbrt causes stack overflow HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from numberintervals.jl.