Skip to content

Fix flux diagram naming of species images#2905

Merged
rwest merged 1 commit intoReactionMechanismGenerator:mainfrom
sevyharris:fix_flux_diagram_naming
Mar 27, 2026
Merged

Fix flux diagram naming of species images#2905
rwest merged 1 commit intoReactionMechanismGenerator:mainfrom
sevyharris:fix_flux_diagram_naming

Conversation

@sevyharris
Copy link
Copy Markdown
Contributor

@sevyharris sevyharris commented Mar 26, 2026

There can be multiple species that end the same way, so using endswith is not guaranteed to get you the right images. This change makes sure the flux diagrams will map the correct species image onto the flux diagram.

Motivation or Problem

The flux diagram tool sometimes grabs the wrong image for a species. See #2904

The problem is that it's relying on the filename ending the same as the species name, instead of matching exactly. In the above example, you get RMG using the image of C4H71-O2 for O2.

Description of Changes

Instead of searching for a file name by checking that it ends with the right key, it now forces the file name to match exactly.

Testing

I tested this using the example in ReactionMechanismGenerator/RMG-Py/issues/2904

The bad "before" image is shown in the bug, and the fixed "after" image is shown below. You can see O2 is now displaying properly.
flux_diagram_0001

I will also test this for the case of nested directories. If you put the O2 image inside another folder, does it still work?
Yes. I tested and this works fine.

There can be multiple species that end the same way, so using endswith is not guaranteed to get you the right images. This change makes sure the flux diagrams will map the correct species image onto the flux diagram.
@sevyharris sevyharris linked an issue Mar 26, 2026 that may be closed by this pull request
@rwest
Copy link
Copy Markdown
Member

rwest commented Mar 27, 2026

I was curious how this came to be. Why had someone deliberately chosen endswith instead of == ?

It's because when Josh first wrote it in 1307f71, species_index was just the number at the end like (42) concatenated with .png so endswith() would correctly match anything(42).png.

Then, in order to fix something else, in daab0fb Connie made species_index equal to the species label instead of the number. This bug hid silently.

This fix is clearly correct. I'll rebase (as it's a single commit) and merge.

@rwest rwest merged commit 0e48892 into ReactionMechanismGenerator:main Mar 27, 2026
19 of 29 checks passed
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.

flux diagram uses wrong image names

2 participants