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

Input check #81

Merged
merged 20 commits into from
Jul 10, 2024
Merged

Input check #81

merged 20 commits into from
Jul 10, 2024

Conversation

judithabk6
Copy link
Owner

still a draft (I know there are commented lines to remove or this sort of things), I have issues with

  • exact tests, not sure why
  • maybe it is the occasion to deal with the reshapes in the src/med_bench/utils/nuisances.py file (need some input on how it should be done @houssamzenati)

I open the PR to discuss if the main direction is ok for everyone (sorry, in develop, not main)

Copy link
Collaborator

@bthirion bthirion left a comment

Choose a reason for hiding this comment

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

Looks good.

src/med_bench/mediation.py Show resolved Hide resolved
src/med_bench/utils/utils.py Outdated Show resolved Hide resolved
src/tests/estimation/test_get_estimation.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@houssamzenati houssamzenati left a comment

Choose a reason for hiding this comment

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

The changes look good to me. Let me know if I can suggest on nuisances.py with the changes that I can state here again:

delete lines 122-125
if len(x.shape) == 1:
x = x.reshape(-1, 1)
if len(m.shape) == 1:
m = m.reshape(-1, 1)

delete line 167-168
if len(x.shape) == 1:
x = x.reshape(-1, 1)

  • replace line 231-236:
    if len(x.shape) == 1:
    x = x.reshape(-1, 1)
    if len(m.shape) == 1:
    mr = m.reshape(-1, 1)
    else:
    mr = np.copy(m)
    by mr = np.copy(m)

Copy link
Collaborator

@bthirion bthirion left a comment

Choose a reason for hiding this comment

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

The PR looks good, but probably needs more tests.

Base automatically changed from develop to main April 23, 2024 16:10
@judithabk6 judithabk6 changed the base branch from main to develop May 2, 2024 14:48
@judithabk6
Copy link
Owner Author

So tests pass, however I think they should not. I missed this modification of tests, 4f63b80 but it results on the exactness tests being no super useful as they do not catch modifications of the behavior of the estimators. And the threshold of 0.01 is larger than the indirect effect so it's really permissive

@codecov-commenter
Copy link

codecov-commenter commented Jun 5, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.08%. Comparing base (43c118b) to head (7a08ff8).

Files Patch % Lines
src/med_bench/mediation.py 90.90% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #81      +/-   ##
===========================================
+ Coverage    86.53%   89.08%   +2.55%     
===========================================
  Files            6        6              
  Lines          750      733      -17     
===========================================
+ Hits           649      653       +4     
+ Misses         101       80      -21     

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

@judithabk6
Copy link
Owner Author

The PR looks good, but probably needs more tests.

The PR looks good, but probably needs more tests.

indeed. I think it would be nice to test each case where the check_input function raises + the output format. I don't know if you have other tests in mind @bthirion ?

As discussed @brash6 we can work on it together depending on who has time first

@bthirion
Copy link
Collaborator

Sorry, I would inspect uncovered lines of code.

@brash6 brash6 mentioned this pull request Jun 20, 2024
@bthirion
Copy link
Collaborator

The changes LGTM. But we need a green CI...

@judithabk6
Copy link
Owner Author

I have modified the tests to make them simpler and to split them (instead of testing several things in the same test). Not sure which one is best. Let me know, but otherwise, I think it's ok, and it will allow to merge the fixes of the CI.

Copy link
Collaborator

@bthirion bthirion left a comment

Choose a reason for hiding this comment

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

LGTM, besides one small detail.

src/tests/utils/test_utils.py Show resolved Hide resolved
Copy link
Collaborator

@bthirion bthirion left a comment

Choose a reason for hiding this comment

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

If you can do a pass to have consistent argument order, that would be great.

if n * dim_m != sum(m.ravel() == 1) + sum(m.ravel() == 0):
raise ValueError("m is not binary")
# check input
y, t, m, x = _check_input(y, t, m, x, setting='binary')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please make sure that the argument order y, t, m, x is there in all functions. Sometimes, there is t, m, x, y

Copy link
Collaborator

@bthirion bthirion left a comment

Choose a reason for hiding this comment

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

LGTM. Will push 2 minor things

src/med_bench/utils/utils.py Outdated Show resolved Hide resolved
src/tests/estimation/test_get_estimation.py Outdated Show resolved Hide resolved
@judithabk6 judithabk6 merged commit 8530e26 into develop Jul 10, 2024
3 checks passed
@brash6 brash6 deleted the input_check branch July 11, 2024 12:27
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.

4 participants