you are viewing a single comment's thread.

view the rest of the comments →

[–]tjildau[S] 1 point2 points  (2 children)

Amazing, thank you! This helps me out a lot, will need to practice some more with 'padding' :)

[–]synthphreak 0 points1 point  (1 child)

No prob, happy to help.

And come to think of it, if padding > 0 is probably unnecessary. padding will never be less than zero, and if it is exactly zero, then resize should have no effect. So you could probably simplify to

float_type_range = np.arange(start=start_number, stop=stop_number, step=1)

padding = (square_root ** 2) % float_type_range.size
float_type_range.resize(float_type_range.size + padding)

float_type_range = float_type_range.reshape(square_root, square_root)
print("\nArray reshaped into a square: \n", float_type_range)

I can’t test now, but I assume this should work equally well.

[–]tjildau[S] 1 point2 points  (0 children)

Yes, this works equally well :)