Skip to content

Commit 260d487

Browse files
committed
Strict parent checks in == methods
1 parent fd7aa4e commit 260d487

File tree

14 files changed

+23
-37
lines changed

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
@@ -1303,8 +1303,7 @@ that power series to different precisions may still be arithmetically
13031303
equal to the minimum of the two precisions.
13041304
"""
13051305
function ==(x::MatrixElem{T}, y::MatrixElem{T}) where {T <: NCRingElement}
1306-
b = check_parent(x, y, false)
1307-
!b && return false
1306+
check_parent(x, y)
13081307
for i = 1:nrows(x)
13091308
for j = 1:ncols(x)
13101309
if x[i, j] != y[i, j]

src/NCPoly.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,13 @@ that power series to different precisions may still be arithmetically
342342
equal to the minimum of the two precisions.
343343
"""
344344
function ==(x::NCPolyRingElem{T}, y::NCPolyRingElem{T}) where T <: NCRingElem
345-
b = check_parent(x, y, false)
346-
!b && return false
345+
check_parent(x, y)
347346
if length(x) != length(y)
348347
return false
349-
else
350-
for i = 1:length(x)
351-
if coeff(x, i - 1) != coeff(y, i - 1)
352-
return false
353-
end
348+
end
349+
for i = 1:length(x)
350+
if coeff(x, i - 1) != coeff(y, i - 1)
351+
return false
354352
end
355353
end
356354
return true

src/Poly.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -839,15 +839,14 @@ that power series to different precisions may still be arithmetically
839839
equal to the minimum of the two precisions.
840840
"""
841841
function ==(x::PolyRingElem{T}, y::PolyRingElem{T}) where T <: RingElement
842-
b = check_parent(x, y, false)
843-
!b && return false
842+
check_parent(x, y)
843+
844844
if length(x) != length(y)
845845
return false
846-
else
847-
for i = 1:length(x)
848-
if coeff(x, i - 1) != coeff(y, i - 1)
849-
return false
850-
end
846+
end
847+
for i = 1:length(x)
848+
if coeff(x, i - 1) != coeff(y, i - 1)
849+
return false
851850
end
852851
end
853852
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
@@ -132,7 +132,7 @@ end
132132
###############################################################################
133133

134134
function ==(a::LaurentMPolyWrap, b::LaurentMPolyWrap)
135-
check_parent(a, b, false) || return false
135+
check_parent(a, b)
136136
if a.mindegs == b.mindegs
137137
return a.mpoly == b.mpoly
138138
end

0 commit comments

Comments
 (0)