def test_smooth_without_size(self):
     arr = self._flat_arr
     surf = Topography(arr, (1, 1)).detrend(detrend_mode='height')
     self.assertEqual(surf.dim, 2)
     self.assertTrue(surf.is_uniform)
     self.assertAlmostEqual(surf.mean(), 0)
     self.assertAlmostEqual(surf.rms_gradient(), 0)
     self.assertTrue(
         surf.rms_height_from_area() < Topography(arr, (1, 1)).rms_height_from_area())
    def test_smooth_flat_2d(self):
        arr = self._flat_arr

        a = 1.2
        b = 2.5
        d = .2
        arr = np.arange(5) * a + d
        arr = arr + np.arange(6).reshape((-1, 1)) * b

        surf = Topography(arr, (1, 1)).detrend(detrend_mode='center')
        self.assertTrue(surf.is_uniform)
        self.assertAlmostEqual(surf.mean(), 0)

        surf = Topography(arr, (1.5, 3.2)).detrend(detrend_mode='slope')
        self.assertEqual(surf.dim, 2)
        self.assertTrue(surf.is_uniform)
        self.assertAlmostEqual(surf.mean(), 0)
        self.assertAlmostEqual(surf.rms_gradient(), 0)

        surf = Topography(arr, arr.shape).detrend(detrend_mode='height')
        self.assertEqual(surf.dim, 2)
        self.assertTrue(surf.is_uniform)
        self.assertAlmostEqual(surf.mean(), 0)
        self.assertAlmostEqual(surf.rms_gradient(), 0)
        self.assertTrue(
            surf.rms_height_from_area() < Topography(arr, arr.shape).rms_height_from_area())

        surf2 = Topography(arr, (1, 1)).detrend(detrend_mode='height')
        self.assertEqual(surf.dim, 2)
        self.assertTrue(surf2.is_uniform)
        self.assertAlmostEqual(surf2.rms_gradient(), 0)
        self.assertTrue(
            surf2.rms_height_from_area() < Topography(arr, arr.shape).rms_height_from_area())

        self.assertAlmostEqual(surf.rms_height_from_area(), surf2.rms_height_from_area())

        x, y, z = surf2.positions_and_heights()
        self.assertAlmostEqual(np.mean(np.diff(x[:, 0])),
                               surf2.physical_sizes[0] / surf2.nb_grid_pts[0])
        self.assertAlmostEqual(np.mean(np.diff(y[0, :])),
                               surf2.physical_sizes[1] / surf2.nb_grid_pts[1])