如何将某个函数应用于 Python 网格?
pythonmatplotlibserver side programmingprogramming更新于 2025/4/16 17:16:17
网格 − 来自坐标向量的坐标矩阵。
让我们举一个例子来了解如何将函数应用于 Python 网格。我们可以使用 numpy 矢量化装饰器来考虑两个列表 x 和 y。
示例
import numpy as np
@np.vectorize
def foo(a, b):
return a + b
x = [0.0, 0.5, 1.0]
y = [0.0, 1.0, 8.0]
print("Function Output: ", foo(x, y))
输出
Function Output: [0. 1.5 9. ]
相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

