Skip to content

Commit cb54580

Browse files
committed
Use np.reshape function instead of .reshape method.
1 parent 01dbb9f commit cb54580

File tree

8 files changed

+88
-55
lines changed

8 files changed

+88
-55
lines changed

colour_visuals/daylight_locus.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,12 @@ def update(self):
172172
lines_dl, *_ = lines_daylight_locus(self._mireds, self._method)
173173

174174
# Daylight Locus
175-
positions = np.concatenate(
176-
[lines_dl["position"][:-1], lines_dl["position"][1:]], axis=1
177-
).reshape([-1, 2])
175+
positions = np.reshape(
176+
np.concatenate(
177+
[lines_dl["position"][:-1], lines_dl["position"][1:]], axis=1
178+
),
179+
(-1, 2),
180+
)
178181

179182
positions = np.hstack(
180183
[
@@ -184,9 +187,12 @@ def update(self):
184187
)
185188

186189
if self._colour is None:
187-
colour_sl = np.concatenate(
188-
[lines_dl["colour"][:-1], lines_dl["colour"][1:]], axis=1
189-
).reshape([-1, 3])
190+
colour_sl = np.reshape(
191+
np.concatenate(
192+
[lines_dl["colour"][:-1], lines_dl["colour"][1:]], axis=1
193+
),
194+
(-1, 3),
195+
)
190196
else:
191197
colour_sl = np.tile(self._colour, (positions.shape[0], 1))
192198

colour_visuals/diagrams.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,12 @@ def update(self):
228228
lines_sl, lines_w = lines_spectral_locus(self._cmfs, self._labels, self._method)
229229

230230
# Spectral Locus
231-
positions = np.concatenate(
232-
[lines_sl["position"][:-1], lines_sl["position"][1:]], axis=1
233-
).reshape([-1, 2])
231+
positions = np.reshape(
232+
np.concatenate(
233+
[lines_sl["position"][:-1], lines_sl["position"][1:]], axis=1
234+
),
235+
(-1, 2),
236+
)
234237

235238
positions = np.hstack(
236239
[
@@ -240,9 +243,12 @@ def update(self):
240243
)
241244

242245
if self._colour is None:
243-
colour_sl = np.concatenate(
244-
[lines_sl["colour"][:-1], lines_sl["colour"][1:]], axis=1
245-
).reshape([-1, 3])
246+
colour_sl = np.reshape(
247+
np.concatenate(
248+
[lines_sl["colour"][:-1], lines_sl["colour"][1:]], axis=1
249+
),
250+
(-1, 3),
251+
)
246252
else:
247253
colour_sl = np.tile(self._colour, (positions.shape[0], 1))
248254

@@ -464,13 +470,15 @@ def update(self):
464470
),
465471
self._model,
466472
)
467-
positions = np.concatenate([positions[:-1], positions[1:]], axis=1).reshape(
468-
[-1, 3]
473+
positions = np.reshape(
474+
np.concatenate([positions[:-1], positions[1:]], axis=1), (-1, 3)
469475
)
470476

471477
if self._colour is None:
472478
colour = XYZ_to_RGB(self._cmfs.values, colourspace)
473-
colour = np.concatenate([colour[:-1], colour[1:]], axis=1).reshape([-1, 3])
479+
colour = np.reshape(
480+
np.concatenate([colour[:-1], colour[1:]], axis=1), (-1, 3)
481+
)
474482
else:
475483
colour = np.tile(self._colour, (positions.shape[0], 1))
476484

colour_visuals/grid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def update(self):
292292
self._grid_major = gfx.Mesh(
293293
gfx.Geometry(
294294
positions=as_contiguous_array(positions),
295-
indices=outline[..., 1].reshape([-1, 4]),
295+
indices=np.reshape(outline[..., 1], (-1, 4)),
296296
colors=as_contiguous_array(
297297
append_channel(
298298
np.tile(self._major_grid_colours, (positions.shape[0], 1)),
@@ -316,7 +316,7 @@ def update(self):
316316
self._grid_minor = gfx.Mesh(
317317
gfx.Geometry(
318318
positions=as_contiguous_array(positions),
319-
indices=outline[..., 1].reshape([-1, 4]),
319+
indices=np.reshape(outline[..., 1], (-1, 4)),
320320
colors=as_contiguous_array(
321321
append_channel(
322322
np.tile(self._minor_grid_colours, (positions.shape[0], 1)),

colour_visuals/planckian_locus.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,12 @@ def update(self):
224224
)
225225

226226
# Planckian Locus
227-
positions = np.concatenate(
228-
[lines_pl["position"][:-1], lines_pl["position"][1:]], axis=1
229-
).reshape([-1, 2])
227+
positions = np.reshape(
228+
np.concatenate(
229+
[lines_pl["position"][:-1], lines_pl["position"][1:]], axis=1
230+
),
231+
(-1, 2),
232+
)
230233

231234
positions = np.hstack(
232235
[
@@ -236,9 +239,12 @@ def update(self):
236239
)
237240

238241
if self._colour is None:
239-
colour_sl = np.concatenate(
240-
[lines_pl["colour"][:-1], lines_pl["colour"][1:]], axis=1
241-
).reshape([-1, 3])
242+
colour_sl = np.reshape(
243+
np.concatenate(
244+
[lines_pl["colour"][:-1], lines_pl["colour"][1:]], axis=1
245+
),
246+
(-1, 3),
247+
)
242248
else:
243249
colour_sl = np.tile(self._colour, (positions.shape[0], 1))
244250

@@ -255,14 +261,14 @@ def update(self):
255261
return
256262

257263
# Labels
258-
lines_itl = lines_l["position"].reshape([len(self._labels), 20, 2])
259-
colours_itl = lines_l["colour"].reshape([len(self._labels), 20, 3])
264+
lines_itl = np.reshape(lines_l["position"], (len(self._labels), 20, 2))
265+
colours_itl = np.reshape(lines_l["colour"], (len(self._labels), 20, 3))
260266
self._iso_temperature_lines = []
261267
self._texts = []
262268
for i, label in enumerate(self._labels):
263-
positions = np.concatenate(
264-
[lines_itl[i][:-1], lines_itl[i][1:]], axis=1
265-
).reshape([-1, 2])
269+
positions = np.reshape(
270+
np.concatenate([lines_itl[i][:-1], lines_itl[i][1:]], axis=1), (-1, 2)
271+
)
266272
positions = np.hstack(
267273
[
268274
positions,
@@ -271,9 +277,10 @@ def update(self):
271277
)
272278

273279
if self._colour is None:
274-
colour_w = np.concatenate(
275-
[colours_itl[i][:-1], colours_itl[i][1:]], axis=1
276-
).reshape([-1, 3])
280+
colour_w = np.reshape(
281+
np.concatenate([colours_itl[i][:-1], colours_itl[i][1:]], axis=1),
282+
(-1, 3),
283+
)
277284
else:
278285
colour_w = np.tile(self._colour, (positions.shape[0], 1))
279286

colour_visuals/pointer_gamut.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ def update(self):
144144
lines_b, lines_v = lines_pointer_gamut(self._method)
145145

146146
# Boundary
147-
positions = np.concatenate(
148-
[lines_b["position"][:-1], lines_b["position"][1:]], axis=1
149-
).reshape([-1, 2])
147+
positions = np.reshape(
148+
np.concatenate([lines_b["position"][:-1], lines_b["position"][1:]], axis=1),
149+
(-1, 2),
150+
)
150151
positions = np.hstack(
151152
[
152153
positions,
@@ -155,9 +156,10 @@ def update(self):
155156
)
156157

157158
if self._colour is None:
158-
colour_b = np.concatenate(
159-
[lines_b["colour"][:-1], lines_b["colour"][1:]], axis=1
160-
).reshape([-1, 3])
159+
colour_b = np.reshape(
160+
np.concatenate([lines_b["colour"][:-1], lines_b["colour"][1:]], axis=1),
161+
(-1, 3),
162+
)
161163
else:
162164
colour_b = np.tile(self._colour, (positions.shape[0], 1))
163165

@@ -310,21 +312,26 @@ def update(self):
310312
for i in range(16):
311313
section = np.vstack([data_pointer_gamut[i], data_pointer_gamut[i][0, ...]])
312314
sections.append(
313-
np.concatenate([section[:-1], section[1:]], axis=1).reshape([-1, 3])
315+
np.reshape(np.concatenate([section[:-1], section[1:]], axis=1), (-1, 3))
314316
)
315317

316-
positions = colourspace_model_axis_reorder(
317-
XYZ_to_colourspace_model(
318-
sections,
319-
CCS_ILLUMINANT_POINTER_GAMUT,
318+
positions = np.reshape(
319+
colourspace_model_axis_reorder(
320+
XYZ_to_colourspace_model(
321+
sections,
322+
CCS_ILLUMINANT_POINTER_GAMUT,
323+
self._model,
324+
**self._kwargs,
325+
),
320326
self._model,
321-
**self._kwargs,
322327
),
323-
self._model,
324-
).reshape([-1, 3])
328+
(-1, 3),
329+
)
325330

326331
if self._colour is None:
327-
colour = XYZ_to_plotting_colourspace(sections, illuminant).reshape([-1, 3])
332+
colour = np.reshape(
333+
XYZ_to_plotting_colourspace(sections, illuminant), (-1, 3)
334+
)
328335
else:
329336
colour = np.tile(self._colour, (positions.shape[0], 1))
330337

colour_visuals/rgb_colourspace.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,15 @@ def update(self):
201201
plotting_colourspace.whitepoint,
202202
)
203203

204-
positions = append_channel(ij, 0).reshape([-1, 3])
204+
positions = np.reshape(append_channel(ij, 0), (-1, 3))
205205

206206
if self._colour is None:
207-
colour_w = XYZ_to_RGB(
208-
xy_to_XYZ(self._colourspace.whitepoint), plotting_colourspace
209-
).reshape([-1, 3])
207+
colour_w = np.reshape(
208+
XYZ_to_RGB(
209+
xy_to_XYZ(self._colourspace.whitepoint), plotting_colourspace
210+
),
211+
(-1, 3),
212+
)
210213
else:
211214
colour_w = np.tile(self._colour, (positions.shape[0], 1))
212215

@@ -380,7 +383,7 @@ def update(self):
380383
gfx.Geometry(
381384
positions=as_contiguous_array(positions),
382385
normals=vertices["normal"],
383-
indices=outline[..., 1].reshape([-1, 4]),
386+
indices=np.reshape(outline[..., 1], (-1, 4)),
384387
colors=as_contiguous_array(append_channel(colour, self._opacity)),
385388
),
386389
(

colour_visuals/rgb_scatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def RGB(self) -> NDArray:
183183
def RGB(self, value: ArrayLike):
184184
"""Setter for the **self.RGB** property."""
185185

186-
self._RGB = as_float_array(value).reshape(-1, 3)
186+
self._RGB = np.reshape(as_float_array(value), (-1, 3))
187187
self._RGB[self._RGB == 0] = EPSILON
188188

189189
def update(self):

colour_visuals/rosch_macadam.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,15 @@ def update(self):
195195
),
196196
self._model,
197197
)
198-
positions = np.concatenate([positions[:-1], positions[1:]], axis=1).reshape(
199-
[-1, 3]
198+
positions = np.reshape(
199+
np.concatenate([positions[:-1], positions[1:]], axis=1), (-1, 3)
200200
)
201201

202202
if self._colour is None:
203203
colour = XYZ_to_RGB(XYZ, colourspace)
204-
colour = np.concatenate([colour[:-1], colour[1:]], axis=1).reshape([-1, 3])
204+
colour = np.reshape(
205+
np.concatenate([colour[:-1], colour[1:]], axis=1), (-1, 3)
206+
)
205207
else:
206208
colour = np.tile(self._colour, (positions.shape[0], 1))
207209

0 commit comments

Comments
 (0)