meshpro / dmsh

:spider_web: Simple mesh generator inspired by distmesh.
GNU General Public License v3.0
210 stars 26 forks source link

generate(geo, show=True) cycles through many plots in tests #17

Closed drew-parsons closed 4 years ago

drew-parsons commented 4 years ago

Several of the dmsh 0.1.5 tests display a plot of the mesh when show=True is provided to dmsh.generate. Some of them cycle repeatedly display the mesh many many times. The worst offender is test_union_rectangles.py, but test_square_hole.py also displays many times before stopping*.

I presume there is some iteration taking place for the generation of these test meshes, and some matplotlib code is set to show the plot at each iteration.

nschloe commented 4 years ago

Use

MPLBACKEND=Agg pytest

The figures aren't displayed then.

drew-parsons commented 4 years ago

Yes, deactivating the plots altogether is easy enough (your environment variable is a better idea than my idea of patching in show=False).

But when you are displaying them, you don't want test_union_rectangles.py to display an endless series of the plots, do you?

nschloe commented 4 years ago

Well, I want the show=True functionality to work and I want to have it covered by tests.

drew-parsons commented 4 years ago

Well yes. But do you mean your intention is to show every single iteration? test_union_rectangles.py never stops in that case, never returns, so you can't say the test passed.

nschloe commented 4 years ago

test_union_rectangles.py never stops in that case

I don't understand. The show=True functionality should not affect the convergence at all.

nschloe commented 4 years ago

show shouldn't be blocking with MPLBACKEND=Agg pytest.

drew-parsons commented 4 years ago

It's the issue that I'm reporting here. It shows an endless stream of plots. You have to press q to close each one individually. Is there actually a finite number of them? I got tired of pressing q so I just killed the test. Here I mean without the MPLBACKEND setting. It returns eventually when I use MPLBACKEND=Agg. So that's a practical workaround. Not entirely intuitive though.

nschloe commented 4 years ago

Not entirely intuitive though.

I should probably add it to the readme, yes. Using MPLBACKEND=Agg is what I do on all of my projects that have plotting. I don't know of a better way.

So that's a practical workaround.

It's actually meant to be used that way.

drew-parsons commented 4 years ago

It's actually meant to be used that way.

Heh documenting in the test dir (or readme) should help then.

nschloe commented 4 years ago

Perhaps I should set the environment variable in the tests.

drew-parsons commented 4 years ago

Perhaps, though it can be nice to see the plots when you run tests manually. Could perhaps set the env variable for the troublemaking tests. But maybe it cleaner to apply it to them all.

nschloe commented 4 years ago

Alright, I've added some instructions to the readme, that'll do for now.

drew-parsons commented 4 years ago

Thanks Nico.