modai_prct10 0.0.1 → 0.0.2
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/Guardfile +28 -0
- data/lib/modai_prct10.rb +27 -0
- data/lib/modai_prct10/version.rb +1 -1
- data/spec/modai_prct10_spec.rb +30 -11
- data/spec/modai_prct10_spec.rb~ +231 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa16e4eb44f3cd5146146102853400b6adf4f6e0
|
4
|
+
data.tar.gz: c0501b57b1912d4e3617b3ad626f44c50a2784e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a66780cb36f35be245aa87b0afcb88583a640cb70183f47e8ab83f1c3ee279297f85aa9f01b6bab3630e7dc5ec570cd2693396f8e6d10d55615fd4a9c458c321
|
7
|
+
data.tar.gz: ec07928ad42bbdac95c0219f45c9c47a7fcc8f79cd32580a8fc00e9bcc3162b8346f73cb8e49ddb27f65ee2588d1530c1e3a83eac57ee611bbdb4f6d44b8177e
|
data/Guardfile
CHANGED
@@ -36,3 +36,31 @@ guard :rspec do
|
|
36
36
|
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
37
37
|
end
|
38
38
|
|
39
|
+
|
40
|
+
guard :bundler do
|
41
|
+
watch('Gemfile')
|
42
|
+
# Uncomment next line if your Gemfile contains the `gemspec' command.
|
43
|
+
# watch(/^.+\.gemspec/)
|
44
|
+
end
|
45
|
+
|
46
|
+
guard :rspec do
|
47
|
+
watch(%r{^spec/.+_spec\.rb$})
|
48
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
49
|
+
watch('spec/spec_helper.rb') { "spec" }
|
50
|
+
|
51
|
+
# Rails example
|
52
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
53
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
54
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
55
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
56
|
+
watch('config/routes.rb') { "spec/routing" }
|
57
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
58
|
+
|
59
|
+
# Capybara features specs
|
60
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
61
|
+
|
62
|
+
# Turnip features and steps
|
63
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
64
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
65
|
+
end
|
66
|
+
|
data/lib/modai_prct10.rb
CHANGED
@@ -76,6 +76,33 @@ class MatrizDensa < MatrizAbstracta
|
|
76
76
|
|
77
77
|
end
|
78
78
|
|
79
|
+
# Suma de matrices densa con dispersa (sobreescribimos el operador / como prueba)
|
80
|
+
def /(o)
|
81
|
+
|
82
|
+
suma = Array.new(matriz.size - 1)
|
83
|
+
for i in 0...matriz.size
|
84
|
+
suma[i] = Array.new(matriz[i].size - 1)
|
85
|
+
for j in 0...matriz[i].size
|
86
|
+
|
87
|
+
suma[i][j] = matriz[i][j]
|
88
|
+
|
89
|
+
# comprobamos el hash
|
90
|
+
if (o.matriz[i] != nil)
|
91
|
+
|
92
|
+
# hay datos en el has para la columna
|
93
|
+
if o.matriz[i].has_key?(j)
|
94
|
+
suma[i][j] = matriz[i][j] + o.matriz[i][j]
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
101
|
+
MatrizDensa.new(suma)
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
|
79
106
|
# Resta de matrices
|
80
107
|
def -(o)
|
81
108
|
|
data/lib/modai_prct10/version.rb
CHANGED
data/spec/modai_prct10_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe ModaiPrct10 do
|
|
6
6
|
|
7
7
|
before :each do
|
8
8
|
|
9
|
-
|
9
|
+
# Matrices DENSAS
|
10
10
|
matA = [[1,2],[3,4]]
|
11
11
|
matB = [[221,2],[3,4]]
|
12
12
|
|
@@ -18,8 +18,8 @@ describe ModaiPrct10 do
|
|
18
18
|
|
19
19
|
@matrizA_R = MatrizDensa.new(matA_R)
|
20
20
|
@matrizB_R = MatrizDensa.new(matB_R)
|
21
|
-
|
22
|
-
|
21
|
+
|
22
|
+
# Matrices DISPERSAS
|
23
23
|
matC = [nil, {1 => 4}] # [[0,0],[0,4]]
|
24
24
|
matD = [{0 => 5}, nil] # [[5,0],[0,0]]
|
25
25
|
|
@@ -30,7 +30,16 @@ describe ModaiPrct10 do
|
|
30
30
|
@matrizC = MatrizDispersa.new(matD)
|
31
31
|
|
32
32
|
@matrizC_R = MatrizDispersa.new(matC_R)
|
33
|
-
@matrizC_R = MatrizDispersa.new(matD_R)
|
33
|
+
@matrizC_R = MatrizDispersa.new(matD_R)
|
34
|
+
|
35
|
+
# Matrices creadas en horas de practicas
|
36
|
+
matA_P_DEN = [[3.4],[5.6]]
|
37
|
+
matB_P_DIS = [nil,{1 => 1}]
|
38
|
+
matB_R_DIS = [nil,{1 => Racional.new(1,2)}]
|
39
|
+
|
40
|
+
@matrizA_P_DEN = MatrizDensa.new(matA_P_DEN)
|
41
|
+
@matrizB_P_DIS = MatrizDispersa.new(matB_P_DIS)
|
42
|
+
@matrizB_R_DIS = MatrizDispersa.new(matB_R_DIS)
|
34
43
|
|
35
44
|
end
|
36
45
|
|
@@ -121,7 +130,7 @@ describe ModaiPrct10 do
|
|
121
130
|
end
|
122
131
|
|
123
132
|
end
|
124
|
-
|
133
|
+
|
125
134
|
context 'comprobar los accessors (DISPERSA)' do
|
126
135
|
|
127
136
|
it "Se debe invocar al metodo matriz() para obtener la matriz (DISPERSA)" do
|
@@ -177,12 +186,12 @@ describe ModaiPrct10 do
|
|
177
186
|
(@matrizC - @matrizC).to_s.should == MatrizDispersa.new([{0 => -5}, {1 => 4}]).to_s
|
178
187
|
end
|
179
188
|
|
180
|
-
=begin
|
181
|
-
|
182
|
-
|
183
|
-
|
189
|
+
=begin
|
190
|
+
it "Se debe poder multiplicar dos matrices (DISPERSA)" do
|
191
|
+
(@matrizC * @matrizC).to_s.should == MatrizDispersa.new([[227,10], [675,22]]).to_s
|
192
|
+
end
|
184
193
|
|
185
|
-
=end
|
194
|
+
=end
|
186
195
|
it "Se debe poder sumar dos matrices de racionales (DISPERSA)" do
|
187
196
|
(@matrizC_R + @matrizC_R).to_s.should == MatrizDispersa.new([{0 => Racional.new(5,1)}, {1 => Racional.new(4,1)}]).to_s
|
188
197
|
end
|
@@ -213,6 +222,16 @@ describe ModaiPrct10 do
|
|
213
222
|
|
214
223
|
end
|
215
224
|
|
216
|
-
|
225
|
+
context 'Comprobar modificacion en la hora de practica' do
|
217
226
|
|
227
|
+
it "Se debe sumar matriz DENSA con DISPERSA" do
|
228
|
+
(@matrizA_P_DEN / @matrizB_P_DIS).to_s.should == MatrizDensa.new([[3,4], [5,7]]).to_s
|
229
|
+
end
|
230
|
+
|
231
|
+
it "Se debe sumar matriz DENSA con DISPERSA con racionales" do
|
232
|
+
(@matrizA_P_DEN / @matrizB_R_DIS).to_s.should == MatrizDensa.new([[3,4], [5,Racional.new(13,2)]]).to_s
|
233
|
+
end
|
218
234
|
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'modai_prct10'
|
3
|
+
include ModaiPrct10
|
4
|
+
|
5
|
+
describe ModaiPrct10 do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
|
9
|
+
# Matrices DENSAS
|
10
|
+
matA = [[1,2],[3,4]]
|
11
|
+
matB = [[221,2],[3,4]]
|
12
|
+
|
13
|
+
matA_R = [[Racional.new(1,1),Racional.new(4,2)],[Racional.new(9,3),Racional.new(16,4)]]
|
14
|
+
matB_R = [[Racional.new(442,2),Racional.new(4,2)],[Racional.new(9,3),Racional.new(16,4)]]
|
15
|
+
|
16
|
+
@matrizA = MatrizDensa.new(matA)
|
17
|
+
@matrizB = MatrizDensa.new(matB)
|
18
|
+
|
19
|
+
@matrizA_R = MatrizDensa.new(matA_R)
|
20
|
+
@matrizB_R = MatrizDensa.new(matB_R)
|
21
|
+
|
22
|
+
# Matrices DISPERSAS
|
23
|
+
matC = [nil, {1 => 4}] # [[0,0],[0,4]]
|
24
|
+
matD = [{0 => 5}, nil] # [[5,0],[0,0]]
|
25
|
+
|
26
|
+
matC_R = [nil, {1 => Racional.new(4,1)}] # [[Racional.new(0,1),Racional.new(0,1)],[Racional.new(0,1),Racional.new(4,1)]]
|
27
|
+
matD_R = [{0 => Racional.new(5,1)}, nil] # [[Racional.new(5,1),Racional.new(0,1)],[Racional.new(0,1),Racional.new(0,1)]]
|
28
|
+
|
29
|
+
@matrizC = MatrizDispersa.new(matC)
|
30
|
+
@matrizC = MatrizDispersa.new(matD)
|
31
|
+
|
32
|
+
@matrizC_R = MatrizDispersa.new(matC_R)
|
33
|
+
@matrizC_R = MatrizDispersa.new(matD_R)
|
34
|
+
|
35
|
+
# Matrices creadas en horas de practicas
|
36
|
+
matA_P_DEN = [[3.4],[5.6]]
|
37
|
+
matB_P_DIS = [nil,{1 => 1}] #[nil,{1 => Racional.new(1,2)}]
|
38
|
+
|
39
|
+
@matrizA_P_DEN = MatrizDensa.new(matA_P_DEN)
|
40
|
+
@matrizB_P_DIS = MatrizDispersa.new(matB_P_DIS)
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'comprobar los accessors (DENSA)' do
|
45
|
+
|
46
|
+
it "Se debe invocar al metodo matriz() para obtener la matriz (DENSA)" do
|
47
|
+
@matrizA.respond_to?("matriz").should == true
|
48
|
+
end
|
49
|
+
|
50
|
+
it "Se debe invocar al metodo filas() para obtener el numero de filas (DENSA)" do
|
51
|
+
@matrizA.respond_to?("filas").should == true
|
52
|
+
end
|
53
|
+
|
54
|
+
it "Se debe invocar al metodo columnas() para obtener el numero de columnas (DENSA)" do
|
55
|
+
@matrizA.respond_to?("columnas").should == true
|
56
|
+
end
|
57
|
+
|
58
|
+
it "Se debe invocar al metodo matriz() para obtener la matriz de racionales (DENSA)" do
|
59
|
+
@matrizA_R.respond_to?("matriz").should == true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "Se debe invocar al metodo filas() para obtener el numero de filas de matriz de racionales (DENSA)" do
|
63
|
+
@matrizA_R.respond_to?("filas").should == true
|
64
|
+
end
|
65
|
+
|
66
|
+
it "Se debe invocar al metodo columnas() para obtener el numero de columnas de matriz de racionales (DENSA)" do
|
67
|
+
@matrizA_R.respond_to?("columnas").should == true
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'Comprobar metodos de conversion (DENSA)' do
|
73
|
+
|
74
|
+
it "Se debe mostrar la matriz (DENSA)" do
|
75
|
+
@matrizA.to_s.should == MatrizDensa.new([[1,2],[3,4]]).to_s
|
76
|
+
end
|
77
|
+
|
78
|
+
it "Se debe convertir a punto flotantes (DENSA)" do
|
79
|
+
@matrizA.to_f.to_s.should == MatrizDensa.new([[1.0,2.0],[3.0,4.0]]).to_s
|
80
|
+
end
|
81
|
+
|
82
|
+
it "Se debe mostrar la matriz de racionales (DENSA)" do
|
83
|
+
@matrizA_R.to_s.should == MatrizDensa.new([[Racional.new(1,1),Racional.new(4,2)],[Racional.new(9,3),Racional.new(16,4)]]).to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'Comprobar las operaciones entre matrices (DENSA)' do
|
89
|
+
|
90
|
+
it "Se debe poder sumar dos matrices (DENSA)" do
|
91
|
+
(@matrizA + @matrizB).to_s.should == MatrizDensa.new([[222,4], [6,8]]).to_s
|
92
|
+
end
|
93
|
+
|
94
|
+
it "Se debe poder restar dos matrices (DENSA)" do
|
95
|
+
(@matrizA - @matrizB).to_s.should == MatrizDensa.new([[-220,0], [0,0]]).to_s
|
96
|
+
end
|
97
|
+
|
98
|
+
it "Se debe poder multiplicar dos matrices (DENSA)" do
|
99
|
+
(@matrizA * @matrizB).to_s.should == MatrizDensa.new([[227,10], [675,22]]).to_s
|
100
|
+
end
|
101
|
+
|
102
|
+
it "Se debe poder sumar dos matrices de racionales (DENSA)" do
|
103
|
+
(@matrizA_R + @matrizB_R).to_s.should == MatrizDensa.new([[Racional.new(222,1),Racional.new(4,1)],[Racional.new(6,1),Racional.new(8,1)]]).to_s
|
104
|
+
end
|
105
|
+
|
106
|
+
it "Se debe poder restar dos matrices de racionales (DENSA)" do
|
107
|
+
(@matrizA_R - @matrizB_R).to_s.should == MatrizDensa.new([[Racional.new(-220,1),Racional.new(0,1)],[Racional.new(0,1),Racional.new(0,1)]]).to_s
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'Comprobar las operaciones de la propia matriz (DENSA)' do
|
113
|
+
|
114
|
+
it "Se debe mostrar el max de la matriz (DENSA)" do
|
115
|
+
@matrizA.max == 4.0
|
116
|
+
end
|
117
|
+
|
118
|
+
it "Se debe mostrar el min de la matriz (DENSA)" do
|
119
|
+
@matrizA.min == 1.0
|
120
|
+
end
|
121
|
+
|
122
|
+
it "Se debe mostrar el max de la matriz de racionales (DENSA)" do
|
123
|
+
@matrizA_R.max == Racional.new(1,1)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "Se debe mostrar el min de la matriz de racionales (DENSA)" do
|
127
|
+
@matrizA_R.min == Racional.new(16,4)
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'comprobar los accessors (DISPERSA)' do
|
133
|
+
|
134
|
+
it "Se debe invocar al metodo matriz() para obtener la matriz (DISPERSA)" do
|
135
|
+
@matrizC.respond_to?("matriz").should == true
|
136
|
+
end
|
137
|
+
|
138
|
+
it "Se debe invocar al metodo filas() para obtener el numero de filas (DISPERSA)" do
|
139
|
+
@matrizC.respond_to?("filas").should == true
|
140
|
+
end
|
141
|
+
|
142
|
+
it "Se debe invocar al metodo columnas() para obtener el numero de columnas (DISPERSA)" do
|
143
|
+
@matrizC.respond_to?("columnas").should == true
|
144
|
+
end
|
145
|
+
|
146
|
+
it "Se debe invocar al metodo matriz() para obtener la matriz de racionales (DISPERSA)" do
|
147
|
+
@matrizC_R.respond_to?("matriz").should == true
|
148
|
+
end
|
149
|
+
|
150
|
+
it "Se debe invocar al metodo filas() para obtener el numero de filas de matriz de racionales (DISPERSA)" do
|
151
|
+
@matrizC_R.respond_to?("filas").should == true
|
152
|
+
end
|
153
|
+
|
154
|
+
it "Se debe invocar al metodo columnas() para obtener el numero de columnas de matriz de racionales (DISPERSA)" do
|
155
|
+
@matrizC_R.respond_to?("columnas").should == true
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'Comprobar metodos de conversion (DISPERSA)' do
|
161
|
+
|
162
|
+
it "Se debe mostrar la matriz (DISPERSA)" do
|
163
|
+
@matrizC.to_s.should == MatrizDispersa.new([nil, {1 => 4}]).to_s
|
164
|
+
end
|
165
|
+
|
166
|
+
it "Se debe convertir a punto flotantes (DISPERSA)" do
|
167
|
+
@matrizC.to_f.to_s.should == MatrizDispersa.new([nil, {1 => 4.0}]).to_s
|
168
|
+
end
|
169
|
+
|
170
|
+
it "Se debe mostrar la matriz de racionales (DISPERSA)" do
|
171
|
+
@matrizC_R.to_s.should == MatrizDispersa.new([nil, {1 => Racional.new(4,1)}]).to_s
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'Comprobar las operaciones entre matrices (DISPERSA)' do
|
177
|
+
|
178
|
+
|
179
|
+
it "Se debe poder sumar dos matrices (DISPERSA)" do
|
180
|
+
(@matrizC + @matrizC).to_s.should == MatrizDispersa.new([{0 => 5}, {1 => 4}]).to_s
|
181
|
+
end
|
182
|
+
|
183
|
+
it "Se debe poder restar dos matrices (DISPERSA)" do
|
184
|
+
(@matrizC - @matrizC).to_s.should == MatrizDispersa.new([{0 => -5}, {1 => 4}]).to_s
|
185
|
+
end
|
186
|
+
|
187
|
+
=begin
|
188
|
+
it "Se debe poder multiplicar dos matrices (DISPERSA)" do
|
189
|
+
(@matrizC * @matrizC).to_s.should == MatrizDispersa.new([[227,10], [675,22]]).to_s
|
190
|
+
end
|
191
|
+
|
192
|
+
=end
|
193
|
+
it "Se debe poder sumar dos matrices de racionales (DISPERSA)" do
|
194
|
+
(@matrizC_R + @matrizC_R).to_s.should == MatrizDispersa.new([{0 => Racional.new(5,1)}, {1 => Racional.new(4,1)}]).to_s
|
195
|
+
end
|
196
|
+
|
197
|
+
it "Se debe poder restar dos matrices de racionales (DISPERSA)" do
|
198
|
+
(@matrizC_R - @matrizC_R).to_s.should == MatrizDispersa.new([{0 => Racional.new(-5,1)}, {1 => Racional.new(4,1)}]).to_s
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'Comprobar las operaciones de la propia matriz (DISPERSA)' do
|
204
|
+
|
205
|
+
it "Se debe mostrar el max de la matriz (DISPERSA)" do
|
206
|
+
@matrizC.max == 4
|
207
|
+
end
|
208
|
+
|
209
|
+
it "Se debe mostrar el min de la matriz (DISPERSA)" do
|
210
|
+
@matrizC.min == 0
|
211
|
+
end
|
212
|
+
|
213
|
+
it "Se debe mostrar el max de la matriz de racionales (DISPERSA)" do
|
214
|
+
@matrizC_R.max == Racional.new(4,1)
|
215
|
+
end
|
216
|
+
|
217
|
+
it "Se debe mostrar el min de la matriz de racionales (DISPERSA)" do
|
218
|
+
@matrizC_R.min == Racional.new(0,1)
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
context 'Comprobar modificacion en la hora de practica' do
|
224
|
+
|
225
|
+
it "Se debe sumar matriz DENSA con DISPERSA" do
|
226
|
+
(@matrizA_P_DEN + @matrizB_P_DIS).to_s.should == MatrizDensa.new([[3,4], [5,7]]).to_s
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modai_prct10
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dailos Herrera Bencomo y Mohammed Mahrach
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/racional.rb
|
59
59
|
- modai_prct10.gemspec
|
60
60
|
- spec/modai_prct10_spec.rb
|
61
|
+
- spec/modai_prct10_spec.rb~
|
61
62
|
- spec/spec_helper.rb
|
62
63
|
homepage: ''
|
63
64
|
licenses:
|
@@ -85,5 +86,6 @@ specification_version: 4
|
|
85
86
|
summary: modai_prct10 ipsum generator
|
86
87
|
test_files:
|
87
88
|
- spec/modai_prct10_spec.rb
|
89
|
+
- spec/modai_prct10_spec.rb~
|
88
90
|
- spec/spec_helper.rb
|
89
91
|
has_rdoc:
|