我应该使用 scipy.pi、numpy.pi 还是 math.pi? [英] Should I use scipy.pi, numpy.pi, or math.pi?

查看:26
本文介绍了我应该使用 scipy.pi、numpy.pi 还是 math.pi?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 SciPy 和 NumPy 的项目中,我应该使用 scipy.pinumpy.pi 还是 math.pi?>

In a project using SciPy and NumPy, should I use scipy.pi, numpy.pi, or math.pi?

推荐答案

>>> import math
>>> import numpy as np
>>> import scipy
>>> math.pi == np.pi == scipy.pi
True

所以没关系,它们都是相同的值.

So it doesn't matter, they are all the same value.

所有三个模块都提供 pi 值的唯一原因是,如果您只使用三个模块中的一个,您可以方便地访问 pi,而无需导入另一个模块.他们没有为 pi 提供不同的值.

The only reason all three modules provide a pi value is so if you are using just one of the three modules, you can conveniently have access to pi without having to import another module. They're not providing different values for pi.

这篇关于我应该使用 scipy.pi、numpy.pi 还是 math.pi?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆