<commit_before>#include <array>
#include "h5writer.h"

H5Writer::H5Writer()
{
	m_enabled = false;
	m_h5file = 0;
	m_fn.assign("");
	m_w = NULL;
}

H5Writer::~H5Writer()
{
	close();
}

bool H5Writer::open(const char *fn)
{
	if (isEnabled()) {
		return false;
	}
	// Create a new file using default properties.
	m_h5file = H5Fcreate(fn, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

	if (m_h5file < 0) {
		return false;
	}

	m_fn.assign(fn);

	fprintf(stdout,"%s: started logging to %s.\n", name(), fn);

	// we intentionally don't enable here: rather, enable in the subclasses

	return true;
}

bool H5Writer::close()
{

	if (isEnabled()) {	// subclass should have disabled already honestly.
		disable();
		fprintf(stdout,"%s: stopped logging to file\n", name());
		m_fn.clear();
	}

	if (m_h5file) {
		H5Fclose(m_h5file);
		m_h5file = 0;
	}

	return true;
}

bool H5Writer::isEnabled()
{
	return m_enabled;
}

void H5Writer::enable()
{
	m_enabled = true;
}

void H5Writer::disable()
{
	m_enabled = false;
}

size_t H5Writer::bytes()
{
	return 0;
}

string H5Writer::filename()
{
	return m_fn;
}

void H5Writer::registerWidget(GtkWidget *w)
{
	m_w = w;
}

void H5Writer::draw()
{
	if (isEnabled()) {

		std::array<std::string, 5> u = {"B", "kB", "MB", "GB", "TB"};

		int i = 0;
		auto b = bytes();

		while (b > 1e3) {
			b \= 1e3;
			i++;
		}

		size_t n = filename().find_last_of("/");
		char str[256];
		snprintf(str, 256, "%s: %.2f %s",
		         filename().substr(n+1).c_str(), b, u[i].c_str());
		gtk_label_set_text(GTK_LABEL(m_w), str);
	}
}
<commit_msg>oops, it's /= not \= (i've been doing too much mldivide in matlab<commit_after>#include <array>
#include "h5writer.h"

H5Writer::H5Writer()
{
	m_enabled = false;
	m_h5file = 0;
	m_fn.assign("");
	m_w = NULL;
}

H5Writer::~H5Writer()
{
	close();
}

bool H5Writer::open(const char *fn)
{
	if (isEnabled()) {
		return false;
	}
	// Create a new file using default properties.
	m_h5file = H5Fcreate(fn, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

	if (m_h5file < 0) {
		return false;
	}

	m_fn.assign(fn);

	fprintf(stdout,"%s: started logging to %s.\n", name(), fn);

	// we intentionally don't enable here: rather, enable in the subclasses

	return true;
}

bool H5Writer::close()
{

	if (isEnabled()) {	// subclass should have disabled already honestly.
		disable();
		fprintf(stdout,"%s: stopped logging to file\n", name());
		m_fn.clear();
	}

	if (m_h5file) {
		H5Fclose(m_h5file);
		m_h5file = 0;
	}

	return true;
}

bool H5Writer::isEnabled()
{
	return m_enabled;
}

void H5Writer::enable()
{
	m_enabled = true;
}

void H5Writer::disable()
{
	m_enabled = false;
}

size_t H5Writer::bytes()
{
	return 0;
}

string H5Writer::filename()
{
	return m_fn;
}

void H5Writer::registerWidget(GtkWidget *w)
{
	m_w = w;
}

void H5Writer::draw()
{
	if (isEnabled()) {

		std::array<std::string, 5> u { {"B", "kB", "MB", "GB", "TB"} };

		int i = 0;
		double b = bytes();

		while (b > 1e3) {
			b /= 1e3;
			i++;
		}

		size_t n = filename().find_last_of("/");
		char str[256];
		snprintf(str, 256, "%s: %.2f %s",
		         filename().substr(n+1).c_str(), b, u[i].c_str());
		gtk_label_set_text(GTK_LABEL(m_w), str);
	}
}

{'fraction_non_alphanumeric': 0.1824196597353497, 'fraction_numerical': 0.027095148078134845, 'mean_word_length': 3.8106060606060606, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7102592', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1356, 'n_words': 306}