Skip to content

Commit

Permalink
Replace ErrorConstrDimMismatch by version from AA
Browse files Browse the repository at this point in the history
The code there is identical.

Also stop exporting error_dim_negative and ErrorConstrDimMismatch.
  • Loading branch information
fingolfin committed Aug 24, 2023
1 parent 1f15e5e commit 1413d1f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 41 deletions.
4 changes: 1 addition & 3 deletions src/Nemo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ export GF

import AbstractAlgebra: Set, Module, Ring, Group, Field, promote_rule

import AbstractAlgebra: pretty, Lowercase, LowercaseOff, Indent, Dedent
import AbstractAlgebra: pretty, Lowercase, LowercaseOff, Indent, Dedent, ErrorConstrDimMismatch

export flint_cleanup, flint_set_num_threads

export error_dim_negative, ErrorConstrDimMismatch

export PadicField, QadicField, NGFiniteField

export QQBar
Expand Down
38 changes: 0 additions & 38 deletions src/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,5 @@
#
###############################################################################

mutable struct ErrorConstrDimMismatch <: Exception
expect_r::Int
expect_c::Int
get_r::Int
get_c::Int
get_l::Int

function ErrorConstrDimMismatch(er::Int, ec::Int, gr::Int, gc::Int)
e = new(er, ec, gr, gc, -1)
return e
end

function ErrorConstrDimMismatch(er::Int, ec::Int, gl::Int)
e = new(er, ec, -1, -1, gl)
return e
end

function ErrorConstrDimMismatch(er::Int, ec::Int, a::Matrix{T}) where {T}
gr, gc = size(a)
return ErrorConstrDimMismatch(er, ec, gr, gc)
end

function ErrorConstrDimMismatch(er::Int, ec::Int, a::Vector{T}) where {T}
gl = length(a)
return ErrorConstrDimMismatch(er, ec, gl)
end
end

function Base.showerror(io::IO, e::ErrorConstrDimMismatch)
if e.get_l == -1
print(io, "Expected dimension $(e.expect_r) x $(e.expect_c), ")
print(io, "got $(e.get_r) x $(e.get_c)")
else
print(io, "Expected an array of length $(e.expect_r * e.expect_c), ")
print(io, "got $(e.get_l)")
end
end

const error_dim_negative = ErrorException("Dimensions must be non-negative")

0 comments on commit 1413d1f

Please sign in to comment.