<commit_before>"""The WaveBlocks Project

IOM plugin providing functions for handling autocorrelation data.

@author: <NAME>
@copyright: Copyright (C) 2012, 2013 <NAME>
@license: Modified BSD License
"""

import numpy as np


def add_autocorrelation(self, parameters, timeslots=None, blockid=0):
    r"""Add storage for the auto correlation computations.

    :param parameters: A :py:class:`ParameterProvider` instance containing
                       at least the key `ncomponents`.
    :param timeslots: The number of time slots we need. Can be set to ``None``
                      to get automatically growing datasets.
    :param blockid: The ID of the data block to operate on.
    """
    N = parameters["ncomponents"]

    if timeslots is None:
        T = 0
        Ts = None
        csTs = 64
    else:
        T = timeslots
        Ts = timeslots
        csTs = min(64, Ts)

    # Check that the "observables" group is present
    grp_ob = self._srf[self._prefixb+str(blockid)].require_group("observables")
    # Create the dataset with appropriate parameters
    grp_ac = grp_ob.create_group("autocorrelation")
    daset_tg = grp_ac.create_dataset("timegrid", (T,), dtype=np.integer, chunks=True, maxshape=(Ts,))
    grp_ac.create_dataset("autocorrelation", (T, N), dtype=np.complexfloating, chunks=(csTs, N), maxshape=(Ts, N))
    daset_tg.attrs["pointer"] = 0


def delete_autocorrelation(self, blockid=0):
    r"""Remove the stored autocorrelations.

    :param blockid: The ID of the data block to operate on.
    """
    try:
        del self._srf[self._prefixb+str(blockid)+"/observables/autocorrelation"]
        # Check if there are other children, if not remove the whole node.
        if len(self._srf[self._prefixb+str(blockid)+"/observables"].keys()) == 0:
            del self._srf[self._prefixb+str(blockid)+"/observables"]
    except KeyError:
        pass


def has_autocorrelation(self, blockid=0):
    r"""Ask if the specified data block has the desired data tensor.

    :param blockid: The ID of the data block to operate on.<commit_msg>Fix missing fill value<commit_after>"""The WaveBlocks Project

IOM plugin providing functions for handling autocorrelation data.

@author: <NAME>
@copyright: Copyright (C) 2012, 2013 <NAME>
@license: Modified BSD License
"""

import numpy as np


def add_autocorrelation(self, parameters, timeslots=None, blockid=0):
    r"""Add storage for the auto correlation computations.

    :param parameters: A :py:class:`ParameterProvider` instance containing
                       at least the key `ncomponents`.
    :param timeslots: The number of time slots we need. Can be set to ``None``
                      to get automatically growing datasets.
    :param blockid: The ID of the data block to operate on.
    """
    N = parameters["ncomponents"]

    if timeslots is None:
        T = 0
        Ts = None
        csTs = 64
    else:
        T = timeslots
        Ts = timeslots
        csTs = min(64, Ts)

    # Check that the "observables" group is present
    grp_ob = self._srf[self._prefixb+str(blockid)].require_group("observables")
    # Create the dataset with appropriate parameters
    grp_ac = grp_ob.create_group("autocorrelation")
    daset_tg = grp_ac.create_dataset("timegrid", (T,), dtype=np.integer, chunks=True, maxshape=(Ts,), fillvalue=-1)
    grp_ac.create_dataset("autocorrelation", (T, N), dtype=np.complexfloating, chunks=(csTs, N), maxshape=(Ts, N))
    daset_tg.attrs["pointer"] = 0


def delete_autocorrelation(self, blockid=0):
    r"""Remove the stored autocorrelations.

    :param blockid: The ID of the data block to operate on.
    """
    try:
        del self._srf[self._prefixb+str(blockid)+"/observables/autocorrelation"]
        # Check if there are other children, if not remove the whole node.
        if len(self._srf[self._prefixb+str(blockid)+"/observables"].keys()) == 0:
            del self._srf[self._prefixb+str(blockid)+"/observables"]
    except KeyError:
        pass


def has_autocorrelation(self, blockid=0):
    r"""Ask if the specified data block has the desired data tensor.

    :param blockid: The ID of the data block to operate on.
{'fraction_non_alphanumeric': 0.10636254501800721, 'fraction_numerical': 0.008883553421368547, 'mean_word_length': 3.259713701431493, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3388479', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1237, 'n_words': 401}