Repository navigation
Closed
Description
Probably numpy dev did something to the dtypes in print outs? Since these doctests still pass with stable numpy, we might have to resort to ELLIPSIS or maxversion pin numpy for doctest in these RST files. What do you think, @mhvk and @saimn ?
_____________________________ [doctest] index.rst ______________________________
436 >>> print(data[1, 4])
437 348
438
439 Note that, like C (and unlike Fortran), Python is 0-indexed and the indices
440 have the slowest axis first and fastest changing axis last; that is, for a 2D
441 image, the fast axis (X-axis) which corresponds to the FITS NAXIS1 keyword, is
442 the second index. Similarly, the 1-indexed subsection of x=11 to 20
443 (inclusive) and y=31 to 40 (inclusive) would be given in Python as::
444
445 >>> data[30:40, 10:20]
Differences (unified diff with -expected +actual):
@@ -8,3 +8,3 @@
[349, 349, 350, 348, 350, 347, 349, 349, 349, 348],
[349, 348, 348, 348, 348, 348, 349, 347, 349, 348],
- [349, 349, 349, 348, 350, 349, 349, 350, 348, 350]], dtype=int16)
+ [349, 349, 349, 348, 350, 349, 349, 350, 348, 350]], dtype='>i2')
docs/io/fits/index.rst:445: DocTestFailure
_____________________________ [doctest] image.rst ______________________________
041
042 >>> from astropy.io import fits
043 >>> fits_image_filename = fits.util.get_testdata_filepath('test0.fits')
044
045 >>> with fits.open(fits_image_filename) as hdul: # open a FITS file
046 ... data = hdul[1].data # assume the first extension is an image
047 >>> print(data[1, 4]) # get the pixel value at x=5, y=2
048 313
049 >>> # get values of the subsection from x=11 to 20, y=31 to 40 (inclusive)
050 >>> data[30:40, 10:20]
Differences (unified diff with -expected +actual):
@@ -8,3 +8,3 @@
[314, 313, 312, 313, 313, 314, 312, 312, 311, 314],
[313, 313, 313, 314, 313, 313, 315, 313, 312, 313],
- [314, 313, 313, 314, 313, 312, 312, 314, 310, 314]], dtype=int16)
+ [314, 313, 313, 314, 313, 312, 312, 314, 310, 314]], dtype='>i2')
docs/io/fits/usage/image.rst:50: DocTestFailure
___________________________ [doctest] unfamiliar.rst ___________________________
294 Examples
295 ^^^^^^^^
296
297 ..
298 EXAMPLE START
299 Group Parameters in Random Access Group HDUs
300
301 To show the contents of the third group, including parameters and data::
302
303 >>> hdul[0].data[2] # doctest: +FLOAT_CMP
Differences (unified diff with -expected +actual):
@@ -1,3 +1,3 @@
-(2.0999999, 42.0, 42.0, array([[[[30., 31., 32., 33., 34.],
+(2.1, 42.0, 42.0, array([[[[30., 31., 32., 33., 34.],
[35., 36., 37., 38., 39.],
- [40., 41., 42., 43., 44.]]]], dtype=float32))
+ [40., 41., 42., 43., 44.]]]], dtype='>f4'))
docs/io/fits/usage/unfamiliar.rst:303: DocTestFailure
Activity
saimn commentedon Mar 17, 2023
Due to numpy/numpy#23295.
Yes I guess we will need ELLIPSIS.
mhvk commentedon Mar 17, 2023
Ah, yes, numpy wanted to be sure one could see the endianness of data if not the default -- which is probably for the better.
I guess this similar to what we'll be doing to our downstream with the unit format changes in #14439, so perhaps we should use @pllim's suggested solution in #14526? I.e., only run the tests for relevant numpy. I think that is better than
..., since it doesn't distract the reader of the documentation (arguably more important than having our doctests run for every version of numpy).Alternatively, we could use
print(...), which avoids the dtype altogether (but also not as good for the reader, since less natural).pllim commentedon Mar 17, 2023
Thanks for the inputs! See #14550 🤞