Py5Vector.astype()#

Create a new Py5Vector instance with a specified numpy dtype.

Examples#

1import numpy as np
2
3v1 = py5.Py5Vector(1, 2, 3)
4v2 = v1.astype(np.float16)
5
6print(repr(v1))
7# Py5Vector3D([1., 2., 3.])
8print(repr(v2))
9# Py5Vector3D([1., 2., 3.], dtype=float16)

Description#

Create a new Py5Vector instance with a specified numpy dtype. Only floating types (np.float16, np.float32, np.float64, and np.float128) are allowed.

Syntax#

astype(dtype) -> Py5Vector

Parameters#

  • dtype: - numpy floating dtype

Updated on January 16, 2022 16:51:21pm UTC