Reputation: 73
I would like to get the elemental modulus (each element of the array is modulated by number x and returned in array format) of the following numpy array:
test = numpy.array([
[5, 2],
[1, 4]
])
How can I go about doing this?
Upvotes: 1
Views: 1487
Reputation: 71610
Use numpy.mod
, demo:
>>> import numpy
>>> test = numpy.array([
[5, 2],
[1, 4]
])
>>> numpy.mod(test,2)
array([[1, 0],
[1, 0]], dtype=int32)
>>>
Upvotes: 2