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

Remove checkData from copy constructor and assignment operator in Fields #1533

Merged
merged 6 commits into from
Feb 4, 2019

Conversation

d7919
Copy link
Member

@d7919 d7919 commented Jan 31, 2019

This allows us to copy and assign from empty fields.

@ZedThree
Copy link
Member

I think we test for this behaviour, so you'll likely need to remove those tests as well

@d7919
Copy link
Member Author

d7919 commented Jan 31, 2019

I think we test for this behaviour, so you'll likely need to remove those tests as well

It passed all the unit tests locally!

Edit Ah, it probably depends on the check level.

@codecov-io
Copy link

Codecov Report

Merging #1533 into next will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #1533      +/-   ##
==========================================
- Coverage   43.06%   43.05%   -0.02%     
==========================================
  Files         201      201              
  Lines       27257    27252       -5     
==========================================
- Hits        11738    11733       -5     
  Misses      15519    15519
Impacted Files Coverage Δ
src/field/field2d.cxx 78.63% <ø> (-0.19%) ⬇️
src/field/fieldperp.cxx 100% <ø> (ø) ⬆️
src/field/field3d.cxx 57.88% <ø> (-0.17%) ⬇️
tests/unit/field/test_field3d.cxx 100% <100%> (ø) ⬆️

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 2a68fee...168aa54. Read the comment docs.

@ZedThree
Copy link
Member

Not sure why CodeCov has chimed in!

Any major objections to this? I think this is the right thing to do (see #1385)

@d7919
Copy link
Member Author

d7919 commented Jan 31, 2019

One possible objection is operator= with mixed types (e.g 3d = 2d) have to do checkdata but same types (3d=3d) don't.

@johnomotani
Copy link
Contributor

I agree this is the right thing to do 👍

@ZedThree
Copy link
Member

ZedThree commented Feb 1, 2019

For the mixed types assignment, I think we need at least the check the rhs is allocated (else the copy won't work), but we could change what we do with that information, e.g. if the rhs is not allocated, deallocate the lhs and return. Otherwise, do the copy without checking if the rhs is finite.

@d7919
Copy link
Member Author

d7919 commented Feb 1, 2019

For the mixed types assignment, I think we need at least the check the rhs is allocated (else the copy won't work), but we could change what we do with that information, e.g. if the rhs is not allocated, deallocate the lhs and return. Otherwise, do the copy without checking if the rhs is finite.

Yes I thought about that a bit but decided for now that I'd just do the simplest thing (i.e. leave the checks in place). Happy to replace those with an isAllocated type check though.

@bendudson
Copy link
Contributor

I think having an isAllocated check, and invalidating the LHS if the RHS is invalid is probably the most consistent approach. I have some worry that not checking for invalid data will make tracking down bugs harder, but a user can always add calls to checkData for debugging.

@d7919
Copy link
Member Author

d7919 commented Feb 1, 2019

I think having an isAllocated check, and invalidating the LHS if the RHS is invalid is probably the most consistent approach. I have some worry that not checking for invalid data will make tracking down bugs harder, but a user can always add calls to checkData for debugging.

I hope this shouldn't impact debugging too much as we still rigorously checkData on the input and output of most operations so at the point of doing any calculation with the fields we should catch this.



/// Check that the data is allocated
ASSERT1(rhs.isAllocated());
Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of ASSERT here we could just choose to return the unallocated Field3D so that we allow assignment from unallocated fields -- I'm not sure that would be good but is an option.

@ZedThree
Copy link
Member

ZedThree commented Feb 4, 2019

Merging this now to immediately update #1345, but we may want to revisit mixed-type assignment for uninitialised fields

@ZedThree ZedThree merged commit f3b3dcb into next Feb 4, 2019
@ZedThree ZedThree deleted the remove_checkdata_field_constructors branch February 4, 2019 13:36
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.

None yet

5 participants