sage icon indicating copy to clipboard operation
sage copied to clipboard

Add `print_mode='digits-unicode'` to p-adic numbers

Open user202729 opened this issue 1 month ago • 4 comments

Problem Description

Currently we have

sage: Zp(2, 10, print_mode='digits')(5)
...0000000101

this causes some "issues" with doctest (it matches too liberally)… because ... is a special marker that stands for "arbitrary string".

Proposed Solution

Implement the following

sage: Zp(2, 10, print_mode='digits-unicode')(5)
…0000000101

that uses the Unicode character instead of 3 ASCII dots ....

Afterwards, the tests can be modified to use this print mode instead of the default one.

There's one precedent of this in src/sage/rings/valuation/limit_valuation.py (although _base_valuation is a private member).

Alternatives Considered

Motivated by looking at https://github.com/sagemath/sage/pull/41194/files

Additional Information

No response

Is there an existing issue for this?

  • [x] I have searched the existing issues for a bug report that matches the one I want to file, without success.

user202729 avatar Nov 22 '25 10:11 user202729

Hello, I am new to open-source contributions and would like to work on this issue as my first contribution. Could you please assign it to me? Any guidance throughout the process would be greatly appreciated. Thank you!

Harkeerat24 avatar Nov 22 '25 15:11 Harkeerat24

Indeed, when I was reviewing this I was afraid about this for the doctests. I wonder if another solution would be to have some keyword (like we do with # random for instance) to ask the tests to check ... as is.

r-mb avatar Nov 24 '25 14:11 r-mb

@r-mb bad news, some of the ... are meant to be ellipsis and others are meant to be literal. For example https://github.com/sagemath/sage/pull/41194/files#diff-1f062e54c60f54af565aeb9ad736fe88eea2295d6ad937dfac099054bb481b0aR2676 has an ellipsis-....

elsewhere I use a different hack to check that: https://github.com/sagemath/sage/blob/5c8d9e9a75a734068e9c11f682b0b1bede6814a9/src/sage/doctest/test.py#L343

But if the problem is any more frequent than a single occurrence, these hacks are unsustainable.

user202729 avatar Nov 24 '25 23:11 user202729

Oof! Nice catch! Indeed the Unicode approach seems better here.

r-mb avatar Nov 25 '25 05:11 r-mb

Hi @user202729, If this issue is still open, could you please assign it to me? I’d be happy to work on it. Thank you!

Yashagarwal9798 avatar Dec 21 '25 21:12 Yashagarwal9798