Skip to content

Commit 804afa5

Browse files
committed
Downgrade Python requirement to 3.12
1 parent 78473c8 commit 804afa5

8 files changed

Lines changed: 248 additions & 352 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ readme = "README.md"
1515

1616
license = "MIT"
1717

18-
requires-python = ">=3.13,<3.14"
18+
requires-python = ">=3.12,<3.13"
1919

2020
dependencies = [
2121
"httpx>=0.28.1",
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from typing import Literal
22

3+
from AEIC.performance.types import SimpleFlightRules
4+
35
from .base import BasePerformanceModel
46

57

6-
class BADAPerformanceModel(BasePerformanceModel):
8+
class BADAPerformanceModel(BasePerformanceModel[SimpleFlightRules]):
79
model_type: Literal['BADA']
810
...

src/AEIC/performance/models/base.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ def from_internal(cls, lto: LTOPerformance) -> LTOPerformanceInput:
103103
)
104104

105105

106-
class BasePerformanceModel[RulesT = SimpleFlightRules](CIBaseModel, ABC):
106+
class BasePerformanceModel[RulesT](CIBaseModel, ABC):
107107
"""Base class for aircraft performance models.
108108
109109
This a generic class parameterized by the type of flight rules accepted by
110-
the class's :meth:`evaluate` method. By default, this is
111-
:class:`SimpleFlightRules <AEIC.performance.types.SimpleFlightRules>`, but
112-
subclasses can override this to specify more sophisticated flight rule
113-
types.
110+
the class's :meth:`evaluate` method. For very simple performance models,
111+
this will just be the basic :class:`SimpleFlightRules
112+
<AEIC.performance.types.SimpleFlightRules>`, but subclasses can override
113+
this to specify more sophisticated flight rule types.
114114
115115
(This class uses the pattern of splitting the :meth:`evaluate` method into
116116
two steps to allow for type checking of the flight rules input before
@@ -160,7 +160,8 @@ def maximum_payload(self) -> float:
160160
"""Optional LTO performance data."""
161161

162162
FLIGHT_RULES_CLASS: ClassVar[type] = SimpleFlightRules
163-
"""The class type for flight rules accepted by this performance model."""
163+
"""The class type for flight rules accepted by this performance model.
164+
Override in derived classes if a different flight rules type is used."""
164165

165166
@model_validator(mode='after')
166167
def load_apu_data(self) -> Self:

src/AEIC/performance/models/legacy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def subset(self, rocd: ROCDFilter) -> PerformanceTable:
321321
)
322322

323323

324-
class LegacyPerformanceModel(BasePerformanceModel):
324+
class LegacyPerformanceModel(BasePerformanceModel[SimpleFlightRules]):
325325
"""Legacy table-based performance model."""
326326

327327
model_type: Literal['legacy']
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from typing import Literal
22

3+
from AEIC.performance.types import SimpleFlightRules
4+
35
from .base import BasePerformanceModel
46

57

6-
class PianoPerformanceModel(BasePerformanceModel):
8+
class PianoPerformanceModel(BasePerformanceModel[SimpleFlightRules]):
79
model_type: Literal['Piano']
810
...
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from typing import Literal
22

3+
from AEIC.performance.types import SimpleFlightRules
4+
35
from .base import BasePerformanceModel
46

57

6-
class TASOPTPerformanceModel(BasePerformanceModel):
8+
class TASOPTPerformanceModel(BasePerformanceModel[SimpleFlightRules]):
79
model_type: Literal['TASOPT']
810
...

tests/test_storage.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,9 @@ def test_fieldset_override(tmp_path: Path):
589589
assert ts_read3[1].mf == 12345
590590

591591

592-
@pytest.mark.forked
593-
def test_basic_merging(tmp_path: Path):
592+
def basic_merging_create_stores(tmp_path: Path):
594593
# Create a number of trajectory stores with names following a pattern.
594+
Config.load()
595595
paths = []
596596
for i in range(4):
597597
path = tmp_path / f'test_{i}.nc'
@@ -601,6 +601,27 @@ def test_basic_merging(tmp_path: Path):
601601
t = make_test_trajectory((j + 1) * 5, j + i * 10)
602602
ts.add(t)
603603

604+
605+
def basic_merging_check_merged_store(merged_path: Path):
606+
# Open the merged store and check contents.
607+
Config.load()
608+
with TrajectoryStore.open(base_file=merged_path) as ts_merged:
609+
assert ts_merged.nc_linked is True
610+
assert len(ts_merged) == 8
611+
assert ts_merged[0].name == 'traj_0'
612+
assert ts_merged[7].name == 'traj_31'
613+
assert ts_merged[4].flight_time.shape == (5,)
614+
615+
616+
@pytest.mark.forked
617+
def test_basic_merging(tmp_path: Path):
618+
# Create a number of trajectory stores with names following a pattern.
619+
run_in_subprocess(basic_merging_create_stores, tmp_path)
620+
paths = []
621+
for i in range(4):
622+
path = tmp_path / f'test_{i}.nc'
623+
paths.append(path)
624+
604625
# Merge the stores into a new store.
605626
merged_path = tmp_path / 'merged.aeic-store'
606627
TrajectoryStore.merge(input_stores=paths, output_store=merged_path)
@@ -610,12 +631,7 @@ def test_basic_merging(tmp_path: Path):
610631
_ = TrajectoryStore.append(base_file=merged_path)
611632

612633
# Open the merged store and check contents.
613-
with TrajectoryStore.open(base_file=merged_path) as ts_merged:
614-
assert ts_merged.nc_linked is True
615-
assert len(ts_merged) == 8
616-
assert ts_merged[0].name == 'traj_0'
617-
assert ts_merged[7].name == 'traj_31'
618-
assert ts_merged[4].flight_time.shape == (5,)
634+
run_in_subprocess(basic_merging_check_merged_store, merged_path)
619635

620636

621637
# Split test into subprocesses to avoid issues with NetCDF libraries.

0 commit comments

Comments
 (0)