Merge remote-tracking branch 'upstream/0.18' into 0.18

This commit is contained in:
Jerome Kieffer 2019-05-17 15:29:03 +02:00
commit 36245ad72e
2 changed files with 16 additions and 7 deletions

View File

@ -27,7 +27,7 @@ from __future__ import absolute_import
__authors__ = ["V. Valls"]
__license__ = "MIT"
__date__ = "16/05/2019"
__date__ = "17/05/2019"
import logging
import numpy
@ -110,7 +110,7 @@ class _StatusBar(qt.QStatusBar):
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:
@ -120,15 +120,16 @@ class _StatusBar(qt.QStatusBar):
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):

View File

@ -35,13 +35,21 @@ __author__ = "Jérôme Kieffer"
__contact__ = "Jerome.Kieffer@ESRF.eu"
__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):
@ -53,7 +61,7 @@ class TestEllipse(unittest.TestCase):
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)
@ -64,7 +72,7 @@ class TestEllipse(unittest.TestCase):
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)