-
Notifications
You must be signed in to change notification settings - Fork 58
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
writing bool image is silently ignored #137
Comments
example code: In [2]: h=fitsio.FITS("example_bool.fits","rw") In [3]: a=rand(10) In [4]: h.write(a) In [5]: a=rand(10)>0.5 In [6]: h.write(a) In [7]: h.close() In [8]: h=fitsio.FITS("example_bool.fits") In [9]: h file: example_bool.fits In [10]: |
I'm sorry I missed your report earlier. I think I was traveling at that time and missed a number of things. The code you posted does produce an error for me h=fitsio.FITS("example_bool.fits","rw")
a=numpy.random.random(10)
h.write(a)
a=numpy.random.random(10)>0.5
h.write(a)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
TypeError: Unsupported numpy image datatype 0
The above exception was the direct cause of the following exception:
SystemError Traceback (most recent call last)
<ipython-input-8-b3fad0e0b795> in <module>()
----> 1 h.write(a)
~/miniconda3/lib/python3.6/site-packages/fitsio/fitslib.py in write(self, data, units, extname, extver, compress, tile_dims, header, names, table_type, write_bitcols, **keys)
483 self.write_image(data, extname=extname, extver=extver,
484 compress=compress, tile_dims=tile_dims,
--> 485 header=header)
486 else:
487 self.write_table(data, units=units,
~/miniconda3/lib/python3.6/site-packages/fitsio/fitslib.py in write_image(self, img, extname, extver, compress, tile_dims, header)
537 header=header,
538 extname=extname, extver=extver,
--> 539 compress=compress, tile_dims=tile_dims)
540
541 if header is not None:
~/miniconda3/lib/python3.6/site-packages/fitsio/fitslib.py in create_image_hdu(self, img, dims, dtype, extname, extver, compress, tile_dims, header)
689 tile_dims=tile_dims,
690 extname=extname,
--> 691 extver=extver)
692
693
SystemError: <built-in method create_image_hdu of _fitsio.FITS object at 0x7f4901b75d08> returned a result with an error set |
no problem! I've just tried again at nersc with python 2.7.14, fitsio 0.9.11 and I get the behavior I initially reported. What version of fitsio did you try for your test? I'll see if I can reproduce your error on the same python (3.6?) and fitsio as you. |
Yes, that was 3.6 and numpy 1.13.3, fitsio from recent master |
Have you tried with python 3 or recent fitsio master? |
I've just tried in python3 with fitsio 0.9.11 and I get the same error as you. Is this the expected behavior? Thanks! |
Maybe; I didn't add the boolean support, maybe @dstndstn or @rainwoodman can comment |
Huh, that's confusing because it looks like we handle NPY_BOOL here,
https://github.com/esheldon/fitsio/blob/0f0f34982341e9746a4f78d6df21af3b73998777/fitsio/fitsio_pywrap.c#L819
(and I just checked the numpy headers and NPY_BOOL is enumeration value 0,
matching your error message.)
…On Tue, Mar 20, 2018 at 2:38 PM, Erin Sheldon ***@***.***> wrote:
Maybe; I didn't add the boolean support, maybe @dstndstn
<https://github.com/dstndstn> or @rainwoodman
<https://github.com/rainwoodman> can comment
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#137 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABBD_VrWHxWUnZ3ILvPL9jDLrbmKz7rxks5tgUy0gaJpZM4PxV9f>
.
|
Where do we stand on this one? |
ping |
Hi Erin, I still get an error with FITSIO 1.1.3 and Python 3.9.0
fails with
|
Writing an np.array of bool is silently ignored. Is this on purpose? It would be useful if at least a warning were returned.
The text was updated successfully, but these errors were encountered: