<commit_before>from pympler.asizeof import asizeof as sizeof  # type: ignore
from hypothesis import given

from ppb_vector import Vector2
from utils import floats


class DummyVector:
    """A naïve representation of vectors."""

    x: float
    y: float

    def __init__(self, x, y):
        self.x = float(x)
        self.y = float(y)


@given(x=floats(), y=floats())
def test_object_size(x, y):
    """Check that Vector2 is 3 times smaller than a naïve version."""
    assert sizeof(Vector2(x, y)) < sizeof(DummyVector(x, y)) / 3<commit_msg>tests/memory: Assert that weak reference to Vector2s can be made<commit_after>import weakref

from pympler.asizeof import asizeof as sizeof  # type: ignore
from hypothesis import given

from ppb_vector import Vector2
from utils import floats, vectors


class DummyVector:
    """A naïve representation of vectors."""

    x: float
    y: float

    def __init__(self, x, y):
        self.x = float(x)
        self.y = float(y)


@given(x=floats(), y=floats())
def test_object_size(x, y):
    """Check that Vector2 is 3 times smaller than a naïve version."""
    assert sizeof(Vector2(x, y)) < sizeof(DummyVector(x, y)) / 3


@given(v=vectors())
def test_weak_ref(v):
    """Check that weak references can be made to Vector2s."""
    assert weakref.ref(v) is not None
{'fraction_non_alphanumeric': 0.11128048780487805, 'fraction_numerical': 0.009146341463414634, 'mean_word_length': 3.6560283687943262, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1509157', 'n_tokens_mistral': 446, 'n_tokens_neox': 416, 'n_words': 150}