<commit_before>#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <cmath>
#include <array>
#include <vector>

/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

namespace py = pybind11;
using std::pow;

static double make_asym_func(
    py::array_t<double, py::array::c_style | py::array::forcecast> dataIn,
    py::array_t<double, py::array::c_style | py::array::forcecast> weightsIn,
    int w_truth
    ){
    // Retrieve the numpy buffer objects
    auto data = dataIn.request(),
         weights = weightsIn.request();

    // Check that the input arrays are conditioned appropriately
    if (data.ndim != 2 || weights.ndim !=2)
        throw std::runtime_error("Input arrays must be two dimensional");

    if (data.shape[0] != weights.shape[0] || data.shape[1] != weights.shape[1])
        throw std::runtime_error("Shape of data and distance arrays unequal");

    if (data.shape[0] != data.shape[1])
        throw std::runtime_error("Arrays must be square");

    if (data.shape[0] %2 == 0)
        throw std::runtime_error("Array dimensions must be odd");

    // Determine the radius of the array and calculate how many unique descrete
    // radii that corresponds to, and use that to construct a vector of arrays
    // to contain the results of calcuations for each radial bin
    int halfSize = (data.shape[0]-1)/2;
    int equationDim = (halfSize+1)*halfSize/2+halfSize;
    std::vector<std::array<double, 5> > EquationArray(equationDim);
    // Enumerate the indicies for the array corresponding to each radii for
    // more readable code
    enum EquationTerms {weight_sum, sum_weight_mean, quad, lin, count};
    // Declare variables used in actual calculations
    int index, x, y;
    double mu, core, asym, var;
    // Get pointers to the underlying c style array of the numpy objects
    double *dataPtr = (double *) data.ptr,
           *weightsPtr = (double *) weights.ptr;
    // Initialize the asymmetry value to zero
    asym = 0;

    for (int dis_i = 0; dis_i < data.shape[0]; dis_i++){
        for(int dis_j = 0; dis_j < data.shape[1]; dis_j++){
            /*
            Instead of looping over each radial bin in a distance array,
            we make note that we can calculate what position in the set of
            possible radii a given pixel at i,j corresponds to. using that
            information it is possible to simply refer to a vector that contains
            results of calculations for that particular radius, and append to<commit_msg>Fix off by one bug<commit_after>#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <cmath>
#include <array>
#include <vector>

/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

namespace py = pybind11;
using std::pow;

static double make_asym_func(
    py::array_t<double, py::array::c_style | py::array::forcecast> dataIn,
    py::array_t<double, py::array::c_style | py::array::forcecast> weightsIn,
    int w_truth
    ){
    // Retrieve the numpy buffer objects
    auto data = dataIn.request(),
         weights = weightsIn.request();

    // Check that the input arrays are conditioned appropriately
    if (data.ndim != 2 || weights.ndim !=2)
        throw std::runtime_error("Input arrays must be two dimensional");

    if (data.shape[0] != weights.shape[0] || data.shape[1] != weights.shape[1])
        throw std::runtime_error("Shape of data and distance arrays unequal");

    if (data.shape[0] != data.shape[1])
        throw std::runtime_error("Arrays must be square");

    if (data.shape[0] %2 == 0)
        throw std::runtime_error("Array dimensions must be odd");

    // Determine the radius of the array and calculate how many unique descrete
    // radii that corresponds to, and use that to construct a vector of arrays
    // to contain the results of calcuations for each radial bin
    int halfSize = (data.shape[0]-1)/2;
    int equationDim = (halfSize+1)*halfSize/2+halfSize+1;
    std::vector<std::array<double, 5> > EquationArray(equationDim);
    // Enumerate the indicies for the array corresponding to each radii for
    // more readable code
    enum EquationTerms {weight_sum, sum_weight_mean, quad, lin, count};
    // Declare variables used in actual calculations
    int index, x, y;
    double mu, core, asym, var;
    // Get pointers to the underlying c style array of the numpy objects
    double *dataPtr = (double *) data.ptr,
           *weightsPtr = (double *) weights.ptr;
    // Initialize the asymmetry value to zero
    asym = 0;

    for (int dis_i = 0; dis_i < data.shape[0]; dis_i++){
        for(int dis_j = 0; dis_j < data.shape[1]; dis_j++){
            /*
            Instead of looping over each radial bin in a distance array,
            we make note that we can calculate what position in the set of
            possible radii a given pixel at i,j corresponds to. using that
            information it is possible to simply refer to a vector that contains
            results of calculations for that particular radius, and append to
{'fraction_non_alphanumeric': 0.10414711953462188, 'fraction_numerical': 0.012948020266466504, 'mean_word_length': 3.0594059405940595, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, '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': '1435819', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1514, 'n_words': 603}