66from typing import Any , Container , Dict , Iterator , List , Optional , Sequence , Union , cast
77
88import numpy as np
9+
910try :
1011 from meshio import Mesh
11- except ModuleNotFoundError :
12+ except ModuleNotFoundError : # pragma: no cover
1213 Mesh = None
1314
1415from . import libpdalpython
1516
16-
1717LogLevelToPDAL = {
1818 logging .ERROR : 0 ,
1919 logging .WARNING : 1 ,
@@ -30,6 +30,7 @@ def __init__(
3030 arrays : Sequence [np .ndarray ] = (),
3131 loglevel : int = logging .ERROR ,
3232 ):
33+ super ().__init__ ()
3334 self ._stages : List [Stage ] = []
3435 if spec :
3536 stages = _parse_stages (spec ) if isinstance (spec , str ) else spec
@@ -79,12 +80,13 @@ def __or__(self, other: Union[Stage, Pipeline]) -> Pipeline:
7980 return new
8081
8182 def __copy__ (self ) -> Pipeline :
82- clone = cast (Pipeline , super ().__copy__ ())
83+ clone = self .__class__ (loglevel = self .loglevel )
84+ clone ._copy_inputs (self )
8385 clone |= self
8486 return clone
8587
86- def get_meshio (self , idx : int ) -> Mesh :
87- if Mesh is None :
88+ def get_meshio (self , idx : int ) -> Optional [ Mesh ] :
89+ if Mesh is None : # pragma: no cover
8890 raise RuntimeError (
8991 "The get_meshio function can only be used if you have installed meshio. "
9092 "Try pip install meshio"
@@ -98,8 +100,7 @@ def get_meshio(self, idx: int) -> Mesh:
98100 [("triangle" , np .stack ((mesh ["A" ], mesh ["B" ], mesh ["C" ]), 1 ))],
99101 )
100102
101- @property
102- def _json (self ) -> str :
103+ def _get_json (self ) -> str :
103104 options_list = []
104105 stage2tag : Dict [Stage , str ] = {}
105106 for stage in self ._stages :
@@ -134,8 +135,8 @@ def inputs(self) -> List[Union[Stage, str]]:
134135 def options (self ) -> Dict [str , Any ]:
135136 return dict (self ._options )
136137
137- def pipeline (self , * arrays : np .ndarray ) -> Pipeline :
138- return Pipeline ((self ,), arrays )
138+ def pipeline (self , * arrays : np .ndarray , loglevel : int = logging . ERROR ) -> Pipeline :
139+ return Pipeline ((self ,), arrays , loglevel )
139140
140141 def __or__ (self , other : Union [Stage , Pipeline ]) -> Pipeline :
141142 return Pipeline ((self , other ))
0 commit comments