From b7bc6e3d808d7d2cc69d033147a205f4e34260af Mon Sep 17 00:00:00 2001 From: Liam Gray Date: Mon, 29 Jul 2024 15:27:24 -0700 Subject: [PATCH] feat(memh5): add warning when trying to make shallow/shared copy to file --- caput/memh5.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/caput/memh5.py b/caput/memh5.py index f0f09102..839b0652 100644 --- a/caput/memh5.py +++ b/caput/memh5.py @@ -2701,8 +2701,20 @@ def _prepare_compression_args(dset): # If copying to file, datasets are not shared, so ensure that these # datasets are properly processed if to_file: - shared = {} - shallow = False + if shared: + warnings.warn( + f"Attempted to share datasets {(*shared,)}, but target group " + f"{g2} is on disk. Datasets cannot be shared." + ) + shared = {} + + if shallow: + warnings.warn( + f"Attempted to make a shallow copy of group {g1}, but target " + f"group {g2} is on disk. Datasets cannot be shared." + ) + shallow = False + elif not shallow: # Make sure shared dataset names are properly formatted shared = {"/" + k if k[0] != "/" else k for k in shared}