CirQuS-UTS / QuanGuru

QuanGuru (pronounced Kangaroo) is a Python library for numerical modelling of quantum systems. It is still under-development, and it consists of tools for numerical simulations of Quantum systems.
BSD 3-Clause "New" or "Revised" License
5 stars 7 forks source link

saveQResCSV does not save arrays with numpy.intc data types #257

Open adriendilonardo opened 5 months ago

adriendilonardo commented 5 months ago

Code for saving qRes objects

def _recursiveSaveList(data, path=None, fileName=None):
    if isinstance(data[0], (list, np.ndarray)):
        if isinstance(data[0][0], (list, np.ndarray)):
            for ind in range(len(data)): #pylint:disable=consider-using-enumerate
                _recursiveSaveList(data[ind], path=path, fileName=fileName+str(ind))
        elif isinstance(data[0][0], (float, int, np.complex128)):
            saveCSV(data, path=path, fileName=fileName)
    elif isinstance(data[0], (float, int, np.complex128)):
        saveCSV(data, path=path, fileName=fileName)

def _saveDictToCSV(data, path=None, fileName=''):
    for key, val in data.items():
        _recursiveSaveList(val, path, fileName=fileName+key)

def saveQResCSV(qRes, path=None, fileNamePrefix=''):
    results = qRes.allResults
    for key, val in results.items():
        result = val.resultsDict
        if len(result.keys()) > 0:
            _saveDictToCSV(result, path, fileNamePrefix+key._allStringSum()) #pylint:disable=protected-access

_recursiveSaveList does not save objects whose numerical data is not float int or np.complex128 however some numpy operations save data as np.intc

github-actions[bot] commented 5 months ago

Branch 257-saveQResCSV_does_not_save_arrays_with_numpy_intc_data_types created!