File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,23 +105,20 @@ def read_data(filename: str) -> np.ndarray:
105105
106106 @staticmethod
107107 def write_data (filename : str , data : np .ndarray ) -> None :
108- """Write data to file
108+ """Write data to file.
109109
110110 Args:
111- filename: File name
112- data: Image array data
111+ filename: File name.
112+ data: Image array data.
113113 """
114- if data .dtype in (
115- np .int8 ,
116- np .uint8 ,
117- np .int16 ,
118- np .uint16 ,
119- np .int32 ,
120- np .uint32 ,
121- ):
114+ if np .issubdtype (data .dtype , np .integer ):
122115 fmt = "%d"
123- else :
116+ elif np . issubdtype ( data . dtype , np . floating ) :
124117 fmt = "%.18e"
118+ else :
119+ raise NotImplementedError (
120+ f"Writing data of type { data .dtype } to text file is not supported."
121+ )
125122 ext = osp .splitext (filename )[1 ]
126123 if ext .lower () in (".txt" , ".asc" , "" ):
127124 np .savetxt (filename , data , fmt = fmt )
You can’t perform that action at this time.
0 commit comments