<commit_before>#include <iostream>
#include <array>
#include <chrono>
#include <vector>
#include <memory>
#include <random>
#include "linalg/util.h"
#include "samplers/ld_sampler.h"
#include "samplers/adaptive_sampler.h"

AdaptiveSampler::AdaptiveSampler(int x_start, int x_end, int y_start, int y_end, int min_sp, int max_sp)
	: Sampler{x_start, x_end, y_start, y_end}, min_spp(round_up_pow2(min_sp)), max_spp(round_up_pow2(max_sp)),
	supersample_px(false),
	rng(std::chrono::duration_cast<std::chrono::milliseconds>(
		std::chrono::high_resolution_clock::now().time_since_epoch()).count())
{
	if (min_sp % 2 != 0){
		std::cout << "Warning: AdaptiveSampler requires power of 2 samples per pixel."
			<< " Rounded min_spp up to " << min_spp << std::endl;
	}
	if (max_sp % 2 != 0){
		std::cout << "Warning: AdaptiveSampler requires power of 2 samples per pixel."
			<< " Rounded max_spp up to " << max_spp << std::endl;
	}
}
void AdaptiveSampler::get_samples(std::vector<Sample> &samples){
	samples.clear();
	if (!has_samples()){
		return;
	}
	int spp = supersample_px ? max_spp : min_spp;
	samples.resize(spp);
	std::vector<std::array<float, 2>> pos(spp), lens(spp);
	LDSampler::sample2d(pos, distrib(rng), distrib(rng));
	LDSampler::sample2d(lens, distrib(rng), distrib(rng));<commit_msg>Check that we aren't trying to supersample the last pixel<commit_after>#include <iostream>
#include <array>
#include <chrono>
#include <vector>
#include <memory>
#include <random>
#include "linalg/util.h"
#include "samplers/ld_sampler.h"
#include "samplers/adaptive_sampler.h"

AdaptiveSampler::AdaptiveSampler(int x_start, int x_end, int y_start, int y_end, int min_sp, int max_sp)
	: Sampler{x_start, x_end, y_start, y_end}, min_spp(round_up_pow2(min_sp)), max_spp(round_up_pow2(max_sp)),
	supersample_px(false),
	rng(std::chrono::duration_cast<std::chrono::milliseconds>(
		std::chrono::high_resolution_clock::now().time_since_epoch()).count())
{
	if (min_sp % 2 != 0){
		std::cout << "Warning: AdaptiveSampler requires power of 2 samples per pixel."
			<< " Rounded min_spp up to " << min_spp << std::endl;
	}
	if (max_sp % 2 != 0){
		std::cout << "Warning: AdaptiveSampler requires power of 2 samples per pixel."
			<< " Rounded max_spp up to " << max_spp << std::endl;
	}
}
void AdaptiveSampler::get_samples(std::vector<Sample> &samples){
	samples.clear();
	if (!supersample_px && !has_samples()){
		return;
	}
	int spp = supersample_px ? max_spp : min_spp;
	samples.resize(spp);
	std::vector<std::array<float, 2>> pos(spp), lens(spp);
	LDSampler::sample2d(pos, distrib(rng), distrib(rng));
	LDSampler::sample2d(lens, distrib(rng), distrib(rng));
{'fraction_non_alphanumeric': 0.16357440363498674, 'fraction_numerical': 0.008330177962892843, 'mean_word_length': 6.591954022988506, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 23, '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': '3377956', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1032, 'n_words': 213}