<commit_before>// This file was developed by <NAME> <<EMAIL>>.
// It is published under the BSD 3-Clause License within the LICENSE file.

#include <tev/imageio/EmptyImageLoader.h>
#include <tev/ThreadPool.h>

#include <istream>

using namespace Eigen;
using namespace filesystem;
using namespace std;

TEV_NAMESPACE_BEGIN

bool EmptyImageLoader::canLoadFile(istream& iStream) const {
    char b[5];
    iStream.read(b, sizeof(b));

    bool result = !!iStream && iStream.gcount() == sizeof(b) && string(b, sizeof(b)) == "empty";

    iStream.clear();
    iStream.seekg(0);
    return result;
}

ImageData EmptyImageLoader::load(istream& iStream, const path& path, const string& channelSelector) const {
    ImageData result;

    string magic;
    Vector2i size;
    int nChannels;
    iStream >> magic >> size.x() >> size.y() >> nChannels;

    if (magic != "empty") {
        throw invalid_argument{tfm::format("Invalid magic empty string %s", magic)};
    }

    auto numPixels = (DenseIndex)size.x() * size.y();
    if (numPixels == 0) {
        throw invalid_argument{"Image has zero pixels."};
    }

    set<string> layerNames;<commit_msg>Get rid of Windows compiler warnings<commit_after>// This file was developed by <NAME> <<EMAIL>>.
// It is published under the BSD 3-Clause License within the LICENSE file.

#include <tev/imageio/EmptyImageLoader.h>
#include <tev/ThreadPool.h>

#include <istream>

using namespace Eigen;
using namespace filesystem;
using namespace std;

TEV_NAMESPACE_BEGIN

bool EmptyImageLoader::canLoadFile(istream& iStream) const {
    char b[5];
    iStream.read(b, sizeof(b));

    bool result = !!iStream && iStream.gcount() == sizeof(b) && string(b, sizeof(b)) == "empty";

    iStream.clear();
    iStream.seekg(0);
    return result;
}

ImageData EmptyImageLoader::load(istream& iStream, const path&, const string&) const {
    ImageData result;

    string magic;
    Vector2i size;
    int nChannels;
    iStream >> magic >> size.x() >> size.y() >> nChannels;

    if (magic != "empty") {
        throw invalid_argument{tfm::format("Invalid magic empty string %s", magic)};
    }

    auto numPixels = (DenseIndex)size.x() * size.y();
    if (numPixels == 0) {
        throw invalid_argument{"Image has zero pixels."};
    }

    set<string> layerNames;
{'fraction_non_alphanumeric': 0.1367595818815331, 'fraction_numerical': 0.004355400696864111, 'mean_word_length': 3.7458677685950414, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 33, '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': '5374120', 'n_tokens_mistral': 759, 'n_tokens_neox': 733, 'n_words': 208}