def testNormalizeMoreIndices(self):
     '''Normalize raises an error if more than two indices are passed as
     input'''
     x = np.arange(10)
     ind = (2, 5, 3)
     with self.assertRaises(ValueError):
        spectrum_functions.normalize(x, ind)
 def testNormalize1IndexTuple(self):
     '''Normalize throws an error if a single index inside a sequence
      is given'''
     x = np.arange(10)
     ind = [3]
     with self.assertRaises(ValueError):
        spectrum_functions.normalize(x, ind)
示例#3
0
 def Normalize(self, ind=None):
     '''Normalize data to integral'''
     data_norm = specfun.normalize(self.intensity, ind)
     return EELSSpectrum(data_norm,
                         SpectrumRange=self.SpectrumRange,
                         dispersion=self.dispersion,
                         ZLP=self.ZLP,
                         units=self.units)
 def testNormalize2Indices(self):
     '''Normalize works as expected when two indices are given'''
     x = np.arange(10)
     ind = (2, 5)
     np.testing.assert_allclose(
         x/9., 
         spectrum_functions.normalize(x, ind)
         )
 def testNormalize1Index(self):
     '''Normalize works as expected when a single index is given'''
     x = np.arange(10)
     ind = 2
     np.testing.assert_allclose(
         x/2., 
         spectrum_functions.normalize(x, ind)
         )
 def testNormalizeFloatIndex(self):
     '''Normalize throws an error when given a float index'''
     x = np.arange(10)
     ind = 2.4
     with self.assertRaises(ValueError):
        spectrum_functions.normalize(x, ind)