Coverage for src/abm_shape_collection/construct_mesh_from_points.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.1.0, created at 2024-09-25 19:34 +0000

1import numpy as np 

2import pandas as pd 

3from sklearn.decomposition import PCA 

4from vtk import vtkPolyData # pylint: disable=no-name-in-module 

5 

6from abm_shape_collection.construct_mesh_from_coeffs import construct_mesh_from_coeffs 

7 

8 

9def construct_mesh_from_points( 

10 pca: PCA, 

11 points: np.ndarray, 

12 feature_names: list[str], 

13 order: int, 

14 prefix: str = "", 

15 suffix: str = "", 

16) -> vtkPolyData: 

17 """ 

18 Construct mesh given PCA transformation points. 

19 

20 Parameters 

21 ---------- 

22 pca 

23 Fit PCA object. 

24 points 

25 Select point in PC space. 

26 feature_names 

27 Spherical harmonics coefficient names. 

28 order 

29 Order of the spherical harmonics coefficient parametrization. 

30 prefix 

31 Prefix string for all coefficient columns. 

32 suffix 

33 Suffix string for all coefficient columns. 

34 

35 Returns 

36 ------- 

37 : 

38 Mesh object. 

39 """ 

40 

41 coeffs = pd.Series(pca.inverse_transform(points), index=feature_names) 

42 return construct_mesh_from_coeffs(coeffs, order, prefix, suffix)