def test_GIVEN_slit_edges_list_has_overlapping_slits_WHEN_validating_chopper_input_THEN_returns_false( chopper_checker, ): chopper_checker.fields_dict[SLIT_EDGES_NAME].values[-1] = ( chopper_checker.fields_dict[SLIT_EDGES_NAME].values[0] + 365) assert chopper_checker.required_fields_present() assert chopper_checker._data_has_correct_type() assert _edges_array_has_correct_shape( chopper_checker.fields_dict[SLIT_EDGES_NAME].values.ndim, chopper_checker.fields_dict[SLIT_EDGES_NAME].values.shape, ) assert not chopper_checker.validate_chopper()
def test_GIVEN_slit_height_is_larger_than_radius_WHEN_validating_chopper_input_THEN_returns_false( chopper_checker, ): chopper_checker.fields_dict[SLITS_NAME] = create_dataset( SLITS_NAME, ValueTypes.INT, 201) assert chopper_checker.required_fields_present() assert chopper_checker._data_has_correct_type() assert _edges_array_has_correct_shape( chopper_checker.fields_dict[SLIT_EDGES_NAME].values.ndim, chopper_checker.fields_dict[SLIT_EDGES_NAME].values.shape, ) assert not chopper_checker.validate_chopper()
def test_GIVEN_mismatch_between_slits_and_slit_edges_array_WHEN_validating_chopper_input_THEN_returns_false( chopper_checker, ): chopper_checker.fields_dict[SLITS_NAME] = create_dataset( SLITS_NAME, ValueTypes.INT, 5) assert chopper_checker.required_fields_present() assert chopper_checker._data_has_correct_type() assert _edges_array_has_correct_shape( chopper_checker.fields_dict[SLIT_EDGES_NAME].values.ndim, chopper_checker.fields_dict[SLIT_EDGES_NAME].values.shape, ) assert not chopper_checker.validate_chopper()
def test_GIVEN_slit_height_and_radius_are_equal_WHEN_validating_chopper_input_THEN_returns_false( chopper_checker, ): dataset_val = 20 slit_height_dataset = create_dataset(SLIT_HEIGHT_NAME, ValueTypes.INT, dataset_val) chopper_checker.fields_dict[SLIT_HEIGHT_NAME].value = slit_height_dataset chopper_checker.fields_dict[RADIUS_NAME].values = dataset_val assert chopper_checker.required_fields_present() assert chopper_checker._data_has_correct_type() assert _edges_array_has_correct_shape( chopper_checker.fields_dict[SLIT_EDGES_NAME].values.ndim, chopper_checker.fields_dict[SLIT_EDGES_NAME].values.shape, ) assert not chopper_checker.validate_chopper()
def test_GIVEN_row_shaped_edges_array_WHEN_validating_disk_chopper_THEN_edges_array_has_correct_shape_returns_true( ): row_array = np.ones(shape=(1, 5)) assert _edges_array_has_correct_shape(row_array.ndim, row_array.shape)
def test_GIVEN_column_shaped_edges_array_WHEN_validating_disk_chopper_THEN_edges_array_has_correct_shape_returns_true( ): column_array = np.ones(shape=(5, 1)) assert _edges_array_has_correct_shape(column_array.ndim, column_array.shape)
def test_GIVEN_edges_array_with_two_dimensions_WHEN_validating_disk_chopper_THEN_edges_array_has_correct_shape_returns_false( ): two_dim_array = np.ones(shape=(5, 5)) assert not _edges_array_has_correct_shape(two_dim_array.ndim, two_dim_array.shape)
def test_GIVEN_edges_array_with_valid_shape_WHEN_validating_disk_chopper_THEN_edges_array_has_correct_shape_returns_true( ): valid_array = np.array([i for i in range(6)]) assert _edges_array_has_correct_shape(valid_array.ndim, valid_array.shape)