-
-
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
randbool() API #9105
Comments
Do you mean deprecating the function or only the method with no argument? In the latter case, this would imply that after deprecation period, |
I meant getting rid of it altogether. This is a valid point that
|
I'd like to see Couldn't we just define |
I wouldn't like |
We have types, so I don't think we need as many function names for closely related functionality. Re: #5986 (comment) I'd also be fine with getting rid of |
For a BitArray, how about (Now that I look at it, it doesn't seem very obvious/nice, but maybe it sparks other ideas.) |
With only two more characters, |
The docs of
It feels like the emphasize is more on generating a scalar value. If
|
Just thinking out loud: the current API
Of course this is more verbose. |
I have another suggestion for the RNG api that came up in the argument ordering thread. Note that I updated the title of this issue. |
Is |
|
I'm wondering if the renaming of |
FWIW, I don't like the idea that |
While this is certainly true, it is really not that informative. Good things, it caters to Matlab refugees, it is short, it preserves some sort of relation to the |
srand is kind of traditional and not bad. I don't really see much need to change it. |
Ok - what about |
I don't think there are good reasons to have both |
To me, the relevant question is whether people should generally be using |
It seems like it's very situation dependent (BitArrays are smaller, allocated way faster, slower to iterate through, way slower for getindex or setindex!, etc.), and the API should move toward making Array{Bool} as convenient to use as BitArray given it's a valid choice (even if was uncommon to index into 1/4 of the elements of the array or update 1/7th of the elements over its lifetime, the current API would still feel a little paternalistic). All for making it clearer which type each bool-related |
I think it may be sufficient to allow filling an |
Sorry -- I was thinking of Julia 0.3, I definitely agree that the situation on 0.4 is good (other than |
It seems like we can go with: Deprecating |
I must be in the minority here, but The definition of Am I wrong in thinking that the non-memory benefit of allocating a BitArray is wiped out once the 1/7th of the elements have been updated (for example)? It really so uncommon that users would be served by faster iteration, indexing, and updating, that Base should introduce these asymmetries and complicate definitions of basic functions to force users away from using Arrays of Bool when they ask for them (we're already more thoroughly exposed to BitArrays than to many pockets of the language we should be encouraged to use)? |
Agreed, special-casing a type is a very bad idea, especially in a language where you can often write very abstract functions parametrized on types. |
I'm also not sold on this change. |
I can see the argument for not making |
I like that too. Basically this now boils down to deprecating @StefanKarpinski @JeffBezanson Thoughts? |
I vote against removing the functions and forcing the usage of more general but verbose methods. I'm likely biased since I use these methods all the time, but I really don't see what's to be gained by removing them, at the cost of reduced code readability. I'd much prefer renaming them instead. The original I'm not convinced by the argument for plain removal by @garborg:
My objection is that BitArrays are, in the current state of affairs, one of the core types in Julia, since they are returned as the result of all element-wise comparisons, and thus are not like any other specialized container. So it doesn't seem unjustified to have specialized methods for constructing some common special cases. One more objection is that I don't expect to see many new array-like container kinds added to Base, while most new containers of such kind would added in packages, where it is perfectly reasonable to add specialized constructors for common cases (for example, if BitArrays were not in Base and I wanted to write a package to add them, I'd surely add those constructors - the fact of not having those methods because the container is in Base seems silly to me). Consider also that Finally, there are currently the functions |
I am ok with having many I agree that it is unlikely we will add more containers to base. |
I guess it would be OK to have both |
I think it's not a great idea to keep things like |
Probably I think my argument boils down to this: |
I don't see why |
But at that point, wouldn't it be better to just make |
@garborg as was mentioned, |
Oops, thanks. On Thu, Jan 1, 2015 at 6:04 PM, Tony Kelman [email protected]
|
Spones is also used to make a sparse matrix of the same structure as another matrix in Matlab. I would be open to getting rid of it, of it can be merged into ones() and have a compact invocation. |
|
We do have @carlobaldassi What about @rfourquet 's suggestion of having a type named |
I wanted today to implement the Moreover, I personally think that it's actually a good thing that the special treatment of The |
I'm sorry to be that guy, but I still don't understand what's the issue here:
Having said all this, it seems like I'm in the minority (probably since I'm a heavy |
I agree with @carlobaldassi. I'm not terribly bothered by the current API – BitArray is a special type and having special constructors for it seems reasonable to me. |
It's more likely I'm in the minority and spoke too loudly, especially given the added exports tradeoff seems ambiguous to me with the current set of containers, so I won't push any more discussion. (Other than for what seems to be in agreement: no name |
I am ok with the special constructors for BitArray as well, but with more consistency that have a clear distinction from the Bool types. |
For a random Bool, instead of randbool(), use rand(Bool) Instead of randbool(dims), use bitrand(dims)
For a random Bool, instead of randbool(), use rand(Bool) Instead of randbool(dims), use bitrand(dims)
The That it could be "elegant" is not important, but the useful thing in it is that it's less methods/implementations to maintain. |
I momentarily felt the temptation for the For now, I am restricting my attention to my original goal - fixing the randbool API, which I have a PR for now. |
For a random Bool, instead of randbool(), use rand(Bool) Instead of randbool([rng], dims), use bitrand([rng], dims) Add randbool deprecation to NEWS
For a random Bool, instead of randbool(), use rand(Bool) Instead of randbool([rng], dims), use bitrand([rng], dims) Add randbool deprecation to NEWS
For a random Bool, instead of randbool(), use rand(Bool) Instead of randbool([rng], dims), use bitrand([rng], dims) Add randbool deprecation to NEWS
I am closing this with the randbool deprecation, which was the original topic of this issue. |
Given that we have
rand(Bool)
, which is fully general, we can deprecaterandbool()
. Any reasons to keep it? Performance wise, there doesn't seem to be any difference either.Cc: @rfourquet
The text was updated successfully, but these errors were encountered: