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

Missing tests for plotting columns into points #394

Open
LucaMarconato opened this issue Dec 18, 2024 · 0 comments
Open

Missing tests for plotting columns into points #394

LucaMarconato opened this issue Dec 18, 2024 · 0 comments

Comments

@LucaMarconato
Copy link
Member

LucaMarconato commented Dec 18, 2024

I got an error when trying to plot a categorical column present in a point object using the datashader backend. I noticed that no tests were covering plotting points columns, so I added those in this linked PR: #395.

I added 4 tests: [continuous column, categorical column] x [datashader, matplotlib]. 3 tests fail only because the artifacts needs to be regenerated, but the (categorical column, datashader) case has a bug, and it gives this error:

INFO     Using 'datashader' backend with 'None' as reduction method to speed up 
         plotting. Depending on the reduction method, the value range of the    
         plot might change. Set method to 'matplotlib' do disable this          
         behaviour.                                                             
FAILED
tests/pl/test_render_points.py:114 (TestPoints.test_plot_points_categorical_color_column[datashader])
self = <tests.pl.test_render_points.TestPoints object at 0x335239bb0>
sdata_blobs = SpatialData object
├── Images
│     ├── 'blobs_image': DataArray[cyx] (3, 512, 512)
│     └── 'blobs_multiscale_image'...e_labels (Labels), blobs_points (Points), blobs_circles (Shapes), blobs_multipolygons (Shapes), blobs_polygons (Shapes)
method = 'datashader'

    @pytest.mark.parametrize("method", ["matplotlib", "datashader"])
    def test_plot_points_categorical_color_column(self, sdata_blobs: SpatialData, method: str):
>       sdata_blobs.pl.render_points("blobs_points", color="genes", method=method).pl.show()

test_render_points.py:117: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../src/spatialdata_plot/pl/basic.py:936: in show
    _render_points(
../../src/spatialdata_plot/pl/render.py:526: in _render_points
    agg = cvs.points(transformed_element, "x", "y", agg=ds.by(col_for_color, ds.count()))
/opt/miniconda3/envs/ome/lib/python3.12/site-packages/datashader/core.py:225: in points
    return bypixel(source, self, glyph, agg)
/opt/miniconda3/envs/ome/lib/python3.12/site-packages/datashader/core.py:1334: in bypixel
    agg.validate(schema)
/opt/miniconda3/envs/ome/lib/python3.12/site-packages/datashader/reductions.py:745: in validate
    self.preprocess.validate(in_dshape)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <datashader.reductions.category_codes object at 0x3390fb260>
in_dshape = dshape("{x: float64, y: float64, genes: ?string}")

    def validate(self, in_dshape):
        if self.column not in in_dshape.dict:
            raise ValueError("specified column not found")
        if not isinstance(in_dshape.measure[self.column], ct.Categorical):
>           raise ValueError("input must be categorical")
E           ValueError: input must be categorical

/opt/miniconda3/envs/ome/lib/python3.12/site-packages/datashader/reductions.py:161: ValueError
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

1 participant