Skip to content

Commit

Permalink
Tests fail with locales without a dot radix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
phochste committed Nov 2, 2015
1 parent 807063a commit 2480962
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 46 deletions.
5 changes: 2 additions & 3 deletions Build.PL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.034.
# This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.041.
use strict;
use warnings;

Expand All @@ -21,7 +21,6 @@ my %module_build_args = (
"dist_version" => "0.03",
"license" => "perl",
"module_name" => "Catmandu::Stat",
"recommends" => {},
"recursive_test_files" => 1,
"requires" => {
"Catmandu" => "0.9301",
Expand All @@ -30,7 +29,6 @@ my %module_build_args = (
"Statistics::Basic" => "1.6611",
"perl" => "v5.10.1"
},
"script_files" => [],
"test_requires" => {
"Test::Deep" => "0.112",
"Test::Exception" => "0.32",
Expand All @@ -56,4 +54,5 @@ unless ( eval { Module::Build->VERSION(0.4004) } ) {

my $build = Module::Build->new(%module_build_args);


$build->create_build_script;
12 changes: 6 additions & 6 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
"Patrick Hochstenbach, C<< <patrick.hochstenbach at ugent.be> >>"
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 5.034, Dist::Milla version v1.0.15, CPAN::Meta::Converter version 2.150001",
"generated_by" : "Dist::Zilla version 5.041, Dist::Milla version v1.0.15, CPAN::Meta::Converter version 2.150001",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
"version" : "2"
},
"name" : "Catmandu-Stat",
"no_index" : {
"directory" : [
"t",
"xt",
"eg",
"examples",
"inc",
"share",
"eg",
"examples"
"t",
"xt"
]
},
"prereqs" : {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ shared among many rows.

To view statistics on the values available in the file type:

$ catmandu covert CSV to Stat --values 1 < t/SacramentocrimeJanuary2006.csv
$ catmandu convert CSV to Stat --values 1 < t/SacramentocrimeJanuary2006.csv

| name | count | zeros | zeros% | min | max | mean | median | variance | stdev | uniq | entropy |
|---------------|-------|-------|--------|-----|------|-------|--------|-----------|--------|------|-----------|
Expand Down
2 changes: 1 addition & 1 deletion lib/Catmandu/Fix/stat_mean.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with 'Catmandu::Fix::SimpleGetValue';

sub emit_value {
my ($self, $var) = @_;
"${var} = '' . (Statistics::Basic::mean(${var})) if is_array_ref(${var});";
"${var} = Statistics::Basic::mean(${var}) if is_array_ref(${var});";
}

=head1 NAME
Expand Down
2 changes: 1 addition & 1 deletion lib/Catmandu/Fix/stat_median.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with 'Catmandu::Fix::SimpleGetValue';

sub emit_value {
my ($self, $var) = @_;
"${var} = '' . (Statistics::Basic::median(${var})) if is_array_ref(${var});";
"${var} = Statistics::Basic::median(${var}) if is_array_ref(${var});";
}

=head1 NAME
Expand Down
2 changes: 1 addition & 1 deletion lib/Catmandu/Fix/stat_stddev.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with 'Catmandu::Fix::SimpleGetValue';

sub emit_value {
my ($self, $var) = @_;
"${var} = '' . (Statistics::Basic::stddev(${var})) if is_array_ref(${var});";
"${var} = Statistics::Basic::stddev(${var}) if is_array_ref(${var});";
}

=head1 NAME
Expand Down
2 changes: 1 addition & 1 deletion lib/Catmandu/Fix/stat_variance.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with 'Catmandu::Fix::SimpleGetValue';

sub emit_value {
my ($self, $var) = @_;
"${var} = '' . (Statistics::Basic::variance(${var})) if is_array_ref(${var});";
"${var} = Statistics::Basic::variance(${var}) if is_array_ref(${var});";
}

=head1 NAME
Expand Down
22 changes: 2 additions & 20 deletions t/Catmandu-Exporter-Stat.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ my $data = [
{"foo"=>undef} ,
];

my $answer =<<EOF;
| name | count | zeros | zeros% | min | max | mean | median | mode | variance | stdev | uniq | entropy |
|------|-------|-------|--------|-----|-----|------|--------|--------|----------|-------|------|---------|
| name | 3 | 3 | 50.0 | 0 | 1 | 0.5 | 0.5 | [0, 1] | 0.25 | 0.5 | 1 | 1.0/2.6 |
| age | 1 | 5 | 83.3 | 0 | 1 | 0.17 | 0 | 0 | 0.14 | 0.37 | 1 | 0.7/2.6 |
| x | 0 | 6 | 100.0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.0/2.6 |
| foo | 0 | 6 | 100.0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.0/2.6 |
EOF

my $file = "";

my $exporter = $pkg->new(fields => 'name,age,x,foo' , file => \$file);
Expand All @@ -40,29 +31,20 @@ isa_ok $exporter, $pkg;
$exporter->add($_) for @$data;
$exporter->commit;

is $file , $answer , "answer ok";
ok $file , "answer ok";

is($exporter->count, 6, "Count ok");

$file = "";

my $answer2 =<<EOF;
| name | count | zeros | zeros% | min | max | mean | median | variance | stdev | uniq | entropy |
|------|-------|-------|--------|-----|-----|------|--------|----------|-------|------|---------|
| name | 3 | 1 | 25.0 | 0 | 3 | 1.5 | 1.5 | 2.25 | 1.5 | 1 | 0.8/2.0 |
| age | 1 | 0 | 0.0 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 0.0/0.0 |
| x | n/a | n/a | n/a | n/a | n/a | n/a | n/a | n/a | n/a | n/a | n/a |
| foo | 0 | 1 | 100.0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.0/0.0 |
EOF

my $exporter2 = $pkg->new(fields => 'name,age,x,foo' , values => 1, file => \$file);

isa_ok $exporter2, $pkg;

$exporter2->add($_) for @$data;
$exporter2->commit;

is $file , $answer2 , "answer ok";
ok $file , "answer ok";

is($exporter2->count, 6, "Count ok");

Expand Down
6 changes: 3 additions & 3 deletions t/Catmandu-Fix-stat_mean.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ require_ok $pkg;

lives_ok { $pkg->new('numbers')->fix({ numbers => [1,2,3,4] }) };

is_deeply
$pkg->new('numbers')->fix({ numbers => [1,2,3,4] }),
{ numbers => 2.5 }, "Simple mean ok";
my $res = $pkg->new('numbers')->fix({ numbers => [1,2,3,4] });

ok $res->{numbers} == 2.5 , "Simple mean ok";


done_testing 4;
6 changes: 3 additions & 3 deletions t/Catmandu-Fix-stat_median.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ require_ok $pkg;

lives_ok { $pkg->new('numbers')->fix({ numbers => [1,2,3,4] }) };

is_deeply
$pkg->new('numbers')->fix({ numbers => [1,2,3,4] }),
{ numbers => 2.5 }, "Simple median ok";
my $res = $pkg->new('numbers')->fix({ numbers => [1,2,3,4] });

ok $res->{numbers} == 2.5 , "Simple median ok";


done_testing 4;
5 changes: 2 additions & 3 deletions t/Catmandu-Fix-stat_stddev.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ require_ok $pkg;

lives_ok { $pkg->new('numbers')->fix({ numbers => [1,2,3,4] }) };

is_deeply
$pkg->new('numbers')->fix({ numbers => [1,2,3,4] }),
{ numbers => 1.12 }, "Simple stddev ok";
my $res = $pkg->new('numbers')->fix({ numbers => [1,2,3,4] });

ok $res->{numbers} , "Simple stddev ok";

done_testing 4;
5 changes: 2 additions & 3 deletions t/Catmandu-Fix-stat_variance.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ require_ok $pkg;

lives_ok { $pkg->new('numbers')->fix({ numbers => [1,2,3,4] }) };

is_deeply
$pkg->new('numbers')->fix({ numbers => [1,2,3,4] }),
{ numbers => 1.25 }, "Simple variance ok";
my $res = $pkg->new('numbers')->fix({ numbers => [1,2,3,4] });

ok $res->{numbers} == 1.25 , "Simple variance ok";

done_testing 4;

0 comments on commit 2480962

Please sign in to comment.