Re: [Numpy-discussion] Math Inspector Beta
Very cool! But the Mac disk image (mathinspector_0.9.1.dmg) isn't opening ("corrupt image"). It's 145279488 bytes and the shasum ends with f1ed9231. ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Unreliable crash when converting using numpy.asarray via C buffer interface
On Tue, Jan 26, 2021 at 3:50 AM Friedrich Romstedt wrote: > > Hi, > > This is with Python 3.8.2 64-bit and numpy 1.19.2 on Windows 10. I'd > like to be able to convert some C++ extension type to a numpy array by > using ``numpy.asarray``. The extension type implements the Python > buffer interface to support this. > > The extension type, called "Image" here, holds some chunk of > ``double``, C order, contiguous, 2 dimensions. It "owns" the buffer; > the buffer is not shared with other objects. The following Python > code crashes:: > > image = <... Image production ...> > ar = numpy.asarray(image) > > However, when I say:: > > image = <... Image production ...> > print("---") > ar = numpy.asarray(image) > > the entire program is executing properly with correct data in the > numpy ndarray produced using the buffer interface. Maybe a dereference bug. Try setting pointers to NULL after freeing, something like this: delete[] view->shape; view->shape = NULL; delete[] view->strides; view->strides = NULL; ... delete[] self->data; self->data = NULL; ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Unreliable crash when converting using numpy.asarray via C buffer interface
On Mon, Feb 15, 2021 at 7:35 PM Mansour Moufid wrote: > > On Tue, Jan 26, 2021 at 3:50 AM Friedrich Romstedt > wrote: > > > > Hi, > > > > This is with Python 3.8.2 64-bit and numpy 1.19.2 on Windows 10. I'd > > like to be able to convert some C++ extension type to a numpy array by > > using ``numpy.asarray``. The extension type implements the Python > > buffer interface to support this. > > > > The extension type, called "Image" here, holds some chunk of > > ``double``, C order, contiguous, 2 dimensions. It "owns" the buffer; > > the buffer is not shared with other objects. The following Python > > code crashes:: > > > > image = <... Image production ...> > > ar = numpy.asarray(image) > > > > However, when I say:: > > > > image = <... Image production ...> > > print("---") > > ar = numpy.asarray(image) > > > > the entire program is executing properly with correct data in the > > numpy ndarray produced using the buffer interface. > > Maybe a dereference bug. > > Try setting pointers to NULL after freeing, something like this: > > delete[] view->shape; > view->shape = NULL; > delete[] view->strides; > view->strides = NULL; > > ... > > delete[] self->data; > self->data = NULL; Sorry for two messages in a row, I just noticed: I don't see the type's tp_free member defined? You can set it to PyObject_Free in Init_ImageType: ImageType.tp_free = PyObject_Free; See here: https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_free ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Re: dtype=(bool) vs dtype=bool
On Tue, Oct 19, 2021 at 9:43 AM wrote: > > See the following testing in IPython shell: > > In [6]: import numpy as np > > In [7]: a = np.array([1], dtype=(bool)) > > In [8]: b = np.array([1], dtype=bool) > > In [9]: a > Out[9]: array([ True]) > > In [10]: b > Out[10]: array([ True]) > > It seems that dtype=(bool) and dtype=bool are both correct usages. If so, > which is preferable? For a one-element tuple, add a comma: >>> bool >>> (bool) >>> (bool,) (,) ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com