pocketpy / gsoc-2024-dev

GSoC'24 develop repository for pybind11 and numpy
https://pocketpy.dev/gsoc/ideas/
6 stars 1 forks source link

Added the boolean dtype #43

Closed faze-geek closed 1 month ago

faze-geek commented 1 month ago

I added the bool dtype and this snippet from the test file now works -

(base) anurag@Anurags-MacBook-Air build % python3                                
Python 3.12.3 | packaged by Anaconda, Inc. | (main, May  6 2024, 14:46:42) [Clang 14.0.6 ] on darwin

>>> import numpy_bindings as np
>>> a = np.array([[1, 0], [0, 1]], dtype=np.bool_)
>>> a
 array([[ true, false],
        [false,  true]])
>>> a == np.array([[True, False], [False, True]])
 array([[ true,  true],
        [ true,  true]])
>>> (a & 1 == np.array([[1, 0], [0, 1]], dtype=np.bool_)).all()
 True
>>> (a | 1 == np.array([[1, 1], [1, 1]], dtype=np.bool_)).all()
 True
>>> (a ^ 1 == np.array([[0, 1], [1, 0]], dtype=np.bool_)).all()
 True
>>> (~a == np.array([[0, 1], [1, 0]], dtype=np.bool_)).all()
 True

However this works with the original pybind11. It doesn't build with the our implementation of pybind11 due to an error with it's stl. @ykiko Can you investigate the build failure here.