<commit_before>// -*- c++ -*-
/*
 * Copyright (c) 2010-2012, <NAME>
 * All rights reserved.
 *
 * ndarray is distributed under a simple BSD-like license;
 * see the LICENSE file that should be present in the root
 * of the source distribution, or alternately available at:
 * https://github.com/ndarray/ndarray
 */
#ifndef NDARRAY_BP_Array_h_INCLUDED
#define NDARRAY_BP_Array_h_INCLUDED

#include "boost/numpy.hpp"
#include "ndarray.h"
#include "ndarray/bp_fwd.h"
#include <vector>

namespace ndarray {
namespace detail {

inline void destroyManagerCObject(void * p) {
    Manager::Ptr * b = reinterpret_cast<Manager::Ptr*>(p);
    delete b;
}

inline boost::python::object makePyObject(Manager::Ptr const & x) {
    boost::intrusive_ptr< ExternalManager<boost::python::object> > y
        = boost::dynamic_pointer_cast< ExternalManager<boost::python::object> >(x);
    if (y) {
        return y->getOwner();
    }
    boost::python::handle<> h(::PyCObject_FromVoidPtr(new Manager::Ptr(x), &destroyManagerCObject));
    return boost::python::object(h);
}

} // namespace detail

template <typename T, int N, int C>
class ToBoostPython< Array<T,N,C> > {<commit_msg>Use Capsule instead of PyObject for Python 3<commit_after>// -*- c++ -*-
/*
 * Copyright (c) 2010-2012, <NAME>
 * All rights reserved.
 *
 * ndarray is distributed under a simple BSD-like license;
 * see the LICENSE file that should be present in the root
 * of the source distribution, or alternately available at:
 * https://github.com/ndarray/ndarray
 */
#ifndef NDARRAY_BP_Array_h_INCLUDED
#define NDARRAY_BP_Array_h_INCLUDED

#include "boost/numpy.hpp"
#include "ndarray.h"
#include "ndarray/bp_fwd.h"
#include <vector>

namespace ndarray {
namespace detail {

inline void destroyManagerCObject(void * p) {
    Manager::Ptr * b = reinterpret_cast<Manager::Ptr*>(p);
    delete b;
}

inline boost::python::object makePyObject(Manager::Ptr const & x) {
    boost::intrusive_ptr< ExternalManager<boost::python::object> > y
        = boost::dynamic_pointer_cast< ExternalManager<boost::python::object> >(x);
    if (y) {
        return y->getOwner();
    }
#if PY_MAJOR_VERSION == 2
    boost::python::handle<> h(::PyCObject_FromVoidPtr(new Manager::Ptr(x), &destroyManagerCObject));
#else
    boost::python::handle<> h(::PyCapsule_New(new Manager::Ptr(x), 0, (PyCapsule_Destructor)&destroyManagerCObject));
#endif
    return boost::python::object(h);
}

} // namespace detail

template <typename T, int N, int C>
class ToBoostPython< Array<T,N,C> > {
{'fraction_non_alphanumeric': 0.14109697933227344, 'fraction_numerical': 0.007551669316375199, 'mean_word_length': 4.812933025404157, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 28, 'https://': 2, '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': '1044738', 'n_tokens_mistral': 846, 'n_tokens_neox': 825, 'n_words': 207}