Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/NCRings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,17 @@ end

*(x::NCRingElement, y::NCRingElem) = parent(y)(x)*y

# general fallback for comparison of elements via promotion.
# This is different from Julia's existing promotion logic because
# it takes parents into account
function ==(x::NCRingElem, y::NCRingElem)
fl, u, v = try_promote(x, y)
if fl
return u == v
else
return false
end
# avoid infinite recursion: we only get here if a ring type "forgot" to
# implement ==, so only do something if x and y have different type
if typeof(x) !== typeof(y)
fl, u, v = try_promote(x, y)
fl && return u == v
end
throw(NotImplementedError(:(==), x, y))
end

==(x::NCRingElem, y::NCRingElement) = x == parent(x)(y)
Expand Down
7 changes: 0 additions & 7 deletions test/generic/AbsSeries-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ end

@test isa(l, Generic.AbsSeries)

@test x in [x, y]
@test x in [y, x]
@test !(x in [y])

@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))

R, x = power_series_ring(ZZ, 30, "x", model=:capped_absolute)
S, x = power_series_ring(ZZ, 30, "x", model=:capped_absolute)
@test R === S
Expand Down
6 changes: 0 additions & 6 deletions test/generic/FactoredFraction-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,6 @@ end
TT = factored_fraction_field(polynomial_ring(QQ, "x")[1])
a = TT(1)
b = T(2)

@test a in [a, b]
@test a in [b, a]
@test !(a in [b])
@test a in keys(Dict(a => 1))
@test !(b in keys(Dict(a => 1)))
end

@testset "Generic.FactoredFracFieldElem.printing" begin
Expand Down
6 changes: 0 additions & 6 deletions test/generic/Fraction-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@
b = T(2)
@test is_perfect(TT)

@test a in [a, b]
@test a in [b, a]
@test !(a in [b])
@test a in keys(Dict(a => 1))
@test !(b in keys(Dict(a => 1)))

# trivial rings can not be fields
R = residue_ring(ZZ, 1)[1]
@test is_trivial(R)
Expand Down
8 changes: 0 additions & 8 deletions test/generic/FreeAssociativeAlgebra-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@

@test collect(exponent_words(varlist[1] + 1)) == [Int[1], Int[]]
@test isone(varlist[1]^0)

_, varlist = polynomial_ring(QQ, var_names)
y = varlist[1]
@test x in [x, y]
@test x in [y, x]
@test !(x in [y])
@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))
end
end

Expand Down
7 changes: 0 additions & 7 deletions test/generic/FunctionField-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ P2 = [(x2 + 1)*z2 + (x2 + 2), z2 + (x2 + 1)//(x2 + 2), z2^2 + 3z2 + 1,
@test !is_perfect(S2)

@test var(S1) == :y1

@test y1 in [y1, y2]
@test y1 in [y2, y1]
@test !(y1 in [y2])

@test y1 in keys(Dict(y1 => 1))
@test !(y2 in keys(Dict(y1 => 1)))
end

@testset "Generic.FunctionField.printing" begin
Expand Down
7 changes: 0 additions & 7 deletions test/generic/LaurentSeries-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ end
l = T(t)

@test isa(l, Generic.LaurentSeriesElem)

@test x in [x, y]
@test x in [y, x]
@test !(x in [y])

@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))

R, x = laurent_series_ring(ZZ, 30, "x")
RR, x = laurent_series_ring(ZZ, 30, "x")
Expand Down
8 changes: 0 additions & 8 deletions test/generic/MPoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@
f3 = finish(C)

@test f1 == f3

_, varlist = polynomial_ring(QQ, var_names)
y = varlist[1]
@test x in [x, y]
@test x in [y, x]
@test !(x in [y])
@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))
end

R1, (x, y) = polynomial_ring(QQ, ["x", "y"])
Expand Down
14 changes: 14 additions & 0 deletions test/generic/Matrix-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,23 @@ end
@test D4[5, 5] == R(5)
@test D4 isa Generic.MatSpaceElem{elem_type(R)}

# test comparison of matrices over different ring, and of different sizes
x = zero_matrix(R, 2, 2)
y = zero_matrix(ZZ, 2, 3)

@test x != y
@test x in [x, y]
@test x in [y, x]
@test !(x in [y])

@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))

# test comparison of matrices over same ring, but of different sizes
x = zero_matrix(ZZ, 2, 2)
y = zero_matrix(ZZ, 2, 3)

@test x != y
@test x in [x, y]
@test x in [y, x]
@test !(x in [y])
Expand Down
7 changes: 0 additions & 7 deletions test/generic/Poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ end
n = S([ZZ(1), ZZ(2), ZZ(3)])

@test isa(n, PolyRingElem)

@test x in [x, y]
@test x in [y, x]
@test !(x in [y])

@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))
end

@testset "Generic.Poly.constructors.varname" begin
Expand Down
7 changes: 0 additions & 7 deletions test/generic/PuiseuxSeries-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ end
l = T(t)

@test isa(l, Generic.PuiseuxSeriesElem)

@test x in [x, y]
@test x in [y, x]
@test !(x in [y])

@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))
end

@testset "Generic.PuiseuxSeries.printing" begin
Expand Down
6 changes: 0 additions & 6 deletions test/generic/RationalFunctionField-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ end
a = TT(1)
b = T(2)

@test a in [a, b]
@test a in [b, a]
@test !(a in [b])
@test a in keys(Dict(a => 1))
@test !(b in keys(Dict(a => 1)))

# Multivariate

T, (x, y) = rational_function_field(QQ, ["x", "y"])
Expand Down
7 changes: 0 additions & 7 deletions test/generic/RelSeries-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ end

@test isa(l, Generic.RelSeries)

@test x in [x, y]
@test x in [y, x]
@test !(x in [y])

@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))

@test_throws DomainError O(0+O(x^0))

@test !occursin("\n", sprint(show, T))
Expand Down
10 changes: 0 additions & 10 deletions test/generic/Residue-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ end
k = T(1)

@test isa(k, EuclideanRingResidueRingElem)

S, = Generic.residue_ring(B, 164538890)
x = R(1)
y = S(1)
@test x in [x, y]
@test x in [y, x]
@test !(x in [y])

@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))
end

@testset "EuclideanRingResidueRingElem.is_trivial" begin
Expand Down
10 changes: 0 additions & 10 deletions test/generic/ResidueField-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@

@test isa(g, EuclideanRingResidueFieldElem)

S, = Generic.residue_ring(B, 2)
x = R(1)
y = S(1)
@test x in [x, y]
@test x in [y, x]
@test !(x in [y])

@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))

# trivial rings can not be fields
@test_throws ArgumentError residue_field(ZZ, 1)
R = residue_ring(ZZ, 1)[1]
Expand Down
9 changes: 0 additions & 9 deletions test/generic/UnivPoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,6 @@

@test f1 == f3

@test x in [x, y]
@test x in [y, x]
@test y in [y, z]
@test !(x in [y])
@test !(y in [x])
@test x in keys(Dict(x => 1))
@test !(y in keys(Dict(x => 1)))
@test !(y in keys(Dict(z => 1)))

S2, x = universal_polynomial_ring(R, :x => 1:3; internal_ordering=ord)

@test length(x) == 3
Expand Down
Loading