From 9da82593bc033c692a2593a8d9ffe56949a38a4b Mon Sep 17 00:00:00 2001
Message-Id: <9da82593bc033c692a2593a8d9ffe56949a38a4b.1335959378.git.humitos@gmail.com>
From: Manuel Kaufmann <humitos@gmail.com>
Date: Wed, 2 May 2012 08:49:21 -0300
Subject: [PATCH Paint] Avoid using numpy 1.6.1 in invert_colors function
There is a bug (or something like that) in numpy 1.6.1 that makes invert_color
to not work properly. So, now we are checking for this version and if it's
found we use the string implementation of this funcion instead.
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
---
Area.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/Area.py b/Area.py
index 50c0744..b889974 100644
a
|
b
|
class Area(gtk.DrawingArea): |
1038 | 1038 | def proc_invert_color(temp_pix): |
1039 | 1039 | try: |
1040 | 1040 | import numpy |
| 1041 | # HACK: This numpy version has a bug and breaks the |
| 1042 | # 'invert_color' function |
| 1043 | # http://bugs.sugarlabs.org/ticket/3509 |
| 1044 | if numpy.__version__ == '1.6.1': |
| 1045 | logging.warning('You have installed a version of numpy ' |
| 1046 | '(1.6.1) that has a bug and can\'t be ' |
| 1047 | 'used. Using string module instead ' |
| 1048 | '(slower)') |
| 1049 | raise ImportWarning |
1041 | 1050 | pix_manip2 = temp_pix.get_pixels_array() |
1042 | 1051 | pix_manip = numpy.ones(pix_manip2.shape, dtype=numpy.uint8) \ |
1043 | 1052 | * 255 |
1044 | 1053 | pix_manip2 = pix_manip - pix_manip2 |
1045 | 1054 | temp_pix = gtk.gdk.pixbuf_new_from_array(pix_manip2, |
1046 | 1055 | gtk.gdk.COLORSPACE_RGB, 8) |
1047 | | except: |
| 1056 | except (ImportError, ImportWarning): |
1048 | 1057 | import string |
1049 | 1058 | a = temp_pix.get_pixels() |
1050 | 1059 | b = len(a) * ['\0'] |