a = np.ndarray([1,1]).astype(np.half)
a
array([[0.007812]], dtype=float16)
a.dtype
dtype('float16')
a.dtype == np.half
True
a.dtype == np.float16
True
a.dtype is np.float16
False
Checking with is leads to inconsistency in checking.
Differential D139121
Replacing `is` with `==` for the dtype check. pashu123 on Dec 1 2022, 8:31 AM. Authored by
Details
array([[0.007812]], dtype=float16)
dtype('float16')
True
True
False Checking with is leads to inconsistency in checking.
Diff Detail
Event TimelineComment Actions LGTM. Maybe add a comment with a link to here for context: https://stackoverflow.com/questions/26921836/correct-way-to-test-for-numpy-dtype |