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

Incorrect signature for gmpy2.digits() in docs #504

Open
skirpichev opened this issue Aug 4, 2024 · 0 comments
Open

Incorrect signature for gmpy2.digits() in docs #504

skirpichev opened this issue Aug 4, 2024 · 0 comments

Comments

@skirpichev
Copy link
Contributor

E.g.:

>>> from gmpy2 import digits
>>> help(digits)
Help on built-in function digits in module gmpy2.gmpy2:

digits(...)
    digits(x, base=10, prec=0, /) -> str

    Return string representing a number x.

In fact, output is different: it's a string for mpz/mpq, but a 3-tuple for mpfr and a 2-tuple for mpc. Signature looks to complex to be described in details, probably -> str | tuple will be enough. Documentation should be adjusted too.

Maybe we should deprecate this function in favor of instance methods (e.g. mpfr.digits())? I think that a generic function, returning a string - is better. Something like to_str(num, base=10, prec=0, /), which will be a wrapper to mpfr_out_str() for the mpfr type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant