def test_table_to_workspace(self) -> None: r"""Test the conversion of a TableWorkspace containing the masked detector ID's to a MaskWorkspace object""" output_workspace = 'test_table_to_workspace_masked' # Have a fake mask table, masking bank 42 mask_table = CreateEmptyTableWorkspace(OutputWorkspace=output_workspace) mask_table.addColumn(type='int', name='Detector ID') begin, end = 167936, 172030 # # Bank 42 has detector ID's from 167936 to 172030 for detector_id in range(begin, 1 + end): mask_table.addRow([detector_id]) # Convert to MaskWorkspace mask_table = _table_to_workspace(mask_table) # Check the output workspace is of type MaskWorkspace assert isinstance(mask_table, MaskWorkspace) # Check the output workspace has 1 on workspace indexes for bank 42, and 0 elsewhere mask_flags = mask_table.extractY().flatten() offset = 3 # due to the detector monitors, workspace_index = detector_id + offset masked_workspace_indexes = slice(begin + offset, 1 + end + offset) assert np.all(mask_flags[masked_workspace_indexes]) # all values are 1 mask_flags = np.delete(mask_flags, masked_workspace_indexes) assert not np.any(mask_flags) # no value is 1 DeleteWorkspace(output_workspace)