##// END OF EJS Templates
small import bug
fperez -
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,41 +1,43 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 Extension for printing Numeric Arrays in flexible ways.
3 Extension for printing Numeric Arrays in flexible ways.
4 """
4 """
5
5
6 from Numeric import ArrayType
7
6 def num_display(self,arg):
8 def num_display(self,arg):
7 """Display method for printing which treats Numeric arrays specially.
9 """Display method for printing which treats Numeric arrays specially.
8 """
10 """
9
11
10 # Non-numpy variables are printed using the system default
12 # Non-numpy variables are printed using the system default
11 if type(arg) != ArrayType:
13 if type(arg) != ArrayType:
12 self._display(arg)
14 self._display(arg)
13 return
15 return
14 # Otherwise, we do work.
16 # Otherwise, we do work.
15 format = __IPYTHON__.runtime_rc.numarray_print_format
17 format = __IPYTHON__.runtime_rc.numarray_print_format
16 print 'NumPy array, format:',format
18 print 'NumPy array, format:',format
17 # Here is where all the printing logic needs to be implemented
19 # Here is where all the printing logic needs to be implemented
18 print arg # nothing yet :)
20 print arg # nothing yet :)
19
21
20
22
21 def magic_format(self,parameter_s=''):
23 def magic_format(self,parameter_s=''):
22 """Specifies format of numerical output.
24 """Specifies format of numerical output.
23
25
24 This command is similar to Ocave's format command.
26 This command is similar to Ocave's format command.
25 """
27 """
26
28
27 valid_formats = ['long','short']
29 valid_formats = ['long','short']
28
30
29 if parameter_s in valid_formats:
31 if parameter_s in valid_formats:
30 self.runtime_rc.numarray_print_format = parameter_s
32 self.runtime_rc.numarray_print_format = parameter_s
31 print 'Numeric output format is now:',parameter_s
33 print 'Numeric output format is now:',parameter_s
32 else:
34 else:
33 print 'Invalid format:',parameter_s
35 print 'Invalid format:',parameter_s
34 print 'Valid formats:',valid_formats
36 print 'Valid formats:',valid_formats
35
37
36 # setup default format
38 # setup default format
37 __IPYTHON__.runtime_rc.numarray_print_format = 'long'
39 __IPYTHON__.runtime_rc.numarray_print_format = 'long'
38
40
39 # Bind our new functions to the interpreter
41 # Bind our new functions to the interpreter
40 __IPYTHON__.__class__.magic_format = magic_format
42 __IPYTHON__.__class__.magic_format = magic_format
41 __IPYTHON__.hooks.display = num_display
43 __IPYTHON__.hooks.display = num_display
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now