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

Add highlight for instance group dock #1860

Conversation

justinvshen
Copy link
Collaborator

Description

add highlighting feature for row in instance group dock

Types of changes

  • Bugfix
  • New feature
  • Refactor / Code style update (no logical changes)
  • Build / CI changes
  • Documentation Update
  • Other (explain)

Does this address any currently open issues?

[list open issues here]

Outside contributors checklist

  • Review the guidelines for contributing to this repository
  • Read and sign the CLA and add yourself to the authors list
  • Make sure you are making a pull request against the develop branch (not main). Also you should start your branch off develop
  • Add tests that prove your fix is effective or that your feature works
  • Add necessary documentation (if appropriate)

Thank you for contributing to SLEAP!

❤️

Copy link

coderabbitai bot commented Jul 10, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

@justinvshen justinvshen changed the base branch from develop to liezl/add-gui-elements-for-sessions July 10, 2024 16:56
@justinvshen justinvshen changed the title Justin/add highlight for instance group dock Add highlight for instance group dock Jul 10, 2024
@roomrys roomrys added the MultiView Stack This PR is part of the MultView stacked PRs. label Jul 11, 2024
Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 74.18%. Comparing base (0f9fe25) to head (df35086).

Files Patch % Lines
sleap/gui/widgets/video.py 73.33% 4 Missing ⚠️
Additional details and impacted files
@@                           Coverage Diff                           @@
##           liezl/add-gui-elements-for-sessions    #1860      +/-   ##
=======================================================================
- Coverage                                74.18%   74.18%   -0.01%     
=======================================================================
  Files                                      135      135              
  Lines                                    25425    25438      +13     
=======================================================================
+ Hits                                     18862    18871       +9     
- Misses                                    6563     6567       +4     

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

Copy link
Collaborator

@roomrys roomrys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make these changes, then things should be in a working state. Also, make sure to run black on sleap/gui/widgets/video.py (and any other file you change - if any)

elif isinstance(select, Instance):
instance.selected = select == instance.instance
elif isinstance(select, InstanceGroup):
instance.selected = True if instance in select else False
instance.selected = select == idx or select == instance.instance
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the old logic otherwise you are just overwriting your changes from above:

Suggested change
instance.selected = select == idx or select == instance.instance

elif isinstance(select, Instance):
instance.selected = select == instance.instance
elif isinstance(select, InstanceGroup):
instance.selected = True if instance in select else False
Copy link
Collaborator

@roomrys roomrys Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InstanceGroup stores Instance objects not QtInstance objects, so we need to use the QtInstance.instance attribute to get the associated Instance.

Also, when using the in keyword in Python, the dunder method __contains__ is called on the object that is being checked for containment. If __contains__ is not implemented, Python falls back to using the __iter__ method to iterate over the elements (if available) and checks each element. If __iter__ is also not implemented, Python then tries to use the __getitem__ method to check for containment by iterating over index values starting from zero.

Neither InstanceGroup.__contains__ nor InstanceGroup.__iter__ is implemented and InstanceGroup.__getitem__ unfortunately only handles this in the case of the Instance selected being the first instance in InstanceGroup.instances (we iterate to too large a number otherwise and get a KeyError). Let's just use in InstanceGroup.instances for now.

Suggested change
instance.selected = True if instance in select else False
instance.selected = True if instance.instance in select.instances else False

Copy link
Collaborator

@roomrys roomrys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug has been located. Sorry if my comments mislead you!

instance.selected = select == idx
elif isinstance(select, Instance):
instance.selected = select == instance.instance
elif isinstance(select, QtInstance.instance):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot access an instance attribute on a class. If you have some time, I would suggest reading this article on instance attributes.

Suggested change
elif isinstance(select, QtInstance.instance):
elif isinstance(select, QtInstance):

@roomrys roomrys marked this pull request as ready for review July 26, 2024 18:13
@roomrys roomrys merged commit 69e00b1 into liezl/add-gui-elements-for-sessions Jul 26, 2024
8 of 9 checks passed
@roomrys roomrys deleted the justin/add-highlight-for-InstanceGroupDock branch July 26, 2024 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiView Stack This PR is part of the MultView stacked PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants