-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing hash
methods
#2222
Comments
I wrote some small script (NEEDS julia 1.11.1!!!!) to get all cases, including the package that defines the type, and the file and line number the list = map(
filter(names(Oscar; all=true)) do name
isdefined(Oscar, name) || return false # remove all wrong exports (see #1964)
T = getfield(Oscar, name)
T isa DataType || T isa UnionAll || return false # remove all non-types and non-parametric-types
parentmodule(==, (T, T)) == Base && return false # remove everything without custom ==
loc = functionloc(==, (T, T))
endswith(loc[1], "julia/base/Base.jl") && loc[2] == 207 && return false # remove everything without custom ==
parentmodule(hash, (T, UInt)) == Base # keep iff there is no custom hash
end,
) do name
T = getfield(Oscar, name)
loc = functionloc(==, (T, T))
if occursin("Oscar.jl/", loc[1])
loc_cleaned = loc[1][first(findlast("Oscar.jl/", loc[1])):end]
elseif occursin("packages/", loc[1])
loc_cleaned = loc[1][(first(findlast("packages/", loc[1])) + length("packages/")):end]
elseif occursin("julia/base/", loc[1])
loc_cleaned = loc[1][first(findlast("julia/base/", loc[1])):end]
else
loc_cleaned = loc[1]
end
name, parentmodule(T), (loc_cleaned, loc[2])
end; Currently (on 499f7ce), I get the following list of things: julia> show(IOContext(stdout, :limit => false), "text/plain", list)
47-element Vector{Tuple{Symbol, Module, Tuple{String, Int32}}}:
(:AbsIdealSheaf, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:AbsNumFieldOrder, Hecke, ("Hecke/p6Ffl/src/NumFieldOrd/NfOrd/NfOrd.jl", 1160))
(:AbsNumFieldOrderSet, Hecke, ("Hecke/p6Ffl/src/NumFieldOrd/NfOrd/NfOrd.jl", 1179))
(:AbsSimpleNumFieldEmbedding, Hecke, ("Hecke/p6Ffl/src/NumField/ComplexEmbeddings/NfAbs.jl", 66))
(:AbsSimpleNumFieldOrder, Hecke, ("Hecke/p6Ffl/src/NumFieldOrd/NfOrd/NfOrd.jl", 1160))
(:AcbFieldElem, Nemo, ("Nemo/0TzOv/src/arb/acb.jl", 332))
(:AffineSchemeOpenSubschemeRing, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/AffineSchemeOpenSubscheme/Rings/Methods.jl", 5))
(:AffineSchemeOpenSubschemeRingElem, Oscar, ("AbstractAlgebra/aPVcM/src/NCRings.jl", 86))
(:ArbFieldElem, Nemo, ("Nemo/0TzOv/src/arb/arb.jl", 366))
(:ClassField, Hecke, ("Hecke/p6Ffl/src/RCF/class_fields.jl", 240))
(:ComplexFieldElem, Nemo, ("Nemo/0TzOv/src/arb/Complex.jl", 321))
(:Divisor, Hecke, ("Hecke/p6Ffl/src/FunField/Divisor.jl", 225))
(:EllipticCurve, Hecke, ("Hecke/p6Ffl/src/EllCrv/EllCrv.jl", 401))
(:FinGenAbGroupHom, Hecke, ("Hecke/p6Ffl/src/GrpAb/Map.jl", 245))
(:FractionalIdeal, Oscar, ("Oscar.jl/src/Rings/FractionalIdeal.jl", 55))
(:FunFldDiff, Hecke, ("Hecke/p6Ffl/src/FunField/Differential.jl", 78))
(:GenOrdFracIdl, Hecke, ("Hecke/p6Ffl/src/GenOrd/FractionalIdeal.jl", 272))
(:IdealGens, Oscar, ("Oscar.jl/src/Rings/mpoly.jl", 427))
(:IdealSheaf, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:IncidenceMatrix, Polymake.LibPolymake, ("julia/base/abstractarray.jl", 3028))
(:KodairaSymbol, Hecke, ("Hecke/p6Ffl/src/EllCrv/LocalData.jl", 849))
(:LocElem, AbstractAlgebra.Generic, ("AbstractAlgebra/aPVcM/src/NCRings.jl", 86))
(:LocalizedEuclideanRingElem, AbstractAlgebra.Generic, ("AbstractAlgebra/aPVcM/src/NCRings.jl", 86))
(:NfAbsNSGenElem, Oscar, ("Oscar.jl/src/Rings/NumberField.jl", 454))
(:NfNSGenElem, Oscar, ("AbstractAlgebra/aPVcM/src/NCRings.jl", 86))
(:OrdLocElem, Hecke, ("AbstractAlgebra/aPVcM/src/NCRings.jl", 86))
(:Polygon, Hecke, ("Hecke/p6Ffl/src/NumFieldOrd/NfOrd/MaxOrd/Polygons.jl", 94))
(:PrimeIdealSheafFromChart, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 2151))
(:ProductIdealSheaf, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:PullbackIdealSheaf, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:PushforwardIdealSheaf, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:QuadBin, Hecke, ("Hecke/p6Ffl/src/QuadForm/QuadBin.jl", 291))
(:RadicalOfIdealSheaf, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:RayVector, Oscar, ("Oscar.jl/src/PolyhedralGeometry/iterators.jl", 88))
(:RealFieldElem, Nemo, ("Nemo/0TzOv/src/arb/Real.jl", 346))
(:RelSimpleNumFieldEmbedding, Hecke, ("Hecke/p6Ffl/src/NumField/ComplexEmbeddings/NfRel.jl", 61))
(:SLPoly, Oscar, ("AbstractAlgebra/aPVcM/src/NCRings.jl", 86))
(:SimplifiedIdealSheaf, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:SingularLocusIdealSheaf, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:SpecOpenRing, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/AffineSchemeOpenSubscheme/Rings/Methods.jl", 5))
(:SpecOpenRingElem, Oscar, ("AbstractAlgebra/aPVcM/src/NCRings.jl", 86))
(:StrictTransformIdealSheaf, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:SubModuleOfFreeModule, Oscar, ("Oscar.jl/src/Modules/UngradedModules/SubModuleOfFreeModule.jl", 396))
(:SumIdealSheaf, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:ToricIdealSheafFromCoxRingIdeal, Oscar, ("Oscar.jl/src/AlgebraicGeometry/Schemes/Sheaves/IdealSheaves.jl", 576))
(:acb, Nemo, ("Nemo/0TzOv/src/arb/acb.jl", 332))
(:arb, Nemo, ("Nemo/0TzOv/src/arb/arb.jl", 366)) One needs unfortunately to check the |
where we have a custom == function, see #2222
@lgoettgens can you please refresh that list? and then we can whittle it down and mark known false-positives. |
The main offender is ... the Geometry ... @HechtiDerLachs will look into the Geometry... |
Done, see #4305 . |
I updated the list above. @HechtiDerLachs It seems you missed some types in |
There are a bunch of our types which implement
==
but nothash
, which leads to confusing behavior and bugs. E.g. for a vector consisting of two such objects which are equal but not identical, the functionunique
will return a vector with both objects, instead of just one. @YueRen just re-discovered this forPolyhedron
, but there are more affected types.Perhaps someone could write a little script to find more instances semi-automatically (e.g.: iterate over all objects in the
Oscar
module; for each which is a type, check if there is a customBase.==
method defined; and then for each check if also a customBase.hash
method is defined; if not, print the type).In the meantime, here is a manual list which is certainly incomplete (and I also might have included some things incorrectly, because I overlooked a
hash
method). Feel free to edit this list or request changes.Cone
PolyhedralFan
(doesn't implement==
)Polyhedron
ToricDivisor
(see ToricVarieties: Add Base.hash #1264)Also for a few types we should perhaps improve the existing hash methods. E.g. we have this right now:
I think they should at least produce different hashes according to their type. Thus a slightly better approach might be to do something like this:
But we could still do more, e.g. for permutation groups the
degree
could be included, and arguably also theorder
(I mean, computing the order costs us, but if we compute a hash for a group, then we probably will also test equality at some point, and then we need a stabilizer chain anyway, so whatever).The text was updated successfully, but these errors were encountered: