The OpenD Programming Language

assumeCanonical

Converts a slice to canonical kind (unsafe).

Slice!(Iterator, N, Canonical, Labels)
assumeCanonical
(
Iterator
size_t N
SliceKind kind
Labels...
)
(
Slice!(Iterator, N, kind, Labels) slice
)

Parameters

slice Slice!(Iterator, N, kind, Labels)

a slice

Return Value

Type: Slice!(Iterator, N, Canonical, Labels)

canonical slice

Examples

auto slice = iota(2, 3).universal.assumeCanonical;
assert(slice == [[0, 1, 2], [3, 4, 5]]);
assert(slice._lengths == [2, 3]);
assert(slice._strides == [3]);
import mir.ndslice.slice;
import mir.ndslice.allocation: slice;

auto dataframe = slice!(double, int, string)(2, 3);
dataframe.label[] = [1, 2];
dataframe.label!1[] = ["Label1", "Label2", "Label3"];

auto assmcanonicaldf = dataframe.assumeCanonical;
assert(assmcanonicaldf._lengths == [2, 3]);
assert(assmcanonicaldf._strides == [3]);

assert(is(typeof(assmcanonicaldf) ==
    Slice!(double*, 2, Canonical, int*, string*)));
assert(assmcanonicaldf.label!0[0] == 1);
assert(assmcanonicaldf.label!1[1] == "Label2");

See Also

Meta