#NEWLINE# @ data_factory ( label = 'Numpy save file' , identifier = is_npy , priority = 100 ) #NEWLINE# def npy_reader( filename , format = 'auto' , auto_merge = False , **kwargs ) : #NEWLINE# #INDENT# '\n    Read in a Numpy structured array saved to a .npy or .npz file.\n\n    Parameters\n    ----------\n    source: str\n        The pathname to the Numpy save file.\n    ' #NEWLINE# import numpy as np #NEWLINE# npy_data = np . load ( kwargs ) #NEWLINE# if ( not hasattr ( npy_data . dtype , 'names' ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Numpy save file loading currently only supports structured arrays, e.g., with specified names.' ) #NEWLINE# #UNINDENT# d = Data ( ) #NEWLINE# for name in npy_data . dtype . names : #NEWLINE# #INDENT# comp = Component . autotyped ( npy_data [ name ] ) #NEWLINE# d . add_component ( comp , label = name ) #NEWLINE# #UNINDENT# return d