Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for biorbd 1.11.0 #98

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:

- name: Print mamba info
run: |
mamba config --show
mamba info
mamba list

Expand Down
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.extraPaths": ["./external/pyScienceMode"],
"python.envFile": "${workspaceFolder}/.vscode/.env",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.rulers": [120]
},
"cmake.configureOnOpen": false
}
6 changes: 2 additions & 4 deletions bioviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,7 @@

self.n_max_events = 100
self.last_event_index = -1
self.events: list[
dict[str:RectangleOnSlider, str:int, str:str], ...
] = [] # event list of [marker/frame/event_name]
self.events: list[dict[str:RectangleOnSlider, str:int, str:str]] = [] # events [marker/frame/event_name]

Check warning on line 334 in bioviz/__init__.py

View check run for this annotation

Codecov / codecov/patch

bioviz/__init__.py#L334

Added line #L334 was not covered by tests

self.active_analyses: AnalysePanel | None = None
self.column_stretch = 0
Expand Down Expand Up @@ -1039,7 +1037,7 @@
data,
auto_start=True,
ignore_animation_warning=True,
experimental_markers_mapping_to_virtual: list[int, ...] = None,
experimental_markers_mapping_to_virtual: list[int] = None,
):
if isinstance(data, str):
self.experimental_markers = Markers.from_c3d(data)
Expand Down
24 changes: 20 additions & 4 deletions bioviz/analyses/muscle_analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
self.ax_passive_forces.set_facecolor(background_color)
self.ax_passive_forces.set_title("Passive forces")
self.ax_passive_forces.set_ylabel("Passive forces coeff")
self.ax_passive_forces.set_ylim((0, 1))

Check warning on line 93 in bioviz/analyses/muscle_analyses.py

View check run for this annotation

Codecov / codecov/patch

bioviz/analyses/muscle_analyses.py#L93

Added line #L93 was not covered by tests

# Add active forces
self.canvas_active_forces = FigureCanvasQTAgg(plt.figure(facecolor=background_color))
Expand All @@ -100,6 +101,7 @@
self.ax_active_forces.set_facecolor(background_color)
self.ax_active_forces.set_title("Active forces")
self.ax_active_forces.set_ylabel("Active forces coeff")
self.ax_active_forces.set_ylim((0, 1))

Check warning on line 104 in bioviz/analyses/muscle_analyses.py

View check run for this annotation

Codecov / codecov/patch

bioviz/analyses/muscle_analyses.py#L104

Added line #L104 was not covered by tests
self.active_forces_slider = QSlider()
active_forces_layout.addWidget(self.active_forces_slider)
self.active_forces_slider.setPalette(self.main_window.palette_active)
Expand Down Expand Up @@ -170,11 +172,21 @@
self.__update_specific_plot(self.canvas_moment_arm, self.ax_moment_arm, x_axis, moment_arm, skip_moment_arm)

self.__update_specific_plot(
self.canvas_passive_forces, self.ax_passive_forces, x_axis, passive_forces, skip_passive_forces
self.canvas_passive_forces,
self.ax_passive_forces,
x_axis,
passive_forces,
skip_passive_forces,
autoscale_y=False,
)

self.__update_specific_plot(
self.canvas_active_forces, self.ax_active_forces, x_axis, active_forces, skip_active_forces
self.canvas_active_forces,
self.ax_active_forces,
x_axis,
active_forces,
skip_active_forces,
autoscale_y=False,
)

self.__update_graph_size()
Expand Down Expand Up @@ -216,11 +228,11 @@
if mus.type() != biorbd.IDEALIZED_ACTUATOR:
active_forces[i, m] = biorbd.HillType(mus).FlCE(emg)
else:
active_forces[i, m] = 0
active_forces[i, m] = emg.activation()

Check warning on line 231 in bioviz/analyses/muscle_analyses.py

View check run for this annotation

Codecov / codecov/patch

bioviz/analyses/muscle_analyses.py#L231

Added line #L231 was not covered by tests

return x_axis, length, moment_arm, passive_forces, active_forces

def __update_specific_plot(self, canvas, ax, x, y, skip=False):
def __update_specific_plot(self, canvas, ax, x, y, skip=False, autoscale_y=True):

Check warning on line 235 in bioviz/analyses/muscle_analyses.py

View check run for this annotation

Codecov / codecov/patch

bioviz/analyses/muscle_analyses.py#L235

Added line #L235 was not covered by tests
# Plot all active muscles
number_of_active = 0
for m in range(self.n_mus):
Expand All @@ -237,8 +249,12 @@
# If there is no data skip relim and vertical bar adjustment
if number_of_active != 0:
# relim so the plot looks nice
if not autoscale_y:
y_lim = ax.get_ylim()

Check warning on line 253 in bioviz/analyses/muscle_analyses.py

View check run for this annotation

Codecov / codecov/patch

bioviz/analyses/muscle_analyses.py#L252-L253

Added lines #L252 - L253 were not covered by tests
ax.relim()
ax.autoscale(enable=True)
if not autoscale_y:
ax.set_ylim(y_lim)

Check warning on line 257 in bioviz/analyses/muscle_analyses.py

View check run for this annotation

Codecov / codecov/patch

bioviz/analyses/muscle_analyses.py#L256-L257

Added lines #L256 - L257 were not covered by tests

# Adjust axis label (give a generic name)
if self.animation_checkbox.isChecked():
Expand Down
1 change: 1 addition & 0 deletions bioviz/biorbd_vtk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Visualization toolkit in pyomeca
"""

from dataclasses import dataclass
import os
import time
Expand Down
5 changes: 1 addition & 4 deletions bioviz/interfaces_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,7 @@

def _get_data_from_eigen(self, Q=None, compute_kin=True):
self.data = []
if compute_kin:
allJCS = self.m.allGlobalJCS(Q)
else:
allJCS = self.m.allGlobalJCS()
allJCS = self.m.allGlobalJCS(Q, compute_kin)

Check warning on line 284 in bioviz/interfaces_collection.py

View check run for this annotation

Codecov / codecov/patch

bioviz/interfaces_collection.py#L284

Added line #L284 was not covered by tests
for jcs in allJCS:
self.data.append(jcs.to_array())

Expand Down
Loading