DiCE icon indicating copy to clipboard operation
DiCE copied to clipboard

Fix incompatible types in assignment

Open daikikatsuragawa opened this issue 2 years ago • 6 comments

Signed-off-by: Daiki Katsuragawa [email protected]

This pull request is one of the steps of #331 . Most of the "Incompatible types in assignment" errors detected by mypy are fixed. Basically, the policy is to modify the process without major changes. Therefore, there are also temporary responses (e.g., defining type hints Any). These are excluded from the modifications in this pull request and will be revised later.

In conclusion, this pull request will have the following effects.

  • Deletion of "Incompatible types in assignment" processes
  • Prevention of unexpected exceptions
  • Improved readability with type hints

daikikatsuragawa avatar Nov 16 '22 15:11 daikikatsuragawa

Codecov Report

Base: 72.04% // Head: 72.12% // Increases project coverage by +0.07% :tada:

Coverage data is based on head (61b7d79) compared to base (8f17cfd). Patch coverage: 78.12% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #344      +/-   ##
==========================================
+ Coverage   72.04%   72.12%   +0.07%     
==========================================
  Files          26       26              
  Lines        3595     3598       +3     
==========================================
+ Hits         2590     2595       +5     
+ Misses       1005     1003       -2     
Flag Coverage Δ
unittests 72.12% <78.12%> (+0.07%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
dice_ml/explainer_interfaces/feasible_base_vae.py 0.00% <0.00%> (ø)
...e_ml/explainer_interfaces/feasible_model_approx.py 0.00% <0.00%> (ø)
dice_ml/explainer_interfaces/explainer_base.py 89.46% <75.00%> (-0.21%) :arrow_down:
dice_ml/explainer_interfaces/dice_genetic.py 94.89% <87.50%> (-0.25%) :arrow_down:
dice_ml/explainer_interfaces/dice_KD.py 91.72% <100.00%> (ø)
dice_ml/explainer_interfaces/dice_pytorch.py 85.84% <100.00%> (+0.12%) :arrow_up:
dice_ml/explainer_interfaces/dice_random.py 93.84% <100.00%> (+0.66%) :arrow_up:
dice_ml/explainer_interfaces/dice_tensorflow2.py 86.23% <100.00%> (-0.05%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov-commenter avatar Nov 16 '22 15:11 codecov-commenter

@daikikatsuragawa thanks for this contribution. Can you share a few lines on the motivation for this PR (e.g., why change cfs from [] to pd.DataFrame()?) and are there any bugs that this PR fixes?

amit-sharma avatar Nov 18 '22 06:11 amit-sharma

@amit-sharma

Comment on each. After completion, send a message with a Mention.

daikikatsuragawa avatar Nov 18 '22 10:11 daikikatsuragawa

Operational error for closed (and reopened). My apologies.

daikikatsuragawa avatar Nov 18 '22 10:11 daikikatsuragawa

@amit-sharma

Should we enable mypy in dice-ml linting build and fix all the mypy errors?

Yes. However, some mypy errors remain at present. It would be good to add them to Lint after they have been resolved.

daikikatsuragawa avatar Feb 19 '23 04:02 daikikatsuragawa

@amit-sharma

@daikikatsuragawa thanks for this contribution. Can you share a few lines on the motivation for this PR (e.g., why change cfs from [] to pd.DataFrame()?)

During the function, the process immediately following was checked and it was determined that the type of cfs is pd.DataFrame. If this is not appropriate, please let me know.

https://github.com/interpretml/DiCE/blob/490b7abce937b2008cf4b7b5dd6ca8f579f967f7/dice_ml/explainer_interfaces/dice_KD.py#L173-L176

and are there any bugs that this PR fixes?

Probably this case (cfs = pd.DataFrame()) only. The others are fixes related to type hinting and refactoring and are not expected to affect behaviour. Unit tests also passed.

daikikatsuragawa avatar Feb 19 '23 04:02 daikikatsuragawa