Change doctests to Python 3 #3690#3744
Conversation
mrocklin
left a comment
There was a problem hiding this comment.
This is fantastic. Thank you for solving this @eric-bonfadini . I have one small comment, but generally this looks great to me. Thank you so much.
dask/array/slicing.py
Outdated
| >>> exp_res = {0: slice(-2, -8, -3), 1: slice(-1, -21, -3), 2: slice(-3, -21, -3), | ||
| ... 3: slice(-2, -21, -3), 4: slice(-1, -21, -3)} | ||
| >>> _slice_1d(100, [20, 20, 20, 20, 20], slice(100, 12, -3)) == exp_res | ||
| True |
There was a problem hiding this comment.
Would it be possible to include full results here in the output rather than explicitly test? In Python 3.6 we can probably depend on deterministic dict ordering. We could probably also use the # doctest: +NORMALIZE_WHITESPACE pragma to help improve the styling, perhaps something like the following?
>>> _slice_1d(100, [20, 20, 20, 20, 20], slice(100, 12, -3)) # doctest: +NORMALIZE_WHITESPACE
{0: slice(-2, -8, -3),
1: slice(-1, -21, -3),
2: slice(-3, -21, -3),
3: slice(-2, -21, -3),
4: slice(-1, -21, -3)}
There was a problem hiding this comment.
I originally used the # doctest: +NORMALIZE_WHITESPACE pragma, but in the end I stuck to the doctests documentation workaround: https://docs.python.org/3.6/library/doctest.html#warnings
I agree that with full results and pragma we can improve readability and styling, I will have a look and I will modify this part.
|
Looks good! It seems that there are a couple of small dictionary ordering issues. You can see them here: https://travis-ci.org/dask/dask/jobs/402509642 |
|
This happens because pprint just sorts dicts entries, while sets are printed with a standard repr and not sorted. I didn't notice locally because I had a In order to fix this issue we have some options: Do you have a preferred option? |
|
I suggest that we just skip the doctest. The documentation value is
probably greater here than the testing value, which is very likely covered
elsewhere.
…On Wed, Jul 11, 2018 at 4:23 PM, Eric Bonfadini ***@***.***> wrote:
This happens because pprint just sorts dicts entries, while sets are
printed with a standard repr and not sorted.
You can double check by running a few times this simple script, sometimes
you will get "{'y', 'z'}", sometime "{'z', 'y'}":
python3 -c "from pprint import pprint; pprint({'dependencies': {'w': {'y',
'z'}}})"
I didn't notice locally because I had a export PYTHONHASHSEED=42 in my
local env that was hiding the issue (in the travis run for non parallel
builds PYTHONHASHSEED is not set).
Moreover, in the previous build (https://travis-ci.org/dask/
dask/jobs/402406831) that test run correctly.
In order to fix this issue we have some options:
1 - compare the function result with the expected value, like explained in
https://docs.python.org/3.6/library/doctest.html#warnings
2 - sort the function result before running the test
3 - set the PYTHONHASHSEED even in non parallel builds
Do you have a preferred option?
Or do you have a better one I didn't think of?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3744 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASszLZdGCreYPE8eIGoypPBnpXX15YGks5uFmzKgaJpZM4VKH47>
.
|
|
# doctest: +SKIP
On Wed, Jul 11, 2018 at 5:17 PM, Matthew Rocklin <mrocklin@anaconda.com>
wrote:
… I suggest that we just skip the doctest. The documentation value is
probably greater here than the testing value, which is very likely covered
elsewhere.
On Wed, Jul 11, 2018 at 4:23 PM, Eric Bonfadini ***@***.***>
wrote:
> This happens because pprint just sorts dicts entries, while sets are
> printed with a standard repr and not sorted.
> You can double check by running a few times this simple script, sometimes
> you will get "{'y', 'z'}", sometime "{'z', 'y'}":
> python3 -c "from pprint import pprint; pprint({'dependencies': {'w':
> {'y', 'z'}}})"
>
> I didn't notice locally because I had a export PYTHONHASHSEED=42 in my
> local env that was hiding the issue (in the travis run for non parallel
> builds PYTHONHASHSEED is not set).
> Moreover, in the previous build (https://travis-ci.org/dask/da
> sk/jobs/402406831) that test run correctly.
>
> In order to fix this issue we have some options:
> 1 - compare the function result with the expected value, like explained
> in https://docs.python.org/3.6/library/doctest.html#warnings
> 2 - sort the function result before running the test
> 3 - set the PYTHONHASHSEED even in non parallel builds
>
> Do you have a preferred option?
> Or do you have a better one I didn't think of?
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#3744 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AASszLZdGCreYPE8eIGoypPBnpXX15YGks5uFmzKgaJpZM4VKH47>
> .
>
|
|
This looks great! Thanks @eric-bonfadini ! Merging. |
This fixes #3690
Modified travis.yml and documentation accordingly.
Modified some doctests in order to run with Python 3.6 (mainly sets, bytes, unicode, etc)
flake8 dask