Sha256: 884f0debe355c7d1dd7acb51fde2a98864959ff2fa9ac050776fb2c487354be3
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
$:.unshift(File.dirname(__FILE__)+'/../lib/') require 'statsample' require 'tmpdir' require 'test/unit' class StatsampleCSVTestCase < Test::Unit::TestCase def initialize(*args) @ds=Statsample::CSV.read(File.dirname(__FILE__)+"/test_csv.csv") super end def test_read assert_equal(6,@ds.cases) assert_equal(%w{id name age city a1},@ds.fields) id=[1,2,3,4,5,6].to_vector(:scale) name=["Alex","Claude","Peter","Franz","George","Fernand"].to_vector(:nominal) age=[20,23,25,27,5.5,nil].to_vector(:scale) city=["New York","London","London","Paris","Tome",nil].to_vector(:nominal) a1=["a,b","b,c","a",nil,"a,b,c",nil].to_vector(:nominal) ds_exp=Statsample::Dataset.new({'id'=>id,'name'=>name,'age'=>age,'city'=>city,'a1'=>a1}, %w{id name age city a1}) ds_exp.fields.each{|f| assert_equal(ds_exp[f],@ds[f]) } assert_equal(ds_exp,@ds) end def test_nil assert_equal(nil,@ds['age'][5]) end def test_write filename=Dir::tmpdir+"/test_write.csv" Statsample::CSV.write(@ds,filename) ds2=Statsample::CSV.read(filename) i=0 ds2.each_array{|row| assert_equal(@ds.case_as_array(i),row) i+=1 } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
statsample-0.4.1 | test/test_csv.rb |
statsample-0.4.0 | test/test_csv.rb |
statsample-0.3.4 | test/test_csv.rb |