上次我检查它时,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。这就解释了您所看到的行为。这样做的根本设计原因可能埋在某个地方的邮件列表中。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)