##// END OF EJS Templates
IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now...
IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now generic functions (using Philip J. Eby's simplegeneric package). This makes it possible to customize the display of third-party classes without having to monkeypatch them. xiter() no longer supports a mode argument and the XMode class has been removed. The same functionality can be implemented via IterAttributeDescriptor and IterMethodDescriptor. One consequence of the switch to generic functions is that xrepr() and xattrs() implementation must define the default value for the mode argument themselves and xattrs() implementations must return real descriptors. IPython/external: This new subpackage will contain all third-party packages that are bundled with IPython. (The first one is simplegeneric). IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent directory which as been dropped in r1703. IPython/Extensions/ipipe.py (iless): Fixed. IPython/Extensions/ibrowse: Fixed sorting under Python 2.3. More docstrings. Moved xrepr(), xiter() and xattrs() documentation into the docstring of the default implementation.

File last commit:

r32:bd729ac1
r415:4a5dcb15
Show More
numeric_formats.py
43 lines | 1.2 KiB | text/x-python | PythonLexer
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # -*- coding: utf-8 -*-
"""
Extension for printing Numeric Arrays in flexible ways.
"""
fperez
small import bug
r32 from Numeric import ArrayType
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 def num_display(self,arg):
"""Display method for printing which treats Numeric arrays specially.
"""
# Non-numpy variables are printed using the system default
if type(arg) != ArrayType:
self._display(arg)
return
# Otherwise, we do work.
format = __IPYTHON__.runtime_rc.numarray_print_format
print 'NumPy array, format:',format
# Here is where all the printing logic needs to be implemented
print arg # nothing yet :)
def magic_format(self,parameter_s=''):
"""Specifies format of numerical output.
This command is similar to Ocave's format command.
"""
valid_formats = ['long','short']
if parameter_s in valid_formats:
self.runtime_rc.numarray_print_format = parameter_s
print 'Numeric output format is now:',parameter_s
else:
print 'Invalid format:',parameter_s
print 'Valid formats:',valid_formats
# setup default format
__IPYTHON__.runtime_rc.numarray_print_format = 'long'
# Bind our new functions to the interpreter
__IPYTHON__.__class__.magic_format = magic_format
__IPYTHON__.hooks.display = num_display