<commit_before>import numpy as np


def read_binary(filename, nx, ny, nz, dsize, headersize):
    """
    docstring, woo!

    Parameters
    ----------
    filename: String
              The name of the file to open
    nx: integer
        The number of data elements in the x-direction
    ny: integer
        The number of data elements in the y-direction
    nz: integer
        The number of data elements in the z-direction
    dsize: numpy data type
           The size of each element in the numpy array
    headersize: integer
                The size of the file header in bytes

    Returns
    -------
    (data, header)
    data: ndarray
            data.shape = (x, y, z) if z > 1
            data.shape = (x, y) if z == 1
            data.shape = (x,) if y == 1 && z == 1
    header: String
            header = file.read(headersize)
    """

    opened_file = open(filename, "rb")

    # read the file header
    header = opened_file.read(headersize)

    data = np.fromfile(opened_file, dsize, -1)

    if nz is not 1:
        data.resize(nx, ny, nz)
    elif ny is not 1:
        data.resize(nx, ny)

    return data, header<commit_msg>DOC: Added documentation for read_binary<commit_after>import numpy as np


def read_binary(filename, nx, ny, nz, dsize, headersize):
    """
    docstring, woo!

    Parameters
    ----------
    filename: String
              The name of the file to open
    nx: integer
        The number of data elements in the x-direction
    ny: integer
        The number of data elements in the y-direction
    nz: integer
        The number of data elements in the z-direction
    dsize: numpy data type
           The size of each element in the numpy array
    headersize: integer
                The size of the file header in bytes

    Returns
    -------
    (data, header)
    data: ndarray
            data.shape = (x, y, z) if z > 1
            data.shape = (x, y) if z == 1
            data.shape = (x,) if y == 1 && z == 1
    header: String
            header = file.read(headersize)
    """

    # open the file
    opened_file = open(filename, "rb")

    # read the file header
    header = opened_file.read(headersize)

    # read the entire file in as 1D list
    data = np.fromfile(opened_file, dsize, -1)

    # reshape the array to 3D
    if nz is not 1:
        data.resize(nx, ny, nz)
    # unless the 3rd dimension is 1, in which case reshape the array to 2D
    elif ny is not 1:
        data.resize(nx, ny)
    # unless the 2nd dimension is also 1, in which case leave the array as 1D

    # return the array and the header
    return data, header
{'fraction_non_alphanumeric': 0.08674054260603745, 'fraction_numerical': 0.008406572411157814, 'mean_word_length': 1.8832599118942732, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5032725', 'n_tokens_mistral': 811, 'n_tokens_neox': 760, 'n_words': 326}