Exemplo n.º 1
0
 def pack_inputs(self, inputs_dict):
     """
     inputs_dict : {k:v} where k corresponds to one of careless.models.base.BaseModel.input_index.keys()
     """
     inputs = ()
     for i in range(len(BaseModel.input_index)):
         k = BaseModel.get_name_by_index(i)
         if k in inputs_dict:
             inputs += (inputs_dict[k], )
         else:
             break
     return inputs
Exemplo n.º 2
0
        def split(inputs, idx):
            harmonic_id = BaseModel.get_harmonic_id(inputs)

            result = ()
            uni, inv = np.unique(harmonic_id[idx], return_inverse=True)
            for i, v in enumerate(inputs):
                name = BaseModel.get_name_by_index(i)
                if name in ('intensities', 'uncertainties'):
                    v = v[uni]
                    v = np.pad(v, [[0, len(inv) - len(v)], [0, 0]],
                               constant_values=1.)
                elif name == 'harmonic_id':
                    v = inv[:, None]
                else:
                    v = v[idx.flatten(), ...]
                result += (v, )
            return result
Exemplo n.º 3
0
def test_by_name():
    for k, v in BaseModel.input_index.items():
        assert BaseModel.get_name_by_index(v) == k