-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/0.18' into 0.18
- Loading branch information
Showing
2 changed files
with
16 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
|
@@ -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) | ||
|
@@ -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) | ||
|