Skip to content

Commit

Permalink
sagemathgh-39174: Return True instead of None to avoid cachefunc bein…
Browse files Browse the repository at this point in the history
…g useless

Just a trivial fix.

(probably just the tip of the iceberg though.)

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->

URL: sagemath#39174
Reported by: user202729
Reviewer(s): Martin Rubey
  • Loading branch information
Release Manager committed Dec 21, 2024
2 parents 4e3005d + 91cf51d commit 291e54b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tarball=configure-VERSION.tar.gz
sha1=ebc4bd50c332f06ad5b2a4ce6217ec65790655ab
sha256=a2fa7623b406a7937ebfbe3cc6d9e17bcf0c219dec2646320b7266326d789b56
sha1=688c89dcc85f95d4637109c80decb8c7a66b8481
sha256=3d46f808d4569dfcabb8c92dfb9ac8687f6fb0d1cf67cda71de79f9dc0c65b0f
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a72ae6d615ddfd3e49b36c200aaf14c24a265916
dc6e5545e0443748153c913364b47cca95feefa4
28 changes: 16 additions & 12 deletions src/sage/combinat/integer_lists/invlex.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -860,14 +860,18 @@ 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)
sage: L._check_finiteness()
True
The following example is infinite::
Expand Down Expand Up @@ -1002,20 +1006,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:
Expand All @@ -1028,24 +1032,24 @@ 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
(self.max_sum < Infinity or
(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")
Expand Down

0 comments on commit 291e54b

Please sign in to comment.