def test_architecture(self): c = Case('test_architecture') c = c.add_architecture('5E.2H') assert c.shape == (5, 2) assert c.shape_len == ((7, 7, 7, 7, 7), (13, 13)) assert c.architecture_str == '5E.2H' assert c.center_shape == { 'A': { 'bottom': 0, 'hight': 0, 'left': 0, 'right': 19.4, 'top': 0, 'width': 19.4 }, 'B': { 'bottom': 0, 'hight': 0, 'left': 0, 'right': 10.0, 'top': 0, 'width': 10.0 } } with pytest.raises(ValidationError) as message: c = c.add_architecture('5E:8:8:7:7:7.2H:18:19') assert message.value.messages == [ 'An arquitecture is already defined.' ] c = Case('test_architecture') c = c.add_architecture('5E:8:8:7:7:7.2H:18:19') assert c.shape == (5, 2) assert c.shape_len == ((8, 8, 7, 7, 7), (18, 19)) assert c.connectivity_count == 0 assert c.connectivities_str == [] fig = plt.figure(figsize=(15, 5)) ax1 = plt.subplot2grid((1, 3), (0, 0), fig=fig) plot_case_sketch(c, ax1) ax2 = plt.subplot2grid((1, 3), (0, 1), fig=fig) plot_case_sketch(c.apply_corrections({'B': {'xalign': 'center'}}), ax2) ax3 = plt.subplot2grid((1, 3), (0, 2), fig=fig) plot_case_sketch(c.apply_corrections({'B': {'xalign': 'right'}}), ax3) return fig
def single_execute(self, data: Dict) -> Dict: kase = Case(data) crr = copy.deepcopy(self.corrections) # See if there are extra corrections attached to the case itself krr = kase['metadata.corrections'] krr = [] if krr is None else krr crr.extend(krr) # Apply each set of corrections for c in crr: self.log.info('Applying correction: {0}\n'.format(c)) kase = kase.apply_corrections(c) self.log.debug(f'Applied a total of {len(crr)} corrections.') self.log.debug(f'{len(krr)} from within the Case definition.') self.log.debug(f'{len(self.corrections)} from protocol-provided data.') return kase.data