コード例 #1
0
 def test_rainflow_rebinning_nbin2(self):
     """
     Test that values are correctly gathered to 2 bins
     """
     self.assertEqual(
         self.cycles_n2,
         rainflow.rebin(rainflow.count_cycles(self.series), n=2))
コード例 #2
0
 def test_series_with_zero_derivatives(self):
     """
     Duplicate values in series to create zero derivatives (platou). Test that these are ignored by the cycle
     counting.
     """
     series = itertools.chain(*([x, x] for x in self.series))
     self.assertEqual(self.cycles, rainflow.count_cycles(series))
コード例 #3
0
 def test_rainflow_rebinning_binwidth5(self):
     """
     Test that values are correctly gathered to new bins of width 5
     """
     self.assertEqual(
         self.cycles_bw5,
         rainflow.rebin(rainflow.count_cycles(self.series), w=5.))
コード例 #4
0
ファイル: test_rainflow.py プロジェクト: dnvgl/qats
 def test_rainflow_counting(self):
     """
     Standard test
     """
     # self.assertEqual(np.array(self.cycles), rainflow.count_cycles(self.series))
     # np.testing module ensures that the list `self.cycles` may be compared to the array returned from count_cycles
     np.testing.assert_array_equal(self.cycles, rainflow.count_cycles(self.series))
コード例 #5
0
 def test_rainflow_counting_using_reversals(self):
     """
     Test that cycle counting using reversals works if endpoints=True
     """
     reversals = list(rainflow.reversals(self.series))
     self.assertEqual(self.cycles,
                      rainflow.count_cycles(reversals, endpoints=True))
コード例 #6
0
ファイル: test_rainflow.py プロジェクト: dnvgl/qats
    def test_mesh(self):
        """
        Multiple tests to ensure meshgrid returned from mesh() is correct.
        """
        # no. of range and mean bins, respectively (should be different to avoid hiding errors caused by transposing)
        nr, nm = 100, 50
        # raw cycles
        cycles = rainflow.count_cycles(self.irreg_series)
        # rebinned cycles - will be used to verify mesh
        cycles_rebinned_range = rainflow.rebin(cycles, binby='range', n=nr)
        cycles_rebinned_mean = rainflow.rebin(cycles, binby='mean', n=nm)
        # generate mesh
        rmesh, mmesh, cmesh = rainflow.mesh(cycles, nr=nr, nm=nm)

        # tests
        # (shape)
        np.testing.assert_equal(cmesh.shape, (nm, nr), err_msg=f"Shape of mesh is wrong, should be {(nm, nr)}")
        np.testing.assert_equal(cmesh.shape, rmesh.shape, err_msg="Shapes do not match: 'cmesh' and 'rmesh'")
        np.testing.assert_equal(cmesh.shape, mmesh.shape, err_msg="Shapes do not match: 'cmesh' and 'mmesh'")
        # (sum of counts; total and along each axis)
        np.testing.assert_equal(cycles[:, 2].sum(), cmesh.sum(), err_msg="Sum of counts and mesh not equal")
        np.testing.assert_array_equal(cycles_rebinned_range[:, 2], cmesh.sum(axis=0),
                                      err_msg=f"Sum of counts along mean axis (constant ranges) are wrong")
        np.testing.assert_array_equal(cycles_rebinned_mean[:, 2], cmesh.sum(axis=1),
                                      err_msg=f"Sum of counts along range axis (constant means) are wrong")
        # (bins along respective axes should match bins obtained by rebinning by 'range' and 'mean', respectively)
        np.testing.assert_array_equal(rmesh[0, :], cycles_rebinned_range[:, 0],
                                      err_msg="Range mesh error (transposed by 'accident'?)")
        np.testing.assert_array_equal(mmesh[:, 0], cycles_rebinned_mean[:, 1],
                                      err_msg="Mean mesh error (transposed by 'accident'?)")
コード例 #7
0
ファイル: test_rainflow.py プロジェクト: dnvgl/qats
 def test_rebin_sum_of_counts(self):
     """
     Test that rebinning does not alter total number of counts.
     """
     cycles = rainflow.count_cycles(self.irreg_series)
     cycles_rebinned_range = rainflow.rebin(cycles, binby='range', n=50)
     self.assertEqual(cycles[:, 2].sum(), cycles_rebinned_range[:, 2].sum(),
                      msg="Total cycle counts changed after rebinning.")
コード例 #8
0
ファイル: test_rainflow.py プロジェクト: dnvgl/qats
 def test_rainflow_rebinning_binwidth2(self):
     """
     Test that values are correctly gathered to new bins of width 2
     """
     # self.assertEqual(self.cycles_bw2, rainflow.rebin(rainflow.count_cycles(self.series), w=2.))
     # np.testing.assert_array_equal(self.cycles_bw2, rainflow.rebin(rainflow.count_cycles(self.series), w=2.))
     np.testing.assert_array_almost_equal(self.cycles_bw2, rainflow.rebin(rainflow.count_cycles(self.series), w=2.),
                                          decimal=6)
コード例 #9
0
 def test_rainflow_counting_with_endpoints(self):
     """
     Test cycle counting when end points are included.
     """
     self.assertEqual(self.cycles_endpoints,
                      rainflow.count_cycles(self.series, endpoints=True))
コード例 #10
0
 def test_rainflow_counting(self):
     """
     Standard test
     """
     self.assertEqual(self.cycles, rainflow.count_cycles(self.series))