-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
Symbolic factor_list() should do integer factorisation of integers/rationals #21067
Comments
Author: Ralf Stephan |
New commits:
|
This comment has been minimized.
This comment has been minimized.
Commit: |
comment:4
One minor thing: could you move the import into the |
comment:5
Two comments:
because it's closer to the idea that the factorisation of a product U*V has a tendency to be the concatenation of the factorisations of U and V. It should be clear that
but keeping the convention that we factor rational numbers into their prime factors should be fine and could be nice for newbies. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:7
Instead of having a special check and a special method for integer/rationals couldn't we use something simpler and more generic like def _factorization_from_pyobject(self):
try:
a = self.pyobject()
except TypeError:
return
try:
f = a.factor()
except (AttributeError, NotImplementedError):
return
# from here I assume that a is a Sage object which might not be the case...
P = self.parent()
facs = [(P(p), P(e)) for p,e in f]
if f.unit().is_one():
return facs
else:
return [(P(f.unit()), P(1))] + facs |
comment:8
Vincent, if you think it's better, then please go ahead on a new branch. I'm not so deep in Python that I could object. |
comment:9
I think "factor" in general could be a little fickle to depend on:
|
comment:11
I think this ticket should also do:
|
Changed branch from u/rws/symbolic_factor___should_do_integer_factorisation_of_integers_rationals to u/rws/21067 |
Changed author from Ralf Stephan to Ralf Stephan, Vincent Delecroix |
comment:13
I used Vincent's code for a new version that tries also to separate the content in a univariate polynomial. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:15
Doctest errors, see patchbot. |
comment:18
LGTM, I only have one comment: + raise ValueError This is only used internally, so it might be good to consider a customized exception: class CannotFactor(RuntimeError):
pass And yes, I think |
Reviewer: Daniel Krenn |
Let symbolic
factor_list()
do integer factorisation if given an integer or fraction.Too much surprise for new users.
Component: symbolics
Author: Ralf Stephan, Vincent Delecroix
Branch/Commit: u/rws/21067 @
a821fb6
Reviewer: Daniel Krenn
Issue created by migration from https://trac.sagemath.org/ticket/21067
The text was updated successfully, but these errors were encountered: