From d99d0346f1dcdc3b8ad8bd1bfa70aa9eaf23b9f0 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Fri, 20 Dec 2024 08:41:29 +0700 Subject: [PATCH 1/2] Return True instead of None to avoid cachefunc being useless --- src/sage/combinat/integer_lists/invlex.pyx | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/sage/combinat/integer_lists/invlex.pyx b/src/sage/combinat/integer_lists/invlex.pyx index 6bef85031ce..466089f335e 100644 --- a/src/sage/combinat/integer_lists/invlex.pyx +++ b/src/sage/combinat/integer_lists/invlex.pyx @@ -860,10 +860,13 @@ If you know what you are doing, you can set check=False to skip this warning.""" OUTPUT: - ``None`` if this method finds a proof that there + ``True`` if this method finds a proof that there exists an upper bound on the length. Otherwise a :exc:`ValueError` is raised. + Note that :func:`cached_method` does not work with methods + returning ``None``, so ``True`` is returned instead. + EXAMPLES:: sage: L = IntegerListsLex(4, max_length=4) @@ -1002,20 +1005,20 @@ If you know what you are doing, you can set check=False to skip this warning.""" """ # Trivial cases if self.max_length < Infinity: - return + return True if self.max_sum < self.min_sum: - return + return True if self.min_slope > self.max_slope: - return + return True if self.max_slope < 0: - return + return True if self.ceiling.limit() < self.floor.limit(): - return + return True if self.ceiling.limit() == 0: # This assumes no trailing zeroes - return + return True if self.min_slope > 0 and self.ceiling.limit() < Infinity: - return + return True # Compute a lower bound on the sum of floor(i) for i=1 to infinity if self.floor.limit() > 0 or self.min_slope > 0: @@ -1028,10 +1031,10 @@ If you know what you are doing, you can set check=False to skip this warning.""" floor_sum_lower_bound = Infinity if self.max_sum < floor_sum_lower_bound: - return + return True if self.max_sum == floor_sum_lower_bound and self.max_sum < Infinity: # This assumes no trailing zeroes - return + return True # Variant on ceiling.limit() ==0 where we actually discover that the ceiling limit is 0 if ( self.max_slope == 0 and @@ -1039,13 +1042,13 @@ If you know what you are doing, you can set check=False to skip this warning.""" (self.ceiling.limit_start() < Infinity and any(self.ceiling(i) == 0 for i in range(self.ceiling.limit_start()+1))) ) ): - return + return True limit_start = max(self.ceiling.limit_start(), self.floor.limit_start()) if limit_start < Infinity: for i in range(limit_start+1): if self.ceiling(i) < self.floor(i): - return + return True raise ValueError("could not prove that the specified constraints yield a finite set") From 91cf51de95a5ff241d148d93f2a1e76c74e05e3e Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:31:53 +0700 Subject: [PATCH 2/2] Fix tests --- src/sage/combinat/integer_lists/invlex.pyx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/combinat/integer_lists/invlex.pyx b/src/sage/combinat/integer_lists/invlex.pyx index 466089f335e..bfb4c8dc3d7 100644 --- a/src/sage/combinat/integer_lists/invlex.pyx +++ b/src/sage/combinat/integer_lists/invlex.pyx @@ -871,6 +871,7 @@ If you know what you are doing, you can set check=False to skip this warning.""" sage: L = IntegerListsLex(4, max_length=4) sage: L._check_finiteness() + True The following example is infinite::