Чтение V 7,3 Mat файл в Python

Вам нужно явно определить operator == для MyStruct1.

struct MyStruct1 {
  bool operator == (const MyStruct1 &rhs) const
  { /* your logic for comparision between "*this" and "rhs" */ }
};

Теперь сравнение == законно для 2 таких объектов.

45
задан Shan 26 June 2013 в 09:53
поделиться

1 ответ

Это сделало задание для меня:

import numpy as np
import h5py

def conv(obj):
    ret = {}
    for k, v in obj.items():
        if hasattr(v, "items"):
            # Nested dicts
            ret[k] = conv(v)
        elif hasattr(v, "shape"):
            # Arrays a Numpy arrays
            ret[k] = np.array(v)
        else:
            # I haven't seen other types, but just in case:
            ret[k] = v
    return ret

with h5py.File('e1_eegmodel.mat', 'r') as f:
    eegmodel = conv(f)
0
ответ дан Lasse Kärkkäinen 23 September 2019 в 08:32
поделиться
Другие вопросы по тегам:

Похожие вопросы: