Commit e7500894fc119720d4fe3e20eb68ba09e377331c

Authored by Thiago Franco de Moraes
1 parent 0f393700
Exists in master

using language_level=3str directive to make cython works like python3

invesalius_cy/cy_mesh.pyx
1 # distutils: language = c++ 1 # distutils: language = c++
  2 +# cython: language_level=3str
2 #cython: boundscheck=False 3 #cython: boundscheck=False
3 #cython: wraparound=False 4 #cython: wraparound=False
4 #cython: initializedcheck=False 5 #cython: initializedcheck=False
@@ -21,7 +22,7 @@ from libcpp cimport bool @@ -21,7 +22,7 @@ from libcpp cimport bool
21 from libcpp.deque cimport deque as cdeque 22 from libcpp.deque cimport deque as cdeque
22 from cython.parallel import prange 23 from cython.parallel import prange
23 24
24 -from cy_my_types cimport vertex_t, normal_t, vertex_id_t 25 +from .cy_my_types cimport vertex_t, normal_t, vertex_id_t
25 26
26 import numpy as np 27 import numpy as np
27 import vtk 28 import vtk
@@ -451,16 +452,16 @@ def ca_smoothing(Mesh mesh, double T, double tmax, double bmin, int n_iters): @@ -451,16 +452,16 @@ def ca_smoothing(Mesh mesh, double T, double tmax, double bmin, int n_iters):
451 452
452 t0 = time.time() 453 t0 = time.time()
453 cdef vector[vertex_id_t]* vertices_staircase = find_staircase_artifacts(mesh, stack_orientation, T) 454 cdef vector[vertex_id_t]* vertices_staircase = find_staircase_artifacts(mesh, stack_orientation, T)
454 - print "vertices staircase", time.time() - t0 455 + print("vertices staircase", time.time() - t0)
455 456
456 t0 = time.time() 457 t0 = time.time()
457 cdef vector[weight_t]* weights = calc_artifacts_weight(mesh, deref(vertices_staircase), tmax, bmin) 458 cdef vector[weight_t]* weights = calc_artifacts_weight(mesh, deref(vertices_staircase), tmax, bmin)
458 - print "Weights", time.time() - t0 459 + print("Weights", time.time() - t0)
459 460
460 del vertices_staircase 461 del vertices_staircase
461 462
462 t0 = time.time() 463 t0 = time.time()
463 taubin_smooth(mesh, deref(weights), 0.5, -0.53, n_iters) 464 taubin_smooth(mesh, deref(weights), 0.5, -0.53, n_iters)
464 - print "taubin", time.time() - t0 465 + print("taubin", time.time() - t0)
465 466
466 del weights 467 del weights
invesalius_cy/floodfill.pyx
  1 +#cython: language_level=3str
  2 +
1 import numpy as np 3 import numpy as np
2 cimport numpy as np 4 cimport numpy as np
3 cimport cython 5 cimport cython
@@ -10,7 +12,7 @@ from libcpp cimport bool @@ -10,7 +12,7 @@ from libcpp cimport bool
10 from libcpp.deque cimport deque as cdeque 12 from libcpp.deque cimport deque as cdeque
11 from libcpp.vector cimport vector 13 from libcpp.vector cimport vector
12 14
13 -from cy_my_types cimport image_t, mask_t 15 +from .cy_my_types cimport image_t, mask_t
14 16
15 cdef struct s_coord: 17 cdef struct s_coord:
16 int x 18 int x
@@ -117,9 +119,9 @@ def floodfill_threshold(np.ndarray[image_t, ndim=3] data, list seeds, int t0, in @@ -117,9 +119,9 @@ def floodfill_threshold(np.ndarray[image_t, ndim=3] data, list seeds, int t0, in
117 cdef cdeque[coord] stack 119 cdef cdeque[coord] stack
118 cdef coord c 120 cdef coord c
119 121
120 - offset_z = odz / 2  
121 - offset_y = ody / 2  
122 - offset_x = odx / 2 122 + offset_z = odz // 2
  123 + offset_y = ody // 2
  124 + offset_x = odx // 2
123 125
124 for i, j, k in seeds: 126 for i, j, k in seeds:
125 if data[k, j, i] >= t0 and data[k, j, i] <= t1: 127 if data[k, j, i] >= t0 and data[k, j, i] <= t1:
@@ -191,13 +193,13 @@ def floodfill_auto_threshold(np.ndarray[image_t, ndim=3] data, list seeds, float @@ -191,13 +193,13 @@ def floodfill_auto_threshold(np.ndarray[image_t, ndim=3] data, list seeds, float
191 for i, j, k in seeds: 193 for i, j, k in seeds:
192 append_queue(stack, i, j, k, d, h, w) 194 append_queue(stack, i, j, k, d, h, w)
193 out[k, j, i] = fill 195 out[k, j, i] = fill
194 - print i, j, k, d, h, w 196 + print(i, j, k, d, h, w)
195 197
196 with nogil: 198 with nogil:
197 while stack.size(): 199 while stack.size():
198 pop_queue(stack, &x, &y, &z, d, h, w) 200 pop_queue(stack, &x, &y, &z, d, h, w)
199 201
200 - # print x, y, z, d, h, w 202 + # print(x, y, z, d, h, w)
201 203
202 xo = x 204 xo = x
203 yo = y 205 yo = y
invesalius_cy/interpolation.pyx
  1 +#cython: language_level=3str
1 # from interpolation cimport interpolate 2 # from interpolation cimport interpolate
2 3
3 import numpy as np 4 import numpy as np
invesalius_cy/mips.pyx
  1 +#cython: language_level=3str
  2 +
1 #http://en.wikipedia.org/wiki/Local_maximum_intensity_projection 3 #http://en.wikipedia.org/wiki/Local_maximum_intensity_projection
2 import numpy as np 4 import numpy as np
3 cimport numpy as np 5 cimport numpy as np
@@ -90,8 +92,8 @@ def lmip(np.ndarray[DTYPE16_t, ndim=3] image, int axis, DTYPE16_t tmin, @@ -90,8 +92,8 @@ def lmip(np.ndarray[DTYPE16_t, ndim=3] image, int axis, DTYPE16_t tmin,
90 92
91 cdef DTYPE16_t get_colour(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww): 93 cdef DTYPE16_t get_colour(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww):
92 cdef DTYPE16_t out_colour 94 cdef DTYPE16_t out_colour
93 - cdef DTYPE16_t min_value = wl - (ww / 2)  
94 - cdef DTYPE16_t max_value = wl + (ww / 2) 95 + cdef DTYPE16_t min_value = wl - (ww // 2)
  96 + cdef DTYPE16_t max_value = wl + (ww // 2)
95 if vl < min_value: 97 if vl < min_value:
96 out_colour = min_value 98 out_colour = min_value
97 elif vl > max_value: 99 elif vl > max_value:
@@ -105,8 +107,8 @@ cdef DTYPE16_t get_colour(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww): @@ -105,8 +107,8 @@ cdef DTYPE16_t get_colour(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww):
105 @cython.cdivision(True) 107 @cython.cdivision(True)
106 cdef float get_opacity(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww) nogil: 108 cdef float get_opacity(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww) nogil:
107 cdef float out_opacity 109 cdef float out_opacity
108 - cdef DTYPE16_t min_value = wl - (ww / 2)  
109 - cdef DTYPE16_t max_value = wl + (ww / 2) 110 + cdef DTYPE16_t min_value = wl - (ww // 2)
  111 + cdef DTYPE16_t max_value = wl + (ww // 2)
110 if vl < min_value: 112 if vl < min_value:
111 out_opacity = 0.0 113 out_opacity = 0.0
112 elif vl > max_value: 114 elif vl > max_value:
@@ -120,8 +122,8 @@ cdef float get_opacity(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww) nogil: @@ -120,8 +122,8 @@ cdef float get_opacity(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww) nogil:
120 @cython.cdivision(True) 122 @cython.cdivision(True)
121 cdef float get_opacity_f32(DTYPEF32_t vl, DTYPE16_t wl, DTYPE16_t ww) nogil: 123 cdef float get_opacity_f32(DTYPEF32_t vl, DTYPE16_t wl, DTYPE16_t ww) nogil:
122 cdef float out_opacity 124 cdef float out_opacity
123 - cdef DTYPE16_t min_value = wl - (ww / 2)  
124 - cdef DTYPE16_t max_value = wl + (ww / 2) 125 + cdef DTYPE16_t min_value = wl - (ww // 2)
  126 + cdef DTYPE16_t max_value = wl + (ww // 2)
125 if vl < min_value: 127 if vl < min_value:
126 out_opacity = 0.0 128 out_opacity = 0.0
127 elif vl > max_value: 129 elif vl > max_value:
@@ -144,8 +146,8 @@ def mida(np.ndarray[DTYPE16_t, ndim=3] image, int axis, DTYPE16_t wl, @@ -144,8 +146,8 @@ def mida(np.ndarray[DTYPE16_t, ndim=3] image, int axis, DTYPE16_t wl,
144 cdef DTYPE16_t max = image.max() 146 cdef DTYPE16_t max = image.max()
145 cdef DTYPE16_t vl 147 cdef DTYPE16_t vl
146 148
147 - cdef DTYPE16_t min_value = wl - (ww / 2)  
148 - cdef DTYPE16_t max_value = wl + (ww / 2) 149 + cdef DTYPE16_t min_value = wl - (ww // 2)
  150 + cdef DTYPE16_t max_value = wl + (ww // 2)
149 151
150 cdef float fmax=0.0 152 cdef float fmax=0.0
151 cdef float fpi 153 cdef float fpi
invesalius_cy/transforms.pyx
  1 +#cython: language_level=3str
  2 +
1 import numpy as np 3 import numpy as np
2 cimport numpy as np 4 cimport numpy as np
3 cimport cython 5 cimport cython