plum icon indicating copy to clipboard operation
plum copied to clipboard

Fix default arguments bug and improve `MethodRedefinitionWarning`

Open wesselb opened this issue 1 year ago • 5 comments

What the title says. WIP.

wesselb avatar Jun 23 '24 18:06 wesselb

Pull Request Test Coverage Report for Build 9635565885

Details

  • 11 of 12 (91.67%) changed or added relevant lines in 4 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 99.682%

Changes Missing Coverage Covered Lines Changed/Added Lines %
plum/resolver.py 6 7 85.71%
<!-- Total: 11 12
Files with Coverage Reduction New Missed Lines %
plum/signature.py 2 98.77%
<!-- Total: 2
Totals Coverage Status
Change from base Build 9552070800: -0.2%
Covered Lines: 1253
Relevant Lines: 1257

💛 - Coveralls

coveralls avatar Jun 23 '24 18:06 coveralls

@wesselb The warning is very noisy and several users are complaining. Can we revert the previous PR until we have something that works fine?

PhilipVinc avatar Jun 24 '24 15:06 PhilipVinc

@PhilipVinc I agree that it's noisy, but it's also already uncovered some issues, so it does have significant utility.

How about an opt-out mechanism, where the warning is supressed if the module of the implementation that overwrites the current method is part of a list?

You'd then do something like

from plum import opt_out_method_redefinition_warning_for_package

opt_out_method_redefinition_warning_for_package("netket")

wesselb avatar Jun 24 '24 15:06 wesselb

What issues?

PhilipVinc avatar Jun 24 '24 15:06 PhilipVinc

E.g., this currently happens on master:

In [1]: from plum import dispatch
   ...:
   ...:
   ...: @dispatch.multi((int, float))
   ...: def f(x: int, y: float, z: float = 1):
   ...:     pass
   ...:
   ...:
   ...: print(f.methods)
List of 2 method(s):
    [0] f(x: int, y: float)
        <function f at 0x7f84606ea040> @ /<ipython-input-1-a3ba1c0fba39>:4
    [1] f(x: int)
        <function f at 0x7f84606ea040> @ /<ipython-input-1-a3ba1c0fba39>:4

This PR fixes that bug.

It's also raising some redefinition warnings in other packages of mine where I wouldn't expect them, so I'm digging into those and might find bugs there too.

wesselb avatar Jun 24 '24 15:06 wesselb

Pull Request Test Coverage Report for Build 9817867630

Details

  • 11 of 12 (91.67%) changed or added relevant lines in 4 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 99.684%

Changes Missing Coverage Covered Lines Changed/Added Lines %
plum/resolver.py 6 7 85.71%
<!-- Total: 11 12
Files with Coverage Reduction New Missed Lines %
plum/signature.py 2 98.75%
<!-- Total: 2
Totals Coverage Status
Change from base Build 9817780198: -0.2%
Covered Lines: 1261
Relevant Lines: 1265

💛 - Coveralls

coveralls avatar Jul 06 '24 08:07 coveralls

Pull Request Test Coverage Report for Build 9817905029

Details

  • 11 of 12 (91.67%) changed or added relevant lines in 4 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 99.684%

Changes Missing Coverage Covered Lines Changed/Added Lines %
plum/resolver.py 6 7 85.71%
<!-- Total: 11 12
Files with Coverage Reduction New Missed Lines %
plum/signature.py 2 98.75%
<!-- Total: 2
Totals Coverage Status
Change from base Build 9817780198: -0.2%
Covered Lines: 1261
Relevant Lines: 1265

💛 - Coveralls

coveralls avatar Jul 06 '24 08:07 coveralls

Pull Request Test Coverage Report for Build 9818904615

Details

  • 23 of 23 (100.0%) changed or added relevant lines in 5 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 99.763%

Files with Coverage Reduction New Missed Lines %
plum/signature.py 2 98.75%
<!-- Total: 2
Totals Coverage Status
Change from base Build 9817780198: -0.2%
Covered Lines: 1265
Relevant Lines: 1268

💛 - Coveralls

coveralls avatar Jul 06 '24 11:07 coveralls

Pull Request Test Coverage Report for Build 9819016971

Details

  • 23 of 23 (100.0%) changed or added relevant lines in 5 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 99.763%

Files with Coverage Reduction New Missed Lines %
plum/signature.py 2 98.75%
<!-- Total: 2
Totals Coverage Status
Change from base Build 9817780198: -0.2%
Covered Lines: 1265
Relevant Lines: 1268

💛 - Coveralls

coveralls avatar Jul 06 '24 11:07 coveralls