Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Explain that min, max do not work for SR #29802

Open
alexjbest opened this issue Jun 5, 2020 · 6 comments
Open

Documentation: Explain that min, max do not work for SR #29802

alexjbest opened this issue Jun 5, 2020 · 6 comments

Comments

@alexjbest
Copy link
Contributor

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.

Component: documentation

Keywords: symbolics, infinity, minimum, maximum

Issue created by migration from https://trac.sagemath.org/ticket/29802

@alexjbest alexjbest added this to the sage-9.2 milestone Jun 5, 2020
@mkoeppe
Copy link
Member

mkoeppe commented Jun 5, 2020

comment:1

This is Python's built-in min. Try min_symbolic

@alexjbest
Copy link
Contributor Author

comment:2

@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?

@mkoeppe mkoeppe changed the title Minimum of Infinity and a real variable not commutative Documentation: Explain that min, max do not work for SR Jun 14, 2020
@kcrisman
Copy link
Member

comment:4

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.)

@kcrisman
Copy link
Member

comment:5

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 #6949 comment:2.

@mkoeppe
Copy link
Member

mkoeppe commented Jul 8, 2020

comment:6

See also #24296

@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Oct 24, 2020
@mkoeppe
Copy link
Member

mkoeppe commented Mar 15, 2021

comment:8

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Mar 15, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 7, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants