3030from . import plot
3131from . import runners
3232from . import util
33+ from .util import PathLike
3334
3435
3536CombinedData = list [tuple [str , np .ndarray | None , float ]]
@@ -54,7 +55,7 @@ def _clean_for_url(string: str) -> str:
5455 return string .replace ("-" , "%2d" )
5556
5657
57- def _get_platform_value (python : Path , item : str ) -> str :
58+ def _get_platform_value (python : PathLike , item : str ) -> str :
5859 """
5960 Get a value from the platform module of the given Python interpreter.
6061 """
@@ -64,7 +65,7 @@ def _get_platform_value(python: Path, item: str) -> str:
6465 return output .strip ().lower ()
6566
6667
67- def _get_architecture (python : Path ) -> str :
68+ def _get_architecture (python : PathLike ) -> str :
6869 machine = _get_platform_value (python , "machine" )
6970 bits = eval (_get_platform_value (python , "architecture" ))[0 ]
7071 if bits == "32bit" :
@@ -152,7 +153,9 @@ def _generate_contents(self) -> str:
152153 fd .write (f"- memory change: { self ._calculate_memory_change ()} " )
153154 return fd .getvalue ()
154155
155- def write_table (self , filename : Path ) -> str | None :
156+ def write_table (self , filename : PathLike ) -> str | None :
157+ filename = Path (filename )
158+
156159 entries = [
157160 ("fork" , unquote (self .head .fork )),
158161 ("ref" , self .head .ref ),
@@ -212,7 +215,7 @@ def get_timing_diff(self) -> CombinedData:
212215 head_data = self .head .get_timing_data ()
213216 return self ._get_combined_data (ref_data , head_data )
214217
215- def write_timing_plot (self , filename : Path ) -> None :
218+ def write_timing_plot (self , filename : PathLike ) -> None :
216219 plot .plot_diff (
217220 self .get_timing_diff (),
218221 filename ,
@@ -231,7 +234,7 @@ def get_memory_diff(self) -> CombinedData:
231234 # Explicitly reversed so higher is bigger
232235 return self ._get_combined_data (head_data , ref_data )
233236
234- def write_memory_plot (self , filename : Path ) -> None :
237+ def write_memory_plot (self , filename : PathLike ) -> None :
235238 plot .plot_diff (
236239 self .get_memory_diff (),
237240 filename ,
@@ -376,7 +379,9 @@ def get_files(self) -> Iterable[tuple[Callable, str, str]]:
376379 return
377380 yield (self .write_pystats_diff , ".md" , "pystats diff" )
378381
379- def write_pystats_diff (self , filename : Path ) -> None :
382+ def write_pystats_diff (self , filename : PathLike ) -> None :
383+ filename = Path (filename )
384+
380385 try :
381386 contents = subprocess .check_output (
382387 [
@@ -434,7 +439,8 @@ def __init__(
434439 self .bases = {}
435440
436441 @classmethod
437- def from_filename (cls , filename : Path ) -> "Result" :
442+ def from_filename (cls , filename : PathLike ) -> "Result" :
443+ filename = Path (filename )
438444 (
439445 name ,
440446 _ ,
@@ -469,7 +475,7 @@ def from_filename(cls, filename: Path) -> "Result":
469475 @classmethod
470476 def from_scratch (
471477 cls ,
472- python : Path ,
478+ python : PathLike ,
473479 fork : str ,
474480 ref : str ,
475481 extra : Iterable [str ] | None = None ,
@@ -687,7 +693,7 @@ def memory_value(metadata):
687693
688694
689695def has_result (
690- results_dir : Path ,
696+ results_dir : PathLike ,
691697 commit_hash : str ,
692698 machine : str ,
693699 pystats : bool ,
@@ -822,14 +828,14 @@ def track(it, *_args, **_kwargs):
822828
823829def load_all_results (
824830 bases : Sequence [str ] | None ,
825- results_dir : Path ,
831+ results_dir : PathLike ,
826832 sorted : bool = True ,
827833 match : bool = True ,
828834 progress : bool = True ,
829835) -> list [Result ]:
830836 results = []
831837
832- for entry in results_dir .glob ("**/*.json" ):
838+ for entry in Path ( results_dir ) .glob ("**/*.json" ):
833839 result = Result .from_filename (entry )
834840 if result .result_info [0 ] not in ["raw results" , "pystats raw" ]:
835841 continue
0 commit comments