-
-
Notifications
You must be signed in to change notification settings - Fork 744
[ndslice] creation/allocation utilities #4182
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
Conversation
} | ||
|
||
/// | ||
unittest |
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.
needs @nogc
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.
thanks!
I already tried my best to review the changes at |
I am thinking about automatic convetion tool ;) |
@wilzbach what do you think about to rename |
import std.range: iota, retro; | ||
auto a = 20.iota.sliced(4, 5); | ||
import std.experimental.ndslice.selection: iotaSlice; | ||
auto a = iotaSlice(4, 5); | ||
|
||
assert(a.dropExactly !(1, 0)(2, 3)[0, 0] == 17); | ||
assert(a.dropExactly !(1, 0)(2, 3).shape == cast(size_t[2])[1, 3]); |
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.
why is there so much whitespace here?
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.
allgned with lines below
Besides testing, what's the rationale for iotaSlice? |
I was actually thinking about this too. Initially I wanted to suggest that we use the same method name for both the gc and allocation version, but prefixing it with |
This is good building block for abstract algorithms along with |
{ | ||
size_t[2] shape = (int[][]).init.shape; | ||
assert(shape[0] == 0); | ||
assert(shape[1] == 0); |
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.
could you add a test for a higher-dimensional array?
We only test 2d in all tests.
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.
2D is OK for recursion algorithms. btw, amount of unittests in ndslice already largest in Phobos except std.datetime
.
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.
2D is OK for recursion algorithms
I was just worried that we create a bias with the tests by only testing 2d.
amount of unittests in ndslice already largest in Phobos except std.datetime
How did you measure this?
Last time I checked there were some parts in Phobos with 100% coverage.
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.
Last time I checked there were some parts in Phobos with 100% coverage.
I mean amount of LOC
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.
How did you measure this?
I just know probos pretty well)
needs rebase :( |
@9il I have an alternative idea about the allocation API:
(Ditto for Full example: http://dpaste.dzfl.pl/c3894699a269 |
We tried this before, but unfortunately |
In addition, current API is similar to |
Then we should fix
OK, but what do you think about only changing
|
If @andralex change it for |
I submitted #4190 which hopefully explains the problem that requires us to provide two functions for everything that uses the allocation API. |
@DmitryOlshansky Could you please merge this. It is blocker for other fixes ( #4203 ) and Mir. |
Auto-merge toggled on |
Thanks! |
Allocation utilities was not implemented before because I needed a time to get real world experience with ndslice and allocators.
In addition, this PR fixes ugly unittests like
Now they looks like
In addition,
iotaSlice
is faster than slicediota
, it has zero size and zero cost.Mir
libmir/mir#38
libmir/mir#42
libmir/mir#44
New names
slice
SliceException
shape
slice
(createSlice
in mir PR)makeSlice
ndarray
makeNdarray
selection
iotaSlice
/IotaSlice