Skip to content

Commit

Permalink
Remove calls to prec_words_to_dec.
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed Jan 7, 2025
1 parent 075253b commit 7f0bac4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions freedesktop/share/applications/snappy.desktop
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[Desktop Entry]
Version=3.1
Version=1.0
Name=SnapPy
GenericName=Manifold browser
Comment=Study hyperbolic 3-manifolds.
MimeType=;
Exec=/home/culler/venv/bin/python3 -m snappy.app
Exec=/usr/bin/env python3 -m snappy.app
Icon=SnapPy
Type=Application
Terminal=false
Categories=Utility;Application;Math;
Categories=Science
StartupWMClass=snappy
2 changes: 1 addition & 1 deletion python/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def __init__(self, data, accuracy=None, precision=None):
self.accuracy = self.decimal_precision
else:
if accuracy is None:
accuracy = prec_words_to_dec(self.gen.sizeword())
accuracy = prec_bits_to_dec(64 * self.gen.sizeword())

This comment has been minimized.

Copy link
@tornaria

tornaria Jan 7, 2025

@culler I don't think this is ok. What is wrong with self.gen.precision()?

Example:

>>> from cypari2 import Pari
>>> pari = Pari()
>>> g.precision()
19
>>> g.bitprecision()
64
>>> g.sizeword()
3

There you have precision in decimal digits, bit precision, and size in words. The relation between bit precision and size in words is implementation defined so better use the functions provided by pari. Because if they change the implementation, they will change these functions.

This comment has been minimized.

Copy link
@culler

culler via email Jan 7, 2025

Author Member

This comment has been minimized.

Copy link
@culler

culler via email Jan 7, 2025

Author Member

This comment has been minimized.

Copy link
@tornaria

tornaria Jan 7, 2025

I think self.gen.precision() is really what you want.

If you want to mess with pari internals, and only support 64 bits, I believe you should use 64 * (sizeword - 2).

What I suggest should be equivalent but better (i.e. work in all circumstances).

This comment has been minimized.

Copy link
@NathanDunfield

NathanDunfield Jan 7, 2025

Member

Yes, @culler just switched to that in a2012b0. Thanks for the suggestion!

self.accuracy = min(accuracy, self.decimal_precision)
self._parent = SnapPyNumbers(self._precision)
if _within_sage:
Expand Down
3 changes: 1 addition & 2 deletions python/pari.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
raise ValueError("you need a more recent version of SageMath")
from sage.libs.pari import pari
from cypari2 import Gen
from cypari2.pari_instance import (prec_words_to_dec,
prec_words_to_bits,
from cypari2.pari_instance import (prec_words_to_bits,
prec_bits_to_dec,
prec_dec_to_bits)
from sage.all import PariError
Expand Down

0 comments on commit 7f0bac4

Please sign in to comment.