栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

SciPy和NumPy之间的关系

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SciPy和NumPy之间的关系

上次我检查它时,scipy

__init__
方法执行

from numpy import *

以便在导入scipy模块时将整个numpy命名空间包含到scipy中。

log10
您描述的行为很有趣,因为 两个 版本都来自numpy。一个是a
ufunc
,另一个是
numpy.lib
功能。为什么scipy偏爱库函数而不是
ufunc
,我不知道该怎么办。


编辑:事实上,我可以回答这个

log10
问题。在scipy
__init__
方法中,我看到以下内容:

# import numpy symbols to scipy name spaceimport numpy as _numfrom numpy import oldnumericfrom numpy import *from numpy.random import rand, randnfrom numpy.fft import fft, ifftfrom numpy.lib.scimath import *

log10
您获得scipy的功能来自
numpy.lib.scimath
。查看该代码,它说:

"""Wrapper functions to more user-friendly calling of certain math functionswhose output data-type is different than the input data-type in certaindomains of the input.For example, for functions like log() with branch cuts, the versions in thismodule provide the mathematically valid answers in the complex plane:>>> import math>>> from numpy.lib import scimath>>> scimath.log(-math.exp(1)) == (1+1j*math.pi)TrueSimilarly, sqrt(), other base logarithms, power() and trig functions arecorrectly handled.  See their respective docstrings for specific examples."""

看来模块覆盖了基础numpy的ufuncs

sqrt
log
log2
logn
log10
power
arccos
arcsin
,和
arctanh
。这就解释了您所看到的行为。这样做的根本设计原因可能埋在某个地方的邮件列表中。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/617359.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号