Opened 5 years ago

Closed 4 years ago

#18743 closed defect (fixed)

Display does not support the 'ascii_art' option of _repr_option

Reported by: tscrim Owned by: tscrim
Priority: major Milestone: sage-6.9
Component: interfaces Keywords: fancy repr
Cc: vbraun, jdemeyer, elixyre, jpflori, SimonKing, kdilks Merged in:
Authors: Travis Scrimshaw Reviewers: Kevin Dilks
Report Upstream: N/A Work issues:
Branch: 7bc49f5 (Commits) Commit: 7bc49f55af4b8758616f75855037387b89410b92
Dependencies: Stopgaps:

Description

The following does not behave as it should:

sage: class Foo(object):
....:     def __repr__(self):
....:         return '''BBB    AA   RRR
....: B  B  A  A  R  R
....: BBB   AAAA  RRR
....: B  B  A  A  R  R
....: BBB   A  A  R   R'''
....:     def _repr_option(self, key):
....:         return key == 'ascii_art'
sage: F = Foo()
sage: [F, F]

Change History (11)

comment:1 Changed 5 years ago by tscrim

  • Branch set to public/interfaces/repr_option_ascii_art-18743
  • Commit set to 15729ebe846214cb60a6e8b0a9637b1829d9465f
  • Status changed from new to needs_review

New commits:

15729ebAdded support for _repr_option('ascii_art').

comment:2 Changed 5 years ago by git

  • Commit changed from 15729ebe846214cb60a6e8b0a9637b1829d9465f to 20bd15dd22b857e41bbe50244112f6128c8082bb

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

20bd15dAdded support for _repr_option('ascii_art').

comment:3 Changed 5 years ago by tscrim

  • Cc elixyre jpflori SimonKing added
  • Status changed from needs_review to needs_work

I am completely dumbfounded as to why this addition causes the failing doctests in interfaces/psage.py. It fails in the original code

ascii_art_repr = ascii_art_repr or o.parent()._repr_option('element_ascii_art')

but only when I've added the line before it! I know I could simply add NonImplementedError or a general Exception as the except types, but this makes me feel like I'm covering up errors that should be allowed to propagate.

Jean-Pierre and Simon, I've cc-ed you incase you had any insight as you were the most recent listed authors to interfaces/expect.py (and have made significant changes and are not currently cc-ed).

comment:4 Changed 5 years ago by vbraun

Is there a __getattr__ hack somewhere in the interface?

Last edited 5 years ago by vbraun (previous) (diff)

comment:5 Changed 5 years ago by tscrim

Would this count: in interfaces.sage0.SageElement

    def __getattr__(self, attrname):
        """
        EXAMPLES::

            sage: m = sage0(4)
            sage: four_gcd = m.gcd
            sage: type(four_gcd)
            <class 'sage.interfaces.sage0.SageFunction'>
        """
        self._check_valid()
        return SageFunction(self, attrname)

comment:6 Changed 5 years ago by git

  • Commit changed from 20bd15dd22b857e41bbe50244112f6128c8082bb to 7bc49f55af4b8758616f75855037387b89410b92

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

6285150Merge branch 'public/interfaces/repr_option_ascii_art-18743' of trac.sagemath.org:sage into public/interfaces/repr_option_ascii_art-18743
7bc49f5Adding `_repr_option` to the interface element to avoid __getattr__.

comment:7 Changed 5 years ago by tscrim

  • Status changed from needs_work to needs_review

Yes, that was the issue. I've just returned False anytime _repr_option is called to avoid calling the __getattr__. Thanks.

Needs review. Should be easy enough at this point.

comment:8 Changed 5 years ago by tscrim

  • Milestone changed from sage-6.8 to sage-6.9

comment:9 Changed 4 years ago by tscrim

  • Cc kdilks added

comment:10 Changed 4 years ago by kdilks

  • Reviewers set to Kevin Dilks
  • Status changed from needs_review to positive_review

comment:11 Changed 4 years ago by vbraun

  • Branch changed from public/interfaces/repr_option_ascii_art-18743 to 7bc49f55af4b8758616f75855037387b89410b92
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.