Project

General

Profile

Revision dd80884c

IDdd80884c1222c5f71d9d9e358704c265e20c8a3d
Parent 0e1b6929
Child 8726bde3

Added by Andreas Kohlbecker 7 months ago

ref #8771 finetuning of statistical values display and more tests

View differences:

modules/cdm_dataportal/test/phpUnit/src/unit/StatisticalValuesTest.php
23 23
    return $stat_val;
24 24
  }
25 25

  
26
  function create_statistical_values($typicalLowerBoundary = null, $typicalUpperrBoundary = null, $average  = null, $sampleSize = null){
26
  function create_statistical_values($typicalLowerBoundary = null, $typicalUpperrBoundary = null, $average  = null, $sampleSize = null, $variance = null, $standard_deviation = null){
27 27
    $stat_vals = statistical_values_array();
28 28
    $stat_vals['TypicalLowerBoundary'] = $this->new_statistical_value($typicalLowerBoundary);
29 29
    $stat_vals['TypicalUpperBoundary'] = $this->new_statistical_value($typicalUpperrBoundary);
30 30
    $stat_vals['SampleSize'] = $this->new_statistical_value($sampleSize);
31 31
    $stat_vals['Average'] = $this->new_statistical_value($average);
32
    if($variance){
33
      $stat_vals['Variance'] = $this->new_statistical_value($variance);
34
    }
35
    if($standard_deviation){
36
      $stat_vals['StandardDeviation'] = $this->new_statistical_value($standard_deviation);
37
    }
32 38
    return $stat_vals;
33 39
  }
34 40

  
......
36 42
    return  html_entity_decode(strip_tags($html), ENT_COMPAT, 'utf-8');
37 43
  }
38 44

  
39
  function test_statistical_values() {
45
  function test_statistical_values_significant_figures_avarage() {
40 46

  
41
    $stat_vals = $this->create_statistical_values(0.123457,  0.123456, 0.123456523847, 5);
47
    $stat_vals = $this->create_statistical_values(0.123457,  0.123456, 0.1234565345, 5);
42 48
    $this->assertEquals('0.123457–0.123456[5;x̄=0.1234565]', $this->html2text(statistical_values($stat_vals)));
43 49

  
44 50
    $stat_vals = $this->create_statistical_values(12.23,  14.2, 13.2231423, 15);
......
56 62
    $stat_vals = $this->create_statistical_values(0.00000001,  1, (1 - 0.00000001) / 2, 20);
57 63
    $this->assertEquals('1.0E-8–1[20;x̄=0.5]', $this->html2text(statistical_values($stat_vals)));
58 64

  
65
    $stat_vals = $this->create_statistical_values(22,  23, 22.5, 4);
66
    $this->assertEquals('22–23[4;x̄=22.5]', $this->html2text(statistical_values($stat_vals)));
67

  
68
    // see https://dev.e-taxonomy.eu/redmine/issues/8771#note-17
69
    $stat_vals = $this->create_statistical_values(22,  23, 22.047619, 24);
70
    $this->assertEquals('22–23[24;x̄=22]', $this->html2text(statistical_values($stat_vals)));
71
  }
72

  
73

  
74
  function test_statistical_values_no_min_max() {
75

  
76
    $stat_vals = $this->create_statistical_values(null,  null, 0.1234, 5);
77
    $this->assertEquals('0.1234[5]', $this->html2text(statistical_values($stat_vals)));
78

  
79
    // as discussed in https://dev.e-taxonomy.eu/redmine/issues/8771#note-16 variance etc should not be suppressed
80
    $stat_vals = $this->create_statistical_values(null,  null, 0.1234, 5, 0.3, 0.12);
81
    $this->assertEquals('0.1234[5;σ²=0.3;σ=0.12]', $this->html2text(statistical_values($stat_vals)));
59 82
  }
60 83

  
61 84
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)