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

sage.rings.integer, rational: Remove compile-time dependency on cypari2 and flint #30022

Closed
mkoeppe opened this issue Jun 29, 2020 · 27 comments
Closed

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 29, 2020

Functions such as set_from_pari_gen should probably be moved to sage.libs.pari.convert_sage.

The compile-time dependency on sage.libs.flint.ulong_extras is for the use of n_factor.

CC: @videlec @kliem @tscrim

Component: refactoring

Author: Matthias Koeppe, Jonathan Kliem

Branch/Commit: b4477da

Reviewer: Jonathan Kliem, Matthias Koeppe

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

@mkoeppe mkoeppe added this to the sage-9.2 milestone Jun 29, 2020
@videlec
Copy link
Contributor

videlec commented Jul 27, 2020

comment:1

Moving set_from_pari_gen in sage.libs.pari would make cypari2 depends on sage. Wouldn't it?

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jul 27, 2020

comment:2

sage.libs.pari.convert_sage already depends on sage (and on cypari2).

@videlec
Copy link
Contributor

videlec commented Jul 27, 2020

comment:3

I misunderstood the ticket description... I thought you wanted to move that to cypari2. Sorry.

It indeed makes sense to have it in sage.libs where all the low-level interfaces actually are.

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Aug 13, 2020
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 13, 2021

comment:6

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 Feb 13, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 28, 2021

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 28, 2021

Author: Matthias Koeppe, ...

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 28, 2021

New commits:

08084b3sage.libs.pari.convert_sage: Move set_integer_from_gen here from sage.rings.integer (set_from_pari_gen)

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 28, 2021

Commit: 08084b3

@kliem
Copy link
Contributor

kliem commented Aug 28, 2021

New commits:

9986723remove compile time dependency of Integer and Rational on cypari2
c08a8b5remove compile-time dependency on flint from integer

@kliem
Copy link
Contributor

kliem commented Aug 28, 2021

Changed commit from 08084b3 to c08a8b5

@kliem
Copy link
Contributor

kliem commented Aug 28, 2021

Changed author from Matthias Koeppe, ... to Matthias Koeppe, Jonathan Kliem

@kliem
Copy link
Contributor

kliem commented Aug 28, 2021

Reviewer: Jonathan Kliem, ...

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 28, 2021

comment:12

Thanks a lot for working on this!

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 28, 2021

comment:13
+            try:
+                from sage.libs.flint.ulong_extras import n_factor_to_list
+                if proof is None:
+                    from sage.structure.proof.proof import get_flag
+                    proof = get_flag(proof, "arithmetic")
+                F = n_factor_to_list(mpz_get_ui(n.value), proof)
+                F = [(smallInteger(a), smallInteger(b)) for a, b in F]
+                F.sort()
+                return IntegerFactorization(F, unit=unit, unsafe=True,
+                                               sort=False, simplify=False)
+            except ImportError:
+                pass

I think it's better to use try: except: else here, only wrapping the actual import in try-except`

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 28, 2021

comment:14

The next module that will need similar work is sage.rings.fast_arith

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 28, 2021

Changed commit from c08a8b5 to 88d91ba

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 28, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

88d91bause try ... except ... else

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 28, 2021

comment:16

Also sage.matrix.args has the cypari2 compile-time dep

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 29, 2021

comment:17

patchbot indicates docbuild failure

[dochtml] cd /home/sagemath/sage-9.1 && ./sage --docbuild --no-pdf-links reference/matrices inventory --no-prune-empty-dirs
[dochtml] [libs     ] docstring of sage.libs.pari.convert_sage.pari_divisors_small:3: WARNING: Content block expected for the "SEEALSO" directive; none found.
[dochtml] [libs     ] The inventory files are in local/share/doc/sage/inventory/en/reference/libs.
[dochtml] Error building the documentation.
[dochtml] Traceback (most recent call last):
[dochtml]   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
[dochtml]     "__main__", mod_spec)
[dochtml]   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
[dochtml]     exec(code, run_globals)
[dochtml]   File "/home/sagemath/sage-9.1/local/lib/python3.7/site-packages/sage_docbuild/__main__.py", line 2, in <module>
[dochtml]     main()
[dochtml]   File "/home/sagemath/sage-9.1/local/lib/python3.7/site-packages/sage_docbuild/__init__.py", line 1813, in main
[dochtml]     builder()
[dochtml]   File "/home/sagemath/sage-9.1/local/lib/python3.7/site-packages/sage_docbuild/__init__.py", line 821, in _wrapper
[dochtml]     getattr(DocBuilder, build_type)(self, *args, **kwds)
[dochtml]   File "/home/sagemath/sage-9.1/local/lib/python3.7/site-packages/sage_docbuild/__init__.py", line 133, in f
[dochtml]     runsphinx()
[dochtml]   File "/home/sagemath/sage-9.1/local/lib/python3.7/site-packages/sage_docbuild/sphinxbuild.py", line 323, in runsphinx
[dochtml]     sys.stderr.raise_errors()
[dochtml]   File "/home/sagemath/sage-9.1/local/lib/python3.7/site-packages/sage_docbuild/sphinxbuild.py", line 258, in raise_errors
[dochtml]     raise OSError(self._error)
[dochtml] OSError: docstring of sage.libs.pari.convert_sage.pari_divisors_small:3: WARNING: Content block expected for the "SEEALSO" directive; none found.
[dochtml] 

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2021

Changed commit from 88d91ba to b4477da

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

b4477dafixed indent

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 31, 2021

comment:19

LGTM, let's get this in.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 31, 2021

Changed reviewer from Jonathan Kliem, ... to Jonathan Kliem, Matthias Koeppe

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 31, 2021

comment:20

Follow-up in #32441

@vbraun
Copy link
Member

vbraun commented Sep 1, 2021

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

4 participants