[PYTHON MATRIX-SIG] Pretty Printer

Steve Spicklemire steve@estel.uindy.edu
Sat, 24 Feb 96 17:40:21 -0500


I'm probably doing something wrong but I couldn't
get PrettyPrinter to work with shape (1,) float
arrays. I made this change to mine... (there's 
probably a much better way to do this... 
but at least I'm back up and running...)


RCS file: PrettyPrinter.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -c5 -r1.1 -r1.2
*** /tmp/,RCSt1026586   Sat Feb 24 17:36:04 1996
--- /tmp/,RCSt2026586   Sat Feb 24 17:36:05 1996
***************
*** 86,96 ****
        format = format + str(max_str_len) + '.' + str(precision) + 'e'
        if large_exponent: format = format + '3'
        item_length = max_str_len + 1
      else:
        format = '%.' + str(precision) + 'f'
!       precision = min(precision, apply(max, tuple(map(lambda x, p=precision,
                                                        f=format: _digits(x,p,f),
                                                        data))))
        max_str_len = len(str(int(max_val))) + precision + 2
        if sign: format = '%#+'
        else: format = '%#'
--- 86,99 ----
        format = format + str(max_str_len) + '.' + str(precision) + 'e'
        if large_exponent: format = format + '3'
        item_length = max_str_len + 1
      else:
        format = '%.' + str(precision) + 'f'
!       if len(data.shape) == 1 and data.shape[0] == 1:
!           precision = min(precision, _digits(data[0],precision,format))
!       else:
!           precision = min(precision, apply(max, tuple(map(lambda x, p=precision,
                                                        f=format: _digits(x,p,f),
                                                        data))))
        max_str_len = len(str(int(max_val))) + precision + 2
        if sign: format = '%#+'
        else: format = '%#'

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================