MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / dump

Method dump

detrsmpl/data/data_structures/human_data_cache.py:75–104  ·  view source on GitHub ↗

Dump keys and items to an npz file. Args: npz_path (str): Path to a dumped npz file. overwrite (bool, optional): Whether to overwrite if there is already a file. Defaults to True. Raises: ValueError

(self, npz_path: str, overwrite: bool = True)

Source from the content-addressed store, hash-verified

73 self.sliced_data.update(sliced_dict)
74
75 def dump(self, npz_path: str, overwrite: bool = True):
76 """Dump keys and items to an npz file.
77
78 Args:
79 npz_path (str):
80 Path to a dumped npz file.
81 overwrite (bool, optional):
82 Whether to overwrite if there is already a file.
83 Defaults to True.
84
85 Raises:
86 ValueError:
87 npz_path does not end with '.npz'.
88 FileExistsError:
89 When overwrite is False and file exists.
90 """
91 if not check_path_suffix(npz_path, ['.npz']):
92 raise ValueError('Not an npz file.')
93 if not overwrite:
94 if check_path_existence(npz_path, 'file') == Existence.FileExist:
95 raise FileExistsError
96 dict_to_dump = {
97 'slice_size': self.slice_size,
98 'data_len': self.data_len,
99 'keypoints_info': self.keypoints_info,
100 'non_sliced_data': self.non_sliced_data,
101 'key_strict': self.key_strict,
102 }
103 dict_to_dump.update(self.sliced_data)
104 np.savez_compressed(npz_path, **dict_to_dump)

Callers 1

load_annotationsMethod · 0.95

Calls 3

check_path_suffixFunction · 0.90
check_path_existenceFunction · 0.90
updateMethod · 0.45

Tested by

no test coverage detected