mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
from __future__ import annotations (#2464)
* from __future__ import annotations * fixup! from __future__ import annotations * fixup! from __future__ import annotations * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from typing import List
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def points_to_polynomial(coordinates: List[List[int]]) -> str:
|
||||
def points_to_polynomial(coordinates: list[list[int]]) -> str:
|
||||
"""
|
||||
coordinates is a two dimensional matrix: [[x, y], [x, y], ...]
|
||||
number of points you want to use
|
||||
@ -60,7 +60,7 @@ def points_to_polynomial(coordinates: List[List[int]]) -> str:
|
||||
while count_of_line < x:
|
||||
count_in_line = 0
|
||||
a = coordinates[count_of_line][0]
|
||||
count_line: List[int] = []
|
||||
count_line: list[int] = []
|
||||
while count_in_line < x:
|
||||
count_line.append(a ** (x - (count_in_line + 1)))
|
||||
count_in_line += 1
|
||||
@ -69,7 +69,7 @@ def points_to_polynomial(coordinates: List[List[int]]) -> str:
|
||||
|
||||
count_of_line = 0
|
||||
# put the y values into a vector
|
||||
vector: List[int] = []
|
||||
vector: list[int] = []
|
||||
while count_of_line < x:
|
||||
vector.append(coordinates[count_of_line][1])
|
||||
count_of_line += 1
|
||||
@ -94,7 +94,7 @@ def points_to_polynomial(coordinates: List[List[int]]) -> str:
|
||||
|
||||
count = 0
|
||||
# make solutions
|
||||
solution: List[str] = []
|
||||
solution: list[str] = []
|
||||
while count < x:
|
||||
solution.append(vector[count] / matrix[count][count])
|
||||
count += 1
|
||||
@ -103,7 +103,7 @@ def points_to_polynomial(coordinates: List[List[int]]) -> str:
|
||||
solved = "f(x)="
|
||||
|
||||
while count < x:
|
||||
remove_e: List[str] = str(solution[count]).split("E")
|
||||
remove_e: list[str] = str(solution[count]).split("E")
|
||||
if len(remove_e) > 1:
|
||||
solution[count] = remove_e[0] + "*10^" + remove_e[1]
|
||||
solved += "x^" + str(x - (count + 1)) + "*" + str(solution[count])
|
||||
|
@ -11,11 +11,12 @@ projection(45) = [[0.27596319193541496, 0.446998331800279],
|
||||
reflection(45) = [[0.05064397763545947, 0.893996663600558],
|
||||
[0.893996663600558, 0.7018070490682369]]
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from math import cos, sin
|
||||
from typing import List
|
||||
|
||||
|
||||
def scaling(scaling_factor: float) -> List[List[float]]:
|
||||
def scaling(scaling_factor: float) -> list[list[float]]:
|
||||
"""
|
||||
>>> scaling(5)
|
||||
[[5.0, 0.0], [0.0, 5.0]]
|
||||
@ -24,7 +25,7 @@ def scaling(scaling_factor: float) -> List[List[float]]:
|
||||
return [[scaling_factor * int(x == y) for x in range(2)] for y in range(2)]
|
||||
|
||||
|
||||
def rotation(angle: float) -> List[List[float]]:
|
||||
def rotation(angle: float) -> list[list[float]]:
|
||||
"""
|
||||
>>> rotation(45) # doctest: +NORMALIZE_WHITESPACE
|
||||
[[0.5253219888177297, -0.8509035245341184],
|
||||
@ -34,7 +35,7 @@ def rotation(angle: float) -> List[List[float]]:
|
||||
return [[c, -s], [s, c]]
|
||||
|
||||
|
||||
def projection(angle: float) -> List[List[float]]:
|
||||
def projection(angle: float) -> list[list[float]]:
|
||||
"""
|
||||
>>> projection(45) # doctest: +NORMALIZE_WHITESPACE
|
||||
[[0.27596319193541496, 0.446998331800279],
|
||||
@ -45,7 +46,7 @@ def projection(angle: float) -> List[List[float]]:
|
||||
return [[c * c, cs], [cs, s * s]]
|
||||
|
||||
|
||||
def reflection(angle: float) -> List[List[float]]:
|
||||
def reflection(angle: float) -> list[list[float]]:
|
||||
"""
|
||||
>>> reflection(45) # doctest: +NORMALIZE_WHITESPACE
|
||||
[[0.05064397763545947, 0.893996663600558],
|
||||
|
Reference in New Issue
Block a user