mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Fix ruff errors (#8936)
* Fix ruff errors Renamed neural_network/input_data.py to neural_network/input_data.py_tf because it should be left out of the directory for the following reasons: 1. Its sole purpose is to be used by neural_network/gan.py_tf, which is itself left out of the directory because of issues with TensorFlow. 2. It was taken directly from TensorFlow's codebase and is actually already deprecated. If/when neural_network/gan.py_tf is eventually re-added back to the directory, its implementation should be changed to not use neural_network/input_data.py anyway. * updating DIRECTORY.md * Change input_data.py_tf file extension Change input_data.py_tf file extension because algorithms-keeper bot is being picky about it --------- Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -22,9 +22,13 @@ REFERENCES :
|
||||
-> Wikipedia reference: https://en.wikipedia.org/wiki/Millimeter
|
||||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
from typing import NamedTuple
|
||||
|
||||
|
||||
class FromTo(NamedTuple):
|
||||
from_factor: float
|
||||
to_factor: float
|
||||
|
||||
from_to = namedtuple("from_to", "from_ to")
|
||||
|
||||
TYPE_CONVERSION = {
|
||||
"millimeter": "mm",
|
||||
@ -40,14 +44,14 @@ TYPE_CONVERSION = {
|
||||
}
|
||||
|
||||
METRIC_CONVERSION = {
|
||||
"mm": from_to(0.001, 1000),
|
||||
"cm": from_to(0.01, 100),
|
||||
"m": from_to(1, 1),
|
||||
"km": from_to(1000, 0.001),
|
||||
"in": from_to(0.0254, 39.3701),
|
||||
"ft": from_to(0.3048, 3.28084),
|
||||
"yd": from_to(0.9144, 1.09361),
|
||||
"mi": from_to(1609.34, 0.000621371),
|
||||
"mm": FromTo(0.001, 1000),
|
||||
"cm": FromTo(0.01, 100),
|
||||
"m": FromTo(1, 1),
|
||||
"km": FromTo(1000, 0.001),
|
||||
"in": FromTo(0.0254, 39.3701),
|
||||
"ft": FromTo(0.3048, 3.28084),
|
||||
"yd": FromTo(0.9144, 1.09361),
|
||||
"mi": FromTo(1609.34, 0.000621371),
|
||||
}
|
||||
|
||||
|
||||
@ -115,7 +119,11 @@ def length_conversion(value: float, from_type: str, to_type: str) -> float:
|
||||
f"Conversion abbreviations are: {', '.join(METRIC_CONVERSION)}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
return value * METRIC_CONVERSION[new_from].from_ * METRIC_CONVERSION[new_to].to
|
||||
return (
|
||||
value
|
||||
* METRIC_CONVERSION[new_from].from_factor
|
||||
* METRIC_CONVERSION[new_to].to_factor
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user