wearepal / data-science-types

Mypy stubs, i.e., type information, for numpy, pandas and matplotlib
Apache License 2.0
202 stars 51 forks source link

add support for unsigned integers #131

Closed Maarten-vd-Sande closed 4 years ago

Maarten-vd-Sande commented 4 years ago

As mentioned briefly in #130, I added support for unsigned integers. When adding unsigned + unsigned -> unsigned, but unsigned + signed -> signed.

Now the still missing datatypes are: np.intp, np.uintp, np.complex64, np.complex128

But I am not entirely sure how to add them, and they are quite niche (even more so than unsigned ;) )

Maarten-vd-Sande commented 4 years ago

Ah, let me add some tests!

edit: absolutely no clue how type-hinting tests work :angel:, should I add some? If so I would need some pointers

tmke8 commented 4 years ago

type-hinting tests are a big problem. I'm not really happy with how we're doing them, but I haven't found a better solution.

That said, something like this would be nice (in the numpy test file):

def test_unsigned() -> None:
    x: np.ndarray[np.uint8] = np.array([3, 4], dtype=np.uint8)
    y: np.ndarray[np.uint8] = x + x
    z: np.ndarray[np.int32] = y
Maarten-vd-Sande commented 4 years ago

@thomkeh I added the tests. Thanks for the help :)

tmke8 commented 4 years ago

Great, thanks!