本文整理汇总了Python中sherpa.models.parameter.Parameter.unlink方法的典型用法代码示例。如果您正苦于以下问题:Python Parameter.unlink方法的具体用法?Python Parameter.unlink怎么用?Python Parameter.unlink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sherpa.models.parameter.Parameter
的用法示例。
在下文中一共展示了Parameter.unlink方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parameter
# 需要导入模块: from sherpa.models.parameter import Parameter [as 别名]
# 或者: from sherpa.models.parameter.Parameter import unlink [as 别名]
class test_parameter(SherpaTestCase):
def setUp(self):
self.p = Parameter('model', 'name', 0, -10, 10, -100, 100, 'units')
self.afp = Parameter('model', 'name', 0, alwaysfrozen=True)
def test_name(self):
self.assertEqual(self.p.modelname, 'model')
self.assertEqual(self.p.name, 'name')
self.assertEqual(self.p.fullname, 'model.name')
def test_alwaysfrozen(self):
self.assertTrue(self.afp.frozen)
self.afp.frozen = True
self.assertTrue(self.afp.frozen)
self.afp.freeze()
self.assertTrue(self.afp.frozen)
self.assertRaises(ParameterErr, self.afp.thaw)
self.assertRaises(ParameterErr, setattr, self.afp, 'frozen', 0)
def test_readonly_attributes(self):
self.assertEqual(self.p.alwaysfrozen, False)
self.assertRaises(AttributeError, setattr, self.p, 'alwaysfrozen', 1)
self.assertEqual(self.p.hard_min, -100.0)
self.assertRaises(AttributeError, setattr, self.p, 'hard_min', -1000)
self.assertEqual(self.p.hard_max, 100.0)
self.assertRaises(AttributeError, setattr, self.p, 'hard_max', 1000)
def test_val(self):
self.p.val = -7
self.assertEqual(self.p.val, -7)
self.assertTrue(type(self.p.val) is SherpaFloat)
self.assertRaises(ValueError, setattr, self.p, 'val', 'ham')
self.assertRaises(ParameterErr, setattr, self.p, 'val', -101)
self.assertRaises(ParameterErr, setattr, self.p, 'val', 101)
def test_min_max(self):
for attr, sign in (('min', -1), ('max', 1)):
setattr(self.p, attr, sign * 99)
val = getattr(self.p, attr)
self.assertEqual(val, sign * 99)
self.assertTrue(type(val) is SherpaFloat)
self.assertRaises(ValueError, setattr, self.p, attr, 'ham')
self.assertRaises(ParameterErr, setattr, self.p, attr, -101)
self.assertRaises(ParameterErr, setattr, self.p, attr, 101)
def test_frozen(self):
self.p.frozen = 1.0
self.assertTrue(self.p.frozen is True)
self.p.frozen = []
self.assertTrue(self.p.frozen is False)
self.assertRaises(TypeError, setattr, self.p.frozen, arange(10))
self.p.link = self.afp
self.assertTrue(self.p.frozen is True)
self.p.link = None
self.p.freeze()
self.assertTrue(self.p.frozen is True)
self.p.thaw()
self.assertTrue(self.p.frozen is False)
def test_link(self):
self.p.link = None
self.assertTrue(self.p.link is None)
self.assertNotEqual(self.p.val, 17.3)
self.afp.val = 17.3
self.p.link = self.afp
self.assertEqual(self.p.val, 17.3)
self.p.unlink()
self.assertTrue(self.p.link is None)
self.assertRaises(ParameterErr, setattr, self.afp, 'link', self.p)
self.assertRaises(ParameterErr, setattr, self.p, 'link', 3)
self.assertRaises(ParameterErr, setattr, self.p, 'link',
3 * self.p + 2)
def test_iter(self):
for part in self.p:
self.assertTrue(part is self.p)