diff --git a/CHANGELOG.md b/CHANGELOG.md index d66b964b324e81682fecc680fc932cfa748b8123..e71635bd8b0e11c51b397ccc8f869eb9136e92c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # v2.2.13 * useless `print()`s removed in metrics +* additional unit tests and doc fixes # v2.2.12 diff --git a/README.md b/README.md index 839bdfc734fad3c372a2ce457ab64f7f55bec09c..b8f864cb20a5c4c49cf549859f060cf30f8264d9 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ _satella.posix_ in unavailable on non-POSIX systems, but the rest should work OK Full [documentation](http://satella.readthedocs.io/en/latest/?badge=latest) is available for the brave souls that do decide to use this library. -Satella is a zero-requirements Python 3.5+ library for writing +Satella is an almost-zero-requirements Python 3.5+ library for writing server applications, especially those dealing with mundane but useful things. It also runs on PyPy. diff --git a/satella/__init__.py b/satella/__init__.py index 3681df438e9000026a1dbf5bcfc718e72ee8568c..4c6704f35f0349acef3b65c06f64ba1ab3101efa 100644 --- a/satella/__init__.py +++ b/satella/__init__.py @@ -1,2 +1,2 @@ # coding=UTF-8 -__version__ = '2.2.13a1' +__version__ = '2.2.13a2' diff --git a/satella/coding/structures/structures.py b/satella/coding/structures/structures.py index 9d08f5b5f464c3b5e8997512f62228e0b23f6923..793c119350c3ef616bc11b06e9e3294c7ecf12fb 100644 --- a/satella/coding/structures/structures.py +++ b/satella/coding/structures/structures.py @@ -79,7 +79,7 @@ class Heap(collections.UserList, tp.Generic[HeapVar]): super().__init__(from_list) heapq.heapify(self.data) - def push_many(self, items: tp.Iterator[HeapVar]) -> None: + def push_many(self, items: tp.Iterable[HeapVar]) -> None: for item in items: self.push(item) @@ -88,11 +88,11 @@ class Heap(collections.UserList, tp.Generic[HeapVar]): """ Use it like: - heap.push(3) + >>> heap.push(3) or: - heap.push(4, myobject) + >>> heap.push(4, myobject) """ heapq.heappush(self.data, item) @@ -137,7 +137,7 @@ class Heap(collections.UserList, tp.Generic[HeapVar]): """ return len(self.data) > 0 - def iter_ascending(self) -> tp.Iterator[HeapVar]: + def iter_ascending(self) -> tp.Iterable[HeapVar]: """ Return an iterator returning all elements in this heap sorted ascending. State of the heap is not changed @@ -146,7 +146,7 @@ class Heap(collections.UserList, tp.Generic[HeapVar]): while heap: yield heapq.heappop(heap) - def iter_descending(self) -> tp.Iterator[HeapVar]: + def iter_descending(self) -> tp.Iterable[HeapVar]: """ Return an iterator returning all elements in this heap sorted descending. State of the heap is not changed. @@ -193,15 +193,12 @@ class TimeBasedHeap(Heap): #notthreadsafe """ - def __repr__(self): - return '<satella.coding.TimeBasedHeap>' - def __repr__(self): return '<satella.coding.TimeBasedHeap with %s elements>' % (len(self.data),) def items(self) -> tp.Iterable[HeapVar]: """ - Return an iterator, but WITHOUT timestamps (only items), in + Return an iterable, but WITHOUT timestamps (only items), in unspecified order """ return (ob for ts, ob in self.data) diff --git a/tests/test_coding/test_structures.py b/tests/test_coding/test_structures.py index 24e45a70aae77ecd39914b3d831b50585de4ef14..cce7377a487dd63f5b42e739821b7a1102480d06 100644 --- a/tests/test_coding/test_structures.py +++ b/tests/test_coding/test_structures.py @@ -30,6 +30,7 @@ class TestTimeBasedHeap(unittest.TestCase): } self.assertEqual(a[e1], '1') + self.assertEqual(hash(e1), hash(2)) def test_tbh(self): tbh = TimeBasedHeap()