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 1 # distutils: language = c++
  2 +# cython: language_level=3str
2 3 #cython: boundscheck=False
3 4 #cython: wraparound=False
4 5 #cython: initializedcheck=False
... ... @@ -21,7 +22,7 @@ from libcpp cimport bool
21 22 from libcpp.deque cimport deque as cdeque
22 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 27 import numpy as np
27 28 import vtk
... ... @@ -451,16 +452,16 @@ def ca_smoothing(Mesh mesh, double T, double tmax, double bmin, int n_iters):
451 452  
452 453 t0 = time.time()
453 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 457 t0 = time.time()
457 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 461 del vertices_staircase
461 462  
462 463 t0 = time.time()
463 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 467 del weights
... ...
invesalius_cy/floodfill.pyx
  1 +#cython: language_level=3str
  2 +
1 3 import numpy as np
2 4 cimport numpy as np
3 5 cimport cython
... ... @@ -10,7 +12,7 @@ from libcpp cimport bool
10 12 from libcpp.deque cimport deque as cdeque
11 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 17 cdef struct s_coord:
16 18 int x
... ... @@ -117,9 +119,9 @@ def floodfill_threshold(np.ndarray[image_t, ndim=3] data, list seeds, int t0, in
117 119 cdef cdeque[coord] stack
118 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 126 for i, j, k in seeds:
125 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 193 for i, j, k in seeds:
192 194 append_queue(stack, i, j, k, d, h, w)
193 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 198 with nogil:
197 199 while stack.size():
198 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 204 xo = x
203 205 yo = y
... ...
invesalius_cy/interpolation.pyx
  1 +#cython: language_level=3str
1 2 # from interpolation cimport interpolate
2 3  
3 4 import numpy as np
... ...
invesalius_cy/mips.pyx
  1 +#cython: language_level=3str
  2 +
1 3 #http://en.wikipedia.org/wiki/Local_maximum_intensity_projection
2 4 import numpy as np
3 5 cimport numpy as np
... ... @@ -90,8 +92,8 @@ def lmip(np.ndarray[DTYPE16_t, ndim=3] image, int axis, DTYPE16_t tmin,
90 92  
91 93 cdef DTYPE16_t get_colour(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww):
92 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 97 if vl < min_value:
96 98 out_colour = min_value
97 99 elif vl > max_value:
... ... @@ -105,8 +107,8 @@ cdef DTYPE16_t get_colour(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww):
105 107 @cython.cdivision(True)
106 108 cdef float get_opacity(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww) nogil:
107 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 112 if vl < min_value:
111 113 out_opacity = 0.0
112 114 elif vl > max_value:
... ... @@ -120,8 +122,8 @@ cdef float get_opacity(DTYPE16_t vl, DTYPE16_t wl, DTYPE16_t ww) nogil:
120 122 @cython.cdivision(True)
121 123 cdef float get_opacity_f32(DTYPEF32_t vl, DTYPE16_t wl, DTYPE16_t ww) nogil:
122 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 127 if vl < min_value:
126 128 out_opacity = 0.0
127 129 elif vl > max_value:
... ... @@ -144,8 +146,8 @@ def mida(np.ndarray[DTYPE16_t, ndim=3] image, int axis, DTYPE16_t wl,
144 146 cdef DTYPE16_t max = image.max()
145 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 152 cdef float fmax=0.0
151 153 cdef float fpi
... ...
invesalius_cy/transforms.pyx
  1 +#cython: language_level=3str
  2 +
1 3 import numpy as np
2 4 cimport numpy as np
3 5 cimport cython
... ...