@@ -514,9 +514,9 @@ def hermite_interpolation(md_target, md_start, md_end, p_start, p_end, v_start,
514514
515515def _interp1d_vectorized (
516516 ctrl_params : np .ndarray , # (K,)
517- ctrl_pts : np .ndarray , # (K, d)
518- query : np .ndarray , # (Q,)
519- ) -> np .ndarray : # (Q, d)
517+ ctrl_pts : np .ndarray , # (K, d)
518+ query : np .ndarray , # (Q,)
519+ ) -> np .ndarray : # (Q, d)
520520 """Vectorised piecewise-linear interpolation of a 1-D parametric curve."""
521521 result = np .empty ((len (query ), ctrl_pts .shape [1 ]), dtype = np .float64 )
522522 for dim in range (ctrl_pts .shape [1 ]):
@@ -526,9 +526,9 @@ def _interp1d_vectorized(
526526
527527def _natural_cubic_spline_eval (
528528 ctrl_params : np .ndarray , # (K,)
529- ctrl_pts : np .ndarray , # (K, d)
530- query : np .ndarray , # (Q,)
531- ) -> np .ndarray : # (Q, d)
529+ ctrl_pts : np .ndarray , # (K, d)
530+ query : np .ndarray , # (Q,)
531+ ) -> np .ndarray : # (Q, d)
532532 """
533533 Evaluate a natural cubic spline (second derivatives = 0 at endpoints) via
534534 ``scipy.interpolate.CubicSpline``.
@@ -552,10 +552,10 @@ def _natural_cubic_spline_eval(
552552
553553def _minimum_curvature_eval (
554554 ctrl_params : np .ndarray , # (K,) P-values (e.g. depth) at knots
555- ctrl_pts : np .ndarray , # (K, 3) XYZ at knots
556- tangents : np .ndarray , # (K, 3) unit tangent vectors at knots
557- query : np .ndarray , # (Q,) query P-values
558- ) -> np .ndarray : # (Q, 3)
555+ ctrl_pts : np .ndarray , # (K, 3) XYZ at knots
556+ tangents : np .ndarray , # (K, 3) unit tangent vectors at knots
557+ query : np .ndarray , # (Q,) query P-values
558+ ) -> np .ndarray : # (Q, 3)
559559 """
560560 Minimum-curvature interpolation (RESQML line kind 5).
561561
@@ -612,10 +612,10 @@ def _minimum_curvature_eval(
612612def _evaluate_one_pillar (
613613 kind : int ,
614614 ctrl_params : Optional [np .ndarray ], # (K,) — may be None for kind=0
615- ctrl_pts : np .ndarray , # (K, d) — d=2 for kind=0, d=3 otherwise
616- tangents : Optional [np .ndarray ], # (K, 3) — only for kinds 3, 5
617- query_params : np .ndarray , # (Q,) query P-values for this pillar
618- ) -> np .ndarray : # (Q, 3)
615+ ctrl_pts : np .ndarray , # (K, d) — d=2 for kind=0, d=3 otherwise
616+ tangents : Optional [np .ndarray ], # (K, 3) — only for kinds 3, 5
617+ query_params : np .ndarray , # (Q,) query P-values for this pillar
618+ ) -> np .ndarray : # (Q, 3)
619619 """
620620 Evaluate a single parametric pillar at *query_params*, returning `(Q, 3)` XYZ.
621621
@@ -728,14 +728,10 @@ def resolve_parametric_line_array(
728728 # ParametricLineFromRepresentationLatticeArray path (RESQML v2.0.1).
729729 supporting_rep_dor = getattr (parametric_lines_obj , "supporting_representation" , None )
730730 if supporting_rep_dor is None :
731- raise ValueError (
732- "ParametricLineFromRepresentationLatticeArray has no supporting_representation reference."
733- )
731+ raise ValueError ("ParametricLineFromRepresentationLatticeArray has no supporting_representation reference." )
734732
735733 if workspace is None :
736- raise ValueError (
737- "A workspace is required to resolve ParametricLineFromRepresentationLatticeArray."
738- )
734+ raise ValueError ("A workspace is required to resolve ParametricLineFromRepresentationLatticeArray." )
739735
740736 sup_uri = get_obj_uri (supporting_rep_dor )
741737 sup_obj = workspace .get_object (sup_uri )
@@ -747,9 +743,7 @@ def resolve_parametric_line_array(
747743 if not pla_results :
748744 pla_results = search_attribute_matching_name_with_path (sup_obj , "parametric_lines" )
749745 if not pla_results :
750- raise ValueError (
751- f"Cannot find a ParametricLineArray in supporting representation { sup_uri } ."
752- )
746+ raise ValueError (f"Cannot find a ParametricLineArray in supporting representation { sup_uri } ." )
753747 _ , sup_pla = pla_results [0 ]
754748
755749 # Read the pillar index selection (IntegerLatticeArray).
@@ -760,9 +754,7 @@ def resolve_parametric_line_array(
760754
761755 from energyml .utils .data .helper import read_array as _read_array_helper # for local use
762756
763- raw_indices = _read_array_helper (
764- energyml_array = idx_obj , root_obj = root_obj , workspace = workspace
765- )
757+ raw_indices = _read_array_helper (energyml_array = idx_obj , root_obj = root_obj , workspace = workspace )
766758 if not isinstance (raw_indices , np .ndarray ):
767759 raw_indices = np .array (raw_indices , dtype = np .int64 )
768760 raw_indices = raw_indices .flatten ().astype (np .int64 )
@@ -791,7 +783,7 @@ def evaluate_parametric_line_array(
791783 query_parameters : np .ndarray , # shape (NKL, n_pillars)
792784 ni : int ,
793785 nj : int ,
794- ) -> np .ndarray : # shape (NKL, n_pillars, 3) float64
786+ ) -> np .ndarray : # shape (NKL, n_pillars, 3) float64
795787 """
796788 Evaluate a ``ParametricLineArray`` at the given query P-values and return
797789 3-D Cartesian coordinates for every grid node.
@@ -906,7 +898,7 @@ def evaluate_parametric_line_array(
906898 for p_idx in range (n_pillars ):
907899 kind = int (kinds [p_idx ])
908900 q_p = query_parameters [:, p_idx ] # (NKL,) P-values for this pillar
909- cp_p = ctrl_pts [:, p_idx , :] # (K, d)
901+ cp_p = ctrl_pts [:, p_idx , :] # (K, d)
910902
911903 # ctrl_params_p: (K,) — derived from global or pillar-specific params.
912904 # For kind=0, ctrl_params is None (vertical) and we pass None.
@@ -1970,7 +1962,7 @@ def from_hsv(hsv_obj: Any) -> "RgbaColor":
19701962 a = hsv_obj .alpha if hsv_obj .alpha is not None else 1.0
19711963 r , g , b = colorsys .hsv_to_rgb (h , s , v )
19721964 return RgbaColor (r , g , b , a )
1973-
1965+
19741966 @staticmethod
19751967 def random () -> "RgbaColor" :
19761968 """Generate a random RGBA color (for testing)."""
@@ -1982,7 +1974,7 @@ def random() -> "RgbaColor":
19821974 b = random .random (),
19831975 a = 1.0 ,
19841976 )
1985-
1977+
19861978 @staticmethod
19871979 def random_from_uuid (uuid_str : str ) -> "RgbaColor" :
19881980 """Generate a random RGBA color based on a UUID string (for consistent testing)."""
@@ -1991,7 +1983,7 @@ def random_from_uuid(uuid_str: str) -> "RgbaColor":
19911983
19921984 # Create a hash of the UUID string to seed the random generator
19931985 hash_bytes = hashlib .sha256 (uuid_str .encode ()).digest ()
1994- seed = int .from_bytes (hash_bytes , ' big' )
1986+ seed = int .from_bytes (hash_bytes , " big" )
19951987 random .seed (seed )
19961988
19971989 return RgbaColor (
@@ -2051,9 +2043,7 @@ def to_vtk_lut(self, n_colors: int = 256) -> np.ndarray:
20512043
20522044 if not self .is_continuous :
20532045 # One exact row per integer entry - no interpolation needed.
2054- return np .array (
2055- [e .color .to_uint8 () for e in sorted_entries ], dtype = np .uint8
2056- )
2046+ return np .array ([e .color .to_uint8 () for e in sorted_entries ], dtype = np .uint8 )
20572047
20582048 # Continuous: sample n_colors levels with linear interpolation in RGBA.
20592049 indices = np .array ([e .index for e in sorted_entries ], dtype = np .float64 )
@@ -2064,9 +2054,7 @@ def to_vtk_lut(self, n_colors: int = 256) -> np.ndarray:
20642054 t = np .linspace (indices [0 ], indices [- 1 ], n_colors )
20652055 result = np .zeros ((n_colors , 4 ), dtype = np .uint8 )
20662056 for ch in range (4 ):
2067- result [:, ch ] = np .clip (
2068- np .interp (t , indices , float_colors [:, ch ]) * 255 , 0 , 255
2069- ).round ().astype (np .uint8 )
2057+ result [:, ch ] = np .clip (np .interp (t , indices , float_colors [:, ch ]) * 255 , 0 , 255 ).round ().astype (np .uint8 )
20702058 return result
20712059
20722060 def scalar_range (self ) -> Tuple [float , float ]:
@@ -2271,7 +2259,9 @@ def read_graphical_rendering_info(
22712259 result = ScalarRenderingInfo (target_obj_uuid = target_uuid )
22722260 found = False
22732261
2274- gis_infos : List [Any ] = getattr (graphical_information_set , "graphical_information" , []) or ([graphical_information_set ] if not isinstance (graphical_information_set , list ) else graphical_information_set )
2262+ gis_infos : List [Any ] = getattr (graphical_information_set , "graphical_information" , []) or (
2263+ [graphical_information_set ] if not isinstance (graphical_information_set , list ) else graphical_information_set
2264+ )
22752265
22762266 for info in gis_infos :
22772267 # Each AbstractGraphicalInformation targets ≥1 objects via target_object[].
@@ -2308,10 +2298,7 @@ def read_graphical_rendering_info(
23082298 raw_alphas = getattr (info , "alpha" , []) or []
23092299 if raw_indices and raw_alphas :
23102300 try :
2311- result .alpha_control_points = [
2312- (float (idx ), float (a ))
2313- for idx , a in zip (raw_indices , raw_alphas )
2314- ]
2301+ result .alpha_control_points = [(float (idx ), float (a )) for idx , a in zip (raw_indices , raw_alphas )]
23152302 except (TypeError , ValueError ) as exc :
23162303 logging .warning (f"read_graphical_rendering_info: cannot parse AlphaInformation indices: { exc } " )
23172304
@@ -2323,7 +2310,7 @@ def read_graphical_rendering_info(
23232310 result .size_min_max = (mm .minimum , mm .maximum )
23242311
23252312 elif "DefaultGraphicalInformation" in type_name :
2326- for elem_info in ( getattr (info , "indexable_element_info" , []) or []) :
2313+ for elem_info in getattr (info , "indexable_element_info" , []) or []:
23272314 if (getattr (elem_info , "is_visible" , None )) is False :
23282315 result .is_visible = False
23292316 const_col = getattr (elem_info , "constant_color" , None )
@@ -2340,4 +2327,4 @@ def read_graphical_rendering_info(
23402327 # AnnotationInformation is intentionally not mapped to ScalarRenderingInfo
23412328 # because it drives label text, not colour/size - handle separately if needed.
23422329
2343- return result if found else None
2330+ return result if found else None
0 commit comments