Skip to content

Commit

Permalink
Update parquet tests after removal of extra delegates.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Aug 17, 2024
1 parent e0c53f9 commit 6915fe7
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions tests/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,11 @@
StorageClassFactory,
)

try:
from lsst.daf.butler.delegates.arrowastropy import ArrowAstropyDelegate
except ImportError:
atable = None
pa = None
try:
from lsst.daf.butler.delegates.arrownumpy import ArrowNumpyDelegate
except ImportError:
np = None
pa = None
try:
from lsst.daf.butler.delegates.arrowtable import ArrowTableDelegate
except ImportError:
pa = None
try:
from lsst.daf.butler.delegates.dataframe import DataFrameDelegate
except ImportError:
pd = None

try:
from lsst.daf.butler.formatters.parquet import (
ArrowAstropySchema,
Expand Down Expand Up @@ -797,9 +784,9 @@ def testWriteReadNumpyDictLossless(self):
_checkNumpyDictEquality(dict1, dict2)


@unittest.skipUnless(pd is not None, "Cannot test InMemoryDataFrameDelegate without pandas.")
@unittest.skipUnless(pd is not None, "Cannot test InMemoryDatastore with DataFrames without pandas.")
class InMemoryDataFrameDelegateTestCase(ParquetFormatterDataFrameTestCase):
"""Tests for InMemoryDatastore, using DataFrameDelegate."""
"""Tests for InMemoryDatastore, using ArrowTableDelegate with Dataframe."""

configFile = os.path.join(TESTDIR, "config/basic/butler-inmemory.yaml")

Expand All @@ -821,7 +808,7 @@ def testLegacyDataFrame(self):

def testBadInput(self):
df1, _ = _makeSingleIndexDataFrame()
delegate = DataFrameDelegate("DataFrame")
delegate = ArrowTableDelegate("DataFrame")

with self.assertRaises(ValueError):
delegate.handleParameters(inMemoryDataset="not_a_dataframe")
Expand Down Expand Up @@ -1166,9 +1153,11 @@ def testBadAstropyColumnParquet(self):
self.butler.put(bad_tab, self.datasetType, dataId={})


@unittest.skipUnless(atable is not None, "Cannot test InMemoryArrowAstropyDelegate without astropy.")
@unittest.skipUnless(atable is not None, "Cannot test InMemoryDatastore with AstropyTable without astropy.")
class InMemoryArrowAstropyDelegateTestCase(ParquetFormatterArrowAstropyTestCase):
"""Tests for InMemoryDatastore, using ArrowAstropyDelegate."""
"""Tests for InMemoryDatastore, using ArrowTableDelegate with
AstropyTable.
"""

configFile = os.path.join(TESTDIR, "config/basic/butler-inmemory.yaml")

Expand All @@ -1182,7 +1171,7 @@ def testBadAstropyColumnParquet(self):

def testBadInput(self):
tab1 = _makeSimpleAstropyTable()
delegate = ArrowAstropyDelegate("ArrowAstropy")
delegate = ArrowTableDelegate("ArrowAstropy")

with self.assertRaises(ValueError):
delegate.handleParameters(inMemoryDataset="not_an_astropy_table")
Expand Down Expand Up @@ -1440,9 +1429,11 @@ def testWriteReadAstropyTableLossless(self):
_checkAstropyTableEquality(tab1, tab2)


@unittest.skipUnless(np is not None, "Cannot test ParquetFormatterArrowNumpy without numpy.")
@unittest.skipUnless(np is not None, "Cannot test ImMemoryDatastore with Numpy table without numpy.")
class InMemoryArrowNumpyDelegateTestCase(ParquetFormatterArrowNumpyTestCase):
"""Tests for InMemoryDatastore, using ArrowNumpyDelegate."""
"""Tests for InMemoryDatastore, using ArrowTableDelegate with
Numpy table.
"""

configFile = os.path.join(TESTDIR, "config/basic/butler-inmemory.yaml")

Expand All @@ -1452,7 +1443,7 @@ def testBadNumpyColumnParquet(self):

def testBadInput(self):
tab1 = _makeSimpleNumpyTable()
delegate = ArrowNumpyDelegate("ArrowNumpy")
delegate = ArrowTableDelegate("ArrowNumpy")

with self.assertRaises(ValueError):
delegate.handleParameters(inMemoryDataset="not_a_numpy_table")
Expand Down Expand Up @@ -1754,7 +1745,7 @@ def testWriteReadAstropyTableLossless(self):
_checkAstropyTableEquality(tab1, tab2)


@unittest.skipUnless(pa is not None, "Cannot test InMemoryArrowTableDelegate without pyarrow.")
@unittest.skipUnless(pa is not None, "Cannot test InMemoryDatastore with ArroWTable without pyarrow.")
class InMemoryArrowTableDelegateTestCase(ParquetFormatterArrowTableTestCase):
"""Tests for InMemoryDatastore, using ArrowTableDelegate."""

Expand Down Expand Up @@ -1935,10 +1926,12 @@ def testWriteReadAstropyTableLossless(self):
_checkAstropyTableEquality(tab1, tab2)


@unittest.skipUnless(np is not None, "Cannot test ParquetFormatterArrowNumpy without numpy.")
@unittest.skipUnless(pa is not None, "Cannot test ParquetFormatterArrowNumpy without pyarrow.")
@unittest.skipUnless(np is not None, "Cannot test InMemoryDatastore with NumpyDict without numpy.")
@unittest.skipUnless(pa is not None, "Cannot test InMemoryDatastore with NumpyDict without pyarrow.")
class InMemoryNumpyDictDelegateTestCase(ParquetFormatterArrowNumpyDictTestCase):
"""Tests for InMemoryDatastore, using ArrowNumpyDictDelegate."""
"""Tests for InMemoryDatastore, using ArrowTableDelegate with
Numpy dict.
"""

configFile = os.path.join(TESTDIR, "config/basic/butler-inmemory.yaml")

Expand Down Expand Up @@ -2109,7 +2102,7 @@ def testWriteArrowSchemaReadAsArrowNumpySchema(self):
self.assertEqual(np_schema2, np_schema1)


@unittest.skipUnless(pa is not None, "Cannot test InMemoryArrowSchemaDelegate without pyarrow.")
@unittest.skipUnless(pa is not None, "Cannot test InMemoryDatastore with ArrowSchema without pyarrow.")
class InMemoryArrowSchemaDelegateTestCase(ParquetFormatterArrowSchemaTestCase):
"""Tests for InMemoryDatastore and ArrowSchema."""

Expand Down

0 comments on commit 6915fe7

Please sign in to comment.