Opened 8 months ago

Closed 8 months ago

#27466 closed defect (fixed)

py3: modules/with_basis/morphism.py

Reported by: jhpalmieri Owned by:
Priority: major Milestone: sage-8.7
Component: python3 Keywords:
Cc: Merged in:
Authors: John Palmieri Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: e3d8e49 (Commits) Commit: e3d8e496b2361bcfe5607f76a3323d759e3b6d6d
Dependencies: Stopgaps:

Description

Python 3 doctest fixes in modules/with_basis/morphism.py

Change History (4)

comment:1 Changed 8 months ago by jhpalmieri

  • Branch set to u/jhpalmieri/py3-morphism

comment:2 follow-up: Changed 8 months ago by jhpalmieri

  • Commit set to e3d8e496b2361bcfe5607f76a3323d759e3b6d6d
  • Status changed from new to needs_review

In morphism.py, it says:

        Pickling fails (:trac:`17957`) because the attribute
        ``phi._inverse_on_support`` is a ``dict.get`` method which is
        not yet picklable::

This seems to no longer be true in Python 3. In Python 2:

sage: dumps({1:1}.get)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: expected string or Unicode object, NoneType found

In Python 3:

sage: dumps({1:1}.get)
b'x\x9ck`J\x8e\x8fO*\xcd\xcc)\xc9\xcc\x8b\x8f\xe7JO-I,))\xe2*d\xa8-dL.NLO\xd5+\xca\xccK/\xd6\xcb\xcc+IMO-\xe2\xcaM\xccN\x8d\x87q\n\x99"\x18\x19\x18\x18\x0c\x0b\x99[\x0bY\x82\nY3\x982\x80,\xb6\xa0B\xf6\xe2\x08f\xa0\x04\xd0\xb4B\x8e\xb6B\xce\xa0B.=\x00X\xd3 \x87'

I don't know why in the first batch of examples, loads(dumps(phi)) == phi returns False in Python 3, but I put in what I hope is a suitable replacement.


New commits:

e3d8e49trac 27466: py3 changes in modules/with_basis/morphism.py

comment:3 in reply to: ↑ 2 Changed 8 months ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

Replying to jhpalmieri:

I don't know why in the first batch of examples, loads(dumps(phi)) == phi returns False in Python 3, but I put in what I hope is a suitable replacement.

My guess is that equality is done by comparing the defining functions, which after pickling are different (because of the different dicts).

This change LGTM.

comment:4 Changed 8 months ago by vbraun

  • Branch changed from u/jhpalmieri/py3-morphism to e3d8e496b2361bcfe5607f76a3323d759e3b6d6d
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.