From 1d61db067f8d7f0c83a718b0978c513752fcc40d Mon Sep 17 00:00:00 2001 From: Silcantar <1491897+Silcantar@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:41:45 -0500 Subject: [PATCH] Change AuDaGeFrame from extending DataFrame to wrapping it. --- src/AuDaGe/audage_frame.py | 21 +++++++++++++++---- src/AuDaGe/iec.py | 2 +- .../{test_audage.py => test_audage_frame.py} | 2 +- tests/test_iec.py | 2 +- tests/test_xsy.py | 4 ++-- 5 files changed, 22 insertions(+), 9 deletions(-) rename tests/{test_audage.py => test_audage_frame.py} (93%) diff --git a/src/AuDaGe/audage_frame.py b/src/AuDaGe/audage_frame.py index 3e840f7..34290ee 100644 --- a/src/AuDaGe/audage_frame.py +++ b/src/AuDaGe/audage_frame.py @@ -1,5 +1,11 @@ """ -AuDaGe +AuDaGe DataFrame extensions + +name: audage_frame.py +by: Josh Lucas +date: 2026-09-14 + +desc: Extensions to DataFrame for AuDaGe purposes. """ from enum import StrEnum, auto @@ -15,15 +21,22 @@ class MandatoryColumns(StrEnum): COMMENT = auto() -class AuDaGeFrame(DataFrame): - """DataFrame extended for AuDaGe purposes.""" +class AuDaGeFrame: + """DataFrame wrapped for AuDaGe purposes.""" + + def __init__(self, *args, **kwargs): + self.dataframe = DataFrame(*args, **kwargs) def missing_columns(self) -> list[MandatoryColumns]: + """Return a list of mandatory columns that are missing from this + DataFrame. + """ return [ label for label in MandatoryColumns - if not label in self.columns + if not label in self.dataframe.columns ] def is_valid(self) -> bool: + """Check whether the DataFrame contains all mandatory columns.""" return self.missing_columns() == [] diff --git a/src/AuDaGe/iec.py b/src/AuDaGe/iec.py index f0e1bed..363eff0 100644 --- a/src/AuDaGe/iec.py +++ b/src/AuDaGe/iec.py @@ -12,7 +12,7 @@ from enum import Enum, IntEnum from pandas import Series, NA -from AuDaGe.audage import AuDaGeFrame +from AuDaGe.audage_frame import AuDaGeFrame WORD_LENGTH = 16 diff --git a/tests/test_audage.py b/tests/test_audage_frame.py similarity index 93% rename from tests/test_audage.py rename to tests/test_audage_frame.py index 35ea5ea..36d26bc 100644 --- a/tests/test_audage.py +++ b/tests/test_audage_frame.py @@ -1,6 +1,6 @@ import unittest -from AuDaGe.audage import AuDaGeFrame +from AuDaGe.audage_frame import AuDaGeFrame class TestAuDaGeFrame(unittest.TestCase): def test_init(self): diff --git a/tests/test_iec.py b/tests/test_iec.py index da217d2..e172f9d 100644 --- a/tests/test_iec.py +++ b/tests/test_iec.py @@ -19,7 +19,7 @@ class TestIEC(unittest.TestCase): iec_definitions = iec.iec_definitions() self.assertTrue(iec_definitions.is_valid()) self.assertEqual( - iec_definitions.shape, + iec_definitions.dataframe.shape, (len(iec.DataTypes.__members__), 7) ) diff --git a/tests/test_xsy.py b/tests/test_xsy.py index a3b5fb3..f0a2c26 100644 --- a/tests/test_xsy.py +++ b/tests/test_xsy.py @@ -27,11 +27,11 @@ class TestXSY(unittest.TestCase): def test_export(self): xsy = XSY() xsy.read(os.path.join(IN_PATH, "hsps.xsy"), expand=False) - xsy.datablock.to_csv( + xsy.datablock.dataframe.to_csv( os.path.join(OUT_PATH, "datablock.csv"), index=False ) - xsy.definitions.to_csv( + xsy.definitions.dataframe.to_csv( os.path.join(OUT_PATH, "defs.csv"), index=False )