Skip to content

Commit 7562c96

Browse files
authored
disallow automatic conversion from interval to float (#34)
1 parent 9ea4f20 commit 7562c96

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

docs/src/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44

55
## Unreleased
66

7+
- ![](https://img.shields.io/badge/bugfix-purple.svg) disallow implicit conversion from interval to float
78
- ![](https://img.shields.io/badge/new%20feature-green.svg) added semi-elliptic and singleton membership functions
89
- ![](https://img.shields.io/badge/new%20feature-green.svg) added `gensurf` to plot generating surface
910
- ![](https://img.shields.io/badge/bugfix-purple.svg) fix plotting of systems with several rules and membership functions.

src/evaluation.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ end
4646

4747
function (fis::SugenoFuzzySystem)(inputs::T) where {T <: NamedTuple}
4848
S = float(eltype(T))
49-
res = Dictionary{Symbol, S}(keys(fis.outputs),
50-
zeros(float(eltype(T)), length(fis.outputs)))
49+
res = Dictionary{Symbol, Union{S, Interval{S}}}(keys(fis.outputs),
50+
zeros(float(eltype(T)),
51+
length(fis.outputs)))
5152
weights_sum = zero(S)
5253
for rule in fis.rules
5354
w = scale(rule.antecedent(fis, inputs), rule)

src/intervals.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ diam(a::Interval) = a.hi - a.lo
1313
diam(x::Real) = zero(x)
1414

1515
Base.convert(::Type{Interval{T}}, x::Real) where {T <: Real} = Interval(T(x), T(x))
16-
Base.convert(::Type{T}, x::Interval) where {T <: AbstractFloat} = (x.lo + x.hi) / 2
1716

1817
Base.float(::Type{Interval{T}}) where {T <: Real} = T
1918

test/test_evaluation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,5 @@ end
182182
service == good --> tip == average
183183
service == excellent || food == delicious --> tip == generous
184184
end
185-
@test fis(service = 2, food = 3)[:tip]FuzzyLogic.Interval(5.304, 19.792) atol=1e-3
185+
@test fis(service = 2, food = 3)[:tip]FuzzyLogic.Interval(2.94, 28.613) atol=1e-3
186186
end

test/test_intervals.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@ using FuzzyLogic: Interval, inf, sup, mid, diam
2424
@test zero(Interval{Float64}) == Interval(0.0, 0.0)
2525

2626
@test convert(Interval{Float64}, 1.0) == Interval(1.0, 1.0)
27-
@test convert(Float64, Interval(0.0, 1.0)) == 0.5
2827
@test float(Interval{BigFloat}) == BigFloat
2928
end

0 commit comments

Comments
 (0)