Skip to content

Commit

Permalink
bug(plots): Prevent tex errors in matplotlib usetex
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob-Stevens-Haas committed Feb 15, 2024
1 parent 27d32fe commit 483fdc8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/gen_experiments/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ def plot_coefficients(
ax: bool = None,
**heatmap_kws,
):
def detex(input: str) -> str:
if input[0] == "$":
input = input[1:]
if input[-1] == "$":
input = input[:-1]
return input

if input_features is None:
input_features = [r"$\dot x_" + f"{k}$" for k in range(coefficients.shape[0])]
else:
input_features = [r"$\dot " + f"{fi}$" for fi in input_features]
input_features = [r"$\dot " + f"{detex(fi)}$" for fi in input_features]

if feature_names is None:
feature_names = [f"f{k}" for k in range(coefficients.shape[1])]
Expand Down

0 comments on commit 483fdc8

Please sign in to comment.