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

prefer loading features from features rather than properties #319

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

jo-mueller
Copy link
Collaborator

I had some issues that the features could not be read into the plotter widget once a dimensionality reduction was done. This is likely due to the fact that somewhere in the code, the properties attribute of the processed layer is set to {}. This in turn leads to unintended behavior in the getlayer_tabular_data function:

def get_layer_tabular_data(layer):
    """
    Return tabular data associated with a layer object.

    Parameters:
    -----------
    layer : object (napari layer)
        An object that may contain tabular data as either properties (older napari versions) or features.

    Returns :
    --------
    pandas.DataFrame or None
        A DataFrame containing the tabular data, or None if no data was found.
    """
    if hasattr(layer, "properties") and layer.properties is not None:
        return pd.DataFrame(layer.properties)
    if hasattr(layer, "features") and layer.features is not None:
        return layer.features
    return None

properties would then exist as an attribute, but it's empty, since everything relevant is in the features attribute. Since the latter is preferably used now, the plotter should also first try to load from there instead of the properties.

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 79.47%. Comparing base (30a3c0c) to head (ceaff42).
Report is 3 commits behind head on main.

Files Patch % Lines
napari_clusters_plotter/_utilities.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #319      +/-   ##
==========================================
- Coverage   79.57%   79.47%   -0.10%     
==========================================
  Files          16       16              
  Lines        2071     2071              
==========================================
- Hits         1648     1646       -2     
- Misses        423      425       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zoccoler zoccoler added this to the 0.8.0 milestone Jun 12, 2024
@zoccoler zoccoler added the bug Something isn't working label Jun 12, 2024
@zoccoler zoccoler merged commit 861bcf5 into main Jun 12, 2024
7 checks passed
@zoccoler zoccoler deleted the fix-feature-loading branch June 12, 2024 12:56
@jo-mueller jo-mueller mentioned this pull request Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants