##// END OF EJS Templates
Moving extensions to either quarantine or deathrow....
Moving extensions to either quarantine or deathrow. When a module is moved to quarantine, it means that while we intend to keep it, it is currently broken or sufficiently untested that it can't be in the main IPython codebase. To be moved back into the main IPython codebase a module must: 1. Work fully. 2. Have a test suite. 3. Be a proper IPython extension and tie into the official APIs. 3. Have members of the IPython dev team who are willing to maintain it. When a module is moved to deathrow, it means that the code is either broken and not worth repairing, deprecated, replaced by newer functionality, or code that should be developed and maintained by a third party.

File last commit:

r2267:928c921b
r2267:928c921b
Show More
numeric_formats.py
43 lines | 1.2 KiB | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
"""
Extension for printing Numeric Arrays in flexible ways.
"""
from Numeric import ArrayType
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