Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve hips/draw/tests/test_paint.py #135

Open
cdeil opened this issue Dec 13, 2018 · 2 comments
Open

Improve hips/draw/tests/test_paint.py #135

cdeil opened this issue Dec 13, 2018 · 2 comments
Assignees
Milestone

Comments

@cdeil
Copy link
Contributor

cdeil commented Dec 13, 2018

I noticed an issue with https://github.com/hipspy/hips/blob/master/hips/draw/tests/test_paint.py

There's an error when just running test_draw_hips_tile_grid because only in test_run the self.painter.run() is executed. Test functions should never depend on each other, all setup code should be in setup or fixture code. Not sure what the proper solution here is, either move the self.painter.run() to setup, or re-consider the setup / tests in this file and try to organise them in a better way.

Also, there is this MPL warning. I didn't track that down yet, maybe it's from here?

ax = plt.subplot(projection=self.geometry.wcs)

Why do we call subplot for each tile? That's probably not a good idea, no?

@adl1995 - I think you wrote this code? Could you maybe have a look?

$ pytest -v hips --remote-data -k test_draw_hips_tile_grid
=============================================================================== test session starts ================================================================================
platform darwin -- Python 3.6.7, pytest-3.6.2, py-1.5.3, pluggy-0.6.0 -- /Users/deil/software/anaconda3/envs/hips-dev/bin/python
cachedir: .pytest_cache
rootdir: /Users/deil/work/code/hips, inifile: setup.cfg
plugins: remotedata-0.3.0, openfiles-0.3.0, doctestplus-0.1.3, arraydiff-0.2
collected 88 items / 87 deselected                                                                                                                                                 

hips/draw/tests/test_paint.py::TestHipsPainter::test_draw_hips_tile_grid FAILED                                                                                              [100%]

===================================================================================== FAILURES =====================================================================================
_____________________________________________________________________ TestHipsPainter.test_draw_hips_tile_grid _____________________________________________________________________

self = <hips.draw.tests.test_paint.TestHipsPainter object at 0x1c1f0012b0>

    def test_draw_hips_tile_grid(self):
>       self.painter.plot_mpl_hips_tile_grid()

hips/draw/tests/test_paint.py:57: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
hips/draw/paint.py:222: in plot_mpl_hips_tile_grid
    ax.imshow(self.image, origin='lower')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <hips.draw.paint.HipsPainter object at 0x1c1f973278>

    @property
    def image(self) -> np.ndarray:
        """Computed sky image (`~numpy.ndarray`).
    
            * The ``dtype`` is always chosen to match the tile ``dtype``.
              This is ``uint8`` for JPG or PNG tiles,
              and can be e.g. ``int16`` or ``float32`` for FITS tiles.
            * The output shape is documented here: `~HipsPainter.shape`.
            """
>       return self.float_image.astype(self.tiles[0].data.dtype)
E       AttributeError: 'NoneType' object has no attribute 'astype'

hips/draw/paint.py:86: AttributeError
------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------
Fetching tiles: 100%|██████████| 38/38 [00:03<00:00, 11.24it/s]
================================================================================= warnings summary =================================================================================
hips/draw/tests/test_paint.py::TestHipsPainter::()::test_draw_hips_tile_grid
  /Users/deil/software/anaconda3/envs/hips-dev/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py:107: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
    warnings.warn(message, mplDeprecation, stacklevel=1)

-- Docs: http://doc.pytest.org/en/latest/warnings.html
=============================================================== 1 failed, 87 deselected, 1 warnings in 4.60 seconds ================================================================
@cdeil cdeil added this to the 0.3 milestone Dec 13, 2018
@cdeil
Copy link
Contributor Author

cdeil commented Dec 14, 2018

After #137 now the travis-ci build is green, and the only warning remaining is this one from MPL.
So @adl1995 - Please take care of this issue first.

I also see that the Windows CI build is hanging in the test that does the plotting:
https://ci.appveyor.com/project/cdeil/hips-19275o3fsp6drby/builds/21010220#L399

@bsipocz or @astrofrog - Probably that's because a GUI windows is popping up?
What needs to be changed to avoid this on Appveyor?
I don't see any settings / commands to choose a non-interactive MPL GUI backend e.g. in https://github.com/astropy/photutils/blob/master/appveyor.yml .

@bsipocz
Copy link
Contributor

bsipocz commented Dec 14, 2018

For linux we have already set the backend in ci-helpers to be non interactive (there it's called MPLBACKEND, maybe the same issue surfaced up here, too). I don't know the windows equivalent though. But if it's fixes it, I suppose we should add the fix to ci-helpers as well.

The latest photutils appveyor build was using mpl 3.0.1, so the issue may be present there, too.

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

No branches or pull requests

3 participants