Closed exAClior closed 1 year ago
Shouldn't this be a DomainError
? It seems more appropriate for the cases when only certain set of arguments are allowed. Also, array construction (i.e. [x, y, z]
etc.) can also be easily skipped in the condition by using &&
s instead, not that it would make a big difference but still 🤔
Patch coverage: 100.00
% and no project coverage change.
Comparison is base (
6de8b96
) 83.77% compared to head (745e439
) 83.78%.:exclamation: Current head 745e439 differs from pull request most recent head 0240b25. Consider uploading reports for the commit 0240b25 to get more accurate results
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Shouldn't this be a
DomainError
? It seems more appropriate for the cases when only certain set of arguments are allowed. Also, array construction (i.e.[x, y, z]
etc.) can also be easily skipped in the condition by using&&
s instead, not that it would make a big difference but still 🤔
You are absolutely correct about both. Thank you so much for pointing them out! I considered other ways instead of doing [x,y,z]
but nothing gives a clean-looking code since I would need to include the unit(x)
for all three sides. Or maybe I am misinterpreting your suggestion of using &&
?
Shouldn't this be a
DomainError
? It seems more appropriate for the cases when only certain set of arguments are allowed. Also, array construction (i.e.[x, y, z]
etc.) can also be easily skipped in the condition by using&&
s instead, not that it would make a big difference but still 🤔You are absolutely correct about both. Thank you so much for pointing them out! I considered other ways instead of doing
[x,y,z]
but nothing gives a clean-looking code since I would need to include theunit(x)
for all three sides. Or maybe I am misinterpreting your suggestion of using&&
?
This is not an issue here infact it will make no difference at all as this is just setup code for a simulation. But usually we try to avoid array allocation in simulation codes so I just pointing it out out of a habit 😅. So you can easily ignore the second comment.
Thanks for doing this.
Indeed it could be a
DomainError
. Also, the check can be made once as part of an inner constructor in the struct definition.With regards to the error, I just remembered that the gradient code uses boundaries with zero length sides to accumulate gradients. So maybe just check that side lengths aren't negative to allow this to work.
Thank you so much for pointing out the inner constructor, I think it solves some of the concerns about using [x,y,z]
Hopefully, the code is now a bit neater.
I also allowed negative values to pass too.
I added checks for side length to be greater than zero for
CubicBoundary
andRectangularBoundary
.I did two unit tests locally. One of them gave an error shown below. Looks like zygote might create a
CubicBoundary
with negative side length. However, I was not able to reproduce this again.