statsample 0.6.7 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -1
- data/Manifest.txt +1 -2
- data/Rakefile +1 -1
- data/demo/dominanceanalysis.rb +2 -1
- data/lib/statsample.rb +2 -2
- data/lib/statsample/bivariate.rb +19 -10
- data/lib/statsample/bivariate/polychoric.rb +6 -6
- data/lib/statsample/bivariate/tetrachoric.rb +6 -6
- data/lib/statsample/converter/{csv19.rb → csv.rb} +13 -4
- data/lib/statsample/converters.rb +1 -5
- data/lib/statsample/crosstab.rb +13 -13
- data/lib/statsample/dataset.rb +1 -1
- data/lib/statsample/dominanceanalysis.rb +18 -16
- data/lib/statsample/dominanceanalysis/bootstrap.rb +19 -19
- data/lib/statsample/factor/pca.rb +8 -8
- data/lib/statsample/factor/principalaxis.rb +9 -9
- data/lib/statsample/graph/svggraph.rb +13 -8
- data/lib/statsample/histogram.rb +3 -3
- data/lib/statsample/matrix.rb +2 -2
- data/lib/statsample/regression/multiple/baseengine.rb +14 -14
- data/lib/statsample/regression/multiple/matrixengine.rb +15 -15
- data/lib/statsample/test/levene.rb +2 -2
- data/lib/statsample/test/umannwhitney.rb +2 -2
- data/lib/statsample/vector.rb +1 -6
- data/po/es/statsample.mo +0 -0
- data/po/es/statsample.po +84 -64
- data/po/statsample.pot +77 -57
- data/test/test_anova.rb +3 -3
- data/test/test_bivariate.rb +38 -27
- data/test/test_csv.rb +4 -4
- data/test/test_regression.rb +3 -2
- data/test/test_svg_graph.rb +15 -15
- metadata +16 -7
- data/lib/statsample/converter/csv18.rb +0 -56
data/test/test_regression.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__)+'/../lib/')
|
2
2
|
require 'statsample'
|
3
|
-
require '
|
4
|
-
|
3
|
+
require 'minitest/unit'
|
4
|
+
MiniTest::Unit.autorun
|
5
|
+
class StatsampleRegressionTestCase < MiniTest::Unit::TestCase
|
5
6
|
def test_parameters
|
6
7
|
@x=[13,20,10,33,15].to_vector(:scale)
|
7
8
|
@y=[23,18,35,10,27 ].to_vector(:scale)
|
data/test/test_svg_graph.rb
CHANGED
@@ -28,35 +28,35 @@ class StatsampleSvgGraphTestCase < Test::Unit::TestCase
|
|
28
28
|
puts "Statsample::Graph::SvgHistogram.new not tested (no ruby-gsl)"
|
29
29
|
end
|
30
30
|
end
|
31
|
+
def assert_svg(msg=nil)
|
32
|
+
msg||="%s isn't a svg file"
|
33
|
+
Tempfile.open("svg") do |fp|
|
34
|
+
yield fp
|
35
|
+
fp.close
|
36
|
+
fp.open
|
37
|
+
assert_match(/DOCTYPE svg/, fp.gets(nil), sprintf(msg,fp.path))
|
38
|
+
end
|
39
|
+
end
|
31
40
|
def test_vector
|
32
|
-
file=@image_path+"/gdchart_bar.jpg"
|
33
41
|
ar=[]
|
34
42
|
(1..1000).each {|a|
|
35
43
|
ar.push(rand(10))
|
36
44
|
}
|
37
45
|
vector=ar.to_vector
|
38
|
-
file
|
39
|
-
vector.svggraph_frequencies(file)
|
40
|
-
file
|
41
|
-
vector.svggraph_frequencies(file,800,600,SVG::Graph::
|
42
|
-
assert(File.exists?(file))
|
43
|
-
file=Tempfile.new("svggraph_bar_horizontal.svg").path
|
44
|
-
vector.svggraph_frequencies(file,800,600,SVG::Graph::BarHorizontalNoOp,:graph_title=>'Horizontal Bar')
|
45
|
-
assert(File.exists?(file))
|
46
|
-
file=Tempfile.new("svggraph_pie.svg").path
|
47
|
-
vector.svggraph_frequencies(file,800,600,SVG::Graph::PieNoOp,:graph_title=>'Pie')
|
48
|
-
assert(File.exists?(file))
|
46
|
+
assert_svg {|file| vector.svggraph_frequencies(file)}
|
47
|
+
assert_svg {|file| vector.svggraph_frequencies(file, 800, 600, SVG::Graph::Bar, :graph_title=>'Bar') }
|
48
|
+
assert_svg {|file| vector.svggraph_frequencies(file, 800, 600, SVG::Graph::BarHorizontalNoOp, :graph_title=>'Horizontal Bar') }
|
49
|
+
assert_svg {|file| vector.svggraph_frequencies(file,800,600, SVG::Graph::PieNoOp, :graph_title=>'Pie') }
|
49
50
|
vector.type=:scale
|
50
51
|
if Statsample.has_gsl?
|
51
52
|
file=Tempfile.new("svg_histogram.svg").path
|
52
53
|
hist=vector.svggraph_histogram(5)
|
53
54
|
File.open(file,"wb") {|fp|
|
54
|
-
|
55
|
+
fp.write(hist.burn)
|
55
56
|
}
|
56
57
|
assert(File.exists?(file))
|
57
|
-
|
58
|
+
else
|
58
59
|
puts "Statsample::Vector#svggraph_histogram.new not tested (no ruby-gsl)"
|
59
|
-
|
60
60
|
end
|
61
61
|
end
|
62
62
|
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: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Bustos
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-25 00:00:00 -03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: "1.0"
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: minimization
|
@@ -52,6 +52,16 @@ dependencies:
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 0.1.0
|
54
54
|
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fastercsv
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
55
65
|
- !ruby/object:Gem::Dependency
|
56
66
|
name: rubyforge
|
57
67
|
type: :development
|
@@ -60,7 +70,7 @@ dependencies:
|
|
60
70
|
requirements:
|
61
71
|
- - ">="
|
62
72
|
- !ruby/object:Gem::Version
|
63
|
-
version: 2.0.
|
73
|
+
version: 2.0.4
|
64
74
|
version:
|
65
75
|
- !ruby/object:Gem::Dependency
|
66
76
|
name: gemcutter
|
@@ -70,7 +80,7 @@ dependencies:
|
|
70
80
|
requirements:
|
71
81
|
- - ">="
|
72
82
|
- !ruby/object:Gem::Version
|
73
|
-
version: 0.
|
83
|
+
version: 0.5.0
|
74
84
|
version:
|
75
85
|
- !ruby/object:Gem::Dependency
|
76
86
|
name: hoe
|
@@ -141,8 +151,7 @@ files:
|
|
141
151
|
- lib/statsample/bivariate/tetrachoric.rb
|
142
152
|
- lib/statsample/codification.rb
|
143
153
|
- lib/statsample/combination.rb
|
144
|
-
- lib/statsample/converter/
|
145
|
-
- lib/statsample/converter/csv19.rb
|
154
|
+
- lib/statsample/converter/csv.rb
|
146
155
|
- lib/statsample/converter/spss.rb
|
147
156
|
- lib/statsample/converters.rb
|
148
157
|
- lib/statsample/crosstab.rb
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Statsample
|
2
|
-
class CSV < SpreadsheetBase
|
3
|
-
class << self
|
4
|
-
# Returns a Dataset based on a csv file
|
5
|
-
#
|
6
|
-
# USE:
|
7
|
-
# ds=Statsample::CSV.read("test_csv.csv")
|
8
|
-
def read(filename, empty=[''],ignore_lines=0,fs=nil,rs=nil)
|
9
|
-
require 'csv'
|
10
|
-
first_row=true
|
11
|
-
fields=[]
|
12
|
-
fields_data={}
|
13
|
-
ds=nil
|
14
|
-
line_number=0
|
15
|
-
|
16
|
-
::CSV.open(filename,'r',fs,rs) do |row|
|
17
|
-
line_number+=1
|
18
|
-
if(line_number<=ignore_lines)
|
19
|
-
#puts "Skip line"
|
20
|
-
next
|
21
|
-
end
|
22
|
-
row.collect!{|c|
|
23
|
-
c.to_s
|
24
|
-
}
|
25
|
-
if first_row
|
26
|
-
fields=extract_fields(row)
|
27
|
-
ds=Statsample::Dataset.new(fields)
|
28
|
-
first_row=false
|
29
|
-
else
|
30
|
-
rowa=process_row(row,empty)
|
31
|
-
ds.add_case(rowa,false)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
convert_to_scale_and_date(ds,fields)
|
35
|
-
ds.update_valid_data
|
36
|
-
ds
|
37
|
-
end
|
38
|
-
# Save a Dataset on a csv file
|
39
|
-
#
|
40
|
-
# USE:
|
41
|
-
# Statsample::CSV.write(ds,"test_csv.csv")
|
42
|
-
def write(dataset,filename, convert_comma=false,*opts)
|
43
|
-
require 'csv'
|
44
|
-
writer=::CSV.open(filename,'w',*opts)
|
45
|
-
writer << dataset.fields
|
46
|
-
dataset.each_array do |row|
|
47
|
-
if(convert_comma)
|
48
|
-
row.collect!{|v| v.to_s.gsub(".",",")}
|
49
|
-
end
|
50
|
-
writer << row
|
51
|
-
end
|
52
|
-
writer.close
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|