<commit_before>
import numpy as np
from scipy.stats import binned_statistic


def pspec(psd2, nbins=None, return_stddev=False, binsize=1.0,
          logspacing=True, max_bin=None, min_bin=None, return_freqs=True):
    '''
    Calculate the radial profile using scipy.stats.binned_statistic.

    Parameters
    ----------
    psd2 : np.ndarray
        2D Spectral power density.
    nbins : int, optional
        Number of bins to use. If None, it is calculated based on the size
        of the given arrays.
    return_stddev : bool, optional
        Return the standard deviations in each bin.
    binsize : float, optional
        Size of bins to be used. If logspacing is enabled, this will increase
        the number of bins used by the inverse of the given binsize.
    logspacing : bool, optional
        Use logarithmically spaces bins.
    max_bin : float, optional
        Give the maximum value to bin to.
    min_bin : float, optional
        Give the minimum value to bin to.
    return_freqs : bool, optional
        Return spatial frequencies.

    Returns
    -------
    bins_cents : np.ndarray
        Centre of the bins.
    ps1D : np.ndarray
        1D binned power spectrum.
    ps1D_stddev : np.ndarray
        Returned when return_stddev is enabled. Standard deviations
        within each of the bins.
    '''

    y = np.arange(psd2.shape[0] - np.floor(psd2.shape[0]/2.).astype(int))
    x = np.arange(psd2.shape[1] - np.floor(psd2.shape[1]/2.).astype(int))

    yy, xx = np.meshgrid(y, x)

    dists = np.sqrt(yy**2 + xx**2)

    if nbins is None:
        nbins = int(np.round(dists.max() / binsize)+1)

    if return_freqs:
        yfreqs = np.fft.fftshift(np.abs(np.fft.fftfreq(psd2.shape[0])))
        xfreqs = np.fft.fftshift(np.abs(np.fft.fftfreq(psd2.shape[1])))<commit_msg>Start -1/2 of array<commit_after>
import numpy as np
from scipy.stats import binned_statistic


def pspec(psd2, nbins=None, return_stddev=False, binsize=1.0,
          logspacing=True, max_bin=None, min_bin=None, return_freqs=True):
    '''
    Calculate the radial profile using scipy.stats.binned_statistic.

    Parameters
    ----------
    psd2 : np.ndarray
        2D Spectral power density.
    nbins : int, optional
        Number of bins to use. If None, it is calculated based on the size
        of the given arrays.
    return_stddev : bool, optional
        Return the standard deviations in each bin.
    binsize : float, optional
        Size of bins to be used. If logspacing is enabled, this will increase
        the number of bins used by the inverse of the given binsize.
    logspacing : bool, optional
        Use logarithmically spaces bins.
    max_bin : float, optional
        Give the maximum value to bin to.
    min_bin : float, optional
        Give the minimum value to bin to.
    return_freqs : bool, optional
        Return spatial frequencies.

    Returns
    -------
    bins_cents : np.ndarray
        Centre of the bins.
    ps1D : np.ndarray
        1D binned power spectrum.
    ps1D_stddev : np.ndarray
        Returned when return_stddev is enabled. Standard deviations
        within each of the bins.
    '''

    y = np.arange(-np.floor(psd2.shape[0]/2.).astype(int),
                  psd2.shape[0] - np.floor(psd2.shape[0]/2.).astype(int))
    x = np.arange(-np.floor(psd2.shape[1]/2.).astype(int),
                  psd2.shape[1] - np.floor(psd2.shape[1]/2.).astype(int))

    yy, xx = np.meshgrid(y, x)

    dists = np.sqrt(yy**2 + xx**2)

    if nbins is None:
        nbins = int(np.round(dists.max() / binsize)+1)

    if return_freqs:
        yfreqs = np.fft.fftshift(np.abs(np.fft.fftfreq(psd2.shape[0])))
        xfreqs = np.fft.fftshift(np.abs(np.fft.fftfreq(psd2.shape[1])))
{'fraction_non_alphanumeric': 0.10481283422459893, 'fraction_numerical': 0.015508021390374332, 'mean_word_length': 2.38245931283906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2986248', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1232, 'n_words': 356}