statsample 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +3 -0
- data/lib/statsample/daru.rb +1 -1
- data/lib/statsample/dataset.rb +1 -125
- data/lib/statsample/multiset.rb +1 -2
- data/lib/statsample/vector.rb +1 -134
- data/lib/statsample/version.rb +1 -1
- data/statsample.gemspec +1 -1
- data/test/test_vector.rb +0 -138
- metadata +5 -6
- data/test/test_dataset.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad9180f3e25cf0cc125d1e4a0e534b89bdaf4c11
|
4
|
+
data.tar.gz: cd72f54dcbf15cdf6413daf54551c8b9820d50fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a001eb384addd6ed71907135a89dd72adaab3b062925fbdeb2b86ec8070cc227c0b9da2be6d4143266091b4e020d37603dbf9b9e2965a410bbac1c8d58fbf4e4
|
7
|
+
data.tar.gz: 2069ae723e70c28a00b0f058aac934ff3894792c3cb5d5467efdcc371f28dac9e52c41ea4b0be6410c9a69c58b3c305fbbca1ddb4ded6bc603d274769e128f4f
|
data/History.txt
CHANGED
data/lib/statsample/daru.rb
CHANGED
@@ -59,8 +59,8 @@ module Daru
|
|
59
59
|
to_multiset_by_split_multiple_fields(*vecs)
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
62
63
|
# Creates a Statsample::Multiset, using one field
|
63
|
-
|
64
64
|
def to_multiset_by_split_one_field(field)
|
65
65
|
raise ArgumentError,"Should use a correct field name" if
|
66
66
|
!@vectors.include? field
|
data/lib/statsample/dataset.rb
CHANGED
@@ -3,132 +3,8 @@ require 'statsample/vector'
|
|
3
3
|
class Hash
|
4
4
|
# Creates a Statsample::Dataset based on a Hash
|
5
5
|
def to_dataframe(*args)
|
6
|
-
|
6
|
+
Daru::DataFrame.new(self, *args)
|
7
7
|
end
|
8
8
|
|
9
9
|
alias :to_dataset :to_dataframe
|
10
10
|
end
|
11
|
-
|
12
|
-
class Array
|
13
|
-
def prefix(s) # :nodoc:
|
14
|
-
self.collect{|c| s+c.to_s }
|
15
|
-
end
|
16
|
-
def suffix(s) # :nodoc:
|
17
|
-
self.collect{|c| c.to_s+s }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
module Statsample
|
22
|
-
# == Deprecation Warning
|
23
|
-
#
|
24
|
-
# This class will soon be replaced by Daru::DataFrame in the
|
25
|
-
# next release. Please see the daru docs at https://github.com/v0dro/daru
|
26
|
-
# for more details
|
27
|
-
class Dataset < Daru::DataFrame
|
28
|
-
# Ordered ids of vectors
|
29
|
-
def fields
|
30
|
-
$stderr.puts "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using Daru::DataFrame#vectors.\n"
|
31
|
-
@vectors.to_a
|
32
|
-
end
|
33
|
-
|
34
|
-
def name= new_name
|
35
|
-
$stderr.puts "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using Daru::DataFrame#rename.\n"
|
36
|
-
|
37
|
-
rename new_name
|
38
|
-
end
|
39
|
-
# Number of cases
|
40
|
-
def cases
|
41
|
-
$stderr.puts "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using Daru::DataFrame#nrows.\n"
|
42
|
-
|
43
|
-
nrows
|
44
|
-
end
|
45
|
-
|
46
|
-
# == Deprecation Warning
|
47
|
-
#
|
48
|
-
# This class will soon be replaced by Daru::DataFrame in the
|
49
|
-
# next release. Use Daru::DataFrame.crosstab_by_assignation
|
50
|
-
# for the same effect. Please see the daru docs at
|
51
|
-
# https://github.com/v0dro/daru for more details.
|
52
|
-
def self.crosstab_by_assignation(rows,columns,values)
|
53
|
-
ds = super(rows, columns, values)
|
54
|
-
Dataset.new ds.to_hash
|
55
|
-
end
|
56
|
-
|
57
|
-
# == Deprecation Warning
|
58
|
-
#
|
59
|
-
# This class will soon be replaced by Daru::DataFrame in the
|
60
|
-
# next release. Use Daru::DataFrame.new for the same effect.
|
61
|
-
# Please see the daru docs at https://github.com/v0dro/daru for more details.
|
62
|
-
def initialize(vectors={}, fields=[])
|
63
|
-
$stderr.puts "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\n"
|
64
|
-
|
65
|
-
if vectors.instance_of? Array
|
66
|
-
@fields=vectors.dup
|
67
|
-
super({}, order: @fields.map { |e| e.respond_to?(:to_sym) ? e.to_sym : e })
|
68
|
-
else
|
69
|
-
# Check vectors
|
70
|
-
@vectors = {}
|
71
|
-
vectors.each do |k,v|
|
72
|
-
@vectors[k.respond_to?(:to_sym) ? k.to_sym : k] = v
|
73
|
-
end
|
74
|
-
@fields = fields
|
75
|
-
super @vectors, order: @fields.map { |e| e.respond_to?(:to_sym) ? e.to_sym : e }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def from_to(from,to)
|
80
|
-
raise NoMethodError, "This method is no longer supported. To see the vector index use Daru::DataFrame#vectors"
|
81
|
-
end
|
82
|
-
|
83
|
-
def add_vector(name, vector)
|
84
|
-
raise NoMethodError, "Deprecated. Use Daru::DataFrame#[]= directly."
|
85
|
-
end
|
86
|
-
|
87
|
-
def add_case_array(v)
|
88
|
-
raise NoMethodError, "Deprecated. Use Daru::DataFrame#add_row instead."
|
89
|
-
end
|
90
|
-
|
91
|
-
def add_case(v,uvd=true)
|
92
|
-
raise NoMethodError, "Deprecated. Use Daru::DataFrame#add_row instead."
|
93
|
-
end
|
94
|
-
|
95
|
-
def update_valid_data
|
96
|
-
raise NoMethodError, "Deprecated. Use Daru::DataFrame#update instead. Also see Daru.lazy_update in the daru docs."
|
97
|
-
end
|
98
|
-
|
99
|
-
def each_array
|
100
|
-
raise NoMethodError, "Deprecated. Use Daru::DataFrame#each_row instead."
|
101
|
-
end
|
102
|
-
|
103
|
-
def fields=(f)
|
104
|
-
$stderr.puts "WARNING: Deprecated. Use Daru::DataFrame#reindex_vectors! instead.\n"
|
105
|
-
|
106
|
-
reindex_vectors! f
|
107
|
-
end
|
108
|
-
|
109
|
-
# Returns the vector named i
|
110
|
-
def [](i)
|
111
|
-
$stderr.puts "WARNING: Daru uses symbols instead of strings for naming vectors. Please switch to symbols.\n"
|
112
|
-
|
113
|
-
if i.is_a? Range
|
114
|
-
beg = i.begin.respond_to?(:to_sym) ? i.to_sym : i
|
115
|
-
en = i.end.respond_to?(:to_sym) ? i.to_sym : i
|
116
|
-
super(beg..en)
|
117
|
-
else
|
118
|
-
super i.to_sym
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def []=(i,v)
|
123
|
-
$stderr.puts "WARNING: Daru uses symbols instead of strings for naming vectors. Please switch to symbols.\n"
|
124
|
-
|
125
|
-
super i, v
|
126
|
-
end
|
127
|
-
|
128
|
-
if Statsample.has_gsl?
|
129
|
-
def clear_gsl
|
130
|
-
raise NoMethodError, "This method is no longer needed/supported."
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
data/lib/statsample/multiset.rb
CHANGED
@@ -43,8 +43,7 @@ module Statsample
|
|
43
43
|
end
|
44
44
|
|
45
45
|
@fields.each do |f|
|
46
|
-
union_field[f] = Daru::Vector.new(union_field[f])
|
47
|
-
union_field[f].rename names[f]
|
46
|
+
union_field[f] = Daru::Vector.new(union_field[f], name: names[f])
|
48
47
|
end
|
49
48
|
|
50
49
|
ds_union = Daru::DataFrame.new(union_field, order: @fields)
|
data/lib/statsample/vector.rb
CHANGED
@@ -2,17 +2,7 @@ module Statsample::VectorShorthands
|
|
2
2
|
# Creates a new Statsample::Vector object
|
3
3
|
# Argument should be equal to Vector.new
|
4
4
|
def to_vector(*args)
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
# Creates a new Daru::Vector object of type :scale.
|
9
|
-
# Deprecated. Use to_numeric instead.
|
10
|
-
def to_scale(*args)
|
11
|
-
Statsample::Vector.new(self, *args)
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_numeric(*args)
|
15
|
-
Statsample::Vector.new(self)
|
5
|
+
Daru::Vector.new(self)
|
16
6
|
end
|
17
7
|
end
|
18
8
|
|
@@ -27,126 +17,3 @@ if Statsample.has_gsl?
|
|
27
17
|
end
|
28
18
|
end
|
29
19
|
end
|
30
|
-
module Statsample
|
31
|
-
|
32
|
-
|
33
|
-
# Collection of values on one dimension. Works as a column on a Spreadsheet.
|
34
|
-
#
|
35
|
-
# == Usage
|
36
|
-
# The fast way to create a vector uses Array.to_vector or Array.to_numeric.
|
37
|
-
#
|
38
|
-
# == Deprecation Warning
|
39
|
-
#
|
40
|
-
# Statsample::Vector has been deprecated in favour of Daru::Vector. Daru is
|
41
|
-
# a dedicated data analysis and manipulation library that brings awesome
|
42
|
-
# data analysis functionality to ruby. Check out the daru docs at
|
43
|
-
# https://github.com/v0dro/daru#notebooks
|
44
|
-
class Vector < Daru::Vector
|
45
|
-
include Statsample::VectorShorthands
|
46
|
-
|
47
|
-
# Valid data. Equal to data, minus values assigned as missing values.
|
48
|
-
#
|
49
|
-
# == Deprecation Warning
|
50
|
-
#
|
51
|
-
# Use Daru::Vector#only_valid instead of this method.
|
52
|
-
def valid_data
|
53
|
-
$stderr.puts "WARNING: valid_data in Statsample::Vector has been deprecated in favor of only_valid in Daru::Vector. Please use that.\n"
|
54
|
-
only_valid.to_a
|
55
|
-
end
|
56
|
-
# Missing values array
|
57
|
-
#
|
58
|
-
# == Deprecation Warning
|
59
|
-
#
|
60
|
-
# Use Daru::Vector#only_valid instead of this method.
|
61
|
-
def missing_data
|
62
|
-
only_missing.to_a
|
63
|
-
end
|
64
|
-
# Original data.
|
65
|
-
#
|
66
|
-
# == Deprecation Warning
|
67
|
-
#
|
68
|
-
# Use Daru::Vector#to_a instead of this method.
|
69
|
-
def data_with_nils
|
70
|
-
to_a
|
71
|
-
end
|
72
|
-
|
73
|
-
def type= val
|
74
|
-
raise NoMethodError, "Daru::Vector automatically figures the type of data. There is no need to assign it anymore."
|
75
|
-
end
|
76
|
-
|
77
|
-
def initialize(data=[], type=:object, opts=Hash.new)
|
78
|
-
$stderr.puts "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that."
|
79
|
-
|
80
|
-
if type == :ordinal or type == :scale
|
81
|
-
$stderr.puts "WARNING: #{type} has been deprecated."
|
82
|
-
end
|
83
|
-
|
84
|
-
if type == :nominal
|
85
|
-
$stderr.puts "WARNING: nominal has been deprecated."
|
86
|
-
end
|
87
|
-
|
88
|
-
if opts[:today_values]
|
89
|
-
raise ArgumentError, "This option is no longer supported in Vector. Watch out for the next version of Daru::Vector that will have full time series support"
|
90
|
-
end
|
91
|
-
|
92
|
-
if opts[:name].nil?
|
93
|
-
@@n_table||=0
|
94
|
-
@@n_table+=1
|
95
|
-
opts[:name] = "Vector #{@@n_table}"
|
96
|
-
end
|
97
|
-
|
98
|
-
super(data, opts)
|
99
|
-
end
|
100
|
-
|
101
|
-
# Create a vector using (almost) any object
|
102
|
-
# * Array: flattened
|
103
|
-
# * Range: transformed using to_a
|
104
|
-
# * Statsample::Vector
|
105
|
-
# * Numeric and string values
|
106
|
-
#
|
107
|
-
# == Deprecation Warning
|
108
|
-
#
|
109
|
-
# Statsample::Vector is to be replaced by Daru::Vector soon. Use the
|
110
|
-
# equivalent method Daru::Vector.[] for this purpose.
|
111
|
-
def self.[](*args)
|
112
|
-
$stderr.puts "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that."
|
113
|
-
super *args
|
114
|
-
end
|
115
|
-
|
116
|
-
# Create a new numeric type vector
|
117
|
-
# Parameters
|
118
|
-
# [n] Size
|
119
|
-
# [val] Value of each value
|
120
|
-
# [&block] If block provided, is used to set the values of vector
|
121
|
-
#
|
122
|
-
# == Deprecation Warning
|
123
|
-
#
|
124
|
-
# Statsample::Vector is to be replaced by Daru::Vector soon. Use the
|
125
|
-
# equivalent method Daru::Vector.[] for this purpose.
|
126
|
-
def self.new_numeric(n,val=nil, &block)
|
127
|
-
if block
|
128
|
-
Statsample::Vector.new(n.times.map {|i| block.call(i)})
|
129
|
-
else
|
130
|
-
Statsample::Vector.new(n.times.map { val })
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
# Deprecated. Use new_numeric instead.
|
135
|
-
def self.new_scale(n, val=nil,&block)
|
136
|
-
new_numeric n, val, &block
|
137
|
-
end
|
138
|
-
|
139
|
-
# Return true if all data is Date, "today" values or nil
|
140
|
-
def can_be_date?
|
141
|
-
raise NoMethodError, "This method is no longer supported."
|
142
|
-
end
|
143
|
-
# Return true if all data is Numeric or nil
|
144
|
-
def can_be_numeric?
|
145
|
-
type == :numeric
|
146
|
-
end
|
147
|
-
|
148
|
-
def to_s
|
149
|
-
sprintf("Vector(type:%s, n:%d)[%s]",@type.to_s,@data.size, @data.collect{|d| d.nil? ? "nil":d}.join(","))
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
data/lib/statsample/version.rb
CHANGED
data/statsample.gemspec
CHANGED
@@ -80,5 +80,5 @@ Gem::Specification.new do |s|
|
|
80
80
|
s.add_development_dependency 'gettext', '~> 3.1'
|
81
81
|
s.add_development_dependency 'mocha', '~> 1.1'
|
82
82
|
s.add_development_dependency 'nmatrix', '~> 0.1.0'
|
83
|
-
s.add_development_dependency 'gsl
|
83
|
+
s.add_development_dependency 'rb-gsl', '~> 1.16'
|
84
84
|
end
|
data/test/test_vector.rb
CHANGED
@@ -1,144 +1,6 @@
|
|
1
1
|
require(File.expand_path(File.dirname(__FILE__) + '/helpers_tests.rb'))
|
2
2
|
|
3
3
|
class StatsampleTestVector < Minitest::Test
|
4
|
-
include Statsample::Shorthand
|
5
|
-
|
6
|
-
context Statsample do
|
7
|
-
setup do
|
8
|
-
@sample = 100
|
9
|
-
@a = Daru::Vector.new(@sample.times.map { |i| (i + rand(10)) % 10 == 0 ? nil : rand(100) })
|
10
|
-
@b = Daru::Vector.new(@sample.times.map { |i| (i + rand(10)) % 10 == 0 ? nil : rand(100) })
|
11
|
-
@correct_a = []
|
12
|
-
@correct_b = []
|
13
|
-
@a.each_with_index do |_v, i|
|
14
|
-
if !@a[i].nil? and !@b[i].nil?
|
15
|
-
@correct_a.push(@a[i])
|
16
|
-
@correct_b.push(@b[i])
|
17
|
-
end
|
18
|
-
end
|
19
|
-
@correct_a = Daru::Vector.new(@correct_a)
|
20
|
-
@correct_b = Daru::Vector.new(@correct_b)
|
21
|
-
|
22
|
-
@common = lambda do |av, bv|
|
23
|
-
assert_equal(@correct_a, av, 'A no es esperado')
|
24
|
-
assert_equal(@correct_b, bv, 'B no es esperado')
|
25
|
-
assert(!av.has_missing_data?, 'A tiene datos faltantes')
|
26
|
-
assert(!bv.has_missing_data?, 'b tiene datos faltantes')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
should 'return correct only_valid' do
|
31
|
-
av, bv = Statsample.only_valid @a, @b
|
32
|
-
av.reset_index!
|
33
|
-
bv.reset_index!
|
34
|
-
av2, bv2 = Statsample.only_valid av, bv
|
35
|
-
@common.call(av, bv)
|
36
|
-
assert_equal(av, av2)
|
37
|
-
assert_not_same(av, av2)
|
38
|
-
assert_not_same(bv, bv2)
|
39
|
-
end
|
40
|
-
|
41
|
-
should 'return correct only_valid_clone' do
|
42
|
-
av, bv = Statsample.only_valid_clone @a, @b
|
43
|
-
av.reset_index!
|
44
|
-
bv.reset_index!
|
45
|
-
@common.call(av, bv)
|
46
|
-
av2, bv2 = Statsample.only_valid_clone av, bv
|
47
|
-
assert_equal(av, av2)
|
48
|
-
assert_same(av, av2)
|
49
|
-
assert_same(bv, bv2)
|
50
|
-
end
|
51
|
-
|
52
|
-
should 'returns correct vector_cols_matrix' do
|
53
|
-
v1 = Daru::Vector.new(%w(a a a b b b c c))
|
54
|
-
v2 = Daru::Vector.new(%w(1 3 4 5 6 4 3 2))
|
55
|
-
v3 = Daru::Vector.new(%w(1 0 0 0 1 1 1 0))
|
56
|
-
ex = Matrix.rows([%w(a 1 1), %w(a 3 0), %w(a 4 0), %w(b 5 0), %w(b 6 1), %w(b 4 1), %w(c 3 1), %w(c 2 0)])
|
57
|
-
assert_equal(ex, Statsample.vector_cols_matrix(v1, v2, v3))
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context Statsample::Vector do
|
62
|
-
context 'when initializing' do
|
63
|
-
should '.new creates a Daru::Vector internally and shows a warning' do
|
64
|
-
assert_output(nil, "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\n") do
|
65
|
-
data = (10.times.map { rand(100) }) + [nil]
|
66
|
-
original = Statsample::Vector.new(@data, :numeric)
|
67
|
-
assert_equal(true, original.kind_of?(Daru::Vector))
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
should '[] returns same results as R-c()' do
|
72
|
-
assert_output(nil, "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\n") do
|
73
|
-
assert_equal(true, Statsample::Vector[1,2,3,4,5].kind_of?(Daru::Vector))
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
should "new_numeric/new_scale creates a Daru::Vector internally and shows a warning" do
|
78
|
-
assert_output(nil, "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\n") do
|
79
|
-
Statsample::Vector.new_scale(4)
|
80
|
-
end
|
81
|
-
|
82
|
-
assert_output(nil, "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\n") do
|
83
|
-
Statsample::Vector.new_numeric(4)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "new types :numeric and :object" do
|
90
|
-
should "numerical data is automatically detected to be of type :numeric" do
|
91
|
-
v = Statsample::Vector.new [1,2,3,4,5,nil]
|
92
|
-
assert_equal(:numeric, v.type)
|
93
|
-
end
|
94
|
-
|
95
|
-
should "object data automatically detected as :object" do
|
96
|
-
v = Statsample::Vector.new [1,2,3,4,'hello','world']
|
97
|
-
assert_equal(:object, v.type)
|
98
|
-
end
|
99
|
-
|
100
|
-
should "initialize Vector with :numeric type" do
|
101
|
-
v = Statsample::Vector.new [1,2,3,4,5,nil], :numeric
|
102
|
-
assert_equal(:numeric, v.type)
|
103
|
-
assert_output(nil, "WARNING: valid_data in Statsample::Vector has been deprecated in favor of only_valid in Daru::Vector. Please use that.\n") do
|
104
|
-
assert_equal([1,2,3,4,5], v.valid_data)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
should "show a warning when initializing with :nominal, :numeric or :ordinal" do
|
109
|
-
assert_output(nil,"WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\nWARNING: nominal has been deprecated.\n") do
|
110
|
-
Statsample::Vector.new [1,2,3,4,5,nil,'hello'], :nominal
|
111
|
-
end
|
112
|
-
|
113
|
-
assert_output(nil,"WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\nWARNING: scale has been deprecated.\n") do
|
114
|
-
Statsample::Vector.new [1,2,3,4,nil,5], :scale
|
115
|
-
end
|
116
|
-
|
117
|
-
assert_output(nil,"WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\nWARNING: ordinal has been deprecated.\n") do
|
118
|
-
Statsample::Vector.new [1,2,3,4,5], :ordinal
|
119
|
-
end
|
120
|
-
|
121
|
-
assert_output(nil,"WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\n") do
|
122
|
-
Statsample::Vector.new_scale 10, 1
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
should "show a warning when Statsample::Vector shorthands are used" do
|
127
|
-
numeric = Statsample::Vector.new([1,2,3,4,nil,5], :numeric)
|
128
|
-
assert_equal(numeric, [1,2,3,4,nil,5].to_numeric)
|
129
|
-
assert_equal(numeric, [1,2,3,4,nil,5].to_vector(:numeric))
|
130
|
-
|
131
|
-
obj = Statsample::Vector.new([1,2,3,4,'one','two'], :object)
|
132
|
-
assert_equal(obj, [1,2,3,4,'one','two'].to_vector(:object))
|
133
|
-
end
|
134
|
-
|
135
|
-
should "test that old shorthands show deprecation warnings" do
|
136
|
-
assert_output(nil,"WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\n") do
|
137
|
-
[1,2,3,4,nil,5].to_scale
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
4
|
should 'return correct histogram' do
|
143
5
|
a = Daru::Vector.new(10.times.map { |v| v })
|
144
6
|
hist = a.histogram(2)
|
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: 2.0.
|
4
|
+
version: 2.0.1
|
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-
|
12
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: daru
|
@@ -278,19 +278,19 @@ dependencies:
|
|
278
278
|
- !ruby/object:Gem::Version
|
279
279
|
version: 0.1.0
|
280
280
|
- !ruby/object:Gem::Dependency
|
281
|
-
name: gsl
|
281
|
+
name: rb-gsl
|
282
282
|
requirement: !ruby/object:Gem::Requirement
|
283
283
|
requirements:
|
284
284
|
- - "~>"
|
285
285
|
- !ruby/object:Gem::Version
|
286
|
-
version: 1.
|
286
|
+
version: '1.16'
|
287
287
|
type: :development
|
288
288
|
prerelease: false
|
289
289
|
version_requirements: !ruby/object:Gem::Requirement
|
290
290
|
requirements:
|
291
291
|
- - "~>"
|
292
292
|
- !ruby/object:Gem::Version
|
293
|
-
version: 1.
|
293
|
+
version: '1.16'
|
294
294
|
description: |
|
295
295
|
A suite for basic and advanced statistics on Ruby. Tested on CRuby 1.9.3, 2.0.0
|
296
296
|
and 2.1.1. See `.travis.yml` for more information.
|
@@ -454,7 +454,6 @@ files:
|
|
454
454
|
- test/test_bivariate.rb
|
455
455
|
- test/test_codification.rb
|
456
456
|
- test/test_crosstab.rb
|
457
|
-
- test/test_dataset.rb
|
458
457
|
- test/test_dominance_analysis.rb
|
459
458
|
- test/test_factor.rb
|
460
459
|
- test/test_factor_map.rb
|
data/test/test_dataset.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require(File.expand_path(File.dirname(__FILE__) + '/helpers_tests.rb'))
|
2
|
-
class StatsampleDatasetTestCase < Minitest::Test
|
3
|
-
def setup
|
4
|
-
assert_output(nil, "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\nWARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\nWARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\nWARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\nWARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\nWARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\n") do
|
5
|
-
@ds = Statsample::Dataset.new({
|
6
|
-
'id' => Statsample::Vector.new([1, 2, 3, 4, 5]),
|
7
|
-
'name' => Statsample::Vector.new(%w(Alex Claude Peter Franz George)),
|
8
|
-
'age' => Statsample::Vector.new([20, 23, 25, 27, 5]),
|
9
|
-
'city' => Statsample::Vector.new(['New York', 'London', 'London', 'Paris', 'Tome']),
|
10
|
-
'a1' => Statsample::Vector.new(['a,b', 'b,c', 'a', nil, 'a,b,c']) },
|
11
|
-
%w(id name age city a1))
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_basic
|
16
|
-
assert_output(nil, "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using Daru::DataFrame#nrows.\n") do
|
17
|
-
assert_equal(5, @ds.cases)
|
18
|
-
end
|
19
|
-
|
20
|
-
assert_output(nil, "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using Daru::DataFrame#vectors.\n") do
|
21
|
-
assert_equal([:id, :name, :age, :city, :a1], @ds.fields)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_fields
|
26
|
-
assert_output(nil, "WARNING: Deprecated. Use Daru::DataFrame#reindex_vectors! instead.\nWARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using Daru::DataFrame#vectors.\n") do
|
27
|
-
@ds.fields = %w(name a1 id age city)
|
28
|
-
assert_equal([:name, :a1, :id, :age, :city], @ds.fields)
|
29
|
-
end
|
30
|
-
|
31
|
-
assert_raise ArgumentError, "Assigning less fields than vectors is no longer supported" do
|
32
|
-
@ds.fields = %w(id name age)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_crosstab_with_asignation
|
37
|
-
v1 = Daru::Vector.new(%w(a a a b b b c c c))
|
38
|
-
v2 = Daru::Vector.new(%w(a b c a b c a b c))
|
39
|
-
v3 = Daru::Vector.new(%w(0 1 0 0 1 1 0 0 1))
|
40
|
-
|
41
|
-
assert_output(nil, "WARNING: Statsample::Dataset and Statsample::Vector have been deprecated in favor of Daru::DataFrame and Daru::Vector. Please switch to using that.\n") do
|
42
|
-
@ds = Statsample::Dataset.crosstab_by_assignation(v1, v2, v3)
|
43
|
-
end
|
44
|
-
|
45
|
-
assert_output(nil, "WARNING: Daru uses symbols instead of strings for naming vectors. Please switch to symbols.\n") do
|
46
|
-
assert_equal(:object, @ds['_id'].type)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|