Skip to content

Default AMR level line preferences and error handling#422

Open
plauri wants to merge 1 commit intofmihpc:masterfrom
plauri:3dslice_amr_fix
Open

Default AMR level line preferences and error handling#422
plauri wants to merge 1 commit intofmihpc:masterfrom
plauri:3dslice_amr_fix

Conversation

@plauri
Copy link
Contributor

@plauri plauri commented Feb 5, 2026

so plot_colormap3dslice does not crash when 1) no colours, linewidths or linestyles have been set and 2) the chosen AMR level is not present in the selected plotting region.

…olormap3dslice does not crash when 1) no colours, linewidths or linestyles have been set and 2) the chosen AMR level is not present in the selected plotting region.
pt.plot.cell_edgecontours(ax1,XmeshPass,YmeshPass,AMRmap,val-0.1,linewidth=amrlinewidthslist[i], colors=amrcolourslist[i], linestyle=amrlinestyleslist[i])
try:
pt.plot.cell_edgecontours(ax1,XmeshPass,YmeshPass,AMRmap,val-0.1,linewidth=amrlinewidthslist[i], colors=amrcolourslist[i], linestyle=amrlinestyleslist[i])
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

See commit 3d6414c

I think this should be changed to an if statement now or at the very least the exception should be printed as it is also possible that matplotlib could fail, in which case this would mask the exception given from it.

I'm not sure the val can even cause an exception to occur alone, or did you have some specific case where it did happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error message that happens for an AMR level not present in the plotted region is long, non-descript and occurring inside matplotlib/NumPy. I think it happens when the array corresponding to an otherwise valid AMR level is empty. I guess this could be checked before passing the arrays to cell_edgecontours to make the error handling more transparent

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe best to add the handling into the function no? If this is an issue that can occur elsewhere that would be best as this function is also used elsewhere couple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants