<commit_before>// Copyright (c) 2013, German Neuroinformatics Node (G-Node)
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted under the terms of the BSD License. See
// LICENSE file in the root of the Project.

#include <nix/util/util.hpp>

#include <nix/hdf5/DataArrayHDF5.hpp>
#include <nix/hdf5/DataSet.hpp>
#include <nix/hdf5/DimensionHDF5.hpp>

using namespace std;

namespace nix {
namespace hdf5 {

DataArrayHDF5::DataArrayHDF5(const DataArrayHDF5 &data_array)
    : EntityWithSourcesHDF5(data_array.file(), data_array.block(), data_array.group(), data_array.id(), data_array.type(), data_array.name()),
      dimension_group(data_array.dimension_group)
{
}


DataArrayHDF5::DataArrayHDF5(const File &file, const Block &block, const Group &group, 
                             const string &id, const string &type, const string &name)
    : DataArrayHDF5(file, block, group, id, type, name, util::getTime())
{
}


DataArrayHDF5::DataArrayHDF5(const File &file, const Block &block, const Group &group, 
                             const string &id, const string &type, const string &name, time_t time)
    : EntityWithSourcesHDF5(file, block, group, id, type, name, time)
{
    dimension_group = this->group().openGroup("dimensions", true);
}

//--------------------------------------------------
// Element getters and setters
//--------------------------------------------------

boost::optional<std::string> DataArrayHDF5::label() const {
    boost::optional<std::string> ret;
    string value;
    group().getAttr("label", value);
    ret = value;
    return ret;
}


void DataArrayHDF5::label(const string &label) {
    if(label.empty()) {
        throw EmptyString("label");
    }<commit_msg>[h5] DataArray: fix label getter to correctly return none<commit_after>// Copyright (c) 2013, German Neuroinformatics Node (G-Node)
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted under the terms of the BSD License. See
// LICENSE file in the root of the Project.

#include <nix/util/util.hpp>

#include <nix/hdf5/DataArrayHDF5.hpp>
#include <nix/hdf5/DataSet.hpp>
#include <nix/hdf5/DimensionHDF5.hpp>

using namespace std;

namespace nix {
namespace hdf5 {

DataArrayHDF5::DataArrayHDF5(const DataArrayHDF5 &data_array)
    : EntityWithSourcesHDF5(data_array.file(), data_array.block(), data_array.group(), data_array.id(), data_array.type(), data_array.name()),
      dimension_group(data_array.dimension_group)
{
}


DataArrayHDF5::DataArrayHDF5(const File &file, const Block &block, const Group &group, 
                             const string &id, const string &type, const string &name)
    : DataArrayHDF5(file, block, group, id, type, name, util::getTime())
{
}


DataArrayHDF5::DataArrayHDF5(const File &file, const Block &block, const Group &group, 
                             const string &id, const string &type, const string &name, time_t time)
    : EntityWithSourcesHDF5(file, block, group, id, type, name, time)
{
    dimension_group = this->group().openGroup("dimensions", true);
}

//--------------------------------------------------
// Element getters and setters
//--------------------------------------------------

boost::optional<std::string> DataArrayHDF5::label() const {
    boost::optional<std::string> ret;
    string value;
    bool have_attr = group().getAttr("label", value);

    if (have_attr) {
        ret = value;
    }

    return ret;
}


void DataArrayHDF5::label(const string &label) {
    if(label.empty()) {
        throw EmptyString("label");
    }
{'fraction_non_alphanumeric': 0.1751227495908347, 'fraction_numerical': 0.012274959083469721, 'mean_word_length': 2.9515086206896552, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '5419033', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1099, 'n_words': 302}