<commit_before>"""
    Python tools and wrappers for the Johns Hopkins Turbulence Databases C library.
"""

import os
import sys
import numpy as np
import ctypes
import inspect
import platform

class libTDB(object):
    def __init__(self,
            libname = 'libTDB',
            srcdir = '.',
            auth_token = '<PASSWORD>'):
        self.libname = libname
        self.srcdir = srcdir
        self.generate_shared_library()
        self.authToken = ctypes.c_char_p(auth_token)
        self.connection_on = False
        self.hdf5_file_list = []
        return None
    def initialize(self, exit_on_error = True):
        #initialize gSOAP
        self.lib.soapinit()
        if exit_on_error:
            #enable exit on error
            self.lib.turblibSetExitOnError(ctypes.c_int(1))
        self.connection_on = True
        return None
    def finalize(self):
        #free gSOAP resources
        self.lib.soapdestroy()
        self.connection_on = False
        return None
    def add_hdf5_file(self, filename):
        if not filename in self.hdf5_file_list:
            self.hdf5_file_list.append(filename)
            return self.lib.turblibAddLocalSource(ctypes.c_char_p(filename + '.h5'))
        else:
            return 0
    def getData(self,
            time, point_coords,
            sinterp = 0, tinterp = 0,
            data_set = 'isotropic1024coarse',
            getFunction = 'getVelocity',
            make_modulo = False):
        if not self.connection_on:
            print('you didn\'t connect to the database')
            sys.exit()
        if not (point_coords.shape[-1] == 3):
            print ('wrong number of values for coordinates in getData')
            sys.exit()<commit_msg>keep loaded hdf5 info<commit_after>"""
    Python tools and wrappers for the Johns Hopkins Turbulence Databases C library.
"""

import os
import sys
import numpy as np
import h5py
import ctypes
import inspect
import platform

class libTDB(object):
    def __init__(self,
            libname = 'libTDB',
            srcdir = '.',
            auth_token = '<PASSWORD>'):
        self.libname = libname
        self.srcdir = srcdir
        self.generate_shared_library()
        self.authToken = ctypes.c_char_p(auth_token)
        self.connection_on = False
        self.hdf5_file_list = []
        self.hdf5_file_desc = {}
        return None
    def initialize(self, exit_on_error = True):
        #initialize gSOAP
        self.lib.soapinit()
        if exit_on_error:
            #enable exit on error
            self.lib.turblibSetExitOnError(ctypes.c_int(1))
        self.connection_on = True
        return None
    def finalize(self):
        #free gSOAP resources
        self.lib.soapdestroy()
        self.connection_on = False
        return None
    def add_hdf5_file(self, filename):
        if not filename in self.hdf5_file_list:
            self.hdf5_file_list.append(filename)
            data = h5py.File(filename + '.h5', mode = 'r')
            self.hdf5_file_desc[filename] = {}
            for key in ['_contents', '_dataset', '_size', '_start']:
                self.hdf5_file_desc[filename][key] = data[key][:]
            data.close()
            return self.lib.turblibAddLocalSource(ctypes.c_char_p(filename + '.h5'))
        else:
            return 0
    def getData(self,
            time, point_coords,
            sinterp = 0, tinterp = 0,
            data_set = 'isotropic1024coarse',
            getFunction = 'getVelocity',
            make_modulo = False):
        if not self.connection_on:
            print('you didn\'t connect to the database')
            sys.exit()
        if not (point_coords.shape[-1] == 3):
            print ('wrong number of values for coordinates in getData')
            sys.exit()
{'fraction_non_alphanumeric': 0.09160709557850145, 'fraction_numerical': 0.009796134498279057, 'mean_word_length': 2.024819855884708, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1485189', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1127, 'n_words': 279}