File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed
Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change 1515from importlib .metadata import version
1616from inspect import signature , Parameter
1717from functools import wraps
18+ from pathlib import Path
1819import multiprocessing
1920import warnings
2021
@@ -69,10 +70,11 @@ def save(self, filename):
6970
7071 @classmethod
7172 def load (cls , filename ):
73+ filename = Path (filename ).resolve ()
7274 try :
7375 data = np .load (filename , allow_pickle = True )
74- except BaseException :
75- data = np .load (filename + ".npz" , allow_pickle = True )
76+ except FileNotFoundError :
77+ data = np .load (filename . with_suffix ( ".npz" ) , allow_pickle = True )
7678
7779 if "_vip_object" not in data :
7880 raise RuntimeError ("The file you specified is not a VIP object." )
Original file line number Diff line number Diff line change 44
55__author__ = "Ralf Farkas"
66
7- import tempfile
87import os
98import sys
109
1413from vip_hci .objects .dataset import Dataset
1514
1615
17- def test_saveable_dataset ():
16+ def test_saveable_dataset (tmp_path ):
1817 """
1918 Test the HCIDataset.save() and .load() methods
2019 """
@@ -26,7 +25,7 @@ def test_saveable_dataset():
2625 ds = Dataset (cube = cube , angles = angles , fwhm = fwhm )
2726
2827 # save
29- fd , fn = tempfile . mkstemp ( prefix = "vip_" )
28+ fn = tmp_path / 'test'
3029 ds .save (fn )
3130
3231 # restore
@@ -36,6 +35,3 @@ def test_saveable_dataset():
3635 aarc (ds2 .cube , cube )
3736 aarc (ds2 .angles , angles )
3837 assert ds2 .fwhm == fwhm
39-
40- # cleanup
41- os .remove (fn )
You can’t perform that action at this time.
0 commit comments