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

extend typing: base #327

Merged
merged 25 commits into from
Jun 29, 2021
Merged

extend typing: base #327

merged 25 commits into from
Jun 29, 2021

Conversation

Borda
Copy link
Member

@Borda Borda commented Jun 29, 2021

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

Fixes # (issue).

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@Borda Borda added enhancement New feature or request refactoring refactoring and code health labels Jun 29, 2021
@codecov
Copy link

codecov bot commented Jun 29, 2021

Codecov Report

Merging #327 (8dbf988) into master (cfc37ff) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #327      +/-   ##
==========================================
- Coverage   96.59%   96.53%   -0.06%     
==========================================
  Files         111      111              
  Lines        3550     3552       +2     
==========================================
  Hits         3429     3429              
- Misses        121      123       +2     
Flag Coverage Δ
Linux 75.81% <85.89%> (+0.01%) ⬆️
Windows 75.81% <85.89%> (+0.01%) ⬆️
cpu 96.53% <100.00%> (+<0.01%) ⬆️
gpu ?
macOS 96.53% <100.00%> (+<0.01%) ⬆️
pytest 96.53% <100.00%> (-0.06%) ⬇️
python3.6 95.66% <100.00%> (+<0.01%) ⬆️
python3.8 96.53% <100.00%> (+<0.01%) ⬆️
python3.9 96.42% <100.00%> (+<0.01%) ⬆️
torch1.3.1 95.66% <100.00%> (+<0.01%) ⬆️
torch1.4.0 95.74% <100.00%> (+<0.01%) ⬆️
torch1.9.0 96.42% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
torchmetrics/collections.py 98.87% <100.00%> (ø)
torchmetrics/metric.py 95.54% <100.00%> (+0.02%) ⬆️
torchmetrics/functional/regression/spearman.py 93.33% <0.00%> (-4.45%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cfc37ff...8dbf988. Read the comment docs.

return CompositionalMetric(torch.bitwise_and, self, other)

def __eq__(self, other: Any):
# Fixme: this shall return bool instead of Metric
Copy link
Member Author

Choose a reason for hiding this comment

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

@justusschock any idea how we could fix this?

Copy link
Member

Choose a reason for hiding this comment

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

I discussed with @tchaton in the past. One can argue for bool and for metric (the metric checks the equality of the outputs for each argument then). Equality would probably go via is or hashes.

So the current behaviour at least is consistent with the other arithmetic and logic operators.

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, I see the arithmetic but feel that logic like eq shall return a bool, that is also why mypy complains as we overwrite something which shall return bool but return metric...

Copy link
Member

Choose a reason for hiding this comment

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

How strict are we with deprecations in metrics? I'm fine with changing it. But I think checking the equality of metrics is not that easy. Probably it would require some syncing and checking the states.

Copy link
Member Author

Choose a reason for hiding this comment

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

we keep 0.1 deprecation loop, but if needed we are fine with breaking changes

@pep8speaks
Copy link

pep8speaks commented Jun 29, 2021

Hello @Borda! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-06-29 10:37:16 UTC

@Borda Borda marked this pull request as ready for review June 29, 2021 09:06
Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

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

I suggested some changes in typing. Maybe this means that we can get rid of the type ignores

torchmetrics/metric.py Outdated Show resolved Hide resolved
torchmetrics/metric.py Outdated Show resolved Hide resolved
torchmetrics/metric.py Show resolved Hide resolved
torchmetrics/metric.py Show resolved Hide resolved
torchmetrics/metric.py Outdated Show resolved Hide resolved
return CompositionalMetric(torch.bitwise_and, self, other)

def __eq__(self, other: Any):
# Fixme: this shall return bool instead of Metric
Copy link
Member

Choose a reason for hiding this comment

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

I discussed with @tchaton in the past. One can argue for bool and for metric (the metric checks the equality of the outputs for each argument then). Equality would probably go via is or hashes.

So the current behaviour at least is consistent with the other arithmetic and logic operators.

torchmetrics/collections.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGTM !

@Borda Borda enabled auto-merge (squash) June 29, 2021 10:48
@Borda Borda disabled auto-merge June 29, 2021 11:22
@Borda Borda merged commit d15249a into master Jun 29, 2021
@Borda Borda deleted the refactor/typing2 branch June 29, 2021 11:23
@Borda Borda self-assigned this Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactoring refactoring and code health
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants