Open mantepse opened 3 weeks ago
Documentation preview for this PR (built with commit 4f42af7c142f7446025f47c4b0dbc2ac8146063b; changes) is ready! :tada: This preview will update shortly after each push to this PR.
@fchapoton, could you please have a look so it doesn't rot away?
Thank you! Sorry, I couldn't resist.
Dear @fchapoton, I would like to put this back to "needs work", because it doesn't quite solve Max' issue, and it's not hard to do that, but I'd like to avoid deprecation of something I just introduced.
Is this OK with you or would you prefer if I open a new pull request?
Ideally, I think there should be a single class for partitions of n
with parts in a given set or interval and length in a given interval, which computes the cardinality efficiently using a few case distinctions and a recurrence if necessary.
This is now much better. Almost all the time is now spent in IntegerListsLex.__init__
, which is a pity, but can probably not be fixed in this pull request.
I'm open for a better name for the class Partitions_parts_length_restricted
. I'm also open for deprecating PartitionsGreatestLE
.
I find it a bit frustrating that we do not need the IntegerListsLex.__init__
at all to compute the cardinality. It would be nice to have a pattern where such an expensive initialisation is postponed until it's needed.
Failing that, it seems that most of the time is spent in Envelope.__init__
. Maybe this can be optimized.
The solution was very simple, so I implemented it.
Max' problem is still much better solved without using Partitions
(it seems to take roughly twice as long), because Partitions
has UniqueRepresentation
, which is expensive if we call it with very many different arguments - we are creating an entry in the cache not only for each size, but for each restriction.
@tscrim, there seems to be a problem with FockSpace
. In FockSpaceTruncated.F.__init__
, the index set is set to be partitions of F._n
, but that doesn't seem to be quite true. Could you please check?
@tscrim, there seems to be a problem with
FockSpace
. InFockSpaceTruncated.F.__init__
, the index set is set to be partitions ofF._n
, but that doesn't seem to be quite true. Could you please check?
Yes, that is not correct. It should be over all partitions of length \leq k
(as per the doc of FockSpaceTruncated
).
OK, I made a catch-all class for partitions which are not restricted by size. This can easily be improved, but I'd prefer to postpone this.
@fchapoton, is the lint error in error?
Other than that, I think that the pull request should be ready to go.
somebody should add PLC0206 to the ruff-minimal ignore list in another pull request
DONE; please review #39021
We provide a new class,
PartitionsSmallestGE
to handle subsets of the constraintslength
,min_length
,max_length
andmin_part
, to make cardinality computations with such constraints reasonable.Fixes #38897