Skip to content

Commit

Permalink
Bump versions and adjust for new linting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
tjstienstra committed Mar 25, 2024
1 parent f473585 commit a528ffe
Show file tree
Hide file tree
Showing 10 changed files with 440 additions and 435 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.262
rev: v0.3.4
hooks:
- id: ruff
args: [ --fix, --show-fixes, --exit-non-zero-on-fix ]
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
sys.path.insert(0, os.path.dirname(__file__))
sys.path.insert(0, os.path.abspath("../src"))

from process_tutorials import main as process_tutorials # noqa: E402
from process_tutorials import main as process_tutorials

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/four_bar_linkage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
TUTORIALS_DIR = os.path.dirname(__file__)


def download_parametrization_data(data_dir: str = None) -> None:
def download_parametrization_data(data_dir: str | None = None) -> None:
"""Download the bicycle and rider data from the BicycleParameters repository."""
if data_dir is None:
data_dir = os.path.join(TUTORIALS_DIR, "data")
Expand Down
848 changes: 426 additions & 422 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plotly = {version = "^5.14.1", optional = true}
pandas = {version = "^2.0.0", optional = true}

[tool.poetry.group.lint.dependencies]
ruff = "^0.0.262"
ruff = "^0.3.4"
pre-commit = "^3.6.0"

[tool.poetry.group.test.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions src/brim/bicycle/tires.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ def _define_constraints(self) -> None:
if self.no_longitudinal_slip or self.no_lateral_slip:
aux_wc = self.auxiliary_handler.get_auxiliary_velocity(self.wheel.center)
v0 = (self.wheel.center.pos_from(self.ground.origin).dt(self.ground.frame)
+ cross(self.wheel.frame.ang_vel_in(self.ground.frame),
self.contact_point.pos_from(self.wheel.center)))
+ cross(self.wheel.frame.ang_vel_in(self.ground.frame),
self.contact_point.pos_from(self.wheel.center)))
aux_v0 = aux_wc - aux_gnd + aux_cp
for vector in no_slip_vectors:
self.system.add_nonholonomic_constraints(
Expand Down
4 changes: 3 additions & 1 deletion src/brim/core/singleton.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Singleton class."""
from __future__ import annotations

from typing import ClassVar

__all__ = ["SingletonMeta", "Singleton"]


class SingletonMeta(type):
"""Metaclass for Singleton."""

_instances = {}
_instances: ClassVar[dict[type, object]] = {}

def __call__(cls, *args, **kwargs):
"""Create a new instance of the class."""
Expand Down
7 changes: 3 additions & 4 deletions src/brim/utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ def check_zero(expr: Expr, n_evaluations: int = 10, atol: float = 1e-8) -> bool:
expr = msubs(expr, dummy_map)
f = lambdify(free, expr, cse=True)
# The comparison is to zero, so the relative tolerance is not used.
rng = np.random.default_rng()
return np.allclose(
np.fromfunction(lambda i: f(*np.random.random(len(free))), (n_evaluations,)),
np.zeros(n_evaluations),
0, atol
)
np.fromfunction(lambda i: f(*rng.random(len(free))), (n_evaluations,)),
np.zeros(n_evaluations), 0, atol)
2 changes: 1 addition & 1 deletion tests/rider/test_rider.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_minimal(self, define_required) -> None:
rider.pelvis = PlanarPelvis("pelvis")
rider.define_all()
else:
with pytest.raises(Exception):
with pytest.raises((ValueError, AttributeError)):
rider.define_all()

def test_form_eoms(self, _setup) -> None:
Expand Down

0 comments on commit a528ffe

Please sign in to comment.