-
Notifications
You must be signed in to change notification settings - Fork 126
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
Rename issubset to is_subscheme for subschemes (#3202) #3252
Rename issubset to is_subscheme for subschemes (#3202) #3252
Conversation
Thanks for the effort. I appreciate it! |
Can you add deprecations for all renamed functions to src/Deprecations.jl? |
At some point before 1.0 |
Ah ok, in this case I wouldn't do a deprecation. |
@@ -183,7 +183,7 @@ function preimage( | |||
) | |||
X = domain(phi) | |||
Y = codomain(phi) | |||
check && (issubset(Z, Y) || (Z = intersect(Y, Z))) | |||
check && (is_subscheme(Z, Y) || (Z = intersect(Y, Z))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not fault of this PR, but I think this code is too clever for its own good and should be changed; don't do an assignment in what looks like a logical expression, one could mistake the =
for a ==
. Instead do
check && (is_subscheme(Z, Y) || (Z = intersect(Y, Z))) | |
if check && !is_subscheme(Z, Y) | |
Z = intersect(Y, Z) | |
end |
However, more seriously, I also wonder why it does that -- normally I would expect a failed check
to trigger an error, not to "correct" the problem. I can't think of any other place we do this, and indeed in this PR multiple other check
s are modified that all do an error (but I do not claim to have checked all place, neither in this PR nor in all of Oscar)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, at least according to Julia docs, it is perfectly fine to use assignment together with short-circuit evaluation:
julia> true && (x = (1, 2, 3))
(1, 2, 3)
About check
: we can take the preimage of any set by first taking the intersection with the codomain, so it looks OK to me. The user has the option to set check
to false
if they know that Z
is a subscheme and they wish to avoid checking the containment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the question was whether this is valid julia code or not.
It is a question about how much time someone has to spend to understand this, when the code has to be improved/rewritten/fixed in a few years, and the original author is not available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Tommy explained, this is not about what is valid syntax, this is about what is maintainable.
Moreover, check
everywhere else means "raise an error if the input is invalid", and here it now means something different. That's bad. For example, before one could set check=true
while e.g. debugging to verify one has no bug in the code, and if there is no error, one has evidence for that, while if there is a bug, one may see an error and can debug it.
But here check
silently papers over mistakes. So presumably no error will be raised, and the behavior may even differ between check=true
and check=false
. I don't think that's acceptable.
But of course this is not an issue with this PR, it is an issue with the existing code, so it can be fixed in a separate PR. But fixed it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely agree. The name of the variable (check
) should clearly indicate what it is checking (check_z_contained_in_y
). And there should be consistency whether the function returns an error whenever the check fails. It might be worth elaborating on this in the OSCAR styleguide (it only briefly mentions input sanity checks).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing blocking this right now for me is the broken CI.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #3252 +/- ##
==========================================
+ Coverage 81.63% 81.77% +0.13%
==========================================
Files 546 546
Lines 73163 73850 +687
==========================================
+ Hits 59730 60393 +663
- Misses 13433 13457 +24
|
…scar-system#3252) * Rename issubset to is_subscheme for schemes
The
issubset
functions where the arguments are not schemes were (obviously) not renamed. This change was rather tricky to implement becauseU
stands for a scheme and we needis_subscheme
, sometimesU
is aninverted_set
and we needissubset
,