Skip to content

Commit

Permalink
Add .edits.PASTA exogenous data source
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Jul 11, 2024
1 parent fabd07e commit 1641e2e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions message_ix_models/project/edits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from sdmx.model.common import Codelist
from sdmx.model.v21 import DataStructureDefinition

from message_ix_models.tools.exo_data import ExoDataSource
from message_ix_models.util import local_data_path

if TYPE_CHECKING:
Expand Down Expand Up @@ -156,6 +157,21 @@ def _transform(value: Any) -> str:
}


class PASTA(ExoDataSource):
"""Retrieve and process PASTA data for use in MESSAGEix-Transport."""

id = "PASTA"

def __init__(self, source, source_kw):
if not source == self.id:
raise ValueError(source)

Check warning on line 167 in message_ix_models/project/edits/__init__.py

View check run for this annotation

Codecov / codecov/patch

message_ix_models/project/edits/__init__.py#L167

Added line #L167 was not covered by tests

self.raise_on_extra_kw(source_kw)

def __call__(self):
raise NotImplementedError

Check warning on line 172 in message_ix_models/project/edits/__init__.py

View check run for this annotation

Codecov / codecov/patch

message_ix_models/project/edits/__init__.py#L172

Added line #L172 was not covered by tests


def gen_demand(context: "Context") -> None:
"""Generate MESSAGEix-Transport demand data from PASTA.
Expand Down
7 changes: 6 additions & 1 deletion message_ix_models/tests/project/test_edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from message_ix_models.project.edits import gen_demand, pasta_native_to_sdmx
from message_ix_models.project.edits import PASTA, gen_demand, pasta_native_to_sdmx
from message_ix_models.util import package_data_path


Expand All @@ -15,6 +15,11 @@ def test_pasta_data(test_context):
copyfile(package_data_path("test", *parts), target)


class TestPASTA:
def test_init(self) -> None:
PASTA("PASTA", {})


def test_pasta_native_to_sdmx(test_context, test_pasta_data):
pasta_native_to_sdmx()

Expand Down

0 comments on commit 1641e2e

Please sign in to comment.