matlab-ruby 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ == 2.0.3 / 2008-05-19
2
+
3
+ * 2 bug fixes
4
+ * Empty matrices are converted to empty ruby arrays.
5
+ * Empty ruby arrays are converted to an empty MATLAB matrix
6
+
1
7
  == 2.0.2 / 2008-05-19
2
8
 
3
9
  * 1 bug fix
@@ -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 all? { |value| value.kind_of?(Numeric) || value.nil? }
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) > 1 || mxGetN(self) > 1) || (mxGetM(self) == 0 && mxGetN(self) == 0)
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)
@@ -4,7 +4,7 @@ module Matlab
4
4
 
5
5
  MAJOR = 2
6
6
  MINOR = 0
7
- TINY = 2
7
+ TINY = 3
8
8
 
9
9
  STRING = [ MAJOR, MINOR, TINY ].join( "." )
10
10
  #:beta-tag:
@@ -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
- assert_equal matrix, matrix.to_matlab.to_ruby
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matlab-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Younger