Skip to content

Remove double-backslashes from latex labels passed to matplotlib.#837

Merged
ColmTalbot merged 1 commit intobilby-dev:mainfrom
AlexandreGoettel:fix_bilby_pipe_latex_plots
Oct 25, 2024
Merged

Remove double-backslashes from latex labels passed to matplotlib.#837
ColmTalbot merged 1 commit intobilby-dev:mainfrom
AlexandreGoettel:fix_bilby_pipe_latex_plots

Conversation

@AlexandreGoettel
Copy link
Copy Markdown
Collaborator

Addresses #836
As far as I can tell, the issue is due to a bug in bilby_pipe, but I noticed that there is already a function to remove matplotlib errors in bilby/core/result.py.

This PR simply adds a line to this function to convert "\" into "".

Either way I think this is a good thing to have, as I can't think of a scenario where having "\" in a matplotlib latex string is a good idea.

Copy link
Copy Markdown
Collaborator

@mj-will mj-will left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked to see how this interacts with raw strings (e.g. r"$\mathcal{M}$")?

@AlexandreGoettel
Copy link
Copy Markdown
Collaborator Author

Have you checked to see how this interacts with raw strings (e.g. r"$\mathcal{M}$")?

Not 100% what you mean but afaik a variable defined as a raw string just becomes a string (with different creation rules) i.e.:
r"$\mathcal{M}$" == "$\\mathcal{M}$" will return True. The code above will work in both cases.

@mj-will
Copy link
Copy Markdown
Collaborator

mj-will commented Oct 25, 2024

Not 100% what you mean but afaik a variable defined as a raw string just becomes a string (with different creation rules) i.e.: r"$\mathcal{M}$" == "$\\mathcal{M}$" will return True. The code above will work in both cases.

Ah, I didn't know that, makes sense then :)

@ColmTalbot ColmTalbot force-pushed the fix_bilby_pipe_latex_plots branch from 639424b to 2916635 Compare October 25, 2024 12:34
@ColmTalbot ColmTalbot merged commit 0d4b91f into bilby-dev:main Oct 25, 2024
@AlexandreGoettel AlexandreGoettel deleted the fix_bilby_pipe_latex_plots branch October 25, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants