0% found this document useful (0 votes)
3 views1 page

NumPy Array Element Tests

Uploaded by

nehatanveer
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

NumPy Array Element Tests

Uploaded by

nehatanveer
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

Test None are Zero


import numpy as np

x = [Link]([1, 2, 3, 4])

print("Original array:")
print(x)

print("Test if none of the elements of the said array is zero:")


print([Link](x))

x = [Link]([0, 1, 2, 3])

print("Original array:")
print(x)

print("Test if none of the elements of the said array is zero:")


print([Link](x))

2. Test Any Non-Zero


import numpy as np

x = [Link]([1, 0, 0, 0])

print("Original array:")
print(x)

print("Test whether any of the elements of a given array is non-zero:")


print([Link](x))

x = [Link]([0, 0, 0, 0])

print("Original array:")
print(x)

print("Test whether any of the elements of a given array is non-zero:")


print([Link](x))

3. Test Finiteness of Elements


import numpy as np

a = [Link]([1, 0, [Link], [Link]])

print("Original array")
print(a)

print("Test a given array element-wise for finiteness :")


print([Link](a))

You might also like