Skip to content

Commit

Permalink
vector2.py: s/other[xy]/other_[xy]/
Browse files Browse the repository at this point in the history
  • Loading branch information
AstraLuma committed Apr 6, 2019
1 parent 6f3bacf commit 5e0f4a4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions ppb_vector/vector2.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ def __add__(self: Vector, other: VectorLike) -> Vector:
"""
rtype = _find_lowest_vector(type(other), type(self))
try:
otherx, othery = Vector2._unpack(other)
other_x, other_y = Vector2._unpack(other)
except ValueError:
return NotImplemented
return rtype(self.x + otherx, self.y + othery)
return rtype(self.x + other_x, self.y + other_y)

def __sub__(self: Vector, other: VectorLike) -> Vector:
"""Subtract one vector from another.
Expand All @@ -224,19 +224,19 @@ def __sub__(self: Vector, other: VectorLike) -> Vector:
"""
rtype = _find_lowest_vector(type(other), type(self))
try:
otherx, othery = Vector2._unpack(other)
other_x, other_y = Vector2._unpack(other)
except ValueError:
return NotImplemented
return rtype(self.x - otherx, self.y - othery)
return rtype(self.x - other_x, self.y - other_y)

def dot(self: Vector, other: VectorLike) -> float:
"""Dot product of two vectors.
:param other: A :py:class:`Vector2` or a vector-like.
For a description of vector-likes, see :py:func:`__new__`.
"""
otherx, othery = Vector2._unpack(other)
return self.x * otherx + self.y * othery
other_x, other_y = Vector2._unpack(other)
return self.x * other_x + self.y * other_y

def scale_by(self: Vector, scalar: typing.SupportsFloat) -> Vector:
"""Scalar multiplication.
Expand Down Expand Up @@ -347,11 +347,11 @@ def __eq__(self: Vector, other: typing.Any) -> bool:
False
"""
try:
otherx, othery = Vector2._unpack(other)
other_x, other_y = Vector2._unpack(other)
except (TypeError, ValueError):
return NotImplemented
else:
return self.x == otherx and self.y == othery
return self.x == other_x and self.y == other_y

def __iter__(self: Vector) -> typing.Iterator[float]:
yield self.x
Expand Down Expand Up @@ -382,9 +382,9 @@ def angle(self: Vector, other: VectorLike) -> float:
:py:meth:`angle` is guaranteed to produce an angle between -180° and 180°.
"""
otherx, othery = Vector2._unpack(other)
other_x, other_y = Vector2._unpack(other)

rv = degrees(atan2(otherx, -othery) - atan2(self.x, -self.y))
rv = degrees(atan2(other_x, -other_y) - atan2(self.x, -self.y))
# This normalizes the value to (-180, +180], which is the opposite of
# what Python usually does but is normal for angles
if rv <= -180:
Expand Down

0 comments on commit 5e0f4a4

Please sign in to comment.