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)
| 207 | |
| 208 | |
| 209 | def 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 | |
| 231 | class PyTablesTestCase(unittest.TestCase): |