def test_setting_info_dict(self): x = np.array((0, 1, 1.5, 2, 3)) h = 2 * x t = NonuniformLineScan(x, h) assert t.info == {} t = NonuniformLineScan(x, h, info=dict(unit='A')) assert t.info['unit'] == 'A' # # This info should be inherited in the pipeline # st = t.scale(2) assert st.info['unit'] == 'A' # # It should be also possible to set the info # st = t.scale(2, info=dict(unit='B')) assert st.info['unit'] == 'B' # # Again the info should be passed # dt = st.detrend(detrend_mode='center') assert dt.info['unit'] == 'B' # # Alternatively, it can be changed # dt = st.detrend(detrend_mode='center', info=dict(unit='C')) assert dt.info['unit'] == 'C'
def test_init_with_lists_calling_scale_and_detrend(self): # initialize with lists instead of arrays t = NonuniformLineScan(x=[1, 2, 3, 4], y=[2, 4, 6, 8]) # the following commands should be possible without errors st = t.scale(1) st.detrend(detrend_mode='center')
def test_setting_info_dict(self): x = np.array((0, 1, 1.5, 2, 3)) h = 2 * x t = NonuniformLineScan(x, h) assert t.info == {} with pytest.deprecated_call(): t = NonuniformLineScan(x, h, info=dict(unit='A')) t = NonuniformLineScan(x, h, unit='A') with pytest.deprecated_call(): assert t.info['unit'] == 'A' # # This info should be inherited in the pipeline # st = t.scale(2) with pytest.deprecated_call(): assert st.info['unit'] == 'A' # # It should be also possible to set the info # with pytest.deprecated_call(): st = t.scale(2, info=dict(unit='B')) st = t.scale(2, 1, unit='B') with pytest.deprecated_call(): assert st.info['unit'] == 'B' # # Again the info should be passed # dt = st.detrend(detrend_mode='center') with pytest.deprecated_call(): assert dt.info['unit'] == 'B' # # It can no longer be changed in detrend (you need to use scale) # with pytest.deprecated_call(): dt = st.detrend(detrend_mode='center', info=dict(unit='C'))
def test_attribute_error(self): t = NonuniformLineScan([1, 2, 4], [2, 4, 8]) with self.assertRaises(AttributeError): t.scale_factor # a scaled line scan has a scale_factor self.assertEqual(t.scale(1).scale_factor, 1) # # This should also work after the topography has been pickled # pt = pickle.dumps(t) t2 = pickle.loads(pt) with self.assertRaises(AttributeError): t2.scale_factor # a scaled line scan has a scale_factor self.assertEqual(t2.scale(1).scale_factor, 1)