def test_SizedDict_size(): d = SizedDict() assert d.size == 0 x = np.random.randn(10) d["a"] = x assert d.size == get_size(x) + sys.getsizeof("a") y = np.random.randn(10) d["b"] = y assert d.size == get_size(x) + get_size(y) + sys.getsizeof("a") + sys.getsizeof("b") # Overwrite z = np.random.randn(10) d["b"] = z assert d.size == get_size(x) + get_size(z) + sys.getsizeof("a") + sys.getsizeof("b")
def test_get_size(): d = {} x = np.random.randn(10) d["a"] = x size1 = sys.getsizeof(d) assert size1 + get_size(x) + get_size("a") == get_size(d)
def test_get_size(): d = {} size1 = get_size(d) x = np.random.randn(10) d["a"] = x assert size1 + get_size(x) + get_size("a") == get_size(d)