<commit_before>import pp
from pp.component import hash_file


def test_hash_geometry() -> None:
    # FIXME, figure out straight hash issue
    # c1 = pp.components.straight(length=10)
    # c2 = pp.components.straight(length=11)
    c1 = pp.components.rectangle(size=(4, 0))
    c2 = pp.components.rectangle(size=(3, 0))
    h1 = c1.hash_geometry()
    h2 = c2.hash_geometry()
    assert h1 != h2


def test_hash_file():
    c = pp.c.straight()
    c.add_label("hi")
    gdspath = c.write_gds()
    h = hash_file(gdspath)
    print(h)
    assert h == "71655c3f7ab57e7a48b55683e8c1bfc4"


def test_hash_array_file():
    """FIXME, this needs some more gdspy fix."""
    c = pp.Component()
    wg = pp.c.straight()
    c.add_array(wg)
    gdspath = c.write_gds()
    h = hash_file(gdspath)
    print(h)
    # assert h == "c6d3387b8ea0de9838a2393dba1f56e6"


if __name__ == "__main__":
    # test_hash_geometry()
    # test_hash_file()
    test_hash_array_file()<commit_msg>better documented test_hash function<commit_after>import pp
from pp.component import hash_file


def test_hash_geometry() -> None:
    """Test geometric hash of the GDS points."""
    c1 = pp.components.straight(length=10)
    c2 = pp.components.straight(length=11)
    h1 = c1.hash_geometry()
    h2 = c2.hash_geometry()
    assert h1 != h2


def test_hash_file():
    """Test hash of the saved GDS file."""
    c = pp.c.straight()
    c.add_label("hi")
    gdspath = c.write_gds()
    h = hash_file(gdspath)
    print(h)
    assert h == "71655c3f7ab57e7a48b55683e8c1bfc4"


def test_hash_array_file():
    """FIXME, this needs some more gdspy fix."""
    c = pp.Component()
    wg = pp.c.straight()
    c.add_array(wg)
    gdspath = c.write_gds()
    h = hash_file(gdspath)
    print(h)
    # assert h == "c6d3387b8ea0de9838a2393dba1f56e6"


if __name__ == "__main__":
    test_hash_geometry()
    # test_hash_file()
    # test_hash_array_file()
{'fraction_non_alphanumeric': 0.13027618551328818, 'fraction_numerical': 0.05627931214174049, 'mean_word_length': 3.295302013422819, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4081299', 'n_tokens_mistral': 813, 'n_tokens_neox': 762, 'n_words': 150}