updade from Atlas repo

This commit is contained in:
Luciano Ramalho
2021-05-21 18:56:12 -03:00
parent c518bf851e
commit 8a330d822b
120 changed files with 2190 additions and 1184 deletions

View File

@@ -209,7 +209,7 @@ class Vector:
def __repr__(self):
components = reprlib.repr(self._components)
components = components[components.find('['):-1]
return 'Vector({})'.format(components)
return f'Vector({components})'
def __str__(self):
return str(tuple(self))
@@ -227,7 +227,7 @@ class Vector:
return functools.reduce(operator.xor, hashes, 0)
def __abs__(self):
return math.sqrt(sum(x * x for x in self))
return math.hypot(*self)
def __bool__(self):
return bool(abs(self))
@@ -250,11 +250,11 @@ class Vector:
pos = cls.shortcut_names.find(name)
if 0 <= pos < len(self._components):
return self._components[pos]
msg = '{.__name__!r} object has no attribute {!r}'
raise AttributeError(msg.format(cls, name))
msg = f'{cls.__name__!r} object has no attribute {name!r}'
raise AttributeError(msg)
def angle(self, n): # <2>
r = math.sqrt(sum(x * x for x in self[n:]))
r = math.hypot(*self[n:])
a = math.atan2(r, self[n-1])
if (n == len(self) - 1) and (self[-1] < 0):
return math.pi * 2 - a