<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import os
from os.path import join, dirname, abspath, split
import pytest
import sys
import tempfile

# fix for fcm, which does not support matplotlib>=1.3.0
from mock import patch, MagicMock
module_mock = MagicMock()


# Add parent directory to beginning of path variable
DIR = dirname(abspath(__file__))
sys.path.insert(0, split(DIR)[0])

import fcswrite


@pytest.mark.skipif("sys.version_info >= (3,0)")
def test_read_fcm():
    """test that fcm can read the data files"""

    with patch.dict('sys.modules', **{ 
            'matplotlib.nxutils': module_mock,
            'matplotlib.nxutils.points_inside_poly': module_mock,
        }):
        from fcm import loadFCS

        fname=tempfile.mktemp(suffix=".fcs", prefix="fcm_read_test")
        data = 1.0*np.arange(400).reshape((100,4))
        chn_names= ['c1', 'channel_2', 'Channel 3', '4jjjjjjjjj']
        fcswrite.write_fcs(filename=fname,
                           chn_names=chn_names,
                           data=data,
                           compat_chn_names=False
                           )

        
        ldata = loadFCS(fname)
        assert ldata.shape == data.shape
        assert ldata.channels == chn_names
        assert np.mean(ldata) == np.mean(data)<commit_msg>skip fcm tests with python3<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import os
from os.path import join, dirname, abspath, split
import pytest
import sys
import tempfile

# Add parent directory to beginning of path variable
DIR = dirname(abspath(__file__))
sys.path.insert(0, split(DIR)[0])

import fcswrite


@pytest.mark.skipif("sys.version_info >= (3,0)")
def test_read_fcm():
    """test that fcm can read the data files"""
    # fix for fcm, which does not support matplotlib>=1.3.0
    from mock import patch, MagicMock
    module_mock = MagicMock()

    with patch.dict('sys.modules', **{ 
            'matplotlib.nxutils': module_mock,
            'matplotlib.nxutils.points_inside_poly': module_mock,
        }):
        from fcm import loadFCS

        fname=tempfile.mktemp(suffix=".fcs", prefix="fcm_read_test")
        data = 1.0*np.arange(400).reshape((100,4))
        chn_names= ['c1', 'channel_2', 'Channel 3', '4jjjjjjjjj']
        fcswrite.write_fcs(filename=fname,
                           chn_names=chn_names,
                           data=data,
                           compat_chn_names=False
                           )

        
        ldata = loadFCS(fname)
        assert ldata.shape == data.shape
        assert ldata.channels == chn_names
        assert np.mean(ldata) == np.mean(data)
{'fraction_non_alphanumeric': 0.11672862453531599, 'fraction_numerical': 0.015985130111524165, 'mean_word_length': 2.4280254777070063, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6682171', 'n_tokens_mistral': 896, 'n_tokens_neox': 859, 'n_words': 201}