MCPcopy Create free account
hub / github.com/PyTables/PyTables / areArraysEqual

Function areArraysEqual

tables/tests/common.py:209–228  ·  view source on GitHub ↗

Are both `arr1` and `arr2` equal arrays? Arguments can be regular NumPy arrays, chararray arrays or structured arrays (including structured record arrays). They are checked for type and value equality.

(arr1, arr2, *, check_type=True)

Source from the content-addressed store, hash-verified

207
208
209def areArraysEqual(arr1, arr2, *, check_type=True):
210 """Are both `arr1` and `arr2` equal arrays?
211
212 Arguments can be regular NumPy arrays, chararray arrays or
213 structured arrays (including structured record arrays). They are
214 checked for type and value equality.
215
216 """
217
218 t1 = type(arr1)
219 t2 = type(arr2)
220
221 if check_type and not (
222 (hasattr(arr1, "dtype") and arr1.dtype == arr2.dtype)
223 or issubclass(t1, t2)
224 or issubclass(t2, t1)
225 ):
226 return False
227
228 return np.all(arr1 == arr2)
229
230
231class PyTablesTestCase(unittest.TestCase):

Callers 1

_checkEqualityLeafMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected