<commit_before>"""
Sasmodels core.
"""
import sys, os
import datetime

from sasmodels import sesans

# CRUFT python 2.6
if not hasattr(datetime.timedelta, 'total_seconds'):
    def delay(dt): return dt.days*86400 + dt.seconds + 1e-6*dt.microseconds
else:
    def delay(dt): return dt.total_seconds()

import numpy as np

try:
    from .kernelcl import load_model as _loader
except ImportError,exc:
    import warnings
    warnings.warn(str(exc))
    warnings.warn("OpenCL not available --- using ctypes instead")
    from .kerneldll import load_model as _loader

def load_model(modelname, dtype='single'):
    """
    Load model by name.
    """
    sasmodels = __import__('sasmodels.models.'+modelname)
    module = getattr(sasmodels.models, modelname, None)
    model = _loader(module, dtype=dtype)
    return model<commit_msg>fix import trap for opencl to reflect new exeception<commit_after>"""
Sasmodels core.
"""
import sys, os
import datetime

from sasmodels import sesans

# CRUFT python 2.6
if not hasattr(datetime.timedelta, 'total_seconds'):
    def delay(dt): return dt.days*86400 + dt.seconds + 1e-6*dt.microseconds
else:
    def delay(dt): return dt.total_seconds()

import numpy as np

try:
    from .kernelcl import load_model as _loader
except RuntimeError,exc:
    import warnings
    warnings.warn(str(exc))
    warnings.warn("OpenCL not available --- using ctypes instead")
    from .kerneldll import load_model as _loader

def load_model(modelname, dtype='single'):
    """
    Load model by name.
    """
    sasmodels = __import__('sasmodels.models.'+modelname)
    module = getattr(sasmodels.models, modelname, None)
    model = _loader(module, dtype=dtype)
    return model
{'fraction_non_alphanumeric': 0.10482921083627797, 'fraction_numerical': 0.01060070671378092, 'mean_word_length': 4.011799410029498, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2098956', 'n_tokens_mistral': 548, 'n_tokens_neox': 539, 'n_words': 159}