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

py3: replace <type by <... (in pyx files of rings folder) #24228

Closed
fchapoton opened this issue Nov 16, 2017 · 26 comments
Closed

py3: replace <type by <... (in pyx files of rings folder) #24228

fchapoton opened this issue Nov 16, 2017 · 26 comments

Comments

@fchapoton
Copy link
Contributor

part of #16085

CC: @embray

Component: python3

Author: Frédéric Chapoton

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/24228

@fchapoton fchapoton added this to the sage-8.1 milestone Nov 16, 2017
@fchapoton
Copy link
Contributor Author

Commit: 1113dea

@fchapoton
Copy link
Contributor Author

New commits:

1113deapy3: replace by <... 'xxx'> in the doctests of rings/ pyx files

@fchapoton
Copy link
Contributor Author

Branch: u/chapoton/24228

@fchapoton

This comment has been minimized.

@tscrim
Copy link
Collaborator

tscrim commented Nov 16, 2017

comment:3

LGTM if green patchbot.

@tscrim
Copy link
Collaborator

tscrim commented Nov 16, 2017

Reviewer: Travis Scrimshaw

@fchapoton
Copy link
Contributor Author

comment:4

Thanks

@embray
Copy link
Contributor

embray commented Nov 20, 2017

comment:5

Personally I'm -1 on changing this en mass, purely from the perspective of documentation quality. If these were all pure tests that aren't shown in the documentation that would be one thing, but when it comes to usage examples I don't like it. It would be nicer to just display one or the other (probably <class ...> for forward-compatibility), and handle the difference in the doctest output checker.

@embray
Copy link
Contributor

embray commented Nov 21, 2017

comment:6

I'm working on an update to the output checker to be flexible about this. Would you consider putting these tickets on hold instead?

@embray
Copy link
Contributor

embray commented Nov 21, 2017

comment:8

Please see #24258

@tscrim
Copy link
Collaborator

tscrim commented Nov 22, 2017

comment:9

I think it would cause more problems/confusion for the user to unexpectedly get something different than when they ran the test (assuming they understand ...). Moreover, I feel that #24258 makes the conversion to Python3 harder because it suppresses the distinctions in a hidden way as opposed to the clearly hacked ... approach. I do agree that it does make the doctests less clean. However, I have less invested than others on Python3, so perhaps they can comment.

From a quick look, a number of the tests probably could be better implemented to not create the output difference (i.e. explicitly test against the type or not have output). So we might also want to spend some effort on that rather than relying on workarounds.

@embray
Copy link
Contributor

embray commented Nov 22, 2017

comment:10

Replying to @tscrim:

I think it would cause more problems/confusion for the user to unexpectedly get something different than when they ran the test (assuming they understand ...). Moreover, I feel that #24258 makes the conversion to Python3 harder because it suppresses the distinctions in a hidden way as opposed to the clearly hacked ... approach. I do agree that it does make the doctests less clean. However, I have less invested than others on Python3, so perhaps they can comment.

From a quick look, a number of the tests probably could be better implemented to not create the output difference (i.e. explicitly test against the type or not have output). So we might also want to spend some effort on that rather than relying on workarounds.

This is the problem with using doctests everywhere. From a documentation standpoint looking at the repr is more interesting. It depends, to me, if the test is in an "EXAMPLES" block or a "TESTS" block. In the former case I think it should be more interesting for reading purposes.

Casual readers of the docs don't necessarily know what ... means in this context. In many cases it's pretty clear (e.g. trailing ellipses at the end of some long floating point expansion). But here it's just awkward and ugly. For the purposes of testing, especially considering that Python 3 is currently not the default (and won't be for still quite a while) it's better to leave existing tests alone as much as possible and adapt minor repr differences to Python 3 only.

@tscrim
Copy link
Collaborator

tscrim commented Nov 22, 2017

comment:11

We are in agreement that they are not pretty, but I think it is much better to show the differences between Python2 and Python3 doctests. Actually, perhaps the best solution would be the output flag suggested on #24261 along with writing better doctests in the cases we can. Thoughts?

@embray
Copy link
Contributor

embray commented Nov 23, 2017

comment:12

It's better in cases that actually matter--this is just a trivial formatting difference that does not impact the validity of the relevant tests (one can invent a pathological case where it matters, such as replacing the builtin int with a user-defined class named "int"). By putting in "..." anywhere one isn't "showing" anything, just brushing the difference under the rug, rather than handling it an explicitly and restrictively.

@embray
Copy link
Contributor

embray commented Nov 23, 2017

comment:13

Also, the point of #24261 is specifically for those relatively rare cases where there is an expected non-trivial difference in behavior between Python 2 and 3. Using it for this case would mean hundreds of examples like

<type 'int'>  # py2
<class 'int'>  # py3

See? It's silly when you look at it that way.

@embray
Copy link
Contributor

embray commented Dec 15, 2017

comment:14

I see a bunch of these got merged anyways since I didn't change the status on them. I'd really prefer to undo that.

@tscrim
Copy link
Collaborator

tscrim commented Dec 15, 2017

comment:15

For the record, I will not actively oppose (up to suggesting changing the appropriate doctests to remove the compatibility issue), but I will not be reviewing those tickets either.

@embray
Copy link
Contributor

embray commented Dec 15, 2017

comment:16

I still don't understand your opposition here. It feels like a bikeshed. We're just talking about making a few documentation examples work more easily testable.

@jdemeyer
Copy link

comment:17

Whatever you do, please beware of conflicts with #24350. I already had several merge conflicts because of changing <type to <....

@tscrim
Copy link
Collaborator

tscrim commented Dec 15, 2017

comment:18

Replying to @embray:

I still don't understand your opposition here. It feels like a bikeshed. We're just talking about making a few documentation examples work more easily testable.

How I see your proposal is that we should hide much more of the difference between Python2/3 by making the framework itself more complicated (and thus more prone to bugs). So IMO it is far from bikeshedding. But like I said, I am not opposing your proposal, but instead choosing not to support it.

Really, we should have very minimal tests that honestly need to include a check that has the output type/class there. Some better (and more robust) checks would be to do isinstance(foo, Bar). So I doubt we would really have to have hundreds of cases as you say in comment:13. However, that might require looking a bit at the actual doctest itself, and so it is not so mechanical of a change.

@embray
Copy link
Contributor

embray commented Dec 15, 2017

comment:19

It's really not complicated...

@embray
Copy link
Contributor

embray commented Dec 15, 2017

comment:20

Replying to @jdemeyer:

Whatever you do, please beware of conflicts with #24350. I already had several merge conflicts because of changing <type to <....

Perhaps in that case we could revert those changes. I meant to put the other tickets for that on hold as well...

@fchapoton
Copy link
Contributor Author

comment:21

Let us close this one as invalid for the time being, please. This will only become a serious issue when we can start to run the tests in python3.

@fchapoton fchapoton removed this from the sage-8.1 milestone Dec 15, 2017
@fchapoton
Copy link
Contributor Author

comment:22

Erik, could you please close this one ?

@fchapoton
Copy link
Contributor Author

Changed branch from u/chapoton/24228 to none

@fchapoton
Copy link
Contributor Author

Changed commit from 1113dea to none

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

No branches or pull requests

4 participants