本文整理汇总了Python中circle.Circle.from_diameter方法的典型用法代码示例。如果您正苦于以下问题:Python Circle.from_diameter方法的具体用法?Python Circle.from_diameter怎么用?Python Circle.from_diameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circle.Circle
的用法示例。
在下文中一共展示了Circle.from_diameter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nonsense_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import from_diameter [as 别名]
def test_nonsense_diameter():
"""
Make sure we can't create a Circle object with a negative or zero
diameter.
"""
with pytest.raises(ValueError):
c = Circle.from_diameter(-2.468)
with pytest.raises(ValueError):
c = Circle.from_diameter(0)
c = Circle.from_diameter(2.468)
with pytest.raises(ValueError):
c.diameter = -2.468
with pytest.raises(ValueError):
c.diameter = 0
示例2: test_alternate_constructor
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import from_diameter [as 别名]
def test_alternate_constructor():
c = Circle.from_diameter(8)
assert c.diameter == 8
assert c.radius == 4
示例3: test_from_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import from_diameter [as 别名]
def test_from_diameter():
c = Circle.from_diameter(4)
assert isinstance(c, Circle)
assert c.radius == 2
assert c.diameter == 4
assert c.area == pi*2**2
示例4: test_from_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import from_diameter [as 别名]
def test_from_diameter():
c = Circle.from_diameter(8)
assert c.radius == 4
示例5: test_from_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import from_diameter [as 别名]
def test_from_diameter():
c = Circle.from_diameter(10)
assert isinstance(c, Circle)
assert c.radius == 5.0
示例6: test_from_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import from_diameter [as 别名]
def test_from_diameter():
c = Circle.from_diameter(4) # should create instance of circle class
assert c.radius == 2
assert c.diameter == 4
assert isinstance(c, Circle)
示例7: test_from_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import from_diameter [as 别名]
def test_from_diameter():
c = Circle.from_diameter(6)
assert (3 == c.radius)
assert (6 == c.diameter)
示例8: test_create_with_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import from_diameter [as 别名]
def test_create_with_diameter():
c = Circle.from_diameter(8)
assert c.diameter == 8
assert c.radius == 4