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

Clean up legacy code in _models.py and related parts #180

Open
5 tasks done
LucaMarconato opened this issue Nov 5, 2023 · 4 comments · Fixed by #205
Open
5 tasks done

Clean up legacy code in _models.py and related parts #180

LucaMarconato opened this issue Nov 5, 2023 · 4 comments · Fixed by #205

Comments

@LucaMarconato
Copy link
Member

LucaMarconato commented Nov 5, 2023

CC @giovp, please comment on this.

_models.py contains a lot of legacy code that makes the code fragile. In particular we should remove the following:

  • _scale, not used anymore now that we have coordinate transformations
  • _spot_diameter/_point_diameter, we should keep one of the two only
  • label_key (and relative methods, like the getter/setter labels_key. This is in reality instance_key, and for some reasons it's used only for labels. The region_key + instance_key logic applies both to labels and shapes (shapes=circles or polygons/multipolygons). I suggest either to add region_key and instance_key to the model, or not put them in the model at all. I favor the second approach.
  • remove _spatial_key, not needed any more

In this PR I would also make the following change:

  • since we don't need both _spot_diameter and _point_diameter, let's remove the points widget from the bottom right UI; it's never used.
@giovp
Copy link
Member

giovp commented Nov 6, 2023

yes! yes agree on all the points

@melonora
Copy link
Collaborator

melonora commented Nov 6, 2023

I can pick this up

@LucaMarconato
Copy link
Member Author

More on this:

  • spot_diameter seems to never be used.

@LucaMarconato
Copy link
Member Author

@melonora addressed the point on labels_key here: https://github.com/scverse/napari-spatialdata/pull/200/files. Great work!

@melonora melonora mentioned this issue Mar 13, 2024
LucaMarconato added a commit that referenced this issue Mar 14, 2024
* Multi table (#196)

* update napari dependency

* change deprecated is_categorical_dtype

* Iinitial table widget

* add table_names to model

* More self explainable function name

* allow changing tables

* fix some tests

* Fixed tests

* Revert "Multi table (#196)" (#197)

This reverts commit aa56cca.

* Avoid exception when registering shortcut (#201)

* Fix undefined attribute _labels_key

Accessing the property `model.labels_key` gave an `AttributeError("'ImageModel' object has no attribute '_labels_key'")`

* Avoid exception when key binding collides with existing

If the shortcut is already registered, Napari does not warn but raise an error. To avoid crashing Napari, we must provide the override argument (no matter whether preserving existing or overriding with the new command).

* add color by in adata view

* remove _scale from model

* remove points coordinates

* remove point_diameter

* remove spot diameter

---------

Co-authored-by: aeisenbarth <54448967+aeisenbarth@users.noreply.github.com>
Co-authored-by: Luca Marconato <m.lucalmer@gmail.com>
melonora added a commit that referenced this issue Mar 19, 2024
* Multi table (#198)

* update napari dependency

* change deprecated is_categorical_dtype

* Iinitial table widget

* add table_names to model

* More self explainable function name

* allow changing tables

* fix some tests

* Fixed tests

* Multi table (#200)

* update napari dependency

* change deprecated is_categorical_dtype

* Iinitial table widget

* add table_names to model

* More self explainable function name

* allow changing tables

* fix some tests

* Fixed tests

* remove legacy squidpy

* remove legacy squidpy

* remove coordinates

* fix tests

* silence warnings

* fix last tests

* fix mypy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Multi table (#202)

* update napari dependency

* change deprecated is_categorical_dtype

* Iinitial table widget

* add table_names to model

* More self explainable function name

* allow changing tables

* fix some tests

* Fixed tests

* remove legacy squidpy

* remove legacy squidpy

* remove coordinates

* fix tests

* silence warnings

* fix last tests

* fix mypy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add table for adatascatter

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Fix adding layer without table

* fix removing layer

* fix wrong point size when affine specified (#193)

* add color by in adata view (#204)

* Issue #180 (#205)

* Multi table (#196)

* update napari dependency

* change deprecated is_categorical_dtype

* Iinitial table widget

* add table_names to model

* More self explainable function name

* allow changing tables

* fix some tests

* Fixed tests

* Revert "Multi table (#196)" (#197)

This reverts commit aa56cca.

* Avoid exception when registering shortcut (#201)

* Fix undefined attribute _labels_key

Accessing the property `model.labels_key` gave an `AttributeError("'ImageModel' object has no attribute '_labels_key'")`

* Avoid exception when key binding collides with existing

If the shortcut is already registered, Napari does not warn but raise an error. To avoid crashing Napari, we must provide the override argument (no matter whether preserving existing or overriding with the new command).

* add color by in adata view

* remove _scale from model

* remove points coordinates

* remove point_diameter

* remove spot diameter

---------

Co-authored-by: aeisenbarth <54448967+aeisenbarth@users.noreply.github.com>
Co-authored-by: Luca Marconato <m.lucalmer@gmail.com>

* Issue #192 (#207)

* Multi table (#196)

* update napari dependency

* change deprecated is_categorical_dtype

* Iinitial table widget

* add table_names to model

* More self explainable function name

* allow changing tables

* fix some tests

* Fixed tests

* Revert "Multi table (#196)" (#197)

This reverts commit aa56cca.

* Avoid exception when registering shortcut (#201)

* Fix undefined attribute _labels_key

Accessing the property `model.labels_key` gave an `AttributeError("'ImageModel' object has no attribute '_labels_key'")`

* Avoid exception when key binding collides with existing

If the shortcut is already registered, Napari does not warn but raise an error. To avoid crashing Napari, we must provide the override argument (no matter whether preserving existing or overriding with the new command).

* add color by in adata view

* remove _scale from model

* remove points coordinates

* remove point_diameter

* remove spot diameter

* fix #192

---------

Co-authored-by: aeisenbarth <54448967+aeisenbarth@users.noreply.github.com>
Co-authored-by: Luca Marconato <m.lucalmer@gmail.com>

* Test spatialelement table join (#208)

* fixed all the non-cytassist images

* refactor get_init_table_list

* fix permutation

* use join

* use join for view

* change hardcoded sample threshold

* bunch of updates

* adjust test

* change into left join

* change into left join

* random hex colors

* get actual index

* change indices and adata

* match rows left

* fix joins

* rename to vars

* fix color by

* fix radii

* pass cs

* fix _calc_default_radii()

* fix tests

* improve speed test

* removed comments

* added code to show circles as ellipses

* correct point layer size after scaling

* fix labels color by

* fix mibitof example

* last bug fixes

* initial step points columns

* add dask import back

* fix points columns

---------

Co-authored-by: wmv_hpomen <w-mv@hotmail.com>
Co-authored-by: Wouter-Michiel Vierdag <michiel.vierdag@embl.de>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: LucaMarconato <2664412+LucaMarconato@users.noreply.github.com>
Co-authored-by: aeisenbarth <54448967+aeisenbarth@users.noreply.github.com>
Co-authored-by: Luca Marconato <m.lucalmer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants