Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/0.18' into 0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
kif committed May 17, 2019
2 parents cc694e1 + 1b26767 commit 36245ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 5 additions & 4 deletions pyFAI/gui/tasks/GeometryTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

__authors__ = ["V. Valls"]
__license__ = "MIT"
__date__ = "16/05/2019"
__date__ = "17/05/2019"

import logging
import numpy
Expand Down Expand Up @@ -110,7 +110,7 @@ def __init__(self, parent=None):
self.clearValues()

def clearValues(self):
self.setValues(None, None, float("nan"), float("nan"), float("nan"))
self.setValues(None, None, numpy.nan, numpy.nan, numpy.nan)

def setValues(self, x, y, pixel, chi, tth):
if x is None:
Expand All @@ -120,15 +120,16 @@ def setValues(self, x, y, pixel, chi, tth):
self.__position.setValue(pos)
self.__pixel.setValue(pixel)
self.__chi.setValue(chi)
tth = numpy.nan if tth is None else tth
self.__2theta.setValue(tth)
if not numpy.isnan(tth):
# NOTE: warelength could be updated, and the the display would not
# NOTE: wavelength could be updated, and the the display would not
# be updated. But here it is safe enougth.
wavelength = CalibrationContext.instance().getCalibrationModel().fittedGeometry().wavelength().value()
q = unitutils.from2ThRad(tth, core_units.Q_A, wavelength)
self.__q.setValue(q)
else:
self.__q.setValue(float("nan"))
self.__q.setValue(numpy.nan)


class CalibrationState(qt.QObject):
Expand Down
14 changes: 11 additions & 3 deletions pyFAI/test/test_utils_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "15/05/2019"
__date__ = "17/05/2019"

import unittest
import numpy
from pyFAI.utils import ellipse as ellipse_mdl


def modulo(value, div=numpy.pi):
"""hack to calculate the value%div but returns the smallest
absolute value, possibly negative"""
q = value / div
i = round(q)
return (i - q) * div


class TestEllipse(unittest.TestCase):

def test_ellipse(self):
Expand All @@ -53,7 +61,7 @@ def test_ellipse(self):
self.assertAlmostEqual(ellipse.center_2, 100)
self.assertAlmostEqual(ellipse.half_long_axis, 20)
self.assertAlmostEqual(ellipse.half_short_axis, 10)
self.assertAlmostEqual(ellipse.angle, 0)
self.assertAlmostEqual(modulo(ellipse.angle), 0)

def test_ellipse2(self):
angles = numpy.arange(0, numpy.pi * 2, 0.2)
Expand All @@ -64,7 +72,7 @@ def test_ellipse2(self):
self.assertAlmostEqual(ellipse.center_2, 100)
self.assertAlmostEqual(ellipse.half_long_axis, 20)
self.assertAlmostEqual(ellipse.half_short_axis, 10)
self.assertAlmostEqual(ellipse.angle, numpy.pi)
self.assertAlmostEqual(modulo(ellipse.angle), 0)

def test_half_circle(self):
angles = numpy.linspace(0, numpy.pi, 10)
Expand Down

0 comments on commit 36245ad

Please sign in to comment.