statsample 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -3
  3. data/History.txt +4 -0
  4. data/README.md +4 -0
  5. data/lib/statsample/converter/csv.rb +41 -54
  6. data/lib/statsample/converters.rb +18 -19
  7. data/lib/statsample/version.rb +1 -1
  8. data/test/fixtures/scientific_notation.csv +4 -0
  9. data/test/helpers_tests.rb +37 -38
  10. data/test/test_analysis.rb +96 -97
  11. data/test/test_anova_contrast.rb +22 -22
  12. data/test/test_anovaoneway.rb +12 -12
  13. data/test/test_anovatwoway.rb +16 -17
  14. data/test/test_anovatwowaywithdataset.rb +22 -24
  15. data/test/test_anovawithvectors.rb +67 -69
  16. data/test/test_awesome_print_bug.rb +9 -9
  17. data/test/test_bartlettsphericity.rb +13 -13
  18. data/test/test_bivariate.rb +122 -126
  19. data/test/test_codification.rb +51 -49
  20. data/test/test_crosstab.rb +44 -40
  21. data/test/test_csv.rb +52 -70
  22. data/test/test_dataset.rb +347 -330
  23. data/test/test_dominance_analysis.rb +22 -24
  24. data/test/test_factor.rb +163 -166
  25. data/test/test_factor_map.rb +25 -30
  26. data/test/test_factor_pa.rb +28 -28
  27. data/test/test_ggobi.rb +19 -18
  28. data/test/test_gsl.rb +13 -15
  29. data/test/test_histogram.rb +74 -77
  30. data/test/test_matrix.rb +29 -31
  31. data/test/test_multiset.rb +132 -126
  32. data/test/test_regression.rb +143 -149
  33. data/test/test_reliability.rb +149 -155
  34. data/test/test_reliability_icc.rb +100 -104
  35. data/test/test_reliability_skillscale.rb +38 -40
  36. data/test/test_resample.rb +14 -12
  37. data/test/test_rserve_extension.rb +33 -33
  38. data/test/test_srs.rb +5 -5
  39. data/test/test_statistics.rb +52 -50
  40. data/test/test_stest.rb +27 -28
  41. data/test/test_stratified.rb +10 -10
  42. data/test/test_test_f.rb +17 -17
  43. data/test/test_test_kolmogorovsmirnov.rb +21 -21
  44. data/test/test_test_t.rb +52 -52
  45. data/test/test_umannwhitney.rb +16 -16
  46. data/test/test_vector.rb +419 -410
  47. data/test/test_wilcoxonsignedrank.rb +60 -63
  48. data/test/test_xls.rb +41 -41
  49. metadata +55 -5
  50. data/web/Rakefile +0 -39
@@ -1,67 +1,64 @@
1
- require(File.expand_path(File.dirname(__FILE__)+'/helpers_tests.rb'))
1
+ require(File.expand_path(File.dirname(__FILE__) + '/helpers_tests.rb'))
2
2
 
3
- class StatsampleUMannWhitneyTestCase < MiniTest::Unit::TestCase
3
+ class StatsampleUMannWhitneyTestCase < Minitest::Test
4
4
  include Statsample::Test
5
5
  context Statsample::Test::WilcoxonSignedRank do
6
- context "Example 1" do
7
- setup do
8
- @v1=[110,122,125,120,140,124,123,137,135,145].to_scale
9
- @v2=[125,115,130,140,140,115,140,125,140,135].to_scale
10
- @u=Statsample::Test::WilcoxonSignedRank.new(@v1,@v2)
11
- end
12
- should "have same result using class or Test#u_mannwhitney" do
13
- assert_equal(Statsample::Test.wilcoxon_signed_rank(@v1,@v2).w, @u.w)
14
- end
15
- should "have correct W values" do
16
- assert_equal(9,@u.w)
17
- end
18
- should "have correct nr values" do
19
- assert_equal(9,@u.nr)
20
- end
21
- should "have correct value for z" do
22
- assert_in_delta(0.503,@u.z,0.001)
23
- end
24
- should "have correct value for probability_z" do
25
- assert_in_delta(0.614,@u.probability_z,0.001)
26
- end
27
- should "have correct value for probability_exact" do
28
- assert_in_delta(0.652,@u.probability_exact,0.001)
29
- end
30
- should "have summary" do
31
- assert(@u.summary!="")
32
- end
33
- end
34
-
35
- context "Example 2" do
36
- setup do
37
- @v2=[78,24,64,45,64,52,30,50,64,50,78,22,84,40,90,72].to_scale
38
- @v1=[78,24,62,48,68,56,25,44,56,40,68,36,68,20,58,32].to_scale
39
- @u=Statsample::Test::WilcoxonSignedRank.new(@v1,@v2)
40
- end
41
- should "have same result using class or Test#u_mannwhitney" do
42
- assert_equal(Statsample::Test.wilcoxon_signed_rank(@v1,@v2).w, @u.w)
43
- end
44
- should "have correct W values" do
45
- assert_equal(67,@u.w)
46
- end
47
- should "have correct nr values" do
48
- assert_equal(14,@u.nr)
49
- end
50
- should "have correct value for z" do
51
- assert_in_delta(2.087,@u.z,0.001)
52
- end
53
- should "have correct value for probability_z" do
54
- assert_in_delta(0.036,@u.probability_z,0.001)
55
- end
56
- should "have correct value for probability_exact" do
57
- assert_in_delta(0.036,@u.probability_exact,0.001)
58
- end
59
- should "have summary" do
60
- assert(@u.summary!="")
61
- end
62
- end
63
-
64
-
65
- end
66
-
6
+ context 'Example 1' do
7
+ setup do
8
+ @v1 = [110, 122, 125, 120, 140, 124, 123, 137, 135, 145].to_scale
9
+ @v2 = [125, 115, 130, 140, 140, 115, 140, 125, 140, 135].to_scale
10
+ @u = Statsample::Test::WilcoxonSignedRank.new(@v1, @v2)
11
+ end
12
+ should 'have same result using class or Test#u_mannwhitney' do
13
+ assert_equal(Statsample::Test.wilcoxon_signed_rank(@v1, @v2).w, @u.w)
14
+ end
15
+ should 'have correct W values' do
16
+ assert_equal(9, @u.w)
17
+ end
18
+ should 'have correct nr values' do
19
+ assert_equal(9, @u.nr)
20
+ end
21
+ should 'have correct value for z' do
22
+ assert_in_delta(0.503, @u.z, 0.001)
23
+ end
24
+ should 'have correct value for probability_z' do
25
+ assert_in_delta(0.614, @u.probability_z, 0.001)
26
+ end
27
+ should 'have correct value for probability_exact' do
28
+ assert_in_delta(0.652, @u.probability_exact, 0.001)
29
+ end
30
+ should 'have summary' do
31
+ assert(@u.summary != '')
32
+ end
33
+ end
34
+
35
+ context 'Example 2' do
36
+ setup do
37
+ @v2 = [78, 24, 64, 45, 64, 52, 30, 50, 64, 50, 78, 22, 84, 40, 90, 72].to_scale
38
+ @v1 = [78, 24, 62, 48, 68, 56, 25, 44, 56, 40, 68, 36, 68, 20, 58, 32].to_scale
39
+ @u = Statsample::Test::WilcoxonSignedRank.new(@v1, @v2)
40
+ end
41
+ should 'have same result using class or Test#u_mannwhitney' do
42
+ assert_equal(Statsample::Test.wilcoxon_signed_rank(@v1, @v2).w, @u.w)
43
+ end
44
+ should 'have correct W values' do
45
+ assert_equal(67, @u.w)
46
+ end
47
+ should 'have correct nr values' do
48
+ assert_equal(14, @u.nr)
49
+ end
50
+ should 'have correct value for z' do
51
+ assert_in_delta(2.087, @u.z, 0.001)
52
+ end
53
+ should 'have correct value for probability_z' do
54
+ assert_in_delta(0.036, @u.probability_z, 0.001)
55
+ end
56
+ should 'have correct value for probability_exact' do
57
+ assert_in_delta(0.036, @u.probability_exact, 0.001)
58
+ end
59
+ should 'have summary' do
60
+ assert(@u.summary != '')
61
+ end
62
+ end
63
+ end
67
64
  end
data/test/test_xls.rb CHANGED
@@ -1,52 +1,52 @@
1
- require(File.expand_path(File.dirname(__FILE__)+'/helpers_tests.rb'))
2
- class StatsampleExcelTestCase < MiniTest::Unit::TestCase
3
- context "Excel reader" do
4
- setup do
5
- @ds=Statsample::Excel.read(File.dirname(__FILE__)+"/fixtures/test_xls.xls")
6
- end
7
- should "set the number of cases" do
8
- assert_equal(6,@ds.cases)
9
- end
10
- should "set correct field names" do
11
- assert_equal(%w{id name age city a1},@ds.fields)
12
- end
13
- should "set a dataset equal to expected" do
14
- id=[1,2,3,4,5,6].to_vector(:scale)
15
- name=["Alex","Claude","Peter","Franz","George","Fernand"].to_vector(:nominal)
16
- age=[20,23,25,nil,5.5,nil].to_vector(:scale)
17
- city=["New York","London","London","Paris","Tome",nil].to_vector(:nominal)
18
- a1=["a,b","b,c","a",nil,"a,b,c",nil].to_vector(:nominal)
19
- ds_exp=Statsample::Dataset.new({'id'=>id,'name'=>name,'age'=>age,'city'=>city,'a1'=>a1}, %w{id name age city a1})
1
+ require(File.expand_path(File.dirname(__FILE__) + '/helpers_tests.rb'))
2
+ class StatsampleExcelTestCase < Minitest::Test
3
+ context 'Excel reader' do
4
+ setup do
5
+ @ds = Statsample::Excel.read(File.dirname(__FILE__) + '/fixtures/test_xls.xls')
6
+ end
7
+ should 'set the number of cases' do
8
+ assert_equal(6, @ds.cases)
9
+ end
10
+ should 'set correct field names' do
11
+ assert_equal(%w(id name age city a1), @ds.fields)
12
+ end
13
+ should 'set a dataset equal to expected' do
14
+ id = [1, 2, 3, 4, 5, 6].to_vector(:scale)
15
+ name = %w(Alex Claude Peter Franz George Fernand).to_vector(:nominal)
16
+ age = [20, 23, 25, nil, 5.5, nil].to_vector(:scale)
17
+ city = ['New York', 'London', 'London', 'Paris', 'Tome', nil].to_vector(:nominal)
18
+ a1 = ['a,b', 'b,c', 'a', nil, 'a,b,c', nil].to_vector(:nominal)
19
+ ds_exp = Statsample::Dataset.new({ 'id' => id, 'name' => name, 'age' => age, 'city' => city, 'a1' => a1 }, %w(id name age city a1))
20
20
  ds_exp.fields.each{|f|
21
- assert_equal(ds_exp[f],@ds[f])
21
+ assert_equal(ds_exp[f], @ds[f])
22
22
  }
23
- assert_equal(ds_exp,@ds)
23
+ assert_equal(ds_exp, @ds)
24
24
  end
25
- should "set to nil empty cells" do
26
- assert_equal(nil,@ds['age'][5])
25
+ should 'set to nil empty cells' do
26
+ assert_equal(nil, @ds['age'][5])
27
27
  end
28
28
  end
29
- context "Excel writer" do
30
- setup do
31
- a=100.times.map{rand(100)}.to_scale
32
- b=(["b"]*100).to_vector
33
- @ds={'b'=>b, 'a'=>a}.to_dataset(%w{b a})
34
- tempfile=Tempfile.new("test_write.xls")
35
- Statsample::Excel.write(@ds,tempfile.path)
36
- @ds2=Statsample::Excel.read(tempfile.path)
37
- end
38
- should "return same fields as original" do
39
- assert_equal(@ds.fields ,@ds2.fields)
40
- end
41
- should "return same number of cases as original" do
29
+ context 'Excel writer' do
30
+ setup do
31
+ a = 100.times.map { rand(100) }.to_scale
32
+ b = (['b'] * 100).to_vector
33
+ @ds = { 'b' => b, 'a' => a }.to_dataset(%w(b a))
34
+ tempfile = Tempfile.new('test_write.xls')
35
+ Statsample::Excel.write(@ds, tempfile.path)
36
+ @ds2 = Statsample::Excel.read(tempfile.path)
37
+ end
38
+ should 'return same fields as original' do
39
+ assert_equal(@ds.fields, @ds2.fields)
40
+ end
41
+ should 'return same number of cases as original' do
42
42
  assert_equal(@ds.cases, @ds2.cases)
43
43
  end
44
- should "return same cases as original" do
45
- i=0
44
+ should 'return same cases as original' do
45
+ i = 0
46
46
  @ds2.each_array do |row|
47
- assert_equal(@ds.case_as_array(i),row)
48
- i+=1
49
- end
47
+ assert_equal(@ds.case_as_array(i), row)
48
+ i += 1
49
+ end
50
50
  end
51
51
  end
52
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsample
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Bustos
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-26 00:00:00.000000000 Z
12
+ date: 2015-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spreadsheet
@@ -412,6 +412,7 @@ files:
412
412
  - test/fixtures/correlation_matrix.rb
413
413
  - test/fixtures/hartman_23.matrix
414
414
  - test/fixtures/repeated_fields.csv
415
+ - test/fixtures/scientific_notation.csv
415
416
  - test/fixtures/stock_data.csv
416
417
  - test/fixtures/test_csv.csv
417
418
  - test/fixtures/test_xls.xls
@@ -457,7 +458,6 @@ files:
457
458
  - test/test_vector.rb
458
459
  - test/test_wilcoxonsignedrank.rb
459
460
  - test/test_xls.rb
460
- - web/Rakefile
461
461
  homepage: https://github.com/sciruby/statsample
462
462
  licenses: []
463
463
  metadata: {}
@@ -490,8 +490,58 @@ required_rubygems_version: !ruby/object:Gem::Requirement
490
490
  version: '0'
491
491
  requirements: []
492
492
  rubyforge_project:
493
- rubygems_version: 2.2.2
493
+ rubygems_version: 2.4.5
494
494
  signing_key:
495
495
  specification_version: 4
496
496
  summary: A suite for basic and advanced statistics on Ruby
497
- test_files: []
497
+ test_files:
498
+ - test/fixtures/bank2.dat
499
+ - test/fixtures/correlation_matrix.rb
500
+ - test/fixtures/hartman_23.matrix
501
+ - test/fixtures/repeated_fields.csv
502
+ - test/fixtures/scientific_notation.csv
503
+ - test/fixtures/stock_data.csv
504
+ - test/fixtures/test_csv.csv
505
+ - test/fixtures/test_xls.xls
506
+ - test/fixtures/tetmat_matrix.txt
507
+ - test/fixtures/tetmat_test.txt
508
+ - test/helpers_tests.rb
509
+ - test/test_analysis.rb
510
+ - test/test_anova_contrast.rb
511
+ - test/test_anovaoneway.rb
512
+ - test/test_anovatwoway.rb
513
+ - test/test_anovatwowaywithdataset.rb
514
+ - test/test_anovawithvectors.rb
515
+ - test/test_awesome_print_bug.rb
516
+ - test/test_bartlettsphericity.rb
517
+ - test/test_bivariate.rb
518
+ - test/test_codification.rb
519
+ - test/test_crosstab.rb
520
+ - test/test_csv.rb
521
+ - test/test_dataset.rb
522
+ - test/test_dominance_analysis.rb
523
+ - test/test_factor.rb
524
+ - test/test_factor_map.rb
525
+ - test/test_factor_pa.rb
526
+ - test/test_ggobi.rb
527
+ - test/test_gsl.rb
528
+ - test/test_histogram.rb
529
+ - test/test_matrix.rb
530
+ - test/test_multiset.rb
531
+ - test/test_regression.rb
532
+ - test/test_reliability.rb
533
+ - test/test_reliability_icc.rb
534
+ - test/test_reliability_skillscale.rb
535
+ - test/test_resample.rb
536
+ - test/test_rserve_extension.rb
537
+ - test/test_srs.rb
538
+ - test/test_statistics.rb
539
+ - test/test_stest.rb
540
+ - test/test_stratified.rb
541
+ - test/test_test_f.rb
542
+ - test/test_test_kolmogorovsmirnov.rb
543
+ - test/test_test_t.rb
544
+ - test/test_umannwhitney.rb
545
+ - test/test_vector.rb
546
+ - test/test_wilcoxonsignedrank.rb
547
+ - test/test_xls.rb
data/web/Rakefile DELETED
@@ -1,39 +0,0 @@
1
- # -*- ruby -*-
2
- require 'rake'
3
- require 'fileutils'
4
- directory "examples"
5
-
6
- def get_base(f)
7
- f.sub(File.dirname(__FILE__)+"/../examples/","").gsub("/","_").gsub(".rb","")
8
- end
9
-
10
-
11
- EXAMPLES=Dir.glob(File.dirname(__FILE__)+"/../examples/**/*.rb").map {|v| [v, get_base(v)]
12
- }.find_all{|v| !v[0].include?"_data"}
13
-
14
- EXAMPLES_BASE=EXAMPLES.map {|v| v[1]}
15
-
16
-
17
- desc "Build all html, rtf and pdf files"
18
- task :build_site do
19
- ruby "build_site.rb"
20
- end
21
-
22
-
23
- task :clean do
24
- Dir.glob(File.dirname(__FILE__)+"/examples/*.pdf").each do |t|
25
- FileUtils.rm t
26
- end
27
- Dir.glob(File.dirname(__FILE__)+"/examples/*.html").each do |t|
28
- FileUtils.rm t
29
- end
30
- Dir.glob(File.dirname(__FILE__)+"/examples/*.rtf").each do |t|
31
- FileUtils.rm t
32
- end
33
- Dir.glob(File.dirname(__FILE__)+"/examples/images/*.*").each do |t|
34
- FileUtils.rm t
35
- end
36
- end
37
-
38
-
39
- load 'upload_task.rb' if File.exists? "upload_task.rb"