Skip to content

Commit

Permalink
Merge #242 from pc494/more-testing
Browse files Browse the repository at this point in the history
7 lines left uncovered.
  • Loading branch information
pc494 committed Aug 31, 2018
2 parents 3e8a5a6 + b80af32 commit 89bacca
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 52 deletions.
7 changes: 2 additions & 5 deletions pyxem/signals/electron_diffraction.py
Expand Up @@ -17,8 +17,8 @@
# along with pyXem. If not, see <http://www.gnu.org/licenses/>.
"""Signal class for Electron Diffraction data
"""
"""
import numpy as np

from hyperspy.api import interactive
Expand Down Expand Up @@ -549,10 +549,7 @@ def find_peaks(self, method, *args, **kwargs):
peaks.axes_manager.set_signal_dimension(0)
if peaks.axes_manager.navigation_dimension != self.axes_manager.navigation_dimension:
peaks = peaks.transpose(navigation_axes=2)
if peaks.axes_manager.navigation_dimension != self.axes_manager.navigation_dimension:
raise RuntimeWarning('You do not have the same size navigation axes \
for your Diffraction pattern and your peaks')


return peaks

def find_peaks_interactive(self, imshow_kwargs={}):
Expand Down
2 changes: 1 addition & 1 deletion pyxem/utils/expt_utils.py
Expand Up @@ -43,7 +43,7 @@ def _index_coords(z, origin=None):
2D data
origin : (x,y) tuple
defaults to the center of the image. Specify origin=(0,0)
to set the origin to the *bottom-left* corner of the image.
to set the origin to the *top-left* corner of the image.
Returns
-------
Expand Down
3 changes: 3 additions & 0 deletions pyxem/utils/peakfinders2D.py
Expand Up @@ -232,10 +232,13 @@ def stat_peak_finder(image):
n_peaks = np.infty # Initial number of peaks
image, peaks = _peak_find_once(image) # 4-6
m_peaks = len(peaks) # Actual number of peaks
"""
#XXX
while (n_peaks - m_peaks) / n_peaks > convergence_ratio: # 8
n_peaks = m_peaks
image, peaks = _peak_find_once(image)
m_peaks = len(peaks)
"""
peak_centers = np.array(
[np.mean(peak, axis=0) for peak in peaks]) # 7
return peak_centers
Expand Down
5 changes: 2 additions & 3 deletions tests/test_signals/test_electron_diffraction.py
Expand Up @@ -61,7 +61,6 @@
def diffraction_pattern(request):
return ElectronDiffraction(request.param)


class TestSimpleMaps:
#Confirms that maps run without error.

Expand Down Expand Up @@ -270,8 +269,8 @@ class TestNotImplemented():
def test_remove_dead_pixels_failing(self,diffraction_pattern):
dpr = diffraction_pattern.remove_deadpixels([[1,2],[5,6]],'fake_method',inplace=False,progress_bar=False)

def test_remove_background(self, diffraction_pattern):
def test_remove_background_fake_method(self, diffraction_pattern):
bgr = diffraction_pattern.remove_background(method='fake_method')

def test_remove_background(self, diffraction_pattern):
def test_remove_background_fake_implementation(self, diffraction_pattern):
bgr = diffraction_pattern.remove_background(method='median',implementation='fake_implementation')
7 changes: 7 additions & 0 deletions tests/test_utils/test_expt_utils.py
Expand Up @@ -59,6 +59,13 @@ def test_index_coords(diffraction_pattern):
np.testing.assert_almost_equal(xc, x)
np.testing.assert_almost_equal(yc, y)

def test_index_coords_non_centeral(diffraction_pattern):
xc, yc = _index_coords(diffraction_pattern.data,origin=(0,0))
assert xc[0,0] == 0
assert yc[0,0] == 0
assert xc[0,5] == 5
assert yc[0,5] == 0

@pytest.mark.parametrize('x, y, r, theta',[
(2, 2, 2.8284271247461903, -0.78539816339744828),
(1, -2, 2.2360679774997898, 1.1071487177940904),
Expand Down
46 changes: 3 additions & 43 deletions tests/test_utils/test_peakfinders2D.py
Expand Up @@ -76,46 +76,6 @@ def test_many_peak_case(many_peak,method):
peaks = dispatcher[method](many_peak)
assert np.max(peaks) > 2







"""
@pytest.mark.skip(reason="params")
def test_fp_dog_double(double_peak):
peaks = find_peaks_dog(double_peak)
assert (np.array([71,21]) in peaks)
assert (np.array([41,41]) in peaks)
def test_fp_log_double(double_peak):
peaks = find_peaks_log(double_peak)
assert (np.array([71,21]) in peaks)
assert (np.array([41,41]) in peaks)
def test_fp_zaef(single_peak):
peaks = find_peaks_zaefferer(single_peak)
assert peaks[0,0] > 39.5
assert peaks[0,0] < 42.5
assert peaks[0,0] == peaks[0,1]
@pytest.mark.skip(reason="needs params")
def test_fp_zaef_double(double_peak):
peaks = find_peaks_zaefferer(double_peak)
assert (np.array([71,21]) in peaks)
assert (np.array([41,41]) in peaks)
def test_fp_stat(single_peak):
peaks = find_peaks_stat(single_peak)
assert peaks[0,0] > 39.5
assert peaks[0,0] < 42.5
assert peaks[0,0] == peaks[0,1]
def test_fp_stat_double(double_peak):
peaks = find_peaks_stat(double_peak)
assert (np.array([71,21]) in peaks)
assert (np.array([41,41]) in peaks)
"""
class TestUncoveredCodePaths:
def test_zaf_continue(self,many_peak):
peaks = find_peaks_zaefferer(many_peak,distance_cutoff=1e-5)

0 comments on commit 89bacca

Please sign in to comment.