(self, kind)
| 258 | |
| 259 | @pytest.mark.parametrize("kind", [None, "sort", "table"]) |
| 260 | def test_in1d(self, kind): |
| 261 | # we use two different sizes for the b array here to test the |
| 262 | # two different paths in in1d(). |
| 263 | for mult in (1, 10): |
| 264 | # One check without np.array to make sure lists are handled correct |
| 265 | a = [5, 7, 1, 2] |
| 266 | b = [2, 4, 3, 1, 5] * mult |
| 267 | ec = np.array([True, False, True, True]) |
| 268 | c = in1d(a, b, assume_unique=True, kind=kind) |
| 269 | assert_array_equal(c, ec) |
| 270 | |
| 271 | a[0] = 8 |
| 272 | ec = np.array([False, False, True, True]) |
| 273 | c = in1d(a, b, assume_unique=True, kind=kind) |
| 274 | assert_array_equal(c, ec) |
| 275 | |
| 276 | a[0], a[3] = 4, 8 |
| 277 | ec = np.array([True, False, True, False]) |
| 278 | c = in1d(a, b, assume_unique=True, kind=kind) |
| 279 | assert_array_equal(c, ec) |
| 280 | |
| 281 | a = np.array([5, 4, 5, 3, 4, 4, 3, 4, 3, 5, 2, 1, 5, 5]) |
| 282 | b = [2, 3, 4] * mult |
| 283 | ec = [False, True, False, True, True, True, True, True, True, |
| 284 | False, True, False, False, False] |
| 285 | c = in1d(a, b, kind=kind) |
| 286 | assert_array_equal(c, ec) |
| 287 | |
| 288 | b = b + [5, 5, 4] * mult |
| 289 | ec = [True, True, True, True, True, True, True, True, True, True, |
| 290 | True, False, True, True] |
| 291 | c = in1d(a, b, kind=kind) |
| 292 | assert_array_equal(c, ec) |
| 293 | |
| 294 | a = np.array([5, 7, 1, 2]) |
| 295 | b = np.array([2, 4, 3, 1, 5] * mult) |
| 296 | ec = np.array([True, False, True, True]) |
| 297 | c = in1d(a, b, kind=kind) |
| 298 | assert_array_equal(c, ec) |
| 299 | |
| 300 | a = np.array([5, 7, 1, 1, 2]) |
| 301 | b = np.array([2, 4, 3, 3, 1, 5] * mult) |
| 302 | ec = np.array([True, False, True, True, True]) |
| 303 | c = in1d(a, b, kind=kind) |
| 304 | assert_array_equal(c, ec) |
| 305 | |
| 306 | a = np.array([5, 5]) |
| 307 | b = np.array([2, 2] * mult) |
| 308 | ec = np.array([False, False]) |
| 309 | c = in1d(a, b, kind=kind) |
| 310 | assert_array_equal(c, ec) |
| 311 | |
| 312 | a = np.array([5]) |
| 313 | b = np.array([2]) |
| 314 | ec = np.array([False]) |
| 315 | c = in1d(a, b, kind=kind) |
| 316 | assert_array_equal(c, ec) |
| 317 |
nothing calls this directly
no test coverage detected