Migrate MapFromFunc from Hecke->AbstractAlgebra#2443
Conversation
|
Some weird things I am noticing with this: To some extent, the abstract type The concrete Anyway, I don't know if this is a big deal at all, but I'm mainly wondering if it would be reasonable or useful to somehow merge the functionalities of |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2443 +/- ##
==========================================
- Coverage 88.14% 88.13% -0.02%
==========================================
Files 129 130 +1
Lines 33017 33113 +96
==========================================
+ Hits 29104 29185 +81
- Misses 3913 3928 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I think it is fine to get a Should we also move |
I think maybe we should replace the current AA |
|
I think we are breaking anyway, so let's try to do all the breaking stuff at once. |
|
Sounds good, I'll get the modifications submitted to Nemo and then fix this up to move fully to the new |
|
Some things to consider:
The Hecke maps use a |
I'm testing this with having EDIT: Having trouble getting this to work, I have EDIT2: ooooooh since this code is in |
| function map_from_func(image_fn::Function, domain, codomain) | ||
| return Generic.FunctionalMap(domain, codomain, image_fn) | ||
| map_from_func(D, C, image_fn) = MapFromFunc(D, C, image_fn) | ||
| map_from_func(D, C, image_fn, inverse_fn) = MapFromFunc(D, C, image_fn, inverse_fn) |
There was a problem hiding this comment.
How about we provide this for backwards compatibility:
| map_from_func(D, C, image_fn, inverse_fn) = MapFromFunc(D, C, image_fn, inverse_fn) | |
| @deprecated map_from_func(image_fn::Function, D, C) = MapFromFunc(D, C, image_fn) |
(in the appropriate file)
| # | ||
| ############################################################################### | ||
|
|
||
| mutable struct MapCache{D, C, De, Ce} |
There was a problem hiding this comment.
It is unfortunate that we also have Generic.MapCache; the similar names may lead to confusion. I actually think the name Generic.MapCache is "wrong" by our modern convention (it should be something like Generic.CacheMap or Generic.CachedMap), but it probably isn't worth the bother to update it -- rather I'd consider ditching it in the not so distant future (but not as part of this PR).
Perhaps we can deprecate the method related to Generic.MapCache sooner, though (so enable_cache, or cached(::Map) etc.
There was a problem hiding this comment.
Since we are adding MapFromFunc here, I'd also be OK with calling this Generic.MapWithCache... as long as the name clearly conveys "this is a type of Map". (But of course I'd still rather prefer removing it ... ;-) )
| old_im | ||
| old_pr | ||
|
|
||
| function MapCache(dom::D, cod::C, ::Type{De}, ::Type{Ce}, lim::Int=100) where {D, C, De, Ce} |
There was a problem hiding this comment.
In Hecke there are function allow_cache! and stop_cache! for all maps with a map header. We could also migrate them here.
| z = new{D, C}() | ||
| z.domain = domain | ||
| z.codomain = codomain | ||
| return z |
There was a problem hiding this comment.
| z = new{D, C}() | |
| z.domain = domain | |
| z.codomain = codomain | |
| return z | |
| return new{D, C}(domain, codomain) |
| z = new{D, C}() | ||
| z.domain = domain | ||
| z.codomain = codomain | ||
| z.image = image | ||
| return z |
There was a problem hiding this comment.
| z = new{D, C}() | |
| z.domain = domain | |
| z.codomain = codomain | |
| z.image = image | |
| return z | |
| return new{D, C}(domain, codomain, image) |
| z = new{D, C}() | ||
| z.domain = domain | ||
| z.codomain = codomain | ||
| z.image = image | ||
| z.preimage = preimage | ||
| return z |
There was a problem hiding this comment.
| z = new{D, C}() | |
| z.domain = domain | |
| z.codomain = codomain | |
| z.image = image | |
| z.preimage = preimage | |
| return z | |
| return new{D, C}(domain, codomain, image, preimage) |
| image | ||
| preimage |
There was a problem hiding this comment.
| image | |
| preimage | |
| image # function (or other kind of object) used to actually compute images | |
| preimage # function (or other kind of object) used to actually compute preimages |
|
|
||
| abstract type IdentityMap <: SetMap end | ||
|
|
||
| abstract type HeckeMap <: FunctionalMap end |
There was a problem hiding this comment.
| abstract type HeckeMap <: FunctionalMap end | |
| abstract type HeckeMap <: SetMap end |
There was a problem hiding this comment.
How about we rename this to MapWithHeader or so?
@thofma opinion?
To make the transition on the Hecke side easier, the Hecke PR thofma/Hecke.jl#2290 could define an alias const HeckeMap = AbstractAlgbra.MapWithHeader ...?
| julia> g = map_from_func(ZZ, QQ, x -> QQ(x)); | ||
|
|
||
| julia> h = compose(f, g) | ||
| Functional composite map |
There was a problem hiding this comment.
We should just delete FunctionalCompositeMap -- and eventually also Generic.FunctionalMap
There was a problem hiding this comment.
To get rid of Generic.FunctionalMap we also need to change map_with_preimage_from_func etc. to call map_from_func
|
|
||
| abstract type Map{D, C, S, T} <: SetElem end | ||
|
|
||
| abstract type SetMap end |
There was a problem hiding this comment.
| # | |
| # The following types are only used as type parameters for `Map` subtypes | |
| # | |
| abstract type SetMap end |
(Paired with thofma/Hecke.jl#2290)
As discussed in 6043, there is some motivation to move
MapFromFuncfrom Hecke into AbstractAlgebra, at least partially so that it can be used inGAP.jl/NemoExt(we hope to migrate some of theiso_oscar_gap/iso_gap_oscarfunctionality to there.To facilitate this, the following things have been moved:
HeckeMap,MapFromFuncMapHeaderMapCacheand some related/supporting functions.
We will also move some related tests, and rewrite some code using
AbstractAlgebra.map_from_func(which creates aGeneric.FunctionalMap) to useMapFromFuncinstead.