We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6cebde9 commit 89c8639Copy full SHA for 89c8639
src/methods.jl
@@ -88,7 +88,7 @@ end
88
@number_methods(Pow, term(f, a), term(f, a, b), skipbasics)
89
@number_methods(Div, term(f, a), term(f, a, b), skipbasics)
90
91
-for f in diadic
+for f in vcat(diadic, [+, -, *, \, /, ^])
92
@eval promote_symtype(::$(typeof(f)),
93
T::Type{<:Number},
94
S::Type{<:Number}) = promote_type(T, S)
@@ -112,18 +112,6 @@ for f in diadic
112
end
113
114
115
-for f in [+, -, *, \, /, ^]
116
- @eval promote_symtype(::$(typeof(f)),
117
- T::Type{<:Number},
118
- S::Type{<:Number}) = promote_type(T, S)
119
- @eval function promote_symtype(::$(typeof(f)),
120
- T::Type{<:SafeReal},
121
- S::Type{<:Number})
122
- X = promote_type(Real, S)
123
- X == Real ? SafeReal : X
124
- end
125
-end
126
-
127
promote_symtype(::typeof(rem2pi), T::Type{<:Number}, mode) = T
128
Base.rem2pi(x::Symbolic{<:Number}, mode::Base.RoundingMode) = term(rem2pi, x, mode)
129
src/types.jl
@@ -698,6 +698,7 @@ function makeadd(sign, coeff, xs...)
698
coeff, d
699
700
701
+add_t(a::Number,b::Number) = promote_symtype(+, symtype(a), symtype(b))
702
add_t(a,b) = promote_symtype(+, symtype(a), symtype(b))
703
sub_t(a,b) = promote_symtype(-, symtype(a), symtype(b))
704
sub_t(a) = promote_symtype(-, symtype(a))
test/basics.jl
@@ -238,7 +238,7 @@ end
238
239
240
@testset "div" begin
241
- @syms x y
+ @syms x::SafeReal y::Real
242
@test (2x/2y).num isa Sym
243
@test (2x/3y).num.coeff == 2
244
@test (2x/3y).den.coeff == 3
@@ -247,4 +247,13 @@ end
247
@test (2.5x/3x).num.coeff == 2.5
248
@test (2.5x/3x).den.coeff == 3
249
@test (x/3x).den.coeff == 3
250
+
251
+ @syms x y
252
+ @test (2x/2y).num isa Sym
253
+ @test (2x/3y).num.coeff == 2
254
+ @test (2x/3y).den.coeff == 3
255
+ @test (2x/-3x) == -2//3
256
+ @test (2.5x/3x).num == 2.5
257
+ @test (2.5x/3x).den == 3
258
+ @test (x/3x) == 1//3
259
0 commit comments