-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Deprecate ones
?
#484
Comments
xref JuliaLang/julia#11557 (comment) and below, and also @Sacha0's PR JuliaLang/julia#24389 |
I have work in progress to this effect that I hope to post in the next day or two :). Best! |
To me |
Note that you rarely need write something as verbose as |
We could just pick whether |
Plan per triage: Revisit next week, specifically considering moving |
Not sure how I feel about moving this and |
It's not a change I'm thrilled about either, but I raised it because it's a logical inconsistency. I think it's fair to say that One option would be to rename it to |
Yes, I would say adding |
I'd be fine with that. Out of curiosity, what are the uses of |
Haha :) I was going to ask - what do you use I think |
See also JuliaLang/julia#23544 |
The dependent variables for an ODE. It would be weird if it just randomly chopped of units when you asked for an array of type |
The fundamental reason to prefer A couple relevant examples from rewrites in base: complex.(ones(size(Ac, 1)), ones(size(Ac, 1))) becomes fill(1.0 + 1.0im, size(Ac, 1)) and 2ones(Int, 2, 2, 2) becomes fill(2, (2, 2, 2)) # or fill(2, 2, 2, 2) if you prefer Please note that these |
@Sacha0: As for |
@carlobaldassi While that is true, a quick GitHub search reveals that almost all uses of |
Using |
@TotalVerb From a quick skim at the first 10 pages of that search, I wouldn't say that "almost all" is a fair assessment. A "significant fraction", at best. There are lots and lots of legitimate use cases for (I also actually have reservations about the readability argument, I think it's questionable to claim that e.g. |
Indeed,
Having just rewritten a few hundred uses of
(Edit: Though I would say roughly half rather than almost all, and appropriate rewrites may be something other than
... that on the other hand, |
To get an objective sense of how The analysis included 156
The remaining calls were semantically reasonable as
Overall, in the wild ~60% of An additional observation: I encountered only one instance of a |
Really interesting discussion ... went from being on the against side to the for side ... Also as another language precedent, R uses |
Wow, thank you @Sacha0 for putting in that effort! The question naturally arises as "what about For whatever reason (I guess it's the symmetry of |
The thing with zeros is that you would seem to be in one of these situations:
There's really no use case where actually allocating a matrix of dense zeros is actually a good idea. |
That’s perhaps true of linear algebra. It’s not uncommon to need a zero-initialized collection in my work on compilers and other data structures. Maybe they are often sparse, but it’s not worth the performance impact to represent them compactly. |
Fair enough – sometimes you don't care about density and the simplicity is worth it. |
Triage: resolved that we keep only the completely non-generic methods i.e. |
@StefanKarpinski for usage recommendations does that mean we would recommend |
This decision seems very surprising to me, it's not so common in base to specifically prevent genericity. What is the reasoning behind? is it that this function comes from matlab where it is not generic (and works only with floats)? |
Further to this, is this issue somehow related to the general problem of constructing arrays that seems to be being considered right now, and if so, how does this help? Or, are we trying to reduce the number of exported methods from |
Writeup forthcoming in JuliaLang/julia#24595 :). Best! |
JuliaLang/julia#24595's OP detailed this issue's broader context, and now a followup in JuliaLang/julia#24595 specifically addresses convenience constructors |
Well, saving at least the It should also be noted that A couple of additional comments on the statistical analysis, since it seems to be the basis of the following discussions and the writeup of JuliaLang/julia#24595. First, ten pages are not really enough for fine-grained conclusions of what's going on in the wild, they can give a rough idea at best. Some files came straight from matlab, for example, as it's clear from their name/style. Secondly, as I suspected, even that analysis shows that roughly half of the uses of Relatedly to the last point, and I think more importantly, what you get to see from a github search will never take into account what's going on in the REPL of people doing exploratory/preliminary work in Julia. Which is exactly where convenience functions come in most handy, and taking them away for no discernible reason is correspondingly most annoying. My point being, having a consistent set of orthogonal primitives that allow to write generic and efficient code is a great goal, and the effort to get there is truly commendable; it's just that not all code is supposed to be beautiful, generic, composable library code. Just my two cents. |
Regarding
which refers to
Note that Concerning your other points, JuliaLang/julia#24595 may be worth reading :). Best! |
I simply find that
I had read it. (I even linked it.) |
Having read JuliaLang/julia#24595 in full and given it due consideration, you are then aware that JuliaLang/julia#24595: (1) concerns a much broader issue of which convenience constructors are only a part; and (2) considers far more than just the statistical analysis posted above and the points you focus on here. I appreciate that you feel strongly about |
Is there a generic zeros(X) anymore, other than: similar(X); fill!(X,0) because the current |
Much thanks for the thoughtful post Chris! :) As an interim shorthand replacement, does Note that such use cases are precisely where the ambiguity in The |
The other problem is that arrays with unconventional indices might want to be created with something like |
Linking JuliaLang/julia#24656, which contains additional discussion of |
I am surprised it's considered odd to use JuliaNLSolvers/NLsolve.jl#89 (comment) However, I do agree with @timholy that it is non-obvious how it should be interpreted. Let me point you to a really non-simple example in DiffEq. https://github.com/JuliaDiffEq/MultiScaleArrays.jl MultiScaleArrays.jl created abstract arrays which are recursive graph-like structures which can be used in the diffeq solvers (and I think it may be compatible with Optim.jl and NLsolve.jl now?). It's a nice convenience for biological models among other things. When we throw it into the ODE solver there's a question: what should we make the cache arrays? In some cases it matters that the user gets back the array they wanted since it will show up in their ODE function To handle this, take a look at the cache for one of the algorithms: Here, Maybe that's just punning off of what already exists, but I think this is an important distinction. When doing generic programming, you have two separate caches: user-facing caches that you want to match types to match their expectation, and internal caches which are just used by the algorithm and you want as much speed as possible. Notice that these are using Hopefully that explanation wasn't too confusing to follow. In all of my cases I can just switch to |
Interesting. You're right that Overall this seems to be a challenging problem. It's a little late in the game, but should we introduce |
I could support a one-argument form of Similarly, we can't assume every
This is another reason I am in favour of |
This discussion is veering towards JuliaLang/julia#18161, and perhaps should continue there :). |
Most recent triage was leaning towards just keeping |
Does it hurt to keep them? I think it helps people who come from numpy feel at home in Julia. |
Closing since we are keeping |
Now that we distinguish
one
andoneunit
,ones(T, sz)
seems like a misnomer. Deprecate in favor offill(oneunit(T), sz)
? If so, should we ditchzeros
too?The text was updated successfully, but these errors were encountered: