MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / test_unit_strs_sequence

Function test_unit_strs_sequence

scripts/test_stringzilla.py:541–569  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

539
540
541def 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
572def test_unit_slicing():

Callers

nothing calls this directly

Calls 2

splitlinesMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…