<commit_before>########################################################################
#
#       License: BSD
#       Created: May 20, 2005
#       Author:  <NAME> - <EMAIL>
#
#       $Id$
#
########################################################################

"""Pyrex utilities for PyTables and HDF5 library.

"""

import sys
import warnings

try:
  import zlib
  zlib_imported = True
except ImportError:
  zlib_imported = False

import numpy

from tables.description import Description, Col
from tables.misc.enum import Enum
from tables.exceptions import HDF5ExtError
from tables.atom import Atom, EnumAtom

from tables.utils import checkFileAccess

from libc.stdio cimport stderr
from libc.stdlib cimport malloc, free
from libc.string cimport strchr, strcpy, strncpy, strcmp, strdup
from cpython cimport PyString_AsString, PyString_FromString
from numpy cimport (import_array, ndarray, dtype,
  NPY_INT64, npy_int64,
  PyArray_DescrFromType)

from definitions cimport (hid_t, herr_t, hsize_t, hssize_t, htri_t,
  H5F_ACC_RDONLY, H5P_DEFAULT, H5D_CHUNKED, H5T_DIR_DEFAULT,
  H5Fopen, H5Fclose, H5Fis_hdf5,
  H5Gopen, H5Gclose,
  H5E_auto_t, H5Eset_auto, H5Eprint,
  H5E_error_t, H5E_walk_t, H5Ewalk, H5E_WALK_DOWNWARD, H5E_DEFAULT,
  H5D_layout_t, H5Dopen, H5Dclose, H5Dget_type,
  H5T_class_t, H5T_sign_t, H5Tcreate, H5Tcopy, H5Tclose,
  H5Tget_nmembers, H5Tget_member_name, H5Tget_member_type,
  H5Tget_member_value, H5Tget_size, H5Tget_native_type,
  H5Tget_class, H5Tget_super, H5Tget_sign, H5Tget_offset, H5Tget_precision,
  H5Tinsert, H5Tenum_create, H5Tenum_insert, H5Tvlen_create,
  H5Tarray_create, H5Tget_array_ndims, H5Tget_array_dims,
  H5Tis_variable_str, H5Tset_size, H5Tset_precision, H5Tpack,
  H5ATTRget_attribute_string, H5ATTRfind_attribute,
  H5ARRAYget_ndims, H5ARRAYget_info,
  create_ieee_float16, create_ieee_complex64, create_ieee_complex128,
  get_order, set_order, is_complex,
  get_len_of_range,
  PyArray_Scalar,
  register_blosc)


# Include conversion tables & type
include "convtypetables.pxi"

__version__ = "$Revision$"

from numpy import typeDict
cdef int have_float16 = ("float16" in typeDict)

#----------------------------------------------------------------------

# External declarations


# PyTables helper routines.
cdef extern from "utils.h":

  int getLibrary(char *libname) nogil
  object _getTablesVersion()
  #object getZLIBVersionInfo()
  object getHDF5VersionInfo()
  object get_filter_names( hid_t loc_id, char *dset_name)

  H5T_class_t getHDF5ClassID(hid_t loc_id, char *name, H5D_layout_t *layout,
                             hid_t *type_id, hid_t *dataset_id) nogil

  # To access to the slice.indices functionality for long long ints
  hssize_t getIndicesExt(object s, hsize_t length,
                         hssize_t *start, hssize_t *stop, hssize_t *step,
                         hsize_t *slicelength)


# Functions from Blosc
cdef extern from "blosc.h" nogil:
  int blosc_set_nthreads(int nthreads)



#----------------------------------------------------------------------
# Initialization code

# The NumPy API requires this function to be called before
# using any NumPy facilities in an extension module.
import_array()

cdef register_blosc_():
  cdef char *version_string, *version_date

  register_blosc(&version_string, &version_date)
  version = (version_string, version_date)
  free(version_string)
  free(version_date)
  return version

# The version of the blosc compression library that is currently included in
# PyTables relies on unaligned memory access, so it is not functional on some
# platforms (see https://github.com/FrancescAlted/blosc/issues/3 and
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=661286).
# This function detects if blosc can work correctly on the current platform.
# This function has been written by <NAME> <<EMAIL>>.
def _arch_without_blosc():
    import platform
    arch = platform.machine().lower()
    for a in ["arm", "sparc", "mips"]:
        if a in arch:
            return True
        return False

# Only register bloc compressor on platforms that actually support it.
if _arch_without_blosc():
    blosc_version = register_blosc_()
else:
    blosc_version = None
<commit_msg>Inverted condition for detection of platforms without blosc<commit_after>########################################################################
#
#       License: BSD
#       Created: May 20, 2005
#       Author:  <NAME> - <EMAIL>
#
#       $Id$
#
########################################################################

"""Pyrex utilities for PyTables and HDF5 library.

"""

import sys
import warnings

try:
  import zlib
  zlib_imported = True
except ImportError:
  zlib_imported = False

import numpy

from tables.description import Description, Col
from tables.misc.enum import Enum
from tables.exceptions import HDF5ExtError
from tables.atom import Atom, EnumAtom

from tables.utils import checkFileAccess

from libc.stdio cimport stderr
from libc.stdlib cimport malloc, free
from libc.string cimport strchr, strcpy, strncpy, strcmp, strdup
from cpython cimport PyString_AsString, PyString_FromString
from numpy cimport (import_array, ndarray, dtype,
  NPY_INT64, npy_int64,
  PyArray_DescrFromType)

from definitions cimport (hid_t, herr_t, hsize_t, hssize_t, htri_t,
  H5F_ACC_RDONLY, H5P_DEFAULT, H5D_CHUNKED, H5T_DIR_DEFAULT,
  H5Fopen, H5Fclose, H5Fis_hdf5,
  H5Gopen, H5Gclose,
  H5E_auto_t, H5Eset_auto, H5Eprint,
  H5E_error_t, H5E_walk_t, H5Ewalk, H5E_WALK_DOWNWARD, H5E_DEFAULT,
  H5D_layout_t, H5Dopen, H5Dclose, H5Dget_type,
  H5T_class_t, H5T_sign_t, H5Tcreate, H5Tcopy, H5Tclose,
  H5Tget_nmembers, H5Tget_member_name, H5Tget_member_type,
  H5Tget_member_value, H5Tget_size, H5Tget_native_type,
  H5Tget_class, H5Tget_super, H5Tget_sign, H5Tget_offset, H5Tget_precision,
  H5Tinsert, H5Tenum_create, H5Tenum_insert, H5Tvlen_create,
  H5Tarray_create, H5Tget_array_ndims, H5Tget_array_dims,
  H5Tis_variable_str, H5Tset_size, H5Tset_precision, H5Tpack,
  H5ATTRget_attribute_string, H5ATTRfind_attribute,
  H5ARRAYget_ndims, H5ARRAYget_info,
  create_ieee_float16, create_ieee_complex64, create_ieee_complex128,
  get_order, set_order, is_complex,
  get_len_of_range,
  PyArray_Scalar,
  register_blosc)


# Include conversion tables & type
include "convtypetables.pxi"

__version__ = "$Revision$"

from numpy import typeDict
cdef int have_float16 = ("float16" in typeDict)

#----------------------------------------------------------------------

# External declarations


# PyTables helper routines.
cdef extern from "utils.h":

  int getLibrary(char *libname) nogil
  object _getTablesVersion()
  #object getZLIBVersionInfo()
  object getHDF5VersionInfo()
  object get_filter_names( hid_t loc_id, char *dset_name)

  H5T_class_t getHDF5ClassID(hid_t loc_id, char *name, H5D_layout_t *layout,
                             hid_t *type_id, hid_t *dataset_id) nogil

  # To access to the slice.indices functionality for long long ints
  hssize_t getIndicesExt(object s, hsize_t length,
                         hssize_t *start, hssize_t *stop, hssize_t *step,
                         hsize_t *slicelength)


# Functions from Blosc
cdef extern from "blosc.h" nogil:
  int blosc_set_nthreads(int nthreads)



#----------------------------------------------------------------------
# Initialization code

# The NumPy API requires this function to be called before
# using any NumPy facilities in an extension module.
import_array()

cdef register_blosc_():
  cdef char *version_string, *version_date

  register_blosc(&version_string, &version_date)
  version = (version_string, version_date)
  free(version_string)
  free(version_date)
  return version

# The version of the blosc compression library that is currently included in
# PyTables relies on unaligned memory access, so it is not functional on some
# platforms (see https://github.com/FrancescAlted/blosc/issues/3 and
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=661286).
# This function detects if blosc can work correctly on the current platform.
# This function has been written by <NAME> <<EMAIL>>.
def _arch_without_blosc():
    import platform
    arch = platform.machine().lower()
    for a in ["arm", "sparc", "mips"]:
        if a in arch:
            return True
        return False

# Only register bloc compressor on platforms that actually support it.
if _arch_without_blosc():
    blosc_version = None
else:
    blosc_version = register_blosc_()


{'fraction_non_alphanumeric': 0.13469049591667653, 'fraction_numerical': 0.020594153154219433, 'mean_word_length': 3.9852507374631267, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 13, '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': '2235013', 'n_tokens_mistral': 2949, 'n_tokens_neox': 2839, 'n_words': 741}