<commit_before>/*
 *  npy_calculation.c - 
 *  
 */

#define _MULTIARRAYMODULE
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "npy_config.h"
#include "numpy/numpy_api.h"



NpyArray *
NpyArray_ArgMax(NpyArray *op, int axis, NpyArray *out)
{
    NpyArray *ap = NULL, *rp = NULL;
    NpyArray_ArgFunc *arg_func;
    char *ip;
    npy_intp *rptr;
    npy_intp i, n, m;
    int elsize;
    int copyret = 0;
    NPY_BEGIN_THREADS_DEF;
    
    if ((ap=NpyArray_CheckAxis(op, &axis, 0)) == NULL) {
        return NULL;
    }
    
    /*
     * We need to permute the array so that axis is placed at the end.
     * And all other dimensions are shifted left.
     */
    if (axis != ap->nd-1) {
        NpyArray_Dims newaxes;
        npy_intp dims[NPY_MAXDIMS];
        int i;
        
        newaxes.ptr = dims;
        newaxes.len = ap->nd;
        for (i = 0; i < axis; i++) dims[i] = i;
        for (i = axis; i < ap->nd - 1; i++) dims[i] = i + 1;
        dims[ap->nd - 1] = axis;
        op = NpyArray_Transpose(ap, &newaxes);
        Py_DECREF(ap);
        if (op == NULL) {
            return NULL;
        }
    }
    else {
        op = ap;
    }
    
    /* Will get native-byte order contiguous copy. */
    ap = NpyArray_ContiguousFromArray(op, op->descr->type_num);
    _Npy_DECREF(op);
    if (ap == NULL) {
        return NULL;
    }
    arg_func = ap->descr->f->argmax;
    if (arg_func == NULL) {<commit_msg>Fixed crash --with-pydebug caused by a bad Py_DECREF call.<commit_after>/*
 *  npy_calculation.c - 
 *  
 */

#define _MULTIARRAYMODULE
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "npy_config.h"
#include "numpy/numpy_api.h"



NpyArray *
NpyArray_ArgMax(NpyArray *op, int axis, NpyArray *out)
{
    NpyArray *ap = NULL, *rp = NULL;
    NpyArray_ArgFunc *arg_func;
    char *ip;
    npy_intp *rptr;
    npy_intp i, n, m;
    int elsize;
    int copyret = 0;
    NPY_BEGIN_THREADS_DEF;
    
    if ((ap=NpyArray_CheckAxis(op, &axis, 0)) == NULL) {
        return NULL;
    }
    
    /*
     * We need to permute the array so that axis is placed at the end.
     * And all other dimensions are shifted left.
     */
    if (axis != ap->nd-1) {
        NpyArray_Dims newaxes;
        npy_intp dims[NPY_MAXDIMS];
        int i;
        
        newaxes.ptr = dims;
        newaxes.len = ap->nd;
        for (i = 0; i < axis; i++) dims[i] = i;
        for (i = axis; i < ap->nd - 1; i++) dims[i] = i + 1;
        dims[ap->nd - 1] = axis;
        op = NpyArray_Transpose(ap, &newaxes);
        _Npy_DECREF(ap);
        if (op == NULL) {
            return NULL;
        }
    }
    else {
        op = ap;
    }
    
    /* Will get native-byte order contiguous copy. */
    ap = NpyArray_ContiguousFromArray(op, op->descr->type_num);
    _Npy_DECREF(op);
    if (ap == NULL) {
        return NULL;
    }
    arg_func = ap->descr->f->argmax;
    if (arg_func == NULL) {
{'fraction_non_alphanumeric': 0.1331493618489134, 'fraction_numerical': 0.004829251466022766, 'mean_word_length': 1.9804727646454265, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, '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': '1548201', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1132, 'n_words': 276}