码迷,mamicode.com
首页 > 编程语言 > 详细

Scipy - science python

时间:2015-01-29 21:07:54      阅读:697      评论:0      收藏:0      [点我收藏+]

标签:python   scipy   

http://blog.csdn.net/pipisorry/article/details/43277755

Scipy中引入包错误:

...

scipy.misc.imsave(filename, numpy.kron(doc, zoom))
...

AttributeError: ‘module‘ object has no attribute ‘misc‘


发生错误的原因:

Most possibly because scipy is a library (package) that contains modules and to import a specific module from the scipy library, you need to specify it and import the module itself. As it‘s a separate module (sub-package), once you import it, it‘s attributes are available to you by using the regular scipy.module.attribute.

The modules inside scipy aren‘t accessible as attributes of the base scipy package.


对引入格式的说明

In Python the distinction between what is the public API of a library and whatare private implementation details is not always clear. Unlike in otherlanguages like Java, it is possible in Python to access “private” function orobjects. Occasionally this may be convenient, but be aware that if you do soyour code may break without warning in future releases. Some widely understoodrules for what is and isn’t public in Python are:

  • Methods / functions / classes and module attributes whose names beginwith a leading underscore are private.
  • If a class name begins with a leading underscore none of its members arepublic, whether or not they begin with a leading underscore.
  • If a module name in a package begins with a leading underscore none ofits members are public, whether or not they begin with a leadingunderscore.
  • If a module or package defines __all__ that authoritatively defines thepublic interface.
  • If a module or package doesn’t define __all__ then all names that don’tstart with a leading underscore are public.

Note:Reading the above guidelines one could draw the conclusion that everyprivate module or object starts with an underscore. This is not thecase; the presence of underscores do mark something as private, butthe absence of underscores do not mark something as public.

In Scipy there are modules whose names don’t start with an underscore, but thatshould be considered private. To clarify which modules these are we definebelow what the public API is for Scipy, and give some recommendations for howto import modules/functions/objects from Scipy.

API - importing from Scipy


解决:

You need to do import scipy.misc orfrom scipy import misc.


from:http://blog.csdn.net/pipisorry/article/details/43277755

ref:


Scipy - science python

标签:python   scipy   

原文地址:http://blog.csdn.net/pipisorry/article/details/43277755

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!