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

Feature/737 isreal iscomplex #738

Merged
merged 6 commits into from
Mar 16, 2021
Merged

Conversation

mtar
Copy link
Collaborator

@mtar mtar commented Mar 12, 2021

Description

Add iscomplex() and isreal() functionality that checks element-wise for complex or real values.

Issue/s resolved: #737

Changes proposed:

  • New feature iscomplex
  • New feature isreal

Type of change

  • New feature (non-breaking change which adds functionality)

Due Diligence

  • All split configurations tested
  • Multiple dtypes tested in relevant functions
  • Documentation updated (if needed)
  • Updated changelog.md under the title "Pending Additions"

Does this change modify the behaviour of other functions? If so, which?

no

@mtar mtar marked this pull request as ready for review March 12, 2021 15:39
@codecov
Copy link

codecov bot commented Mar 12, 2021

Codecov Report

Merging #738 (7dbca71) into master (af8a4bb) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #738   +/-   ##
=======================================
  Coverage   95.98%   95.98%           
=======================================
  Files          63       63           
  Lines        8060     8069    +9     
=======================================
+ Hits         7736     7745    +9     
  Misses        324      324           
Flag Coverage Δ
gpu 95.09% <100.00%> (+<0.01%) ⬆️
unit 94.36% <100.00%> (+0.16%) ⬆️

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

Impacted Files Coverage Δ
heat/core/types.py 96.35% <100.00%> (+0.13%) ⬆️

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 af8a4bb...7dbca71. Read the comment docs.

Comment on lines +627 to +632
sanitation.sanitize_in(x)

if issubclass(x.dtype, _complexfloating):
return x.imag != 0
else:
return factories.zeros(x.shape, bool, split=x.split, device=x.device, comm=x.comm)
Copy link
Member

Choose a reason for hiding this comment

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

why not use torch.is_complex?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did not find it 🔍 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

torch.is_complex returns the result for the whole tensor, not element-wise

Copy link
Member

Choose a reason for hiding this comment

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

wow. that is a really annoying difference. but that is what it is

Comment on lines +627 to +632
sanitation.sanitize_in(x)

if issubclass(x.dtype, _complexfloating):
return x.imag != 0
else:
return factories.zeros(x.shape, bool, split=x.split, device=x.device, comm=x.comm)
Copy link
Member

Choose a reason for hiding this comment

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

wow. that is a really annoying difference. but that is what it is

@coquelin77 coquelin77 merged commit 13627f3 into master Mar 16, 2021
@coquelin77 coquelin77 deleted the feature/737-isreal-iscomplex branch March 16, 2021 14:31
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.

implement isreal / iscomplex
2 participants