carray 1.5.2 → 1.5.3

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +32 -0
  3. data/NEWS.md +26 -3
  4. data/Rakefile +1 -1
  5. data/TODO.md +5 -4
  6. data/carray.gemspec +7 -5
  7. data/ext/ca_obj_bitarray.c +4 -7
  8. data/ext/ca_obj_bitfield.c +3 -5
  9. data/ext/ca_obj_block.c +1 -6
  10. data/ext/ca_obj_unbound_repeat.c +21 -52
  11. data/ext/carray_attribute.c +16 -1
  12. data/ext/carray_core.c +22 -16
  13. data/ext/carray_math.rb +20 -2
  14. data/ext/carray_numeric.c +32 -51
  15. data/ext/carray_test.c +9 -0
  16. data/ext/carray_undef.c +0 -8
  17. data/ext/version.h +4 -4
  18. data/lib/carray.rb +1 -3
  19. data/lib/carray/autoload.rb +0 -2
  20. data/lib/carray/basic.rb +1 -3
  21. data/lib/carray/broadcast.rb +58 -21
  22. data/lib/carray/compose.rb +34 -10
  23. data/lib/carray/construct.rb +1 -3
  24. data/lib/carray/info.rb +1 -3
  25. data/lib/carray/inspect.rb +3 -5
  26. data/lib/carray/io/imagemagick.rb +1 -3
  27. data/lib/carray/iterator.rb +2 -3
  28. data/lib/carray/mask.rb +18 -7
  29. data/lib/carray/math.rb +4 -6
  30. data/lib/carray/math/histogram.rb +1 -3
  31. data/lib/carray/math/recurrence.rb +1 -3
  32. data/lib/carray/mkmf.rb +1 -3
  33. data/lib/carray/object/ca_obj_iterator.rb +1 -3
  34. data/lib/carray/object/ca_obj_link.rb +1 -3
  35. data/lib/carray/object/ca_obj_pack.rb +1 -3
  36. data/lib/carray/obsolete.rb +1 -3
  37. data/lib/carray/ordering.rb +1 -3
  38. data/lib/carray/serialize.rb +22 -13
  39. data/lib/carray/string.rb +1 -3
  40. data/lib/carray/struct.rb +3 -5
  41. data/lib/carray/testing.rb +5 -10
  42. data/lib/carray/time.rb +1 -3
  43. data/lib/carray/transform.rb +1 -3
  44. data/spec/Classes/CAUnboudRepeat_spec.rb +24 -0
  45. data/spec/Features/feature_boolean_spec.rb +15 -14
  46. data/spec/Features/feature_broadcast.rb +16 -0
  47. data/spec/Features/feature_mask_spec.rb +6 -0
  48. metadata +12 -10
@@ -19,6 +19,20 @@ describe "CAUnboundRepeat" do
19
19
 
20
20
  end
21
21
 
22
+ example "ref" do
23
+ a = CA_INT(0..2)[:*,nil]
24
+ is_asserted_by { a[0] == 0 }
25
+ is_asserted_by { a[1] == 1 }
26
+ is_asserted_by { a[2] == 2 }
27
+ is_asserted_by { a.bind(3,3) == CA_INT([[0,1,2],
28
+ [0,1,2],
29
+ [0,1,2]]) }
30
+ is_asserted_by { a[0,0] == 0 }
31
+ is_asserted_by { a[0,1] == 1 }
32
+ is_asserted_by { a[0,2] == 2 }
33
+ is_asserted_by { a.to_a == [[0,1,2]] }
34
+ end
35
+
22
36
  example "bind" do
23
37
 
24
38
  a = CA_INT([1,2,3])
@@ -75,4 +89,14 @@ describe "CAUnboundRepeat" do
75
89
  is_asserted_by { a[:*,nil][:*,nil,nil].shape == [1,1,3] }
76
90
  end
77
91
 
92
+ example "extra * in arithmetic operation" do
93
+ a = CA_INT(1..3)
94
+ b = CA_INT(1..3)
95
+ aa = a[:*,:*,nil]
96
+ bb = b[:*,nil,:*]
97
+ is_asserted_by { aa.bind_with(bb) == a[3,:%][:*,nil,nil] }
98
+ is_asserted_by { aa + bb == (a[3,:%]+b[:%,3])[:*,nil,nil] }
99
+ end
100
+
101
+
78
102
  end
@@ -75,23 +75,24 @@ describe "TestBooleanType " do
75
75
 
76
76
  end
77
77
 
78
- example "boolean_bit_operation_with_non_boolean_type" do
78
+ example "boolean_bit_operation_with_non_boolean_integer_type" do
79
79
 
80
- a = CArray.int(3,3).seq!
81
- b = CArray.int(3,3).seq! + 1
82
- e0 = a < 4
83
- e1 = a >= 4
84
-
85
- # ---
86
- expect { e0 & b }.not_to raise_error
87
- expect { e0 | b }.not_to raise_error
88
- expect { e0 ^ b }.not_to raise_error
89
- # ---
90
- expect { b & e0 }.not_to raise_error
91
- expect { b | e0 }.not_to raise_error
92
- expect { b ^ e0 }.not_to raise_error
80
+ a = CA_BOOLEAN([1,1,1,1])
81
+ b = CA_INT([0,1,2,3])
82
+
83
+ is_asserted_by { a & b == CA_INT([0, 1, 0, 1]) }
84
+ is_asserted_by { a | b == CA_INT([1, 1, 3, 3]) }
85
+ is_asserted_by { a ^ b == CA_INT([1, 0, 3, 2]) }
93
86
 
94
87
  end
95
88
 
89
+ example "boolean_arithmetic_operation" do
90
+ a = CA_BOOLEAN([1,1,0,0])
91
+ b = CA_INT( [0,1,1,0])
92
+
93
+ expect { a + a }.to raise_error(CArray::DataTypeError)
94
+
95
+ is_asserted_by { a + b == CA_INT([1, 2, 1, 0]) }
96
+ end
96
97
 
97
98
  end
@@ -97,4 +97,20 @@ describe "CArray.broadcast" do
97
97
  is_asserted_by { cc == c }
98
98
  end
99
99
 
100
+ example "extension of dimension" do
101
+ a = CA_INT([[1,2,3],[4,5,6]])
102
+
103
+ is_asserted_by { a.broadcast_to(1,2,1,3) == CA_INT([[[[ 1, 2, 3 ]],
104
+ [[ 4, 5, 6 ]]]]) }
105
+
106
+ is_asserted_by { a.reshape(2,1,3).broadcast_to(1,2,1,3) == CA_INT([[[[ 1, 2, 3 ]],
107
+ [[ 4, 5, 6 ]]]]) }
108
+
109
+ is_asserted_by { a.reshape(1,2,3).broadcast_to(1,2,1,3) == CA_INT([[[[ 1, 2, 3 ]],
110
+ [[ 4, 5, 6 ]]]]) }
111
+
112
+
113
+ end
114
+
115
+
100
116
  end
@@ -199,6 +199,12 @@ describe "Feature: Masking" do
199
199
  example "count_not_masked" do
200
200
  # test_basic_featrues
201
201
  end
202
+
203
+ example "compare with UNDEF" do
204
+ a = CA_INT([1,UNDEF,2])
205
+ is_asserted_by { a.eq(UNDEF) == a.is_masked }
206
+ is_asserted_by { a.ne(UNDEF) == a.is_not_masked }
207
+ end
202
208
 
203
209
  example "unmask" do
204
210
  # ---
metadata CHANGED
@@ -1,22 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carray
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroki Motoyoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-22 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: " Ruby/CArray is an extension library for the multi-dimensional array
14
- class.\n CArray can store integers and floating point numbers to perform calculations\n
15
- \ efficiently. Therefore, Ruby/CArray is suitable for numerical computation and
16
- data\n analysis. Ruby/CArray has different features from other multidimensional
17
- array\n libraries (narray, numo-narray, nmatrix), such as element-specific masks,
18
- \n creation of reference arrays that can reflect changes to the referent, \n
19
- \ the ability to access memory pointers of other objects, user-defined arrays,\n
13
+ description: " Ruby/CArray is an extension library for the multi-dimensional numerical
14
+ array class.\n CArray can store integers and floating point numbers to perform
15
+ calculations\n efficiently. Therefore, Ruby/CArray is suitable for numerical
16
+ computation and data\n analysis. Ruby/CArray has different features from other
17
+ multidimensional array\n libraries (narray, numo-narray, nmatrix), such as element-wise
18
+ masks, \n creation of reference arrays that can reflect changes to the referent,
19
+ \n the ability to access memory pointers of other objects, user-defined arrays,\n
20
20
  \ and so on.\n"
21
21
  email: ''
22
22
  executables: []
@@ -24,6 +24,7 @@ extensions:
24
24
  - ext/extconf.rb
25
25
  extra_rdoc_files: []
26
26
  files:
27
+ - ".yardopts"
27
28
  - LICENSE
28
29
  - NEWS.md
29
30
  - README.md
@@ -222,7 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
223
  - !ruby/object:Gem::Version
223
224
  version: '0'
224
225
  requirements: []
225
- rubygems_version: 3.0.3
226
+ rubyforge_project:
227
+ rubygems_version: 2.7.7
226
228
  signing_key:
227
229
  specification_version: 4
228
230
  summary: Multi-dimesional array class for Ruby