()
| 539 | |
| 540 | |
| 541 | def test_unit_strs_sequence(): |
| 542 | native = "p3\np2\np1" |
| 543 | big = Str(native) |
| 544 | |
| 545 | lines = big.splitlines() |
| 546 | assert [2, 1, 0] == list(lines.argsort()) |
| 547 | assert "p3" in lines |
| 548 | assert "p4" not in lines |
| 549 | |
| 550 | assert repr(lines) == "sz.Strs(['p3', 'p2', 'p1'])" |
| 551 | assert repr(Str("a" * 1_000_000).split()).endswith("... ])") |
| 552 | |
| 553 | assert str(lines) == "['p3', 'p2', 'p1']" |
| 554 | assert str(Str("a" * 1_000_000).split()).startswith("['aaa") |
| 555 | assert str(Str("a" * 1_000_000).split()).endswith("aaa']") |
| 556 | |
| 557 | lines_sorted = lines.sorted() |
| 558 | assert [0, 1, 2] == list(lines_sorted.argsort()) |
| 559 | assert ["p1", "p2", "p3"] == list(lines_sorted) |
| 560 | |
| 561 | # Reverse order |
| 562 | assert [2, 1, 0] == list(lines_sorted.argsort(reverse=True)) |
| 563 | lines_sorted_reverse = lines.sorted(reverse=True) |
| 564 | assert ["p3", "p2", "p1"] == list(lines_sorted_reverse) |
| 565 | |
| 566 | # Sampling an array |
| 567 | sampled = lines.sample(100, seed=42) |
| 568 | assert "p3" in sampled |
| 569 | assert "p4" not in sampled |
| 570 | |
| 571 | |
| 572 | def test_unit_slicing(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…