Improve Parameter tests a bit
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import absolute_import, division, print_function, unicode_literals
+import pytest
import numpy as np
from numpy.testing import assert_allclose
from ..modeling import Parameter, ParameterList
@@ -16,6 +17,35 @@ def test_parameter_init():
assert par.max is np.nan
assert par.frozen is False
+ par = Parameter('spam', '42 deg')
+ assert par.factor == 42
+ assert par.scale == 1
+ assert par.unit == 'deg'
+
+def test_parameter_value():
+ par = Parameter('spam', 42, 'deg', 10)
+
+ value = par.value
+ assert isinstance(value, float)
+ assert value == 420
+
+ par.value = 70
+ assert par.scale == 10
+ assert_allclose(par.factor, 7)
+
+
+def test_parameter_quantity():
+ par = Parameter('spam', 42, 'deg', 10)
+
+ quantity = par.quantity
+ assert quantity.unit == 'deg'
+ assert quantity.value == 420
+
+ par.quantity = '70 deg'
+ assert_allclose(par.factor, 7)
+ assert par.scale == 10
+ assert par.unit == 'deg'
+
def test_parameter_repr():
par = Parameter('spam', 42, 'deg')
