Fix all errors mentioned in pre-commit run (#2512)

* Fix all errors mentioned in pre-commit run:

- Fix end of file
- Remove trailing whitespace
- Fix files with black
- Fix imports with isort

* Fix errors
This commit is contained in:
Dhruv 2020-09-30 14:08:00 +05:30 committed by GitHub
parent e6e2dc69d5
commit 0a42ae9095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 86 additions and 85 deletions

View File

@ -3,14 +3,16 @@ render 3d points for 2d surfaces.
""" """
from __future__ import annotations from __future__ import annotations
import math import math
__version__ = "2020.9.26" __version__ = "2020.9.26"
__author__ = "xcodz-dot, cclaus, dhruvmanila" __author__ = "xcodz-dot, cclaus, dhruvmanila"
def convert_to_2d(x: float, y: float, z: float, scale: float, def convert_to_2d(
distance: float) -> tuple[float, float]: x: float, y: float, z: float, scale: float, distance: float
) -> tuple[float, float]:
""" """
Converts 3d point to a 2d drawable point Converts 3d point to a 2d drawable point
@ -26,15 +28,17 @@ def convert_to_2d(x: float, y: float, z: float, scale: float,
TypeError: Input values must either be float or int: ['1', 2, 3, 10, 10] TypeError: Input values must either be float or int: ['1', 2, 3, 10, 10]
""" """
if not all(isinstance(val, (float, int)) for val in locals().values()): if not all(isinstance(val, (float, int)) for val in locals().values()):
raise TypeError("Input values must either be float or int: " raise TypeError(
f"{list(locals().values())}") "Input values must either be float or int: " f"{list(locals().values())}"
)
projected_x = ((x * distance) / (z + distance)) * scale projected_x = ((x * distance) / (z + distance)) * scale
projected_y = ((y * distance) / (z + distance)) * scale projected_y = ((y * distance) / (z + distance)) * scale
return projected_x, projected_y return projected_x, projected_y
def rotate(x: float, y: float, z: float, axis: str, def rotate(
angle: float) -> tuple[float, float, float]: x: float, y: float, z: float, axis: str, angle: float
) -> tuple[float, float, float]:
""" """
rotate a point around a certain axis with a certain angle rotate a point around a certain axis with a certain angle
angle can be any integer between 1, 360 and axis can be any one of angle can be any integer between 1, 360 and axis can be any one of
@ -67,18 +71,20 @@ def rotate(x: float, y: float, z: float, axis: str,
input_variables = locals() input_variables = locals()
del input_variables["axis"] del input_variables["axis"]
if not all(isinstance(val, (float, int)) for val in input_variables.values()): if not all(isinstance(val, (float, int)) for val in input_variables.values()):
raise TypeError("Input values except axis must either be float or int: " raise TypeError(
f"{list(input_variables.values())}") "Input values except axis must either be float or int: "
f"{list(input_variables.values())}"
)
angle = (angle % 360) / 450 * 180 / math.pi angle = (angle % 360) / 450 * 180 / math.pi
if axis == 'z': if axis == "z":
new_x = x * math.cos(angle) - y * math.sin(angle) new_x = x * math.cos(angle) - y * math.sin(angle)
new_y = y * math.cos(angle) + x * math.sin(angle) new_y = y * math.cos(angle) + x * math.sin(angle)
new_z = z new_z = z
elif axis == 'x': elif axis == "x":
new_y = y * math.cos(angle) - z * math.sin(angle) new_y = y * math.cos(angle) - z * math.sin(angle)
new_z = z * math.cos(angle) + y * math.sin(angle) new_z = z * math.cos(angle) + y * math.sin(angle)
new_x = x new_x = x
elif axis == 'y': elif axis == "y":
new_x = x * math.cos(angle) - z * math.sin(angle) new_x = x * math.cos(angle) - z * math.sin(angle)
new_z = z * math.cos(angle) + x * math.sin(angle) new_z = z * math.cos(angle) + x * math.sin(angle)
new_y = y new_y = y

View File

@ -3,11 +3,11 @@
predict house price. predict house price.
""" """
import pandas as pd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import pandas as pd
from sklearn.datasets import load_boston from sklearn.datasets import load_boston
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.ensemble import GradientBoostingRegressor from sklearn.ensemble import GradientBoostingRegressor
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.model_selection import train_test_split from sklearn.model_selection import train_test_split
@ -42,10 +42,7 @@ def main():
training_score = model.score(X_train, y_train).round(3) training_score = model.score(X_train, y_train).round(3)
test_score = model.score(X_test, y_test).round(3) test_score = model.score(X_test, y_test).round(3)
print("Training score of GradientBoosting is :", training_score) print("Training score of GradientBoosting is :", training_score)
print( print("The test score of GradientBoosting is :", test_score)
"The test score of GradientBoosting is :",
test_score
)
# Let us evaluation the model by finding the errors # Let us evaluation the model by finding the errors
y_pred = model.predict(X_test) y_pred = model.predict(X_test)
@ -57,8 +54,7 @@ def main():
# So let's run the model against the test data # So let's run the model against the test data
fig, ax = plt.subplots() fig, ax = plt.subplots()
ax.scatter(y_test, y_pred, edgecolors=(0, 0, 0)) ax.scatter(y_test, y_pred, edgecolors=(0, 0, 0))
ax.plot([y_test.min(), y_test.max()], ax.plot([y_test.min(), y_test.max()], [y_test.min(), y_test.max()], "k--", lw=4)
[y_test.min(), y_test.max()], "k--", lw=4)
ax.set_xlabel("Actual") ax.set_xlabel("Actual")
ax.set_ylabel("Predicted") ax.set_ylabel("Predicted")
ax.set_title("Truth vs Predicted") ax.set_title("Truth vs Predicted")

View File

@ -73,4 +73,3 @@ The array elements are taken from a Standard Normal Distribution , having mean =
------------------ ------------------