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
parent should only depend on input parent #24833
Comments
comment:1
I think we might also make a difference between methods and functions. The methods really act on a specific parent, so there it makes more sense to be strict. But I think that global functions like |
This comment has been minimized.
This comment has been minimized.
comment:3
Ticket description update: I only want to deal with member functions for now. |
This comment has been minimized.
This comment has been minimized.
comment:4
Replying to @jdemeyer:
Exactly, and since most global functions are symbolic, and users of calculus do not expect that they need special arguments or functions to get extended behaviour that behaviour should be default for global functions. |
comment:5
@rwst: why did you erase my modifications on the ticket description!? |
The aim of this ticket is to apply the following principle of least surprise to member functions (aka methods)
The ouptut parent should only depend on the input parent.
Many Sage numerical member functions contradict the above principle:
Let us emphasize that this ticket does not deal with function (such as
sqrt(2)
) but only with member functions (like2.sqrt()
).The parallel can be done with mathematical functions that have a well defined domain and codomain. In the above examples, the member functions try to be two things at the same time: a partial function of the initial domain (ie
log
from the positive reals to the reals) or as a domain restriction of a more general one (ielog
on complexes minus the negative real line).There are basically two ways to sort this out (see also this sage-devel thread)
RR(1.0).log()
would be the0
inCC
)ValueError
when the domain is not appropriateThe above just stands for the default behavior. It would still be possible to switch behaviors with one of
extend=True
orcodomain=CC
log_real
andlog_complex
For an element of comparison, in the Python standard library,
math
is dealing with real floating point (both input/output). AValueError
is raised when the input is not in the domainWhile
cmath
is dealing with complexes (input/output)The
mpmath
library is also silently convertingmpf
tompc
depending on the domainCC: @rwst
Component: basic arithmetic
Issue created by migration from https://trac.sagemath.org/ticket/24833
The text was updated successfully, but these errors were encountered: