当我们创建一个新的数字时:
import matplotlib.pyplot as plt
fig = plt.figure()
Run Code Online (Sandbox Code Playgroud)
我们可以在控制台中看到如下输出:
<Figure size 432x288 with 0 Axes>
Run Code Online (Sandbox Code Playgroud)
所以当我们使用add_axes时:
add_axes(rect, projection=None, polar=False, **kwargs)
Run Code Online (Sandbox Code Playgroud)
我们实际上是否定义了包含"盒子"的x,y轴,这个"盒子"将绑定图形(更具数学意义的轴)并且仅此而已?或者实际上这行代码是创建一个具有所需尺寸的空图形,其中我们稍后添加的任何数据都将被装入?(或以上都没有?)
那个问题让我想知道我怎么能在物理上理解matplotlib的轴是什么.
谢谢你的帮助.
我目前正在为太阳活动区域建立一个数据库,其中一列应该获取区域编号,目前我已通过以下方式声明:
noaa_number = sql.Column(sql.Integer, nullable=True)
Run Code Online (Sandbox Code Playgroud)
但是,由于随着区域的发展可能会分配新的编号,因此哪种列类型可以更好地支持列表来保留给定区域的所有编号?因此,不要有这样的条目:
noaa_number = 12443
Run Code Online (Sandbox Code Playgroud)
我可以将结果存储为:
#a simple entry
noaa_number = [12443]
#or multiple results
noaa_number = [12444,12445]
Run Code Online (Sandbox Code Playgroud)
列表中的这些元素将是整数。
我正在检查文档,最好的想法是将这一列作为字符串放置并解析其中的所有数字。虽然这很好用,但我想知道是否有更好、更合适的方法。
出于好奇,使用 df.columns 或 df.keys() 获取 DataFrame 的列名称(假设是 df)之间有什么实际区别吗?
我按类型检查了结果,看起来完全一样。我是否遗漏了一些东西,或者这两种方法就像看起来一样多余?一种比另一种更适合使用吗?
谢谢。
如果我在脚本中运行多个测试,例如:
import pytest
@pytest.mark.parametrize("test_input,expected", [
("3+5", 8),
("2+4", 6),
("6*9", 42),
])
def test_eval(test_input, expected):
assert eval(test_input) == expected
@pytest.mark.parametrize('test_input,expected', [
(1,1),
(2,2),
(2,3),
])
def test_equal(test_input,expected):
assert test_input == expected
if __name__ == '__main__':
'''
Test Zone!
'''
#executing the tests
pytest.main([__file__])
Run Code Online (Sandbox Code Playgroud)
如何使用最后一行pytest.main([__file__])一次运行一个测试,而不是一次运行所有测试?