From d0ba956b5d0934478a86f757afa19b7da5e307d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 19 Sep 2024 09:22:32 +0200 Subject: [PATCH] Remove `assertions.jl` now moved to AA (thofma/Hecke.jl#1607) --- docs/Build.jl | 5 +- docs/src/manual/developer/macros.md | 62 --- src/AlgAss/StructureConstantAlgebra.jl | 4 +- src/AlgAssAbsOrd/Conjugacy.jl | 3 - src/AlgAssAbsOrd/LocallyFreeClassGroup.jl | 2 - src/AlgAssAbsOrd/Order.jl | 3 - src/AlgAssAbsOrd/PIP.jl | 3 - src/Assertions.jl | 564 ---------------------- src/EllCrv/NewtonLift.jl | 1 - src/FieldFactory/ab_exts.jl | 5 - src/GrpAb/stable_sub.jl | 3 - src/Hecke.jl | 189 +++++--- src/LinearAlgebra/LatEnum.jl | 3 - src/LocalField/Poly.jl | 2 - src/LocalField/qAdic.jl | 3 - src/Map/automorphisms.jl | 2 - src/Misc/serialize.jl | 1 - src/ModAlgAss/ModAlgAss.jl | 2 - src/NfMaxOrd.jl | 2 - src/NumField/NfAbs.jl | 5 - src/NumField/NfAbs/MPolyAbsFact.jl | 3 - src/NumField/NfAbs/MPolyGcd.jl | 2 - src/NumField/NfAbs/NormRelation.jl | 3 - src/NumField/NfAbs/Simplify.jl | 2 - src/NumField/NfRel/NfRel.jl | 2 - src/NumField/Subfields.jl | 2 - src/NumFieldOrd/NfOrd.jl | 3 - src/NumFieldOrd/NfOrd/Clgp.jl | 6 - src/NumFieldOrd/NfOrd/Clgp/Proof.jl | 2 - src/NumFieldOrd/NfOrd/Clgp/Saturate.jl | 2 - src/NumFieldOrd/NfOrd/Ideal/Ideal.jl | 2 - src/NumFieldOrd/NfOrd/LLL.jl | 3 - src/NumFieldOrd/NfOrd/LinearAlgebra.jl | 4 - src/NumFieldOrd/NfOrd/RayClassGrp.jl | 3 - src/NumFieldOrd/NfOrd/ResidueRing.jl | 8 - src/NumFieldOrd/NfOrd/Unit.jl | 3 - src/NumFieldOrd/NfRelOrd/NfRelOrd.jl | 2 - src/QuadForm/Lattices.jl | 10 - src/QuadForm/Quad/GenusRep.jl | 3 - src/QuadForm/Quad/ZGenusRep.jl | 3 - src/RCF/rcf.jl | 4 - src/Sparse/Module.jl | 5 - src/exports.jl | 6 - 43 files changed, 118 insertions(+), 829 deletions(-) delete mode 100644 docs/src/manual/developer/macros.md delete mode 100644 src/Assertions.jl diff --git a/docs/Build.jl b/docs/Build.jl index 5721d6800b..6038062de1 100644 --- a/docs/Build.jl +++ b/docs/Build.jl @@ -43,15 +43,14 @@ using Pkg, Nemo, Documenter, DocumenterVitepress, DocumenterCitations "pmat/introduction.md", "misc/conjugacy.md", ], - "Extra features" => ["features/macros.md", - "features/mset.md", + "Extra features" => ["features/mset.md", ], "Examples" => "examples.md", "References" => "references.md", "Developer" => [ "dev/test.md", ] ] - + # Overwrite printing to make the header not full of redundant nonsense # Turns # Hecke.Order - Method diff --git a/docs/src/manual/developer/macros.md b/docs/src/manual/developer/macros.md deleted file mode 100644 index 4d8f1ee1c5..0000000000 --- a/docs/src/manual/developer/macros.md +++ /dev/null @@ -1,62 +0,0 @@ -# Macros -```@meta -CurrentModule = Hecke -DocTestSetup = quote - using Hecke - end -``` - -We describe here various macros provided by Hecke. - -## Verbosity macros -There is a list of symbols called *verbosity scopes* which represent keywords used to -trigger some particular macros within the codes. Each of these verbosity scopes is -associated with a *verbosity level*, being set to $0$ by default. A verbosity macro -is joined to a verbosity scope `S` and a value `k` (set to $1$ by default) such that, -if the current verbosity level `l` of `S` is bigger than or equal to `k`, then the -macro triggers a given action. - -```@docs -add_verbosity_scope(s::Symbol) -set_verbosity_level(s::Symbol, l::Int) -get_verbosity_level(s::Symbol) -``` - -### Printings - -```@docs -@vprintln -@vprint -``` - -### Actions - -```@docs -@v_do -``` - -## Assertion macros -There is a list of symbols called *assertion scopes* which represent keywords used to -trigger some particular macros within the codes. Each of these assertion scopes is -associated with an *assertion level*, being set to $0$ by default. An assertion macro -is joined to an assertion scope `S` and a value `k` (set to $1$ by default) such that, -if the current assertion level `l` of `S` is bigger than or equal to `k`, then the -macro triggers an action on the given assertion - -```@docs -add_assertion_scope(s::Symbol) -set_assertion_level(s::Symbol, l::Int) -get_assertion_level(s::Symbol) -``` - -### Check - -```@docs -@hassert -``` - -## Miscellaneous - -```@docs -@req -``` diff --git a/src/AlgAss/StructureConstantAlgebra.jl b/src/AlgAss/StructureConstantAlgebra.jl index 73426215af..1fdeeb9782 100644 --- a/src/AlgAss/StructureConstantAlgebra.jl +++ b/src/AlgAss/StructureConstantAlgebra.jl @@ -1,5 +1,3 @@ -add_assertion_scope(:StructureConstantAlgebra) - ################################################################################ # # Derived types @@ -146,7 +144,7 @@ end @doc raw""" structure_constant_algebra(K::SimpleNumField) -> StructureConstantAlgebra, Map - + Given a number field $L/K$, return $L$ as a $K$-algebra $A$ together with a $K$-linear map $A \to L$. diff --git a/src/AlgAssAbsOrd/Conjugacy.jl b/src/AlgAssAbsOrd/Conjugacy.jl index a8dc375ff3..7dc136d2ff 100644 --- a/src/AlgAssAbsOrd/Conjugacy.jl +++ b/src/AlgAssAbsOrd/Conjugacy.jl @@ -1,6 +1,3 @@ -add_verbosity_scope(:Conjugacy) -add_assertion_scope(:Conjugacy) - include("Conjugacy/Husert.jl") include("Conjugacy/Lifting.jl") include("Conjugacy/Random.jl") diff --git a/src/AlgAssAbsOrd/LocallyFreeClassGroup.jl b/src/AlgAssAbsOrd/LocallyFreeClassGroup.jl index 801cefc92d..a1bafdf73d 100644 --- a/src/AlgAssAbsOrd/LocallyFreeClassGroup.jl +++ b/src/AlgAssAbsOrd/LocallyFreeClassGroup.jl @@ -4,8 +4,6 @@ # ################################################################################ -add_verbosity_scope(:LocallyFreeClassGroup) - # Bley, Boltje "Computation of Locally Free Class Groups" # If the left and right conductor of O in a maximal order coincide (which is the # case if O is the integral group ring of a group algebra), the computation can diff --git a/src/AlgAssAbsOrd/Order.jl b/src/AlgAssAbsOrd/Order.jl index d204c42794..3e7883de02 100644 --- a/src/AlgAssAbsOrd/Order.jl +++ b/src/AlgAssAbsOrd/Order.jl @@ -1,6 +1,3 @@ -add_assertion_scope(:AlgAssOrd) -add_verbosity_scope(:AlgAssOrd) - elem_type(::Type{AlgAssAbsOrd{S, T}}) where {S, T} = AlgAssAbsOrdElem{S, T} ideal_type(::AlgAssAbsOrd{S, T}) where {S, T} = AlgAssAbsOrdIdl{S, T} diff --git a/src/AlgAssAbsOrd/PIP.jl b/src/AlgAssAbsOrd/PIP.jl index 3647d46e72..92f2c766c0 100644 --- a/src/AlgAssAbsOrd/PIP.jl +++ b/src/AlgAssAbsOrd/PIP.jl @@ -1,6 +1,3 @@ -add_verbosity_scope(:PIP) -add_assertion_scope(:PIP) - ################################################################################ # # Is principal for maximal orders diff --git a/src/Assertions.jl b/src/Assertions.jl deleted file mode 100644 index 42e6c053dc..0000000000 --- a/src/Assertions.jl +++ /dev/null @@ -1,564 +0,0 @@ -################################################################################ -# -# Assertions.jl : Verbose printing and custom assertions -# -# This file is part of Hecke. -# -# Copyright (c) 2015: Claus Fieker, Tommy Hofmann -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# (C) 2015-2019 Claus Fieker, Tommy Hofmann -# -################################################################################ - -################################################################################ -# -# Verbose -# -################################################################################ - -global const VERBOSE_SCOPE = Symbol[] - -global const VERBOSE_LOOKUP = Dict{Symbol, Int}() - -global const VERBOSE_PRINT_INDENT = Int[ 0 ] - -@doc raw""" - add_verbosity_scope(s::Symbol) -> Nothing - -Add the symbol `s` to the list of (global) verbosity scopes. - -# Examples - -```jldoctest -julia> add_verbosity_scope(:MyScope) - -``` -""" -function add_verbosity_scope(s::Symbol) - !(s in VERBOSE_SCOPE) && push!(VERBOSE_SCOPE, s) - nothing -end - -function pushindent() - a = VERBOSE_PRINT_INDENT[1] - VERBOSE_PRINT_INDENT[1] = a + 1 - nothing -end - -function clearindent() - VERBOSE_PRINT_INDENT[1] = 0 - nothing -end - -function popindent() - a = VERBOSE_PRINT_INDENT[1] - VERBOSE_PRINT_INDENT[1] = a - 1 - @assert VERBOSE_PRINT_INDENT[1] >= 0 - nothing -end - -function _global_indent() - s = " "^VERBOSE_PRINT_INDENT[1] - return s -end - -@doc raw""" - @vprintln(S::Symbol, k::Int, msg::String) - @vprintln S k msg - - @vprintln(S::Symbol, msg::String) - @vprintln S msg - -This macro can be used to control printings inside the code. - -The macro `@vprintln` takes two or three arguments: a symbol `S` specifying a -*verbosity scope*, an optional integer `k` and a string `msg`. If `k` is not -specified, it is set by default to $1$. - -To each verbosity scope `S` is associated a *verbosity level* `l` which is cached. -If the verbosity level $l$ of `S` is bigger than or equal to $k$, the macro `@vprintln` -triggers the printing of the associated string `msg` followed by a newline. - -One can add a new verbosity scope by calling the function [`add_verbosity_scope`](@ref). - -When starting a new instance, all the verbosity levels are set to $0$. One can adjust the -verbosity level of a verbosity scope by calling the function [`set_verbosity_level`](@ref). - -One can access the current verbosity level of a verbosity scope by calling the -function [`get_verbosity_level`](@ref). - -# Examples - -We will set up different verbosity scopes with different verbosity levels in a -custom function to show how to use this macro. - -```jldoctest -julia> add_verbosity_scope(:Test1); - -julia> add_verbosity_scope(:Test2); - -julia> add_verbosity_scope(:Test3); - -julia> set_verbosity_level(:Test1, 1); - -julia> set_verbosity_level(:Test2, 3); - -julia> function vprint_example() - @vprintln :Test1 "Triggered" - @vprintln :Test2 2 "Triggered" - @vprintln :Test3 "Not triggered" - @vprintln :Test2 4 "Not triggered" - end -vprint_example (generic function with 1 method) - -julia> vprint_example() -Triggered -Triggered -``` - -If one does not setup in advance a verbosity scope, the macro will raise an -`ExceptionError` showing the error message "Not a valid symbol". -""" -macro vprintln(s, msg) - quote - if get_verbosity_level($s) >= 1 - print(_global_indent()) - println($(esc(msg))) - flush(stdout) - end - end -end - -macro vprintln(s, l::Int, msg) - quote - if get_verbosity_level($s) >= $l - print(_global_indent()) - println($(esc(msg))) - flush(stdout) - end - end -end - -@doc raw""" - @vprint(S::Symbol, k::Int, msg::String) - @vprint S k msg - - @vprint(S::Symbol, msg::String) - @vprint S msg - -The same as [`@vprintln`](@ref), but without the final newline. -""" -macro vprint(s, msg) - quote - if get_verbosity_level($s) >= 1 - print(_global_indent()) - print($(esc(msg))) - flush(stdout) - end - end -end - -macro vprint(s, l::Int, msg) - quote - if get_verbosity_level($s) >= $l - print(_global_indent()) - print($(esc(msg))) - flush(stdout) - end - end -end - -@doc raw""" - @v_do(S::Symbol, k::Int, act::Expr) - @v_do S k act - - @v_do(S::Symbol, act::Expr) - @v_do S act - -This macro can be used to control actions inside the code. - -The macro `@v_do` takes two or three arguments: a symbol `S` specifying a -*verbosity scope*, an optional integer `k` and an action `act`. If `k` is not -specified, it is set by default to $1$. - -To each verbosity scope `S` is associated a *verbosity level* `l`. -If the verbosity level $l$ of `S` is bigger than or equal to $k$, the macro `@v_do` triggers -the action `act`. - -One can add a new verbosity scope by calling the function [`add_verbosity_scope`](@ref). - -When starting a new instance, all the verbosity levels are set to $0$. One can adjust the -verbosity level of a verbosity scope by calling the function [`set_verbosity_level`](@ref). - -One can access the current verbosity level of a verbosity scope by calling the -function [`get_verbosity_level`](@ref). - -# Examples - -We will set up different verbosity scopes with different verbosity levels in a -custom function to show how to use this macro. - -```jldoctest -julia> add_verbosity_scope(:Test1); - -julia> add_verbosity_scope(:Test2); - -julia> add_verbosity_scope(:Test3); - -julia> set_verbosity_level(:Test1, 1); - -julia> set_verbosity_level(:Test2, 3); - -julia> function v_do_example(a::Int, b::Int, c::Int, d::Int) - @v_do :Test1 a = 2*a - @v_do :Test2 2 b = 3*b - @v_do :Test3 c = 4*c - @v_do :Test2 4 d = 5*d - return (a, b, c, d) - end -v_do_example (generic function with 1 method) - -julia> v_do_example(1,1,1,1) -(2, 3, 1, 1) -``` - -If one does not setup in advance a verbosity scope, the macro will raise an -`ExceptionError` showing the error message "Not a valid symbol". -""" -macro v_do(s, action) - quote - if get_verbosity_level($s) >= 1 - $(esc(action)) - end - end -end - -macro v_do(s, l::Int, action) - quote - if get_verbosity_level($s) >= $l - $(esc(action)) - end - end -end - -@doc raw""" - set_verbosity_level(s::Symbol, l::Int) -> Int - -If `s` represents a known verbosity scope, set the current verbosity level of -`s` to `l`. - -One can access the current verbosity level of `s` by calling the function -[`get_verbosity_level`](@ref). - -If `s` is not yet known as a verbosity scope, the function raises an `ErrorException` -showing the error message "Not a valid symbol". One can add `s` to the list of -verbosity scopes by calling the function [`add_verbosity_scope`](@ref). - -# Examples - -```jldoctest -julia> add_verbosity_scope(:MyScope) - -julia> set_verbosity_level(:MyScope, 4) -4 - -julia> set_verbosity_level(:MyScope, 0) -0 -``` -""" -function set_verbosity_level(s::Symbol, l::Int) - !(s in VERBOSE_SCOPE) && error("Not a valid symbol") - VERBOSE_LOOKUP[s] = l -end - -@doc raw""" - get_verbosity_level(s::Symbol) -> Int - -If `s` represents a known verbosity scope, return the current verbosity level -of `s`. - -One can modify the current verbosity level of `s` by calling the function -[`set_verbosity_level`](@ref). - -If `s` is not yet known as a verbosity scope, the function raises an `ErrorException` -showing the error message "Not a valid symbol". One can add `s` to the list of -verbosity scopes by calling the function [`add_verbosity_scope`](@ref). - -# Examples - -```jldoctest -julia> add_verbosity_scope(:MyScope) - -julia> get_verbosity_level(:MyScope) -0 - -julia> set_verbosity_level(:MyScope, 4) -4 - -julia> get_verbosity_level(:MyScope) -4 - -julia> set_verbosity_level(:MyScope, 0) -0 - -julia> get_verbosity_level(:MyScope) -0 -``` -""" -function get_verbosity_level(s::Symbol) - !(s in VERBOSE_SCOPE) && error("Not a valid symbol") - return get(VERBOSE_LOOKUP, s, 0)::Int -end - -################################################################################ -# -# Assertions -# -################################################################################ - -global const ASSERT_SCOPE = Symbol[] - -global const ASSERT_LOOKUP = Dict{Symbol, Int}() - -@doc raw""" - add_assertion_scope(s::Symbol) -> Nothing - -Add the symbol `s` to the list of (global) assertion scopes. - -# Examples - -```jldoctest -julia> add_assertion_scope(:MyScope) - -``` -""" -function add_assertion_scope(s::Symbol) - !(s in ASSERT_SCOPE) && push!(ASSERT_SCOPE, s) - nothing -end - -@doc raw""" - set_assertion_level(s::Symbol, l::Int) -> Int - -If `s` represents a known assertion scope, set the current assertion level -of `s` to `l`. - -One can access the current assertion level of `s` by calling the function -[`get_assertion_level`](@ref). - -If `s` is not yet known as an assertion scope, the function raises an `ErrorException` -showing the error message "Not a valid symbol". One can add `s` to the list of -assertion scopes by calling the function [`add_assertion_scope`](@ref). - -# Examples - -```jldoctest -julia> add_assertion_scope(:MyScope) - -julia> set_assertion_level(:MyScope, 4) -4 - -julia> set_assertion_level(:MyScope, 0) -0 -``` -""" -function set_assertion_level(s::Symbol, l::Int) - !(s in ASSERT_SCOPE) && error("Not a valid symbol") - if l >= 9000 - @info "Assertion level over 9000! This might be slow" - end - ASSERT_LOOKUP[s] = l -end - -@doc raw""" - get_assertion_level(s::Symbol) -> Int - -If `s` represents a symbol of a known assertion scope, return the current -assertion level of `s`. - -One can modify the current assertion level of `s` by calling the function -[`set_assertion_level`](@ref). - -If `s` is not yet known as an assertion scope, the function raises an `ErrorException` -showing the error message "Not a valid symbol". One can add `s` to the list of -assertion scopes by calling the function [`add_assertion_scope`](@ref). - -# Examples - -```jldoctest -julia> add_assertion_scope(:MyScope) - -julia> get_assertion_level(:MyScope) -0 - -julia> set_assertion_level(:MyScope, 1) -1 - -julia> get_assertion_level(:MyScope) -1 - -julia> set_assertion_level(:MyScope, 0) -0 - -julia> get_assertion_level(:MyScope) -0 -``` -""" -function get_assertion_level(s::Symbol) - !(s in ASSERT_SCOPE) && error("Not a valid symbol") - return get(ASSERT_LOOKUP, s, 0)::Int -end - -@doc raw""" - @hassert(S::Symbol, k::Int, assert::Expr) - @hassert S k assert - - @hassert(S::Symbol, assert::Expr) - @hassert S assert - -This macro can be used to control assertion checks inside the code. - -The macro `@hassert` takes two or three arguments: a symbol `S` specifying an -*assertion scope*, an optional integer `k` and an assertion `assert`. If `k` -is not specified, it is set by default to $1$. - -To each assertion scope `S` is associated an *assertion level* `l` which is cached. -If the assertion level $l$ of `S` is bigger than or equal to $k$, the macro `@hassert` -triggers the check of the assertion `assert`. If `assert` is wrong, an `AssertionError` -is thrown. - -One can add a new assertion scope by calling the function [`add_assertion_scope`](@ref). - -When starting a new instance, all the assertion levels are set to $0$. One can adjust the -assertion level of an assertion scope by calling the function [`set_assertion_level`](@ref). - -One can access the current assertion level of an assertion scope by calling the -function [`get_assertion_level`](@ref). - -# Examples - -We will set up different assertion scopes with different assertion levels in a -custom function to show how to use this macro. - -```jldoctest -julia> add_assertion_scope(:MyScope) - -julia> get_assertion_level(:MyScope) -0 - -julia> function hassert_test(x::Int) - @hassert :MyScope 700 mod(x, 3) == 0 - return div(x, 3) - end -hassert_test (generic function with 1 method) - -julia> hassert_test(2) -0 - -julia> set_assertion_level(:MyScope, 701); - -julia> try hassert_test(2) - catch e e - end -AssertionError("\$(Expr(:escape, :(mod(x, 3) == 0)))") - -julia> hassert_test(3) -1 - -julia> set_assertion_level(:MyScope, 0) -0 -``` - -If one does not setup in advance an assertion scope, the macro will raise an -`ExceptionError` showing the error message "Not a valid symbol". -""" -macro hassert(s, cond) - quote - if get_assertion_level($s) >= 1 - @assert $(esc(cond)) - end - end -end - -macro hassert(s, l::Int, cond) - quote - if get_assertion_level($s) >= $l - @assert $(esc(cond)) - end - end -end - -function assertions(flag::Bool) - for s in Hecke.ASSERT_SCOPE - flag ? set_assertion_level(s, 8999) : set_assertion_level(s, 0) - end -end - -################################################################################ -# -# Require -# -################################################################################ - -@doc raw""" - @req(assert, msg) - @req assert msg - -Check whether the assertion `assert` is true. If not, throw an `ArgumentError` -with error message `msg`. - -The macro `@req` takes two arguments: the first one is an assertion `assert` -(an expression which returns a boolean) and a string `msg` corresponding to the desired -error message to be returned whenever `assert` is false. - -If the number of arguments is not 2, an `AssertionError` is raised. - -# Examples - -```jldoctest -julia> function req_test(x::Int) - @req iseven(x) "x must be even" - return div(x,2) - end -req_test (generic function with 1 method) - -julia> try req_test(3) - catch e e - end -ArgumentError("x must be even") - -julia> try req_test(2) - catch e e - end -1 - -``` -""" -macro req(cond, msg) - quote - if !($(esc(cond))) - throw(ArgumentError($(esc(msg)))) - end - end -end diff --git a/src/EllCrv/NewtonLift.jl b/src/EllCrv/NewtonLift.jl index 9f5377bc8f..1f4cfc44dc 100644 --- a/src/EllCrv/NewtonLift.jl +++ b/src/EllCrv/NewtonLift.jl @@ -1,6 +1,5 @@ #import Hecke.AbstractAlgebra export newton_lift -add_verbosity_scope(:NewtonIteration) _valuation(x::RingElem) = iszero(x) ? QQ(precision(parent(x))) : valuation(x) diff --git a/src/FieldFactory/ab_exts.jl b/src/FieldFactory/ab_exts.jl index 05b68aed0e..c9331a3944 100644 --- a/src/FieldFactory/ab_exts.jl +++ b/src/FieldFactory/ab_exts.jl @@ -1,8 +1,3 @@ -add_verbosity_scope(:AbExt) -add_assertion_scope(:AbExt) - -add_verbosity_scope(:MaxAbExt) - ############################################################################### # # Abelian extensions diff --git a/src/GrpAb/stable_sub.jl b/src/GrpAb/stable_sub.jl index 4872c805e6..42f63ab63e 100644 --- a/src/GrpAb/stable_sub.jl +++ b/src/GrpAb/stable_sub.jl @@ -1,6 +1,3 @@ -add_verbosity_scope(:StabSub) -add_assertion_scope(:StabSub) - ############################################################################### # # Tools for ZpnGModules diff --git a/src/Hecke.jl b/src/Hecke.jl index 644089a123..a4da653ada 100644 --- a/src/Hecke.jl +++ b/src/Hecke.jl @@ -77,6 +77,18 @@ import AbstractAlgebra: get_cached!, @alias import AbstractAlgebra: pretty, Lowercase, LowercaseOff, Indent, Dedent, terse, is_terse +import AbstractAlgebra: + add_assertion_scope, + add_verbosity_scope, + assertions, + clearindent, + get_assertion_level, + get_verbosity_level, + popindent, + pushindent, + set_assertion_level, + set_verbosity_level + import AbstractAlgebra: Solve, coprime_base_steel import LinearAlgebra: dot, nullspace, rank, ishermitian @@ -171,6 +183,109 @@ function __init__() _RealRings[i] = _RealRing() end + add_verbosity_scope(:AbExt) + add_assertion_scope(:AbExt) + + add_verbosity_scope(:AbsFact) + add_assertion_scope(:AbsFact) + + add_verbosity_scope(:AbsNumFieldOrder) + add_assertion_scope(:AbsNumFieldOrder) + + add_assertion_scope(:AbsOrdQuoRing) + + add_verbosity_scope(:AlgAssOrd) + add_assertion_scope(:AlgAssOrd) + + add_verbosity_scope(:Automorphisms) + + add_verbosity_scope(:ClassField) + add_assertion_scope(:ClassField) + + add_verbosity_scope(:ClassGroup) + add_assertion_scope(:ClassGroup) + add_verbosity_scope(:ClassGroup_time) + add_verbosity_scope(:ClassGroup_gc) + add_verbosity_scope(:ClassGroupProof) + + add_verbosity_scope(:CompactPresentation) + add_assertion_scope(:CompactPresentation) + + add_verbosity_scope(:Conjugacy) + add_assertion_scope(:Conjugacy) + + add_verbosity_scope(:GenRep) + add_assertion_scope(:GenRep) + + add_verbosity_scope(:HNF) + add_assertion_scope(:HNF) + + add_verbosity_scope(:LatEnum) + add_assertion_scope(:LatEnum) + + add_verbosity_scope(:Lattice) + add_assertion_scope(:Lattice) + + add_verbosity_scope(:LLL) + add_assertion_scope(:LLL) + + add_verbosity_scope(:LocallyFreeClassGroup) + + add_verbosity_scope(:MaxAbExt) + + add_assertion_scope(:ModLattice) + + add_verbosity_scope(:MPolyGcd) + + add_verbosity_scope(:NewtonIteration) + + add_verbosity_scope(:NormRelation) + add_assertion_scope(:NormRelation) + + add_assertion_scope(:padic_poly) + + add_verbosity_scope(:Par) + + add_assertion_scope(:PID_Test) + + add_verbosity_scope(:PIP) + add_assertion_scope(:PIP) + + add_verbosity_scope(:PolyFactor) + add_assertion_scope(:PolyFactor) + + add_verbosity_scope(:PseudoHnf) + add_assertion_scope(:PseudoHnf) + add_verbosity_scope(:PseudoHnfKB) + + add_verbosity_scope(:qAdic) + add_assertion_scope(:qAdic) + + add_verbosity_scope(:RayFacElem) + add_assertion_scope(:RayFacElem) + + add_verbosity_scope(:RelNumFieldOrder) + + add_assertion_scope(:RelSimpleNumField) + + add_assertion_scope(:Rres) + + add_verbosity_scope(:Saturate) + + add_verbosity_scope(:Simplify) + + add_verbosity_scope(:Subfields) + + add_verbosity_scope(:StabSub) + add_assertion_scope(:StabSub) + + add_assertion_scope(:StructureConstantAlgebra) + + add_verbosity_scope(:UnitGroup) + add_assertion_scope(:UnitGroup) + + add_verbosity_scope(:ZGenRep) + add_assertion_scope(:ZGenRep) end module Globals @@ -201,14 +316,6 @@ include("Aliases.jl") AbstractAlgebra.factor(x::RingElement) = factor(x) -################################################################################ -# -# Verbose printing and custom assertions -# -################################################################################ - -include("Assertions.jl") - ################################################################################ # # Setter and getter for objects @@ -437,71 +544,6 @@ function test_module(x, new::Bool = true; long::Bool = false, with_gap::Bool = f end end -################################################################################ -# -# Verbose time printing -# -################################################################################ - -macro vtime(args...) - if length(args) == 2 - msg = string(args[2]) - quote - if get_verbosity_level($(args[1])) >= 1 - local t0 = time_ns() - local val = $(esc(args[2])) - println((time_ns()-t0)/1e9, " @ ", $msg) - val - else - local val2 = $(esc(args[2])) - val2 - end - end - elseif length(args) == 3 - msg = string(args[3]) - quote - if get_verbosity_level($(args[1])) >= $(args[2]) - local t0 = time_ns() - local val = $(esc(args[3])) - println((time_ns()-t0)/1e9, " @ ", $msg) - val - else - local val2 = $(esc(args[3])) - val2 - end - end - end -end - -#usage -# @vtime_add_ellapsed :ClassGroup 2 clg :saturate s= hnf(a) -# @vtime_add :ClassGroup 2 clg :saturate 0.5 -# -> clg.time[:saturate] += -function _vtime_add(D::Dict, k::Any, v::Any) - if haskey(D, k) - D[k] += v - else - D[k] = v - end -end - -macro vtime_add(flag, level, var, key, value) - quote - if get_verbosity_level($flag) >= $level - _vtime_add($(esc(var)).time, $key, $(esc(value))) - end - end -end - -macro vtime_add_elapsed(flag, level, var, key, stmt) - quote - tm = @elapsed $(esc(stmt)) - if get_verbosity_level($flag) >= $level - _vtime_add($(esc(var)).time, $key, tm) - end - end -end - ################################################################################ # # Exception types @@ -529,7 +571,6 @@ Base.showerror(io::IO, ::NotImplemented) = function checkbounds(a::Int, b::Int) nothing; end; ################################################################################ -add_assertion_scope(:PID_Test) ################################################################################ # diff --git a/src/LinearAlgebra/LatEnum.jl b/src/LinearAlgebra/LatEnum.jl index 27b97b8199..1afa615224 100644 --- a/src/LinearAlgebra/LatEnum.jl +++ b/src/LinearAlgebra/LatEnum.jl @@ -45,9 +45,6 @@ # L, U for the other bound as well and using this for exclusion. # (see other comment below) -add_assertion_scope(:LatEnum) -add_verbosity_scope(:LatEnum) - function show(io::IO, E::enum_ctx) println(io, "EnumCtx") if isdefined(E, :c) diff --git a/src/LocalField/Poly.jl b/src/LocalField/Poly.jl index 377ba97574..7c6ec1a026 100644 --- a/src/LocalField/Poly.jl +++ b/src/LocalField/Poly.jl @@ -1,5 +1,3 @@ -add_assertion_scope(:padic_poly) - ################################################################################ # # setprecision diff --git a/src/LocalField/qAdic.jl b/src/LocalField/qAdic.jl index 479a47099f..44ac9cfacc 100644 --- a/src/LocalField/qAdic.jl +++ b/src/LocalField/qAdic.jl @@ -1,6 +1,3 @@ -add_verbosity_scope(:qAdic) -add_assertion_scope(:qAdic) - @attributes QadicField function residue_field(Q::QadicField) diff --git a/src/Map/automorphisms.jl b/src/Map/automorphisms.jl index 7005eeb464..d4631227ae 100644 --- a/src/Map/automorphisms.jl +++ b/src/Map/automorphisms.jl @@ -1,5 +1,3 @@ -add_verbosity_scope(:Automorphisms) - ################################################################################ # # Automorphisms diff --git a/src/Misc/serialize.jl b/src/Misc/serialize.jl index e9efe39762..e260e2ef47 100644 --- a/src/Misc/serialize.jl +++ b/src/Misc/serialize.jl @@ -60,7 +60,6 @@ # return NumFieldHom{AbsSimpleNumField, AbsSimpleNumField}(K, L, a) #end # -add_verbosity_scope(:Par) function _bizarre(a::Int, b::Int) return length(Hecke.class_group(Hecke.wildanger_field(a, b)[1])[1]) diff --git a/src/ModAlgAss/ModAlgAss.jl b/src/ModAlgAss/ModAlgAss.jl index 6133dbc5d0..b9d4241662 100644 --- a/src/ModAlgAss/ModAlgAss.jl +++ b/src/ModAlgAss/ModAlgAss.jl @@ -1,5 +1,3 @@ -add_assertion_scope(:ModLattice) - @attributes mutable struct ModAlgAss{S, T, U} base_ring::S dim::Int diff --git a/src/NfMaxOrd.jl b/src/NfMaxOrd.jl index 107c5d833a..e49555af0c 100644 --- a/src/NfMaxOrd.jl +++ b/src/NfMaxOrd.jl @@ -1,5 +1,3 @@ -add_verbosity_scope(:AbsNumFieldOrder) -add_assertion_scope(:AbsNumFieldOrder) #set_verbosity_level(:NfOrd, 1) include("NfOrd/NfMaxOrd.jl") diff --git a/src/NumField/NfAbs.jl b/src/NumField/NfAbs.jl index 3cb8a09f1e..4aa2f43f60 100644 --- a/src/NumField/NfAbs.jl +++ b/src/NumField/NfAbs.jl @@ -1,10 +1,5 @@ import Nemo.sub!, Base.gcd -add_verbosity_scope(:PolyFactor) -add_assertion_scope(:PolyFactor) -add_verbosity_scope(:CompactPresentation) -add_assertion_scope(:CompactPresentation) - if Int == Int32 global const p_start = next_prime(2^30) else diff --git a/src/NumField/NfAbs/MPolyAbsFact.jl b/src/NumField/NfAbs/MPolyAbsFact.jl index 72c5c3b85e..51a5339d75 100644 --- a/src/NumField/NfAbs/MPolyAbsFact.jl +++ b/src/NumField/NfAbs/MPolyAbsFact.jl @@ -8,9 +8,6 @@ import Nemo: shift_left, shift_right import Base: * export factor_absolute -add_verbosity_scope(:AbsFact) -add_assertion_scope(:AbsFact) - function Hecke.norm(f::MPolyRingElem{AbsSimpleNumFieldElem}) Kx = parent(f) K = base_ring(Kx) diff --git a/src/NumField/NfAbs/MPolyGcd.jl b/src/NumField/NfAbs/MPolyGcd.jl index e36f14cd6c..fc7a7119d2 100644 --- a/src/NumField/NfAbs/MPolyGcd.jl +++ b/src/NumField/NfAbs/MPolyGcd.jl @@ -1,5 +1,3 @@ -add_verbosity_scope(:MPolyGcd) - function gcd(f::Hecke.Generic.MPoly{<:NumFieldElem}, g::Hecke.Generic.MPoly{<:NumFieldElem}) R = parent(f) K = coefficient_ring(f) diff --git a/src/NumField/NfAbs/NormRelation.jl b/src/NumField/NfAbs/NormRelation.jl index 0f8873eca0..ca5c916f6b 100644 --- a/src/NumField/NfAbs/NormRelation.jl +++ b/src/NumField/NfAbs/NormRelation.jl @@ -4,9 +4,6 @@ using Hecke import Hecke: one, can_solve_with_solution_and_kernel, kernel, lcm!, simplify, NfFactorBase, morphism_type, nf -add_verbosity_scope(:NormRelation) -add_assertion_scope(:NormRelation) - include("NormRelation/Setup.jl") include("NormRelation/SUnits.jl") include("NormRelation/Clgp.jl") diff --git a/src/NumField/NfAbs/Simplify.jl b/src/NumField/NfAbs/Simplify.jl index 60cd1bd64c..9e1783f969 100644 --- a/src/NumField/NfAbs/Simplify.jl +++ b/src/NumField/NfAbs/Simplify.jl @@ -1,5 +1,3 @@ -add_verbosity_scope(:Simplify) - @doc raw""" simplify(K::AbsSimpleNumField; canonical::Bool = false) -> AbsSimpleNumField, NumFieldHom{AbsSimpleNumField, AbsSimpleNumField} diff --git a/src/NumField/NfRel/NfRel.jl b/src/NumField/NfRel/NfRel.jl index 44e77b59c7..c1b469a216 100644 --- a/src/NumField/NfRel/NfRel.jl +++ b/src/NumField/NfRel/NfRel.jl @@ -32,8 +32,6 @@ # ################################################################################ -add_assertion_scope(:RelSimpleNumField) - ################################################################################ # # Copy diff --git a/src/NumField/Subfields.jl b/src/NumField/Subfields.jl index 9f482b9d1e..45806c4ccc 100644 --- a/src/NumField/Subfields.jl +++ b/src/NumField/Subfields.jl @@ -1,5 +1,3 @@ -add_verbosity_scope(:Subfields) - # Compute basis for the subfield of K that is generated by the elements of as. function _subfield_basis(K::S, as::Vector{T}) where { S <: Union{AbsSimpleNumField, Hecke.RelSimpleNumField}, diff --git a/src/NumFieldOrd/NfOrd.jl b/src/NumFieldOrd/NfOrd.jl index 8239c15760..596e62b165 100644 --- a/src/NumFieldOrd/NfOrd.jl +++ b/src/NumFieldOrd/NfOrd.jl @@ -27,9 +27,6 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -add_verbosity_scope(:AbsNumFieldOrder) -add_assertion_scope(:AbsNumFieldOrder) - include("NfOrd/Clgp/Types.jl") include("NfOrd/NfOrd.jl") include("NfOrd/LLL.jl") diff --git a/src/NumFieldOrd/NfOrd/Clgp.jl b/src/NumFieldOrd/NfOrd/Clgp.jl index 2168e883f5..3f442e84d5 100644 --- a/src/NumFieldOrd/NfOrd/Clgp.jl +++ b/src/NumFieldOrd/NfOrd/Clgp.jl @@ -64,12 +64,6 @@ # ################################################################################ -add_verbosity_scope(:ClassGroup) -add_verbosity_scope(:ClassGroup_time) -add_verbosity_scope(:ClassGroup_gc) - -add_assertion_scope(:ClassGroup) - include("Clgp/Ctx.jl") include("Clgp/FacBase_Euc.jl") include("Clgp/FacBase_Idl.jl") diff --git a/src/NumFieldOrd/NfOrd/Clgp/Proof.jl b/src/NumFieldOrd/NfOrd/Clgp/Proof.jl index a9478c4458..9d2568db4d 100644 --- a/src/NumFieldOrd/NfOrd/Clgp/Proof.jl +++ b/src/NumFieldOrd/NfOrd/Clgp/Proof.jl @@ -1,8 +1,6 @@ # Import the progress bar and Dates for the conversion of seconds import Dates -add_verbosity_scope(:ClassGroupProof) - # This is a modified showprogress from Pkg.GitTools PROGRESS_BAR_PERCENTAGE_GRANULARITY = Ref(0.1) diff --git a/src/NumFieldOrd/NfOrd/Clgp/Saturate.jl b/src/NumFieldOrd/NfOrd/Clgp/Saturate.jl index d8619994e4..e4b9c33ead 100644 --- a/src/NumFieldOrd/NfOrd/Clgp/Saturate.jl +++ b/src/NumFieldOrd/NfOrd/Clgp/Saturate.jl @@ -1,8 +1,6 @@ module RelSaturate using Hecke -add_verbosity_scope(:Saturate) - export saturate! function mod_p(R::Vector{FacElem{AbsSimpleNumFieldElem, AbsSimpleNumField}}, Q::AbsNumFieldOrderIdeal{AbsSimpleNumField, AbsSimpleNumFieldElem}, p::Int, T::Hecke.fpField, D::Vector, cached::Bool) diff --git a/src/NumFieldOrd/NfOrd/Ideal/Ideal.jl b/src/NumFieldOrd/NfOrd/Ideal/Ideal.jl index 85ba49e9e5..3ada9ff390 100644 --- a/src/NumFieldOrd/NfOrd/Ideal/Ideal.jl +++ b/src/NumFieldOrd/NfOrd/Ideal/Ideal.jl @@ -32,8 +32,6 @@ # ################################################################################ -add_assertion_scope(:Rres) - ################################################################################ # # Deepcopy diff --git a/src/NumFieldOrd/NfOrd/LLL.jl b/src/NumFieldOrd/NfOrd/LLL.jl index 2d107e6468..285d088ea1 100644 --- a/src/NumFieldOrd/NfOrd/LLL.jl +++ b/src/NumFieldOrd/NfOrd/LLL.jl @@ -1,6 +1,3 @@ -add_verbosity_scope(:LLL) -add_assertion_scope(:LLL) - ################################################################################ # # Special functions for real fields and quadratic fields diff --git a/src/NumFieldOrd/NfOrd/LinearAlgebra.jl b/src/NumFieldOrd/NfOrd/LinearAlgebra.jl index b8d04df08d..1e00f61cb8 100644 --- a/src/NumFieldOrd/NfOrd/LinearAlgebra.jl +++ b/src/NumFieldOrd/NfOrd/LinearAlgebra.jl @@ -1,9 +1,5 @@ import Base.vcat, Base.hcat -add_verbosity_scope(:PseudoHnf) -add_assertion_scope(:PseudoHnf) -add_verbosity_scope(:PseudoHnfKB) - function _det_bound(M::Generic.Mat{AbsSimpleNumFieldOrderElem}) n = nrows(M) O = base_ring(M) diff --git a/src/NumFieldOrd/NfOrd/RayClassGrp.jl b/src/NumFieldOrd/NfOrd/RayClassGrp.jl index 5e903354b3..f1636df559 100644 --- a/src/NumFieldOrd/NfOrd/RayClassGrp.jl +++ b/src/NumFieldOrd/NfOrd/RayClassGrp.jl @@ -1,6 +1,3 @@ -add_verbosity_scope(:RayFacElem) -add_assertion_scope(:RayFacElem) - ############################################################################### # # Map Type diff --git a/src/NumFieldOrd/NfOrd/ResidueRing.jl b/src/NumFieldOrd/NfOrd/ResidueRing.jl index 2006cd71e4..fa90a34f9b 100644 --- a/src/NumFieldOrd/NfOrd/ResidueRing.jl +++ b/src/NumFieldOrd/NfOrd/ResidueRing.jl @@ -32,14 +32,6 @@ # ################################################################################ -################################################################################ -# -# Assertion -# -################################################################################ - -add_assertion_scope(:AbsOrdQuoRing) - ################################################################################ # # Field access diff --git a/src/NumFieldOrd/NfOrd/Unit.jl b/src/NumFieldOrd/NfOrd/Unit.jl index adbd107c66..31ddd0e22f 100644 --- a/src/NumFieldOrd/NfOrd/Unit.jl +++ b/src/NumFieldOrd/NfOrd/Unit.jl @@ -32,9 +32,6 @@ # ################################################################################ -add_verbosity_scope(:UnitGroup) -add_assertion_scope(:UnitGroup) - include("Unit/FindUnits.jl") include("Unit/Helper.jl") include("Unit/Independent.jl") diff --git a/src/NumFieldOrd/NfRelOrd/NfRelOrd.jl b/src/NumFieldOrd/NfRelOrd/NfRelOrd.jl index 817627afe0..c5cefe6705 100644 --- a/src/NumFieldOrd/NfRelOrd/NfRelOrd.jl +++ b/src/NumFieldOrd/NfRelOrd/NfRelOrd.jl @@ -1,5 +1,3 @@ -add_verbosity_scope(:RelNumFieldOrder) - ################################################################################ # # Is maximal order known diff --git a/src/QuadForm/Lattices.jl b/src/QuadForm/Lattices.jl index 57273d93e6..253e26ff4e 100644 --- a/src/QuadForm/Lattices.jl +++ b/src/QuadForm/Lattices.jl @@ -1,13 +1,3 @@ -################################################################################ -# -# Verbosity and assertion scopes -# -################################################################################ - -add_verbosity_scope(:Lattice) - -add_assertion_scope(:Lattice) - ################################################################################ # # Ambient space diff --git a/src/QuadForm/Quad/GenusRep.jl b/src/QuadForm/Quad/GenusRep.jl index 19b2a113bf..9be54667f1 100644 --- a/src/QuadForm/Quad/GenusRep.jl +++ b/src/QuadForm/Quad/GenusRep.jl @@ -3,9 +3,6 @@ # With permission ported from Magma package of Markus Kirschmer: # http://www.math.rwth-aachen.de/~Markus.Kirschmer/magma/lat.html -add_verbosity_scope(:GenRep) -add_assertion_scope(:GenRep) - ################################################################################ # # SpinorGeneraCtx diff --git a/src/QuadForm/Quad/ZGenusRep.jl b/src/QuadForm/Quad/ZGenusRep.jl index 0c90ff95cc..41b20323cf 100644 --- a/src/QuadForm/Quad/ZGenusRep.jl +++ b/src/QuadForm/Quad/ZGenusRep.jl @@ -27,9 +27,6 @@ # ############################################################################### -add_verbosity_scope(:ZGenRep) -add_assertion_scope(:ZGenRep) - ############################################################################### # # Neighbours diff --git a/src/RCF/rcf.jl b/src/RCF/rcf.jl index b3d46d7f19..03d37ccac6 100644 --- a/src/RCF/rcf.jl +++ b/src/RCF/rcf.jl @@ -1,7 +1,3 @@ -add_verbosity_scope(:ClassField) -add_assertion_scope(:ClassField) - - ############################################################################### # # Number_field interface and reduction to prime power case diff --git a/src/Sparse/Module.jl b/src/Sparse/Module.jl index a31f3c466e..dea719186a 100644 --- a/src/Sparse/Module.jl +++ b/src/Sparse/Module.jl @@ -4,11 +4,6 @@ # Hecke.lift, Hecke.rational_reconstruction, Hecke.elementary_divisors, # Hecke.rank, Hecke.det -add_verbosity_scope(:HNF) - -add_assertion_scope(:HNF) - - function show(io::IO, M::ModuleCtxNmod) print(io, "Sparse module over $(M.R) of (current) rank $(nrows(M.basis)) and $(nrows(M.gens))") end diff --git a/src/exports.jl b/src/exports.jl index 663026678f..9b77d91215 100644 --- a/src/exports.jl +++ b/src/exports.jl @@ -6,12 +6,6 @@ export == export ^ export ⊕ export ⊗ -export @hassert -export @req -export @v_do -export @vprint -export @vprintln -export @vtime export AbstractLat export AbstractSpace export AbstractSpaceMor