Opened 3 years ago

Closed 3 years ago

#20548 closed enhancement (fixed)

py3 print in numerical folder

Reported by: chapoton Owned by:
Priority: major Milestone: sage-7.2
Component: python3 Keywords:
Cc: Merged in:
Authors: Frédéric Chapoton, Matthias Koeppe Reviewers: Frédéric Chapoton, Matthias Koeppe
Report Upstream: N/A Work issues:
Branch: 4142421 (Commits) Commit: 41424218fbfdf598f3c772aa52300f4ae4c3d6f4
Dependencies: Stopgaps:

Description

another small step, trying to turn print to python3 behaviour

Change History (23)

comment:1 Changed 3 years ago by chapoton

  • Branch set to public/20548
  • Commit set to 5922fbaf3f43b362482fb0e7c18129de0fe1b399
  • Status changed from new to needs_review

New commits:

5922fbapython3 print in numerical folder

comment:2 Changed 3 years ago by git

  • Commit changed from 5922fbaf3f43b362482fb0e7c18129de0fe1b399 to cb257a07c32a2d9a6adb053e3662d0e0ee029b44

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

cb257a0python3 print in numerical, details and fixing

comment:3 Changed 3 years ago by jdemeyer

  • Status changed from needs_review to needs_info

Is this valid Python 3?

print

comment:4 Changed 3 years ago by jdemeyer

  • Status changed from needs_info to needs_work

Well, it's technically valid but it doesn't do what you think it does:

Python 3.3.2 (default, Dec  7 2013, 12:59:33) 
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print
<built-in function print>

comment:5 Changed 3 years ago by jdemeyer

One more detail, since you're changing the code anyway. Change this

        if b.obj_constant_term > self._backend.zero(): print("+ {}".format(b.obj_constant_term))
        elif b.obj_constant_term < self._backend.zero(): print("- {}".format(-b.obj_constant_term))

to

        if b.obj_constant_term > self._backend.zero():
            print("+ {}".format(b.obj_constant_term))
        elif b.obj_constant_term < self._backend.zero():
            print("- {}".format(-b.obj_constant_term))

which is much more readable

comment:6 Changed 3 years ago by jdemeyer

Same for

        if d > self._backend.zero(): print("+ {} ".format(d))
        elif d < self._backend.zero(): print("- {} ".format(-d))

comment:7 Changed 3 years ago by git

  • Commit changed from cb257a07c32a2d9a6adb053e3662d0e0ee029b44 to ca3d65330731d5707fc27bf7036f02e6e216e401

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

ca3d653python3 print in numerical, fine tuning

comment:8 Changed 3 years ago by chapoton

  • Status changed from needs_work to needs_review

done

comment:9 Changed 3 years ago by mkoeppe

needs merge or rebase

comment:10 Changed 3 years ago by git

  • Commit changed from ca3d65330731d5707fc27bf7036f02e6e216e401 to 46fe07f0bccb30b6728ce089a767cfdbfc51d515

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

46fe07fMerge branch 'public/20548' into 7.2.rc1

comment:11 Changed 3 years ago by mkoeppe

You missed several backends

comment:12 Changed 3 years ago by chapoton

The aim is to have the doctests pass when adding a global future print import in sage/all.py.

For that, all the backends where something was needed were modified.

You can check this by adding from __future__ import print_function in src/sage/all.py on top of this branch and running all the tests in the numerical folder.

If you want to take the opportunity to convert everything else to python3 print style in the numerical folder, please do.

Last edited 3 years ago by chapoton (previous) (diff)

comment:13 Changed 3 years ago by chapoton

ping ?

comment:14 Changed 3 years ago by git

  • Commit changed from 46fe07f0bccb30b6728ce089a767cfdbfc51d515 to 41424218fbfdf598f3c772aa52300f4ae4c3d6f4

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

4142421python3 print in remaining mip backends

comment:15 Changed 3 years ago by mkoeppe

  • Authors changed from Frédéric Chapoton to Frédéric Chapoton, Matthias Koeppe

Yes, as I said, you missed some backends. I've done the remaining ones.

comment:16 follow-up: Changed 3 years ago by chapoton

ok, I had forgotten about the optional backends, indeed.

Why did you change two print to sys.stdout.write ?

comment:17 in reply to: ↑ 16 Changed 3 years ago by mkoeppe

Replying to chapoton:

Why did you change two print to sys.stdout.write ?

These are print-without-newlines.

comment:18 Changed 3 years ago by chapoton

ok, then I am happy with your commit. Are you ok with mines ?

comment:19 Changed 3 years ago by mkoeppe

yes, looking good

comment:20 Changed 3 years ago by chapoton

So, can I set to positive review ?

comment:21 Changed 3 years ago by mkoeppe

sure

comment:22 Changed 3 years ago by chapoton

  • Reviewers set to Frédéric Chapoton, Matthias Koeppe
  • Status changed from needs_review to positive_review

done, thanks

comment:23 Changed 3 years ago by vbraun

  • Branch changed from public/20548 to 41424218fbfdf598f3c772aa52300f4ae4c3d6f4
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.