<commit_before># -*- Mode: Python -*-  

"""
Markov random field utils. 
"""

__version__ = '0.0'

# Includes
from numpy cimport import_array, ndarray

# Externals
cdef extern from "mrf.h":
    
    void mrf_import_array()
    void ve_step(ndarray ppm, 
                 ndarray ref,
                 ndarray XYZ, 
                 ndarray mix, 
                 double beta, 
                 int copy, 
                 int hard)
    double concensus(ndarray ppm, 
		     ndarray XYZ, 
                     ndarray mix)


# Initialize numpy
mrf_import_array()
import_array()
import numpy as np


def _ve_step(ppm, ref, XYZ, double beta, int copy, int hard):
    
    if not ppm.flags['C_CONTIGUOUS'] or not ppm.dtype=='double':
        raise ValueError('ppm array should be double C-contiguous')

    if not ref.flags['C_CONTIGUOUS'] or not ref.dtype=='double':
        raise ValueError('ref array should be double C-contiguous')
    
    XYZ = np.asarray(XYZ, dtype='int')
    
    ve_step(<ndarray>ppm, <ndarray>ref, <ndarray>XYZ, None, beta, copy, hard)
    return ppm 


def _concensus(ppm, XYZ): 
    return concensus(<ndarray>ppm, <ndarray>XYZ, None) 
<commit_msg>cython modifs<commit_after># -*- Mode: Python -*-  

"""
Markov random field utils. 
"""

__version__ = '0.0'

# Includes
from numpy cimport import_array, ndarray

# Externals
cdef extern from "mrf.h":
    
    void mrf_import_array()
    void ve_step(ndarray ppm, 
                 ndarray ref,
                 ndarray XYZ, 
                 ndarray mix, 
                 double beta, 
                 int copy, 
                 int hard)
    double concensus(ndarray ppm, 
		     ndarray XYZ, 
                     ndarray mix)


# Initialize numpy
mrf_import_array()
import_array()
import numpy as np


def _ve_step(ppm, ref, XYZ, double beta, int copy, int hard, mix=None):
    
    if not ppm.flags['C_CONTIGUOUS'] or not ppm.dtype=='double':
        raise ValueError('ppm array should be double C-contiguous')

    if not ref.flags['C_CONTIGUOUS'] or not ref.dtype=='double':
        raise ValueError('ref array should be double C-contiguous')
    
    XYZ = np.asarray(XYZ, dtype='int')
    
    ve_step(<ndarray>ppm, <ndarray>ref, <ndarray>XYZ, <ndarray>mix, 
             beta, copy, hard)
    return ppm 


def _concensus(ppm, XYZ, mix=None): 
    return concensus(<ndarray>ppm, <ndarray>XYZ, <ndarray>mix) 

{'fraction_non_alphanumeric': 0.10526315789473684, 'fraction_numerical': 0.001670843776106934, 'mean_word_length': 2.280821917808219, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 15, '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': '5269351', 'n_tokens_mistral': 837, 'n_tokens_neox': 772, 'n_words': 217}