1+ import logging
2+
13import numpy as np
24import h5py
35
@@ -155,18 +157,14 @@ def list_all_attributes(self):
155157
156158 # MAPPINGS -----------------------------------------------
157159 def list_mappings (self ):
158- """
159- List all mappings in this file
160- """
160+ """ List all mappings in this file """
161161 if super (File , self ).__contains__ ("lookup" ):
162162 return list (super (File , self ).__getitem__ ("lookup" ).keys ())
163163
164164 return []
165165
166166 def delete_mapping (self , title ):
167- """
168- Remove a mapping.
169- """
167+ """ Remove a mapping. """
170168 try :
171169 lookup = super (File , self ).__getitem__ ("lookup" )
172170 del lookup [title ]
@@ -175,7 +173,7 @@ def delete_mapping(self, title):
175173 raise LookupError (f"No such mapping: { title } " )
176174
177175 def delete_matrix (self , name ):
178- """Remove a matrix."""
176+ """ Remove a matrix."""
179177 try :
180178 data_group = super (File , self ).__getitem__ ("data" )
181179 del data_group [name ]
@@ -184,7 +182,8 @@ def delete_matrix(self, name):
184182 raise LookupError (f"No such matrix: { name } " )
185183
186184 def mapping (self , title ):
187- """Return dict containing key:value pairs for specified mapping."""
185+ """ Return dict containing key:value pairs for specified mapping. """
186+
188187 # fetch entries
189188 if not super (File , self ).__contains__ ("lookup" ):
190189 raise LookupError (f"No such mapping: { title } " )
@@ -305,7 +304,7 @@ def __len__(self):
305304 return 0
306305
307306 def __setitem__ (self , key , dataset ):
308- # We need to determine atom and shape from the object that's been passed in.
307+ # We need to determine dtype and shape from the object that's been passed in.
309308 # This assumes 'dataset' is a numpy object.
310309
311310 # Check if it's already an h5py dataset (copy?)
@@ -337,8 +336,8 @@ def __delitem__(self, key):
337336 # Try standard delete
338337 try :
339338 super (File , self ).__delitem__ (key )
340- except Exception :
341- pass
339+ except Exception as e :
340+ logging . debug ( f"Failed to delete key { key } : { e . args } " )
342341
343342 def __iter__ (self ):
344343 """Iterate over the keys in this container"""
0 commit comments