-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
naming: setdiff, diff, gradient #26361
Comments
Ref. #20041 (comment) and downstream discussion regarding |
The standard notation for this is |
|
I’m not sure there’s another reasonable short name for the set difference operation; calling this |
I vote strongly against If you must change then I vote for |
I would support a general # pseudocode for one-dimension
unaccumulate(op, A) = unaccumulate(op, A[1], A)
unaccumulate(op, v0, A) = [v0, (op(A[i], A[i-1]) for i in 2:length(A))...] With this definition, I think this is a bit of a tangent, though, since, like |
If the names are getting a bit long it seems fine to me to use |
👍 for Matt's general |
I'm skeptical that anyone will comprehend a neologism like +1 for merging Note also that @mbauman's definition of |
(Note that |
I've used
The third one is by far the most common (I'd estimate roughly 80%)… but it's largely irrelevant in Julia since Uses 1 and 2 are actually quite distinct from each other, and the conflation between the two has been a large source of bugs in my experience. Here's one of my favorite examples, which includes both use-cases and two different ways of dealing with off-by-one errors: A([1; find(diff(A)>2*median(diff(A)))+1]) So, yes, my desire to change the behavior of |
I think I've seen python overload arithmetic for sets. Maybe + for union, * for intersect, - for setdiff, etc? |
Python uses Julia has synonyms for I think we don't currently have a symmetric difference function for sets? |
I propose to use backslash (like reverse division) and deprecate all set operations on |
The problem with Honestly, I think |
Personally, I use things like |
Tangential, but I'm a little puzzled by the interest in |
True, but that was just an example (since @mbauman mentioned it, together with |
Triage decided not to do anything here. |
Came across this issue today while writing some set differences in some of my own packages. No chance to reconsider the (A ∪ B) - (A ∩ B) reads so much nicer than setdiff(A ∪ B, A ∩ B) |
I will frequently, if I'm doing a lot of setdiff operations just locally define While it's somewhat tempting for the syntax, I'm pretty uncomfortable trying to actually stuff setdiff into either |
It's rather unfortunate that the set minus symbol |
I like the setdiff unicode. If we accept the argument that the Unicode can
be confused with backslash and therefore confuse readers of code that
contains both vectors and sets, we also have to accept the argument that
any two types defining + will be confusing in the same context. This is
argument is not very strong in my opinion. People can always type the
explicit setdiff if they think that in some contexts it could be confused
with backslash.
…On Sun, Jan 5, 2020, 12:16 Stefan Karpinski ***@***.***> wrote:
It's rather unfortunate that the set minus symbol ∖ looks identical to
backslash symbol \ in so many fonts. If it were reliably double wide,
then I think it would be fine to give it this meaning.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#26361?email_source=notifications&email_token=AAZQW3PTM4LWZZXWQ3QN54DQ4H2WJA5CNFSM4EUHOA22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIDZBHQ#issuecomment-570921118>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZQW3NJNUS5WAKSLYGUHNLQ4H2WJANCNFSM4EUHOA2Q>
.
|
It's quite important for generic programming to work in Julia that we are strict about generic functions having a single meaning. So far that is working remarkably well. Let's not throw it out just so that we can have a little syntactic convenience. |
You mean introducing the unicode syntax would restrict the meaning of setdiff? How does it restrict meaning, I don't get it, appreciate if you can clarify. |
There's no problem with introducing a Unicode symbol for setdiff. However, the obvious Unicode character, |
I think there are a couple issues with these names:
set
involves assigning something, e.g. setenv, setfield, setroundingOther possible names for
setdiff
: difference, complement, without, delete, removeOther possible names for
diff
: finitediff, differences, decumulateThe text was updated successfully, but these errors were encountered: