numpy/numpy — pull request #4916 by yotam (2014-07-29 15:05:10+00:00)
Title: BUG: Avoid type promotion in tril and triu.

This looks like it was originally fixed in [an old commit](https://github.com/numpy/numpy/commit/1af2f37eae78986b370e2d44df6c5156945d69d8), however the issue was reintroduced by the refactoring in [a recent commit](https://github.com/numpy/numpy/commit/1392888ec4ddb37d4fa7bbb9231712af0dda4ea6). This commit maintains the datatype of the array in `np.triu` and `np.tril`.

Before

>>> import numpy as np
>>> a = np.array([[0, 1], [1, 0]], dtype=np.bool)
>>> a
array([[False, True],
[ True, False]], dtype=bool)
>>> np.triu(a)
array([[0, 1],
[0, 0]])

After

>>> import numpy as np
>>> a = np.array([[0, 1], [1, 0]], dtype=np.bool)
>>> a
array([[False, True],
[ True, False]], dtype=bool)
>>> np.triu(a)
array([[False, True],
[False, False]], dtype=bool)
>>>