<commit_before>package imagej.dataset;

import static org.junit.Assert.*;
import imagej.data.Types;

import org.junit.Test;

public class PrimitiveDatasetCreatorTest
{
	private PrimitiveDatasetCreator creator;
	private DatasetFactory factory;
	
	@Test
	public void testPrimitiveDatasetCreator()
	{
		this.factory = new PlanarDatasetFactory();
		this.creator = new PrimitiveDatasetCreator(factory);
		assertNotNull(this.creator);
	}

	@Test
	public void testCreateDataset() {
		this.factory = new PlanarDatasetFactory();
		this.creator = new PrimitiveDatasetCreator(factory);
		assertNotNull(this.creator);
		
		Dataset ds;
		int[] dimensions;
		
		/* 
		 * 1-bit from boolean[] will not work since boolean[] does not match the Type's internal storage (which matches Imglib)
		 * 
		ds = this.creator.createDataset(dimensions, false, new boolean[]{false, true, true});
		assertEquals(Types.findType("1-bit signed"), ds.getType());
		assertArrayEquals(dimensions, ds.getDimensions());
		assertEquals(0, ds.getLong(new int[]{0,0}));
		assertEquals(1, ds.getLong(new int[]{0,1}));
		assertEquals(1, ds.getLong(new int[]{0,2}));
		*/
		
		// signed 8-bit
		dimensions = new int[]{1,3};
		ds = this.creator.createDataset(dimensions, false, new byte[]{-5, 0, 5});
		assertFalse(ds.getType().isFloat());
		assertFalse(ds.getType().isUnsigned());
		assertEquals(Byte.MIN_VALUE, ds.getType().getMinIntegral());
		assertEquals(Byte.MAX_VALUE, ds.getType().getMaxIntegral());
		assertArrayEquals(dimensions, ds.getDimensions());
		assertEquals(-5, ds.getLong(new int[]{0,0}));<commit_msg>add test for 1-bit unsigned creation from a boolean[]<commit_after>package imagej.dataset;

import static org.junit.Assert.*;
import imagej.data.Types;

import org.junit.Test;

public class PrimitiveDatasetCreatorTest
{
	private PrimitiveDatasetCreator creator;
	private DatasetFactory factory;
	
	@Test
	public void testPrimitiveDatasetCreator()
	{
		this.factory = new PlanarDatasetFactory();
		this.creator = new PrimitiveDatasetCreator(factory);
		assertNotNull(this.creator);
	}

	@Test
	public void testCreateDataset() {
		this.factory = new PlanarDatasetFactory();
		this.creator = new PrimitiveDatasetCreator(factory);
		assertNotNull(this.creator);
		
		Dataset ds;
		int[] dimensions;
		
		/* 
		 * 1-bit from boolean[] will not work since boolean[] does not match the Type's internal storage (which matches Imglib)
		 * 
		*/
		dimensions = new int[]{1,3};
		ds = this.creator.createDataset(dimensions, false, new boolean[]{false, true, true});
		assertEquals(Types.findType("1-bit unsigned"), ds.getType());
		assertArrayEquals(dimensions, ds.getDimensions());
		assertEquals(0, ds.getLong(new int[]{0,0}));
		assertEquals(1, ds.getLong(new int[]{0,1}));
		assertEquals(1, ds.getLong(new int[]{0,2}));
		
		// signed 8-bit
		dimensions = new int[]{1,3};
		ds = this.creator.createDataset(dimensions, false, new byte[]{-5, 0, 5});
		assertFalse(ds.getType().isFloat());
		assertFalse(ds.getType().isUnsigned());
		assertEquals(Byte.MIN_VALUE, ds.getType().getMinIntegral());
		assertEquals(Byte.MAX_VALUE, ds.getType().getMaxIntegral());
		assertArrayEquals(dimensions, ds.getDimensions());
		assertEquals(-5, ds.getLong(new int[]{0,0}));
{'fraction_non_alphanumeric': 0.14511627906976743, 'fraction_numerical': 0.013333333333333334, 'mean_word_length': 5.325490196078431, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6273892', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1035, 'n_words': 222}