html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/pull/3846#issuecomment-597085649,https://api.github.com/repos/pydata/xarray/issues/3846,597085649,MDEyOklzc3VlQ29tbWVudDU5NzA4NTY0OQ==,14808389,2020-03-10T13:29:04Z,2020-03-10T13:29:04Z,MEMBER,"sounds good. By then I might also have the CLI ready so we hopefully could then use it the same way we use `black`. Also note that it currently requires valid doctest lines. There is at least one instance in the code where that is not true (a missing continuation line prompt (`... `) in the docstring of `DataArray.swap_dims`) so these issues would need to be fixed first, anyways.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,577283480 https://github.com/pydata/xarray/pull/3846#issuecomment-596883896,https://api.github.com/repos/pydata/xarray/issues/3846,596883896,MDEyOklzc3VlQ29tbWVudDU5Njg4Mzg5Ng==,5635139,2020-03-10T03:30:49Z,2020-03-10T03:30:49Z,MEMBER,"That's awesome @keewis ! Cool tool... Shall I merge this and then you do a PR with those changes on top? And from there we can start adding subset of the files to run in CI?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,577283480 https://github.com/pydata/xarray/pull/3846#issuecomment-596859274,https://api.github.com/repos/pydata/xarray/issues/3846,596859274,MDEyOklzc3VlQ29tbWVudDU5Njg1OTI3NA==,14808389,2020-03-10T01:45:22Z,2020-03-10T01:45:22Z,MEMBER,"The tool is at https://github.com/keewis/black-doctest. It is still experimental and is missing a lot of the features `black` has (e.g. no CLI, yet) but here's the output for `dataarray.py`:
changes for xarray/core/dataarray.py ```diff diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index 7a95aedc..0fafd69b 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -875,8 +875,7 @@ class DataArray(AbstractArray, DataWithCoords): Shallow versus deep copy - >>> array = xr.DataArray([1, 2, 3], dims='x', - ... coords={'x': ['a', 'b', 'c']}) + >>> array = xr.DataArray([1, 2, 3], dims=""x"", coords={""x"": [""a"", ""b"", ""c""]}) >>> array.copy() array([1, 2, 3]) @@ -1344,7 +1343,7 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> da = xr.DataArray([1, 3], [('x', np.arange(2))]) + >>> da = xr.DataArray([1, 3], [(""x"", np.arange(2))]) >>> da.interp(x=0.5) array(2.0) @@ -1475,8 +1474,9 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> arr = xr.DataArray(data=[0, 1], dims=""x"", - coords={""x"": [""a"", ""b""], ""y"": (""x"", [0, 1])}) + >>> arr = xr.DataArray( + ... data=[0, 1], dims=""x"", coords={""x"": [""a"", ""b""], ""y"": (""x"", [0, 1])} + ... ) >>> arr array([0, 1]) @@ -1589,12 +1589,11 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> arr = xr.DataArray(data=np.ones((2, 3)), - ... dims=['x', 'y'], - ... coords={'x': - ... range(2), 'y': - ... range(3), 'a': ('x', [3, 4]) - ... }) + >>> arr = xr.DataArray( + ... data=np.ones((2, 3)), + ... dims=[""x"", ""y""], + ... coords={""x"": range(2), ""y"": range(3), ""a"": (""x"", [3, 4])}, + ... ) >>> arr array([[1., 1., 1.], @@ -1603,7 +1602,7 @@ class DataArray(AbstractArray, DataWithCoords): * x (x) int64 0 1 * y (y) int64 0 1 2 a (x) int64 3 4 - >>> arr.set_index(x='a') + >>> arr.set_index(x=""a"") array([[1., 1., 1.], [1., 1., 1.]]) @@ -1718,8 +1717,9 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> arr = DataArray(np.arange(6).reshape(2, 3), - ... coords=[('x', ['a', 'b']), ('y', [0, 1, 2])]) + >>> arr = DataArray( + ... np.arange(6).reshape(2, 3), coords=[(""x"", [""a"", ""b""]), (""y"", [0, 1, 2])] + ... ) >>> arr array([[0, 1, 2], @@ -1727,8 +1727,8 @@ class DataArray(AbstractArray, DataWithCoords): Coordinates: * x (x) |S1 'a' 'b' * y (y) int64 0 1 2 - >>> stacked = arr.stack(z=('x', 'y')) - >>> stacked.indexes['z'] + >>> stacked = arr.stack(z=(""x"", ""y"")) + >>> stacked.indexes[""z""] MultiIndex(levels=[['a', 'b'], [0, 1, 2]], codes=[[0, 0, 0, 1, 1, 1], [0, 1, 2, 0, 1, 2]], names=['x', 'y']) @@ -1768,8 +1768,9 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> arr = DataArray(np.arange(6).reshape(2, 3), - ... coords=[('x', ['a', 'b']), ('y', [0, 1, 2])]) + >>> arr = DataArray( + ... np.arange(6).reshape(2, 3), coords=[(""x"", [""a"", ""b""]), (""y"", [0, 1, 2])] + ... ) >>> arr array([[0, 1, 2], @@ -1777,8 +1778,8 @@ class DataArray(AbstractArray, DataWithCoords): Coordinates: * x (x) |S1 'a' 'b' * y (y) int64 0 1 2 - >>> stacked = arr.stack(z=('x', 'y')) - >>> stacked.indexes['z'] + >>> stacked = arr.stack(z=(""x"", ""y"")) + >>> stacked.indexes[""z""] MultiIndex(levels=[['a', 'b'], [0, 1, 2]], codes=[[0, 0, 0, 1, 1, 1], [0, 1, 2, 0, 1, 2]], names=['x', 'y']) @@ -1817,9 +1818,10 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- >>> import xarray as xr - >>> arr = DataArray(np.arange(6).reshape(2, 3), - ... coords=[('x', ['a', 'b']), ('y', [0, 1, 2])]) - >>> data = xr.Dataset({'a': arr, 'b': arr.isel(y=0)}) + >>> arr = DataArray( + ... np.arange(6).reshape(2, 3), coords=[(""x"", [""a"", ""b""]), (""y"", [0, 1, 2])] + ... ) + >>> data = xr.Dataset({""a"": arr, ""b"": arr.isel(y=0)}) >>> data Dimensions: (x: 2, y: 3) @@ -1829,12 +1831,12 @@ class DataArray(AbstractArray, DataWithCoords): Data variables: a (x, y) int64 0 1 2 3 4 5 b (x) int64 0 3 - >>> stacked = data.to_stacked_array(""z"", ['y']) - >>> stacked.indexes['z'] + >>> stacked = data.to_stacked_array(""z"", [""y""]) + >>> stacked.indexes[""z""] MultiIndex(levels=[['a', 'b'], [0, 1, 2]], labels=[[0, 0, 0, 1], [0, 1, 2, -1]], names=['variable', 'y']) - >>> roundtripped = stacked.to_unstacked_dataset(dim='z') + >>> roundtripped = stacked.to_unstacked_dataset(dim=""z"") >>> data.identical(roundtripped) True @@ -2694,13 +2696,13 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> arr = xr.DataArray([5, 5, 6, 6], [[1, 2, 3, 4]], ['x']) - >>> arr.diff('x') + >>> arr = xr.DataArray([5, 5, 6, 6], [[1, 2, 3, 4]], [""x""]) + >>> arr.diff(""x"") array([0, 1, 0]) Coordinates: * x (x) int64 2 3 4 - >>> arr.diff('x', 2) + >>> arr.diff(""x"", 2) array([ 1, -1]) Coordinates: @@ -2750,7 +2752,7 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> arr = xr.DataArray([5, 6, 7], dims='x') + >>> arr = xr.DataArray([5, 6, 7], dims=""x"") >>> arr.shift(x=1) array([ nan, 5., 6.]) @@ -2800,7 +2802,7 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> arr = xr.DataArray([5, 6, 7], dims='x') + >>> arr = xr.DataArray([5, 6, 7], dims=""x"") >>> arr.roll(x=1) array([7, 5, 6]) @@ -2849,9 +2851,9 @@ class DataArray(AbstractArray, DataWithCoords): -------- >>> da_vals = np.arange(6 * 5 * 4).reshape((6, 5, 4)) - >>> da = DataArray(da_vals, dims=['x', 'y', 'z']) + >>> da = DataArray(da_vals, dims=[""x"", ""y"", ""z""]) >>> dm_vals = np.arange(4) - >>> dm = DataArray(dm_vals, dims=['z']) + >>> dm = DataArray(dm_vals, dims=[""z""]) >>> dm.dims ('z') @@ -2909,9 +2911,11 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> da = xr.DataArray(np.random.rand(5), - ... coords=[pd.date_range('1/1/2000', periods=5)], - ... dims='time') + >>> da = xr.DataArray( + ... np.random.rand(5), + ... coords=[pd.date_range(""1/1/2000"", periods=5)], + ... dims=""time"", + ... ) >>> da array([ 0.965471, 0.615637, 0.26532 , 0.270962, 0.552878]) @@ -3052,8 +3056,8 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> arr = xr.DataArray([5, 6, 7], dims='x') - >>> arr.rank('x') + >>> arr = xr.DataArray([5, 6, 7], dims=""x"") + >>> arr.rank(""x"") array([ 1., 2., 3.]) Dimensions without coordinates: x @@ -3093,8 +3097,11 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> da = xr.DataArray(np.arange(12).reshape(4, 3), dims=['x', 'y'], - ... coords={'x': [0, 0.1, 1.1, 1.2]}) + >>> da = xr.DataArray( + ... np.arange(12).reshape(4, 3), + ... dims=[""x"", ""y""], + ... coords={""x"": [0, 0.1, 1.1, 1.2]}, + ... ) >>> da array([[ 0, 1, 2], @@ -3105,7 +3112,7 @@ class DataArray(AbstractArray, DataWithCoords): * x (x) float64 0.0 0.1 1.1 1.2 Dimensions without coordinates: y >>> - >>> da.differentiate('x') + >>> da.differentiate(""x"") array([[30. , 30. , 30. ], [27.545455, 27.545455, 27.545455], @@ -3147,8 +3154,11 @@ class DataArray(AbstractArray, DataWithCoords): Examples -------- - >>> da = xr.DataArray(np.arange(12).reshape(4, 3), dims=['x', 'y'], - ... coords={'x': [0, 0.1, 1.1, 1.2]}) + >>> da = xr.DataArray( + ... np.arange(12).reshape(4, 3), + ... dims=[""x"", ""y""], + ... coords={""x"": [0, 0.1, 1.1, 1.2]}, + ... ) >>> da array([[ 0, 1, 2], @@ -3159,7 +3169,7 @@ class DataArray(AbstractArray, DataWithCoords): * x (x) float64 0.0 0.1 1.1 1.2 Dimensions without coordinates: y >>> - >>> da.integrate('x') + >>> da.integrate(""x"") array([5.4, 6.6, 7.8]) Dimensions without coordinates: y ```
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,577283480 https://github.com/pydata/xarray/pull/3846#issuecomment-596199930,https://api.github.com/repos/pydata/xarray/issues/3846,596199930,MDEyOklzc3VlQ29tbWVudDU5NjE5OTkzMA==,14808389,2020-03-08T12:25:27Z,2020-03-08T12:25:27Z,MEMBER,"I wouldn't vendor exactly that script since it looks more like a proof-of-concept. I'm currently trying to rewrite it so if that works out I'd propose to use that instead. In the future, we might be able to use the `black` executable for this since they're currently considering it: psf/black#144","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,577283480 https://github.com/pydata/xarray/pull/3846#issuecomment-596159599,https://api.github.com/repos/pydata/xarray/issues/3846,596159599,MDEyOklzc3VlQ29tbWVudDU5NjE1OTU5OQ==,5635139,2020-03-08T02:38:30Z,2020-03-08T02:38:30Z,MEMBER,"> would it make sense to apply `black` to the doctest lines? The only thing I found was a [script](https://gist.github.com/mattharrison/2a1a263597d80e99cf85e898b800ec32) which from a quick glance over the code extracts the doctest lines one by one, strips the prompt, applies black to it and puts back the prompt. It is not as convenient as the `black` executable but it could help with bringing the comfort of `black` to the doctest lines. > > If we do want to use something like that, it would probably be good to find a maintained tool. For sure! I'm not sure there is a maintained tool... We could vendor the script?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,577283480 https://github.com/pydata/xarray/pull/3846#issuecomment-596151353,https://api.github.com/repos/pydata/xarray/issues/3846,596151353,MDEyOklzc3VlQ29tbWVudDU5NjE1MTM1Mw==,14808389,2020-03-08T00:17:21Z,2020-03-08T00:17:21Z,MEMBER,"would it make sense to apply `black` to the doctest lines? The only thing I found was a [script](https://gist.github.com/mattharrison/2a1a263597d80e99cf85e898b800ec32) which from a quick glance over the code extracts the doctest lines one by one, strips the prompt, applies black to it and puts back the prompt. It is not as convenient as the `black` executable but it could help with bringing the comfort of `black` to the doctest lines. If we do want to use something like that, it would probably be good to find a maintained tool.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,577283480