enthought / mayavi

@@ -30,8 +30,6 @@
Loading
30 30
else:
31 31
    faulthandler.enable()
32 32
33 -
PY_VER = sys.version_info[0]
34 -
35 33
36 34
def get_trait_def(value, **kwargs):
37 35
    """ Return the appropriate trait type, reformatted string and
@@ -78,10 +76,6 @@
Loading
78 76
    number_map = {int: 'traits.Int',
79 77
                  float: 'traits.Float'}
80 78
81 -
    # In Python 2 there is long type
82 -
    if PY_VER < 3:
83 -
        number_map[long] = 'traits.Int'
84 -
85 79
    if type_ in number_map:
86 80
        return number_map[type_], str(value), kwargs_code
87 81
@@ -90,11 +84,6 @@
Loading
90 84
            value = ''
91 85
        return 'traits.String', '{!r}'.format(value), kwargs_code
92 86
93 -
    elif PY_VER < 3 and type_ is unicode:
94 -
        if value == u'\x00':
95 -
            value = u''
96 -
        return 'traits.Unicode', '{!r}'.format(value), kwargs_code
97 -
98 87
    elif type_ in (tuple, list):
99 88
        shape = (len(value),)
100 89
        dtypes = set(type(element) for element in value)

@@ -24,12 +24,6 @@
Loading
24 24
from .engine_manager import get_engine
25 25
26 26
27 -
if sys.version_info[0] > 2:
28 -
    string_types = (str,)
29 -
else:
30 -
    string_types = (basestring,)
31 -
32 -
33 27
def world_to_display(x, y, z, figure=None):
34 28
    """ Converts 3D world coordinates to screenshot pixel coordinates.
35 29
@@ -285,14 +279,14 @@
Loading
285 279
    # bounds.
286 280
    bounds = np.array(ren.compute_visible_prop_bounds())
287 281
    if distance is not None and not (
288 -
            isinstance(distance, string_types) and distance == 'auto'):
282 +
            isinstance(distance, str) and distance == 'auto'):
289 283
        r = distance
290 284
    else:
291 285
        r = max(bounds[1::2] - bounds[::2]) * 2.0
292 286
293 287
    cen = (bounds[1::2] + bounds[::2]) * 0.5
294 288
    if focalpoint is not None and not (
295 -
            isinstance(focalpoint, string_types) and focalpoint == 'auto'):
289 +
            isinstance(focalpoint, str) and focalpoint == 'auto'):
296 290
        cen = np.asarray(focalpoint)
297 291
298 292
    # Find camera position.

@@ -10,10 +10,7 @@
Loading
10 10
11 11
import sys
12 12
13 -
if sys.version_info[0] > 2:
14 -
    import builtins
15 -
else:
16 -
    import __builtin__ as builtins
13 +
import builtins
17 14
18 15
19 16
class TreeNode:

@@ -19,7 +19,6 @@
Loading
19 19
    ColorControlPoint, ChannelBase, FunctionControl, GradientEditorWidget
20 20
)
21 21
22 -
PY3 = sys.version_info[0] > 2
23 22
24 23
##########################################################################
25 24
# `QGradientControl` class.
@@ -163,17 +162,12 @@
Loading
163 162
        set_status_text: a callback used to set the status text
164 163
             when using the editor.
165 164
        """
166 -
        if PY3:
167 -
            kw = dict(
168 -
                master=master, gradient_table=gradient_table,
169 -
                color_space=color_space, width=width,
170 -
                height=height
171 -
            )
172 -
            super().__init__(**kw)
173 -
        else:
174 -
            FunctionControl.__init__(self, master, gradient_table, color_space,
175 -
                                     width, height)
176 -
            QtGui.QWidget.__init__(self, parent=master)
165 +
        kw = dict(
166 +
            master=master, gradient_table=gradient_table,
167 +
            color_space=color_space, width=width,
168 +
            height=height
169 +
        )
170 +
        super().__init__(**kw)
177 171
        self.resize(width, height)
178 172
        self.setMinimumSize(100, 50)
179 173
@@ -303,15 +297,10 @@
Loading
303 297
                 'h', 's', 'v', 'r', 'g', 'b', 'a' separately
304 298
                 specified creates different panels for each.
305 299
        """
306 -
        if PY3:
307 -
            kw = dict(master=master, vtk_table=vtk_table,
308 -
                      on_change_color_table=on_change_color_table,
309 -
                      colors=colors)
310 -
            super().__init__(**kw)
311 -
        else:
312 -
            QtGui.QWidget.__init__(self, master)
313 -
            GradientEditorWidget.__init__(self, master, vtk_table,
314 -
                                          on_change_color_table, colors)
300 +
        kw = dict(master=master, vtk_table=vtk_table,
301 +
                    on_change_color_table=on_change_color_table,
302 +
                    colors=colors)
303 +
        super().__init__(**kw)
315 304
316 305
        gradient_preview_width = self.gradient_preview_width
317 306
        gradient_preview_height = self.gradient_preview_height

@@ -50,9 +50,6 @@
Loading
50 50
51 51
BASE_REFERENCE_COUNT = vtk.vtkObject().GetReferenceCount()
52 52
53 -
if sys.version_info[0] > 2:
54 -
    unicode = str
55 -
56 53
57 54
def getbuffer(array):
58 55
    return getattr(numpy, 'getbuffer', memoryview)(array)
@@ -713,7 +710,7 @@
Loading
713 710
714 711
def is_array_sig(s):
715 712
    """Given a signature, return if the signature has an array."""
716 -
    if not isinstance(s, (unicode, str)):
713 +
    if not isinstance(s, str):
717 714
        return False
718 715
    arr_types = ['Array', 'vtkPoints', 'vtkIdList']
719 716
    for i in arr_types:

@@ -164,20 +164,14 @@
Loading
164 164
        data = self.data
165 165
        if data is not None:
166 166
            sdata = write_dataset_to_string(data)
167 -
            if sys.version_info[0] > 2:
168 -
                z = gzip_string(sdata.encode('ascii'))
169 -
            else:
170 -
                z = gzip_string(sdata)
167 +
            z = gzip_string(sdata.encode('ascii'))
171 168
            d['data'] = z
172 169
        return d
173 170
174 171
    def __set_pure_state__(self, state):
175 172
        z = state.data
176 173
        if z is not None:
177 -
            if sys.version_info[0] > 2:
178 -
                d = gunzip_string(z).decode('ascii')
179 -
            else:
180 -
                d = gunzip_string(z)
174 +
            d = gunzip_string(z).decode('ascii')
181 175
            r = tvtk.DataSetReader(read_from_input_string=1,
182 176
                                   input_string=d)
183 177
            warn = r.global_warning_display

@@ -220,10 +220,7 @@
Loading
220 220
        # The only reason this method is separate is to generate code
221 221
        # for an individual class when debugging.
222 222
        fname = camel2enthought(tvtk_name) + '.py'
223 -
        if sys.version_info[0] > 2:
224 -
            out = open(os.path.join(self.out_dir, fname), 'w', encoding='utf-8')
225 -
        else:
226 -
            out = open(os.path.join(self.out_dir, fname), 'w')
223 +
        out = open(os.path.join(self.out_dir, fname), 'w', encoding='utf-8')
227 224
        self.wrap_gen.generate_code(node, out)
228 225
        out.close()
229 226
Files Coverage
mayavi 57.25%
tvtk 39.23%
Project Totals (263 files) 49.83%
1739.2
TRAVIS_OS_NAME=linux
1740.1
TRAVIS_OS_NAME=linux
1740.2
TRAVIS_OS_NAME=linux
1741.1
TRAVIS_OS_NAME=linux
1736.2
TRAVIS_OS_NAME=linux
1737.1
TRAVIS_OS_NAME=linux
1738.1
TRAVIS_OS_NAME=linux
1739.1
TRAVIS_OS_NAME=linux
1742.1
TRAVIS_OS_NAME=linux
1743.1
TRAVIS_OS_NAME=linux
1722.2
TRAVIS_OS_NAME=linux
1722.1
TRAVIS_OS_NAME=linux
1723.2
TRAVIS_OS_NAME=linux
1723.1
TRAVIS_OS_NAME=linux
1724.2
TRAVIS_OS_NAME=linux
1724.1
TRAVIS_OS_NAME=linux
1725.2
TRAVIS_OS_NAME=linux
1725.1
TRAVIS_OS_NAME=linux
1726.2
TRAVIS_OS_NAME=linux