Skip to content

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

Description

@cdeil

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 ================================================================

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions