Opened 2 years ago
Last modified 4 months ago
#29802 new defect
Documentation: Explain that min, max do not work for SR
Reported by: | alexjbest | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | sage-9.7 |
Component: | documentation | Keywords: | symbolics, infinity, minimum, maximum |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
On 9.2beta0
sage: a = var('a') sage: min(a,+Infinity) a sage: min(+Infinity,a) +Infinity
returning a in both cases would be best, but at the very worst this should consistently throw an error imo.
Change History (11)
comment:1 Changed 2 years ago by
comment:2 Changed 2 years ago by
@mkoeppe, thanks, sorry for the noise, I searched pretty hard for this information (using Google and trac search). I wonder how we could make this information more discoverable?
Perhaps adding a min
method to sage.symbolic.expression.Expression
to compute the minimum of self
and other
in this way?
comment:3 Changed 2 years ago by
- Component changed from symbolics to documentation
- Priority changed from major to minor
- Summary changed from Minimum of Infinity and a real variable not commutative to Documentation: Explain that min, max do not work for SR
comment:4 Changed 2 years ago by
I am pretty sure we tried doing something along the lines of making this easier to find, but apparently not. For instance, it could be useful in plot documentation too - see here.
See also:
As for the suggestion, are there any other builtins that we are able to treat in this manner? Other than things like repr() = __repr__()
? I don't see anything about min
or max
in the Python docs on custom classes. The actual CPython source seems to implement a generic function that then gets a max via gt and min via lt, but I don't see an easy way (or desire) to hack this. Unfortunately improving doc - a lot - may be the best way to handle this. (I don't immediately see how the key
argument would solve this, for instance.)
comment:5 Changed 2 years ago by
Interestingly, we actually do do this for abs
(see builtins list), and it causes a problem, because
sage: abs? Signature: abs(x, /) Docstring: Return the absolute value of the argument. Init docstring: Initialize self. See help(type(self)) for accurate signature. File: Type: builtin_function_or_method
But presumably we want something more than that, such as the content here. I'm not sure why this is what is returned.
Anyway - maybe that means we can overload min
/max
somehow, maybe even as naively as for abs
. Though note comment:2:ticket:6949.
comment:6 Changed 2 years ago by
See also #24296
comment:7 Changed 22 months ago by
- Milestone changed from sage-9.2 to sage-9.3
comment:8 Changed 17 months ago by
- Milestone changed from sage-9.3 to sage-9.4
Setting new milestone based on a cursory review of ticket status, priority, and last modification date.
comment:9 Changed 13 months ago by
- Milestone changed from sage-9.4 to sage-9.5
comment:10 Changed 8 months ago by
- Milestone changed from sage-9.5 to sage-9.6
comment:11 Changed 4 months ago by
- Milestone changed from sage-9.6 to sage-9.7
This is Python's built-in min. Try
min_symbolic