<commit_before># -*- coding: utf-8 -*-
from os import path as op
from nose.tools import assert_raises, assert_true

import numpy as np

from expyfun.io import write_hdf5, read_hdf5
from expyfun._utils import _TempDir, object_diff, requires_pytables

tempdir = _TempDir()


@requires_pytables
def test_hdf5():
    """Test HDF5 IO
    """
    test_file = op.join(tempdir, 'test.hdf5')
    x = dict(a=dict(b=np.zeros(3)), c=np.zeros(2, np.complex256),
             d=[dict(e=(1, -2., 'hello'))])
    assert_raises(TypeError, write_hdf5, test_file, 1)
    write_hdf5(test_file, x)
    assert_raises(IOError, write_hdf5, test_file, x)  # file exists
    write_hdf5(test_file, x, overwrite=True)
    assert_raises(IOError, read_hdf5, test_file + 'FOO')  # not found
    xx = read_hdf5(test_file)
    print(object_diff(x, xx))
    assert_true(object_diff(x, xx) == '')  # no assert_equal, ugly output<commit_msg>FIX: Silly numpy<commit_after># -*- coding: utf-8 -*-
from os import path as op
from nose.tools import assert_raises, assert_true

import numpy as np

from expyfun.io import write_hdf5, read_hdf5
from expyfun._utils import _TempDir, object_diff, requires_pytables

tempdir = _TempDir()


@requires_pytables
def test_hdf5():
    """Test HDF5 IO
    """
    test_file = op.join(tempdir, 'test.hdf5')
    x = dict(a=dict(b=np.zeros(3)), c=np.zeros(2, np.complex128),
             d=[dict(e=(1, -2., 'hello'))])
    assert_raises(TypeError, write_hdf5, test_file, 1)
    write_hdf5(test_file, x)
    assert_raises(IOError, write_hdf5, test_file, x)  # file exists
    write_hdf5(test_file, x, overwrite=True)
    assert_raises(IOError, read_hdf5, test_file + 'FOO')  # not found
    xx = read_hdf5(test_file)
    print(object_diff(x, xx))
    assert_true(object_diff(x, xx) == '')  # no assert_equal, ugly output
{'fraction_non_alphanumeric': 0.13072255929398788, 'fraction_numerical': 0.02206287920573635, 'mean_word_length': 4.168091168091168, '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': '790656', 'n_tokens_mistral': 717, 'n_tokens_neox': 702, 'n_words': 157}