numo-narray-alt 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/numo/narray/data.c +13 -2
- data/ext/numo/narray/index.c +22 -9
- data/ext/numo/narray/narray.c +1 -0
- data/ext/numo/narray/numo/narray.h +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 10e112d34dd103c74a42d19029a55e73ccbf12834f0a35028cb36361c22fce82
|
|
4
|
+
data.tar.gz: a72e185be47dea83dd226b9d681646fc66582a8af4e5467af66b100fcc8978b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7370426c2fd94fe941777358feda59993417d962c132308dce65a4d2187693e36166ab64b39e15751e0ae844defe37499d7d928f280ea4122ac7ae83d92f158
|
|
7
|
+
data.tar.gz: bc87a9588b7dc313338a7c209dcd15dda63e4dd76d7f1a76e4d65551c016e6d0027714bc959eb46cfb2374392ebaba03ffb33cc0e4619963378bd5d9975bfecf
|
data/ext/numo/narray/data.c
CHANGED
|
@@ -325,9 +325,17 @@ static void na_check_reshape(int argc, VALUE* argv, VALUE self, size_t* shape) {
|
|
|
325
325
|
/* get shape from argument */
|
|
326
326
|
for (i = 0; i < argc; ++i) {
|
|
327
327
|
switch (TYPE(argv[i])) {
|
|
328
|
-
case T_FIXNUM:
|
|
329
|
-
|
|
328
|
+
case T_FIXNUM: {
|
|
329
|
+
ssize_t x = NUM2SSIZET(argv[i]);
|
|
330
|
+
if (x < 0) {
|
|
331
|
+
rb_raise(rb_eArgError, "size must be non-negative");
|
|
332
|
+
}
|
|
333
|
+
if (x != 0 && total > SIZE_MAX / (size_t)x) {
|
|
334
|
+
rb_raise(rb_eArgError, "total size is too large");
|
|
335
|
+
}
|
|
336
|
+
total *= shape[i] = (size_t)x;
|
|
330
337
|
break;
|
|
338
|
+
}
|
|
331
339
|
case T_NIL:
|
|
332
340
|
case T_TRUE:
|
|
333
341
|
if (unfixed >= 0) {
|
|
@@ -341,6 +349,9 @@ static void na_check_reshape(int argc, VALUE* argv, VALUE self, size_t* shape) {
|
|
|
341
349
|
}
|
|
342
350
|
|
|
343
351
|
if (unfixed >= 0) {
|
|
352
|
+
if (total == 0) {
|
|
353
|
+
rb_raise(rb_eArgError, "cannot determine unfixed dimension when total size is zero");
|
|
354
|
+
}
|
|
344
355
|
if (NA_SIZE(na) % total != 0) {
|
|
345
356
|
rb_raise(rb_eArgError, "Total size size must be divisor");
|
|
346
357
|
}
|
data/ext/numo/narray/index.c
CHANGED
|
@@ -126,7 +126,7 @@ static void na_parse_narray_index(VALUE a, int orig_dim, ssize_t size, na_index_
|
|
|
126
126
|
GetNArray(idx, nidx);
|
|
127
127
|
n = NA_SIZE(nidx);
|
|
128
128
|
q->idx = ALLOC_N(size_t, n);
|
|
129
|
-
if (
|
|
129
|
+
if (nidx->type != NARRAY_DATA_T) {
|
|
130
130
|
rb_bug("NArray#where returned wrong type of NArray");
|
|
131
131
|
}
|
|
132
132
|
if (rb_obj_class(idx) == numo_cInt32) {
|
|
@@ -183,7 +183,13 @@ na_parse_range(VALUE range, ssize_t step, int orig_dim, ssize_t size, na_index_a
|
|
|
183
183
|
|
|
184
184
|
rb_arithmetic_sequence_components_t x;
|
|
185
185
|
rb_arithmetic_sequence_extract(range, &x);
|
|
186
|
+
if (!RB_INTEGER_TYPE_P(x.step)) {
|
|
187
|
+
rb_raise(rb_eArgError, "step must be an Integer");
|
|
188
|
+
}
|
|
186
189
|
step = NUM2SSIZET(x.step);
|
|
190
|
+
if (step == 0) {
|
|
191
|
+
rb_raise(rb_eArgError, "step must not be zero");
|
|
192
|
+
}
|
|
187
193
|
|
|
188
194
|
beg = beg_orig = NUM2SSIZET(x.begin);
|
|
189
195
|
if (beg < 0) {
|
|
@@ -475,13 +481,17 @@ static void na_index_aref_nadata(
|
|
|
475
481
|
na_get_strides_nadata(na1, strides_na1, elmsz);
|
|
476
482
|
|
|
477
483
|
for (i = j = 0; i < ndim; i++) {
|
|
478
|
-
|
|
484
|
+
const int qi_orig_dim = q[i].orig_dim;
|
|
485
|
+
stride1 = 0;
|
|
486
|
+
if (qi_orig_dim < na1->base.ndim) {
|
|
487
|
+
stride1 = strides_na1[qi_orig_dim];
|
|
479
488
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
489
|
+
// numeric index -- trim dimension
|
|
490
|
+
if (!keep_dim && q[i].n == 1 && q[i].step == 0) {
|
|
491
|
+
beg = q[i].beg;
|
|
492
|
+
na2->offset += stride1 * beg;
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
485
495
|
}
|
|
486
496
|
|
|
487
497
|
na2->base.shape[j] = size = q[i].n;
|
|
@@ -491,8 +501,11 @@ static void na_index_aref_nadata(
|
|
|
491
501
|
na2->base.reduce = rb_funcall(m, '|', 1, na2->base.reduce);
|
|
492
502
|
}
|
|
493
503
|
|
|
494
|
-
|
|
495
|
-
|
|
504
|
+
if (qi_orig_dim >= na1->base.ndim) {
|
|
505
|
+
// new dimension
|
|
506
|
+
SDX_SET_STRIDE(na2->stridx[j], elmsz);
|
|
507
|
+
} else if (q[i].idx != NULL) {
|
|
508
|
+
// array index
|
|
496
509
|
index = q[i].idx;
|
|
497
510
|
SDX_SET_INDEX(na2->stridx[j], index);
|
|
498
511
|
q[i].idx = NULL;
|
data/ext/numo/narray/narray.c
CHANGED
|
@@ -1322,6 +1322,7 @@ static VALUE nary_store_binary(int argc, VALUE* argv, VALUE self) {
|
|
|
1322
1322
|
narray_t* na;
|
|
1323
1323
|
|
|
1324
1324
|
narg = rb_scan_args(argc, argv, "11", &vstr, &voffset);
|
|
1325
|
+
Check_Type(vstr, T_STRING);
|
|
1325
1326
|
str_len = RSTRING_LEN(vstr);
|
|
1326
1327
|
if (narg == 2) {
|
|
1327
1328
|
offset = NUM2SIZET(voffset);
|
|
@@ -13,10 +13,10 @@ extern "C" {
|
|
|
13
13
|
#endif
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
|
-
#define NARRAY_VERSION "0.11.
|
|
16
|
+
#define NARRAY_VERSION "0.11.1"
|
|
17
17
|
#define NARRAY_VERSION_MAJOR 0
|
|
18
18
|
#define NARRAY_VERSION_MINOR 11
|
|
19
|
-
#define NARRAY_VERSION_PATCH
|
|
19
|
+
#define NARRAY_VERSION_PATCH 1
|
|
20
20
|
#define NARRAY_VERSION_CODE \
|
|
21
21
|
(NARRAY_VERSION_MAJOR * 10000 + NARRAY_VERSION_MINOR * 100 + NARRAY_VERSION_PATCH)
|
|
22
22
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: numo-narray-alt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.11.
|
|
4
|
+
version: 0.11.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yoshoku
|
|
@@ -214,7 +214,7 @@ licenses:
|
|
|
214
214
|
metadata:
|
|
215
215
|
homepage_uri: https://github.com/yoshoku/numo-narray-alt
|
|
216
216
|
changelog_uri: https://github.com/yoshoku/numo-narray-alt/blob/main/CHANGELOG.md
|
|
217
|
-
documentation_uri: https://gemdocs.org/gems/numo-narray-alt/0.11.
|
|
217
|
+
documentation_uri: https://gemdocs.org/gems/numo-narray-alt/0.11.1/
|
|
218
218
|
rubygems_mfa_required: 'true'
|
|
219
219
|
post_install_message: |
|
|
220
220
|
===
|
|
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
238
238
|
- !ruby/object:Gem::Version
|
|
239
239
|
version: '0'
|
|
240
240
|
requirements: []
|
|
241
|
-
rubygems_version: 4.0.
|
|
241
|
+
rubygems_version: 4.0.16
|
|
242
242
|
specification_version: 4
|
|
243
243
|
summary: Numo::NArray Alternative is a project forked from Numo::NArray.
|
|
244
244
|
test_files: []
|