Skip to content

Commit

Permalink
add py.typed file; apply ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
nreinicke committed Nov 9, 2023
1 parent 1cf442d commit 26917ed
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
3 changes: 1 addition & 2 deletions nrel/routee/powertrain/core/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import json
import warnings
from dataclasses import dataclass, replace
from typing import Optional
from dataclasses import dataclass

from nrel.routee.powertrain.core.model_config import ModelConfig
from nrel.routee.powertrain.utils.fs import get_version
Expand Down
Empty file added nrel/routee/powertrain/py.typed
Empty file.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dev = [
"mypy",
"maturin",
"ruff",
"shapely",
"boxsdk",
"jupyter-book",
"sphinx-book-theme",
Expand All @@ -51,7 +52,7 @@ include = [
] # package names should match these glob patterns (["*"] by default)

[tool.setuptools.package-data]
"*" = ["py.typed"]
"nrel.routee.powertrain" = ["py.typed"]

[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]
14 changes: 7 additions & 7 deletions scripts/developers/train_model_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,27 +183,27 @@ def _azimuth(point1, point2):


def add_entry_link_angles(group):
l = [0] # can't determine first link entry angle so we set to 0
angles = [0] # can't determine first link entry angle so we set to 0
for i in range(1, len(group)):
link1 = group.iloc[i - 1]
link2 = group.iloc[i]
line1, line2 = match_link_geoms(link1, link2)
angle = compute_angle(line1, line2)
l.append(angle)
s = pd.Series(l, index=group.index)
angles.append(angle)
s = pd.Series(angles, index=group.index)
return s


def add_exit_link_angles(group):
l = []
angles = []
for i in range(0, len(group) - 1):
link1 = group.iloc[i]
link2 = group.iloc[i + 1]
line1, line2 = match_link_geoms(link1, link2)
angle = compute_angle(line1, line2)
l.append(angle)
l.append(0) # can't determine last link exit angle so we set to 0
s = pd.Series(l, index=group.index)
angles.append(angle)
angles.append(0) # can't determine last link exit angle so we set to 0
s = pd.Series(angles, index=group.index)
return s


Expand Down
6 changes: 3 additions & 3 deletions tests/test_train_estimate_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_sklearn_random_forest(self):
outfile = self.out_path / "estimator.onnx"
estimator = list(vehicle_model.estimators.values())[0]
estimator.to_file(outfile)
new_estimator = ONNXEstimator.from_file(outfile)
_ = ONNXEstimator.from_file(outfile)
outfile.unlink()

r2 = new_vehicle_model.predict(self.df)
Expand All @@ -104,13 +104,13 @@ def test_smartcore_random_forest(self):
outfile = self.out_path / "estimator.json"
estimator = list(vehicle_model.estimators.values())[0]
estimator.to_file(outfile)
new_estimator = SmartCoreEstimator.from_file(outfile)
_ = SmartCoreEstimator.from_file(outfile)
outfile.unlink()

outfile = self.out_path / "estimator.bin"
estimator = list(vehicle_model.estimators.values())[0]
estimator.to_file(outfile)
new_estimator = SmartCoreEstimator.from_file(outfile)
_ = SmartCoreEstimator.from_file(outfile)
outfile.unlink()

r2 = new_vehicle_model.predict(self.df)
Expand Down

0 comments on commit 26917ed

Please sign in to comment.