Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend data handling for the EDITS transport MCE #205

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}


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
Loading