Skip to content

Commit 555a183

Browse files
committed
Strict parent checks in == methods
1 parent 69cf57e commit 555a183

14 files changed

+23
-37
lines changed

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
@@ -417,8 +417,7 @@ that power series to different precisions may still be arithmetically
417417
equal to the minimum of the two precisions.
418418
"""
419419
function ==(x::FracElem{T}, y::FracElem{T}) where {T <: RingElem}
420-
b = check_parent(x, y, false)
421-
!b && return false
420+
check_parent(x, y)
422421

423422
return (denominator(x, false) == denominator(y, false) &&
424423
numerator(x, false) == numerator(y, false)) ||

src/Matrix.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,8 +1266,7 @@ that power series to different precisions may still be arithmetically
12661266
equal to the minimum of the two precisions.
12671267
"""
12681268
function ==(x::MatrixElem{T}, y::MatrixElem{T}) where {T <: NCRingElement}
1269-
b = check_parent(x, y, false)
1270-
!b && return false
1269+
check_parent(x, y)
12711270
for i = 1:nrows(x)
12721271
for j = 1:ncols(x)
12731272
if x[i, j] != y[i, j]

src/NCPoly.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,13 @@ that power series to different precisions may still be arithmetically
340340
equal to the minimum of the two precisions.
341341
"""
342342
function ==(x::NCPolyRingElem{T}, y::NCPolyRingElem{T}) where T <: NCRingElem
343-
b = check_parent(x, y, false)
344-
!b && return false
343+
check_parent(x, y)
345344
if length(x) != length(y)
346345
return false
347-
else
348-
for i = 1:length(x)
349-
if coeff(x, i - 1) != coeff(y, i - 1)
350-
return false
351-
end
346+
end
347+
for i = 1:length(x)
348+
if coeff(x, i - 1) != coeff(y, i - 1)
349+
return false
352350
end
353351
end
354352
return true

src/Poly.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -837,15 +837,14 @@ that power series to different precisions may still be arithmetically
837837
equal to the minimum of the two precisions.
838838
"""
839839
function ==(x::PolyRingElem{T}, y::PolyRingElem{T}) where T <: RingElement
840-
b = check_parent(x, y, false)
841-
!b && return false
840+
check_parent(x, y)
841+
842842
if length(x) != length(y)
843843
return false
844-
else
845-
for i = 1:length(x)
846-
if coeff(x, i - 1) != coeff(y, i - 1)
847-
return false
848-
end
844+
end
845+
for i = 1:length(x)
846+
if coeff(x, i - 1) != coeff(y, i - 1)
847+
return false
849848
end
850849
end
851850
return true

src/RelSeries.jl

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

733732
xval = valuation(x)
734733
xprec = precision(x)

src/Residue.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@ that power series to different precisions may still be arithmetically
243243
equal to the minimum of the two precisions.
244244
"""
245245
function ==(a::ResElem{T}, b::ResElem{T}) where {T <: RingElement}
246-
fl = check_parent(a, b, false)
247-
!fl && return false
246+
check_parent(a, b)
248247
return data(a) == data(b)
249248
end
250249

src/ResidueField.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ that power series to different precisions may still be arithmetically
227227
equal to the minimum of the two precisions.
228228
"""
229229
function ==(a::ResFieldElem{T}, b::ResFieldElem{T}) where {T <: RingElement}
230-
fl = check_parent(a, b, false)
231-
!fl && return false
230+
check_parent(a, b)
232231
return data(a) == data(b)
233232
end
234233

src/generic/FreeAssociativeAlgebra.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ end
295295
###############################################################################
296296

297297
function ==(a::FreeAssociativeAlgebraElem{T}, b::FreeAssociativeAlgebraElem{T}) where T
298-
fl = check_parent(a, b, false)
299-
!fl && return false
298+
check_parent(a, b)
300299
return a.length == b.length &&
301300
view(a.exps, 1:a.length) == view(b.exps, 1:b.length) &&
302301
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
@@ -134,7 +134,7 @@ end
134134
###############################################################################
135135

136136
function ==(a::LaurentMPolyWrap, b::LaurentMPolyWrap)
137-
check_parent(a, b, false) || return false
137+
check_parent(a, b)
138138
if a.mindegs == b.mindegs
139139
return a.mpoly == b.mpoly
140140
end

0 commit comments

Comments
 (0)