healsparse won't read a `pathlib.Path`
Closed this issue · 0 comments
sidneymau commented
When trying to read from a pathlib.Path
object, healsparse will throw an error about only supporting fits and parquet files; e.g.,
(Pdb) hsp_plus
PosixPath('/pscratch/sd/s/smau/y6-image-sims/debug-cosmos-rand-piff-median_color-seed/DES0608-5414/16200/plus/des-pizza-slices-y6/DES0608-5414/metadetect/DES0608-5414_metadetect-config_mdetcat_part0000-healsparse-mask.hs')
(Pdb) healsparse.HealSparseMap.read(hsp_plus)
*** NotImplementedError: HealSparse only supports fits and parquet files.
(Pdb) healsparse.HealSparseMap.read(hsp_plus.as_posix())
HealSparseMap: nside_coverage = 128, nside_sparse = 131072, int32, 2551130 valid pixels
the error is also slightly confusing as the file format is not a problem.
This is happening because a Path
doesn't match as a str
(
healsparse/healsparse/io_coverage.py
Lines 33 to 46 in 8335092
One possible solution would be checking
isinstance(filename_or_fits, (str, Path))
instead of
isinstance(filename_or_fits, str)
I haven't checked if any of the code downstream would complain about a Path
...