Code Duplication    Length = 15-15 lines in 2 locations

savu/plugins/loaders/random_hdf5_loader.py 1 location

@@ 118-132 (lines=15) @@
115
116
        return self.hdf5._open_backing_h5(fname, 'r')
117
118
    def __get_start_slice_list(self, slice_dirs, shape, n_frames):
119
        n_processes = len(self.exp.get('processes'))
120
        rank = self.exp.get('process')
121
        frames = np.array_split(np.arange(n_frames), n_processes)[rank]
122
        f_range = list(range(0, frames[0])) if len(frames) else []
123
        sl = [slice(0, 1) if i in slice_dirs else slice(None)
124
              for i in range(len(shape))]
125
        idx = 0
126
        for i in f_range:
127
            if sl[slice_dirs[idx]] == shape[slice_dirs[idx]]-1:
128
                idx += 1
129
            tmp = sl[slice_dirs[idx]]
130
            sl[slice_dirs[idx]] = slice(tmp.start+1, tmp.stop+1)
131
132
        return sl, len(frames)
133
134
    def __convert_patterns(self, data_obj):
135
        pattern_list = self.parameters['patterns']

savu/plugins/loaders/base_tomophantom_loader.py 1 location

@@ 144-158 (lines=15) @@
141
142
        return self.hdf5._open_backing_h5(fname, 'r')
143
144
    def __get_start_slice_list(self, slice_dirs, shape, n_frames):
145
        n_processes = len(self.exp.get('processes'))
146
        rank = self.exp.get('process')
147
        frames = np.array_split(np.arange(n_frames), n_processes)[rank]
148
        f_range = list(range(0, frames[0])) if len(frames) else []
149
        sl = [slice(0, 1) if i in slice_dirs else slice(None)
150
              for i in range(len(shape))]
151
        idx = 0
152
        for i in f_range:
153
            if sl[slice_dirs[idx]] == shape[slice_dirs[idx]]-1:
154
                idx += 1
155
            tmp = sl[slice_dirs[idx]]
156
            sl[slice_dirs[idx]] = slice(tmp.start+1, tmp.stop+1)
157
158
        return sl, len(frames)
159
160
    def __convert_patterns(self, data_obj, object_type):
161
        if (object_type == 'synth_proj_data'):