Comments (11)
unfortunately ifelse()
is a builtin and therefore cannot be extended:
julia> import Base: ifelse
julia> ifelse(::Int) = nothing
ERROR: cannot add methods to a builtin function
Stacktrace:
[1] top-level scope at none:0
FYI @oschulz
from numberintervals.jl.
I know. :-(
Ran into this when I did the benchmark example in #11, that's why I had to use a custom interval_ifelse()
.
from numberintervals.jl.
Ok, I started a discussion on the Julia discourse, maybe there is some way around it
from numberintervals.jl.
Thanks!
from numberintervals.jl.
@gwater , should we reopen this now that ifelse
is becoming generic in Julia v1.8.0?
from numberintervals.jl.
I was thinking about that the other day… I'm currently working on an overhaul of the internals, basically separating the notion of numbers and intervals. Essentially I define a type
struct FuzzyReal{T} <: AbstractFloat
interval::IEEE1788_Interval{T}
end
and then the method would look like this
ifelse(::Missing, a::FuzzyReal{T}, b::FuzzyReal{T}) = FuzzyReal(hull(a.interval, b.interval))
correct?
Notably, if the two underlying intervals are disjoint, we cannot describe their union using a single IEEE1788 interval. That's why we need to take the hull of their union.
from numberintervals.jl.
I agree, that definition would be best - anything other than the hull (tracking the separate intervals) would have the potential of growing exponentially.
I wonder if there's a better name than FuzzyReal - sounds a bit like fuzzy logic, which it's not, for course. And it may sound a bit to, well, fuzzy, for something that follows rigorous rules and gives guarantees (true result will be in the interval). Why not NumberInterval
, in line with the package name?
from numberintervals.jl.
ifelse(::Missing, a::FuzzyReal{T}, b::FuzzyReal{T})
is problematic, though, it forces the user to pass FuzzyReal
explicitly, which makes it difficult to use intervals in generic code. If comparisons of intervals would return a custom value, e.g. Indeterminate()
or so, ifelse
could be specialized in a more generic way like ifelse(::Indeterminate, a, b) = interval_hull(a, b)
.
from numberintervals.jl.
ifelse(::Missing, a::FuzzyReal{T}, b::FuzzyReal{T})
is problematic, though, it forces the user to passFuzzyReal
explicitly, which makes it difficult to use intervals in generic code. If comparisons of intervals would return a custom value, e.g.Indeterminate()
or so,ifelse
could be specialized in a more generic way likeifelse(::Indeterminate, a, b) = interval_hull(a, b)
.
That's an interesting point. I have been wondering if it might be worth defining this new type (regardless of its name) with a field for the third logical value. So:
struct FuzzyReal{T, V}
interval::IEEE1788_Interval{T}
indeterminate::V
end
then we could set the field indeterminate
to missing
by default but users could choose to set a different value to define custom behavior in indeterminate cases. What do you think?
from numberintervals.jl.
Why not
NumberInterval
, in line with the package name?
In thinking about the relationship between the number subtype and the IEEE intervals more deeply I have found that I would rather separate the notions of intervals and numbers completely. So the FuzzyReal
should, in my opinion, not provide any set behaviours such as intersections, hulls, etc. Consequently, the name should make that clear, too.
from numberintervals.jl.
with a field for the third logical value.
Nowadays, a Julia Union
should handle that efficiently, I hope. I would suggest that comparison operators return a Union{Indeterminate,Bool}
, with numeric intervals being a separate thing.
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
- Proposal: replace Indeterminate() with Base.missing HOT 15
- 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.