Skip to content
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

Properly handle integral types other than plain int #909

Merged
merged 3 commits into from
Apr 26, 2018

Conversation

f0k
Copy link
Member

@f0k f0k commented Apr 25, 2018

In a couple of places, Lasagne has isinstance(..., int) checks. Those will fail for a long in Python 2 (which appear in ndarray.shape under Windows), and for np.int64 in Python 3 (which appear in np.prod(ndarray.shape), for example). A generic type check that works both in Python 2 and 3 is isinstance(x, (numbers.Integral, np.integer)).
This PR adds lasagne.utils.int_types, a tuple of numbers.Integral, np.integer, and uses it instead of int where appropriate. It also extends lasagne.utils.as_tuple to allow a type tuple instead of a single type.

Fixes #847.

@f0k f0k merged commit 7992faa into Lasagne:master Apr 26, 2018
@f0k f0k deleted the int_types branch April 26, 2018 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant