matlab-ruby 2.0.2 → 2.0.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.
data/History.txt
CHANGED
@@ -50,7 +50,10 @@ end
|
|
50
50
|
class Array
|
51
51
|
# Converts the array into a 1 Dimensional MATLAB numeric or cell matrix
|
52
52
|
def to_matlab
|
53
|
-
if
|
53
|
+
if empty?
|
54
|
+
matrix = Matlab::Matrix.new(0, 0)
|
55
|
+
matrix.to_matlab
|
56
|
+
elsif all? { |value| value.kind_of?(Numeric) || value.nil? }
|
54
57
|
matrix = Matlab::Matrix.new(size, 1)
|
55
58
|
|
56
59
|
each_with_index do |value, index|
|
@@ -231,7 +234,9 @@ class SWIG::TYPE_p_mxArray_tag
|
|
231
234
|
mxArrayToString(self)
|
232
235
|
when mxIsLogical(self)
|
233
236
|
mxIsLogicalScalarTrue(self)
|
234
|
-
when (mxGetM(self)
|
237
|
+
when (mxGetM(self) == 0 && mxGetN(self) == 0)
|
238
|
+
[]
|
239
|
+
when (mxGetM(self) > 1 || mxGetN(self) > 1)
|
235
240
|
Matlab::Matrix.from_matlab(self)
|
236
241
|
when mxIsDouble(self)
|
237
242
|
mxGetScalar(self)
|
data/lib/matlab/version.rb
CHANGED
@@ -66,7 +66,13 @@ class ConversionsTest < Test::Unit::TestCase
|
|
66
66
|
|
67
67
|
def test_should_convert_a_0x0_matlab_matrix
|
68
68
|
matrix = Matlab::Matrix.new(0, 0)
|
69
|
-
|
69
|
+
result = matrix.to_matlab.to_ruby
|
70
|
+
assert_equal [], result
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_should_convert_an_empty_ruby_array
|
74
|
+
array = []
|
75
|
+
assert_equal array, array.to_matlab.to_ruby
|
70
76
|
end
|
71
77
|
|
72
78
|
def test_matlab_cell_matrix_to_matlab_to_ruby
|