Skip to content

Commit eeb33d4

Browse files
authored
Avoid pirating Base.real (#101)
1 parent 1718c0b commit eeb33d4

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.5.8"
3+
version = "0.5.9"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/ApproxFunBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Base: values, convert, getindex, setindex!, *, +, -, ==, <, <=, >, |, !,
2323
isless, union, angle, join, isnan, isapprox, isempty, sort, merge, promote_rule,
2424
minimum, maximum, extrema, argmax, argmin, findmax, findmin, isfinite,
2525
zeros, zero, one, promote_rule, repeat, length, resize!, isinf,
26-
getproperty, findfirst, unsafe_getindex, fld, cld, div, real, imag,
26+
getproperty, findfirst, unsafe_getindex, fld, cld, div, imag,
2727
@_inline_meta, eachindex, firstindex, lastindex, keys, isreal, OneTo,
2828
Array, Vector, Matrix, view, ones, @propagate_inbounds, print_array,
2929
split, iszero, permutedims

src/Fun.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ end
430430

431431
transpose(f::Fun) = f # default no-op
432432

433-
for op = (:(real),:(imag),:(conj))
434-
@eval ($op)(f::Fun{S}) where {S<:RealSpace} = Fun(f.space,($op)(f.coefficients))
433+
for op = (:real, :imag, :conj)
434+
@eval Base.$op(f::Fun{S}) where {S<:RealSpace} = Fun(f.space, ($op)(f.coefficients))
435435
end
436436

437437
conj(f::Fun) = error("Override conj for $(typeof(f))")

test/SpacesTest.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ import ApproxFunBase: PointSpace, HeavisideSpace, PiecewiseSegment, dimension, V
1212
@test f/a == Fun(x->(x-0.1)*exp(-x),space(f))
1313

1414
f = Fun(space(f),[1.,2.,3.])
15+
16+
@testset "real/complex coefficients" begin
17+
c = [1:4;]
18+
for c2 in Any[c, c*im]
19+
g = Fun(PointSpace(1:4), c2)
20+
for fn in [real, imag, conj]
21+
@test coefficients(fn(g)) == fn(c2)
22+
end
23+
end
24+
end
1525
end
1626

1727
@testset "Derivative operator for HeavisideSpace" begin

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import ApproxFunBase: ∞
2525
[(1,1),(1,2),(2,1),(2,2),(3,1),(3,2)]
2626
end
2727

28+
@testset "issue #94" begin
29+
@test ApproxFunBase.real !== Base.real
30+
@test_throws MethodError ApproxFunBase.real(1,2)
31+
end
32+
2833
# TODO: Tensorizer tests
2934
end
3035

0 commit comments

Comments
 (0)