0% found this document useful (0 votes)
37 views1 page

2.6.6 Packages: Python Scientific Lecture Notes, Release 2012.3 (Euroscipy 2012)

Python packages allow related modules to be grouped together. The scipy package contains many subpackages for scientific computing tasks like ndimage for image processing. Within ndimage there are modules for filters, morphology operations, and more. Functions can be imported from modules within a package to access its capabilities.

Uploaded by

claudyane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views1 page

2.6.6 Packages: Python Scientific Lecture Notes, Release 2012.3 (Euroscipy 2012)

Python packages allow related modules to be grouped together. The scipy package contains many subpackages for scientific computing tasks like ndimage for image processing. Within ndimage there are modules for filters, morphology operations, and more. Functions can be imported from modules within a package to access its capabilities.

Uploaded by

claudyane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python Scientific lecture notes, Release 2012.

3 (EuroScipy 2012)

See http://docs.python.org/tutorial/modules.html for more information about modules.

2.6.6 Packages

A directory that contains many modules is called a package. A package is a module with submodules (which can
have submodules themselves, etc.). A special file called __init__.py (which may be empty) tells Python that
the directory is a Python package, from which modules can be imported.
sd-2116 /usr/lib/python2.6/dist-packages/scipy $ ls
[17:07]
cluster/ io/ README.txt@ stsci/
__config__.py@ LATEST.txt@ setup.py@ __svn_version__.py@
__config__.pyc lib/ setup.pyc __svn_version__.pyc
constants/ linalg/ setupscons.py@ THANKS.txt@
fftpack/ linsolve/ setupscons.pyc TOCHANGE.txt@
__init__.py@ maxentropy/ signal/ version.py@
__init__.pyc misc/ sparse/ version.pyc
INSTALL.txt@ ndimage/ spatial/ weave/
integrate/ odr/ special/
interpolate/ optimize/ stats/
sd-2116 /usr/lib/python2.6/dist-packages/scipy $ cd ndimage
[17:07]

sd-2116 /usr/lib/python2.6/dist-packages/scipy/ndimage $ ls
[17:07]
doccer.py@ fourier.pyc interpolation.py@ morphology.pyc setup.pyc
doccer.pyc info.py@ interpolation.pyc _nd_image.so
setupscons.py@
filters.py@ info.pyc measurements.py@ _ni_support.py@
setupscons.pyc
filters.pyc __init__.py@ measurements.pyc _ni_support.pyc tests/
fourier.py@ __init__.pyc morphology.py@ setup.py@

From Ipython:
In [1]: import scipy

In [2]: scipy.__file__
Out[2]: ’/usr/lib/python2.6/dist-packages/scipy/__init__.pyc’

In [3]: import scipy.version

In [4]: scipy.version.version
Out[4]: ’0.7.0’

In [5]: import scipy.ndimage.morphology

In [6]: from scipy.ndimage import morphology

In [17]: morphology.binary_dilation ?
Type: function
Base Class: <type ’function’>
String Form: <function binary_dilation at 0x9bedd84>
Namespace: Interactive
File: /usr/lib/python2.6/dist-packages/scipy/ndimage/morphology.py
Definition: morphology.binary_dilation(input, structure=None,
iterations=1, mask=None, output=None, border_value=0, origin=0,
brute_force=False)
Docstring:
Multi-dimensional binary dilation with the given structure.

2.6. Reusing code: scripts and modules 30

You might also like