Skip to content

Commit cd5214b

Browse files
committed
Strict parent checks in == methods
1 parent 6d282a9 commit cd5214b

14 files changed

Lines changed: 23 additions & 37 deletions

src/AbsSeries.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,7 @@ that power series to different precisions may still be arithmetically
486486
equal to the minimum of the two precisions.
487487
"""
488488
function ==(x::AbsPowerSeriesRingElem{T}, y::AbsPowerSeriesRingElem{T}) where T <: RingElement
489-
b = check_parent(x, y, false)
490-
!b && return false
489+
check_parent(x, y)
491490

492491
prec = min(precision(x), precision(y))
493492
m1 = min(length(x), length(y))

src/Fraction.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,7 @@ that power series to different precisions may still be arithmetically
412412
equal to the minimum of the two precisions.
413413
"""
414414
function ==(x::FracElem{T}, y::FracElem{T}) where {T <: RingElem}
415-
b = check_parent(x, y, false)
416-
!b && return false
415+
check_parent(x, y)
417416

418417
return (denominator(x, false) == denominator(y, false) &&
419418
numerator(x, false) == numerator(y, false)) ||

src/Matrix.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,8 +1313,7 @@ that power series to different precisions may still be arithmetically
13131313
equal to the minimum of the two precisions.
13141314
"""
13151315
function ==(x::MatrixElem{T}, y::MatrixElem{T}) where {T <: NCRingElement}
1316-
b = check_parent(x, y, false)
1317-
!b && return false
1316+
check_parent(x, y)
13181317
for i = 1:nrows(x)
13191318
for j = 1:ncols(x)
13201319
if x[i, j] != y[i, j]

src/NCPoly.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,13 @@ that power series to different precisions may still be arithmetically
345345
equal to the minimum of the two precisions.
346346
"""
347347
function ==(x::NCPolyRingElem{T}, y::NCPolyRingElem{T}) where T <: NCRingElem
348-
b = check_parent(x, y, false)
349-
!b && return false
348+
check_parent(x, y)
350349
if length(x) != length(y)
351350
return false
352-
else
353-
for i = 1:length(x)
354-
if coeff(x, i - 1) != coeff(y, i - 1)
355-
return false
356-
end
351+
end
352+
for i = 1:length(x)
353+
if coeff(x, i - 1) != coeff(y, i - 1)
354+
return false
357355
end
358356
end
359357
return true

src/Poly.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -898,15 +898,14 @@ that power series to different precisions may still be arithmetically
898898
equal to the minimum of the two precisions.
899899
"""
900900
function ==(x::PolyRingElem{T}, y::PolyRingElem{T}) where T <: RingElement
901-
b = check_parent(x, y, false)
902-
!b && return false
901+
check_parent(x, y)
902+
903903
if length(x) != length(y)
904904
return false
905-
else
906-
for i = 1:length(x)
907-
if coeff(x, i - 1) != coeff(y, i - 1)
908-
return false
909-
end
905+
end
906+
for i = 1:length(x)
907+
if coeff(x, i - 1) != coeff(y, i - 1)
908+
return false
910909
end
911910
end
912911
return true

src/RelSeries.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,7 @@ that power series to different precisions may still be arithmetically
731731
equal to the minimum of the two precisions.
732732
"""
733733
function ==(x::RelPowerSeriesRingElem{T}, y::RelPowerSeriesRingElem{T}) where T <: RingElement
734-
b = check_parent(x, y, false)
735-
!b && return false
734+
check_parent(x, y)
736735

737736
xval = valuation(x)
738737
xprec = precision(x)

src/Residue.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ that power series to different precisions may still be arithmetically
257257
equal to the minimum of the two precisions.
258258
"""
259259
function ==(a::ResElem{T}, b::ResElem{T}) where {T <: RingElement}
260-
fl = check_parent(a, b, false)
261-
!fl && return false
260+
check_parent(a, b)
262261
return data(a) == data(b)
263262
end
264263

src/ResidueField.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ that power series to different precisions may still be arithmetically
198198
equal to the minimum of the two precisions.
199199
"""
200200
function ==(a::ResFieldElem{T}, b::ResFieldElem{T}) where {T <: RingElement}
201-
fl = check_parent(a, b, false)
202-
!fl && return false
201+
check_parent(a, b)
203202
return data(a) == data(b)
204203
end
205204

src/generic/FreeAssociativeAlgebra.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ end
301301
###############################################################################
302302

303303
function ==(a::FreeAssociativeAlgebraElem{T}, b::FreeAssociativeAlgebraElem{T}) where T
304-
fl = check_parent(a, b, false)
305-
!fl && return false
304+
check_parent(a, b)
306305
return a.length == b.length &&
307306
view(a.exps, 1:a.length) == view(b.exps, 1:b.length) &&
308307
view(a.coeffs, 1:a.length) == view(b.coeffs, 1:b.length)

src/generic/LaurentMPoly.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ end
146146
###############################################################################
147147

148148
function ==(a::LaurentMPolyWrap, b::LaurentMPolyWrap)
149-
check_parent(a, b, false) || return false
149+
check_parent(a, b)
150150
if a.mindegs == b.mindegs
151151
return a.mpoly == b.mpoly
152152
end

0 commit comments

Comments
 (0)