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

remove redundant attributes_check #287

Merged
merged 2 commits into from
Aug 10, 2023
Merged

Conversation

aaarrti
Copy link
Collaborator

@aaarrti aaarrti commented Jul 26, 2023

Description

  • We have a function, attributes_check, which is used as a decorator, but it is not a decorator.
  • Moreover, it does nothing, and therefore is completely redundant, so let's remove it.

Implemented changes

  • Removed @attributes_check

To illustrate, what the problem is, let's look at the following example.

def attributes_check(metric):
    attr = metric.__dict__
    print(attr)

class A:
 @attributes_check
    def __init__(self, a=1, *, b=2):
        self.a = a
        self.b = b
  1. Running it, we get {} printed out, the moment class definition is loaded. Because the function does not implement decorator patter (does not return a function), and metric is actually a type.
  2. We get {} because __dict__ stores instance attributes, which will only be defined after __init__ (unless class is slotted).

@codecov-commenter
Copy link

codecov-commenter commented Jul 26, 2023

Codecov Report

Merging #287 (4ced200) into main (f5f5805) will decrease coverage by 0.08%.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main     #287      +/-   ##
==========================================
- Coverage   93.37%   93.29%   -0.08%     
==========================================
  Files          62       62              
  Lines        3471     3430      -41     
==========================================
- Hits         3241     3200      -41     
  Misses        230      230              
Files Changed Coverage Δ
quantus/metrics/axiomatic/completeness.py 95.00% <ø> (-0.13%) ⬇️
quantus/metrics/axiomatic/input_invariance.py 100.00% <ø> (ø)
quantus/metrics/axiomatic/non_sensitivity.py 100.00% <ø> (ø)
quantus/metrics/base_batched.py 87.17% <ø> (-0.33%) ⬇️
quantus/metrics/base_perturbed.py 93.10% <ø> (-0.23%) ⬇️
quantus/metrics/complexity/complexity.py 100.00% <ø> (ø)
quantus/metrics/complexity/effective_complexity.py 100.00% <ø> (ø)
quantus/metrics/complexity/sparseness.py 100.00% <ø> (ø)
...s/metrics/faithfulness/faithfulness_correlation.py 96.22% <ø> (-0.07%) ⬇️
...ntus/metrics/faithfulness/faithfulness_estimate.py 98.14% <ø> (-0.04%) ⬇️
... and 27 more

Copy link
Member

@annahedstroem annahedstroem left a comment

Choose a reason for hiding this comment

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

OK, thanks for this attention to detail!

@annahedstroem annahedstroem merged commit c288a7d into main Aug 10, 2023
7 checks passed
@annahedstroem annahedstroem deleted the remove-attributes-check branch November 27, 2023 14:01
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

Successfully merging this pull request may close these issues.

None yet

3 participants