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
Deprecate global RealNumber() and ComplexNumber() #13110
Comments
Changed keywords from none to complex |
Author: Travis Scrimshaw |
comment:1
Simple fix and easy to review. |
comment:2
Don't you want it more along the lines of
to avoid accepting malformed input such as
perhaps? |
comment:3
Also, a typo; 'fixzed'>'fixed' |
comment:4
That is a good idea. Updated (and typo fixzed :P) and now it will also work for |
comment:5
It seems to me that you should explain in the doc that a new kind of input is now allowed. So far, the doc says that the only possible input is a pair of numbers. |
Attachment: trac_13110-python_complex_input-ts.patch.gz |
comment:6
I've updated the documentation and added a (quick 'n' dirty) parser for string inputs as well. |
comment:7
This is really nice, but I think the string parser should be more strict in order to enforce a more consistent syntax. How about just accepting the Python |
comment:8
Replying to @eviatarbach:
I disagree since the output from |
comment:9
This makes sense, but |
comment:10
True, but it's the "natural" in between since python complex strings are |
comment:11
We already have a clash
and I'm pretty sure you won't get to predefine |
comment:12
I'm a bit scared by the included number parser ;-) Can we use a regex? This would also be better at validating input. |
comment:13
The ticket states that
makes much more sense to solve the problem at hand.
I realize that we have the documentation:
According to that documentation, the proposed input is not valid anyway. By changing that you're changing the interface the routine offers. That's fine, but once you start changing it, you should improve it. Note that |
comment:14
Replying to @nbruin:
This is already how I've done it done in the current patch.
That was the original implementation with two reals as input, and I haven't changed that. Nevertheless, I agree that it should be changed (see below).
How about we check if the input is a (pair of) Volker, good point. I don't use regex too often so it's never really something I think of. I'll do that on the next patch. |
comment:15
I agree that it would be best if |
comment:16
Hmm. What do you all think of just making |
comment:17
Replying to @vbraun:
Yes, indeed. That very "eval" instruction is marked with a "TODO", indicating that it could use improvements. I'd say that's the place to a string interpretation routine, rather than in There is one thing that I think in general, guessing precision from number of digits written down is rarely going to produce desirable results, so I'd be for providing the user interface with a default precision (complex) field. |
comment:35
Replying to @jdemeyer:
That does not
|
comment:36
I think that the simplest would just be to remove |
This comment has been minimized.
This comment has been minimized.
Changed keywords from complex to none |
Changed author from Travis Scrimshaw to Vincent Delecroix |
Changed branch from u/epilys/deprecate_global_realnumber___and_complexnumber__ to u/vdelecroix/13110 |
This comment has been minimized.
This comment has been minimized.
comment:40
Mostly setting to needs review in order to let patchbots test it! |
comment:41
I don't like the verbosity of |
comment:42
Replying to @jdemeyer:
Fine for me. |
comment:43
Replying to @videlec:
Though a problem is that names starting with underscore in |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:45
Replying to @videlec:
Not a big problem, just import |
comment:47
Replying to @videlec:
Put this in
|
comment:49
Replying to @videlec:
This would be a (not very elegant) solution diff --git a/src/sage/repl/ipython_extension.py b/src/sage/repl/ipython_extension.py
index 90a8049d72..22110fe5ac 100644
--- a/src/sage/repl/ipython_extension.py
+++ b/src/sage/repl/ipython_extension.py
@@ -476,8 +476,12 @@ class SageCustomizations(object):
Set up Sage command-line environment
"""
# import outside of cell so we don't get a traceback
- from sage.repl.user_globals import initialize_globals
+ from sage.repl.user_globals import initialize_globals, set_global
+ from sage.rings.real_mpfr import create_RealNumber
+ from sage.rings.complex_number import create_ComplexNumber
initialize_globals(self.all_globals(), self.shell.user_ns)
+ set_global('_Real', create_RealNumber)
+ set_global('_Complex', create_ComplexNumber)
self.run_init() |
comment:50
does not apply |
The
RealNumber()
andComplexNumber()
global functions are converting string to floating-point numbers. They do not do what their names suggestThese two functions are mostly intended for the Sage preparser and shouldn't be used directly. We deprecate them in view of removing them from the global namespace. In the future, we might use the names
RealNumber
andComplexNumber
as proper factories.Component: numerical
Author: Vincent Delecroix
Branch/Commit: u/vdelecroix/13110 @
140f7bd
Issue created by migration from https://trac.sagemath.org/ticket/13110
The text was updated successfully, but these errors were encountered: