Skip to content

Commit

Permalink
Merge #168
Browse files Browse the repository at this point in the history
168: Add Vector.zero as a class-level attribute r=AstraLuma a=nbraud



Co-authored-by: nicoo <nicolas@braud-santoni.eu>
  • Loading branch information
bors[bot] and nbraud committed Oct 26, 2021
2 parents 12163bd + ba1864f commit 273df90
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ppb_vector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class Vector:
x: float
y: float

# Class-level attributes
zero: typing.ClassVar['Vector']

__match_args__ = ('x', 'y')

# Tell CPython that this isn't an extendable dict
Expand Down Expand Up @@ -574,4 +577,7 @@ def reflect(self, surface_normal: VectorLike) -> 'Vector':
return self - (2 * (self * surface_normal) * surface_normal)


Vector.zero = Vector(0, 0)


Sequence.register(Vector)
5 changes: 5 additions & 0 deletions tests/test_zero.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from ppb_vector import Vector


def test_zero():
assert not Vector.zero

0 comments on commit 273df90

Please sign in to comment.