Skip to content

Commit

Permalink
tests: add tests for a file composed of multiple dtypes (#33)
Browse files Browse the repository at this point in the history
* add test

* Enhance test
  • Loading branch information
eyurtsev authored Oct 7, 2021
1 parent e84109f commit 199126a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions fcsparser/tests/test_fcs_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy
import pytest
from numpy import array
from numpy.testing import assert_array_equal

from .. import parse as parse_fcs
from ..api import FCSParser
Expand Down Expand Up @@ -372,6 +373,44 @@ def test_reading_in_memory_fcs_file(self):
self.assertTrue(numpy.all(diff < 10 ** -8))


class TestMultiDtypeParsing(unittest.TestCase):
"""Verify that parsing of an fcs file that's composed of multiple dtypes works."""

@pytest.mark.skip(reason="Needs to be fixed, appears broken from initial commit")
def test_parse_into_numpy_data_correctly(self):
"""Test that we can parse the data into a numpy matrix correctly.
This test is currently broken. It's likely been broken since the initial commit.
Users are probably relying on the dataframe output (tested below), which
does seem to work correctly.
"""
fname = FILE_IDENTIFIER_TO_PATH['cyflow cube 8']
# This file contains a list of multiple dtypes
# ['<u2', '<u2', '<u2', '<u2', '<u2', '<u2', '<u2', '<u2', '<u4', '<u1']
fcsparser = FCSParser(path=fname)
# Make sure that data gets parsed as 2-dimensional
self.assertEquals(fcsparser.data.shape, (725, 10))

def test_parsed_into_dataframe_correctly(self):
"""Test that we can parse the data into a dataframe correctly."""
fname = FILE_IDENTIFIER_TO_PATH['cyflow cube 8']
# This file contains a list of multiple dtypes
# ['<u2', '<u2', '<u2', '<u2', '<u2', '<u2', '<u2', '<u2', '<u4', '<u1']
fcsparser = FCSParser(path=fname)
# Make sure that data gets parsed as 2-dimensional
self.assertEquals(fcsparser.dataframe.shape, (725, 10))
# Verify that the values are correct.
assert_array_equal(
fcsparser.dataframe.values[:2, :],
numpy.array(
[
[8, 7, 15, 15, 5, 8, 7, 6, 23, 0],
[6, 7, 13, 14, 6, 9, 10, 4, 23, 0]
]
)
)


# FCS file that contains only the header.
CYTEK_NL_2000_sample_header = os.path.join(BASE_PATH, 'cytek-nl-2000', 'sample_header.fcs')

Expand Down

0 comments on commit 199126a

Please sign in to comment.