Skip to content

Commit

Permalink
Rename Platform.list_models to .models/.scenarios
Browse files Browse the repository at this point in the history
To be more consistent with existing Platform methods like
.regions() and .units():
- rename Platform.list_models to Platform.models
- rename Platform.list_scenarios to Platform.scenarios
  • Loading branch information
fonfon committed Aug 1, 2020
1 parent a6bd9ac commit 6ce64c4
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ All changes

- :meth:`Platform.add_model` using :meth:`.Backend.add_model`
- :meth:`Platform.add_scenario` using :meth:`.Backend.add_scenario`
- :meth:`Platform.list_models` using :meth:`.Backend.list_models`
- :meth:`Platform.list_scenarios` using :meth:`.Backend.list_scenarios`
- :meth:`Platform.models` using :meth:`.Backend.models`
- :meth:`Platform.scenarios` using :meth:`.Backend.scenarios`
- :meth:`Platform.get_meta` using :meth:`.Backend.get_meta`
- :meth:`Platform.set_meta` using :meth:`.Backend.set_meta`
- :meth:`Platform.remove_meta` using :meth:`.Backend.remove_meta`
Expand Down
3 changes: 2 additions & 1 deletion doc/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ There are a number of guides out there, e.g. on docutils_.
Building the docs locally
-------------------------

Install the dependencies, above.
Install the dependencies, above. Repeat the installation steps on code changes
of ixmp to be able to refer to the adapted code.

From the command line, run::

Expand Down
4 changes: 2 additions & 2 deletions doc/source/api-backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ Backend API
get_nodes
get_scenarios
get_units
list_models
list_scenarios
models
open_db
read_file
remove_meta
scenarios
set_doc
set_log_level
set_meta
Expand Down
4 changes: 2 additions & 2 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ Platform
backend.base.Backend.close_db
backend.base.Backend.get_doc
backend.base.Backend.get_meta
backend.base.Backend.list_models
backend.base.Backend.list_scenarios
backend.base.Backend.models
backend.base.Backend.open_db
backend.base.Backend.remove_meta
backend.base.Backend.scenarios
backend.base.Backend.set_doc
backend.base.Backend.set_meta

Expand Down
4 changes: 2 additions & 2 deletions ixmp/backend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def add_scenario(self, name: str):
"""

@abstractmethod
def list_models(self) -> Generator[str, None, None]:
def models(self) -> Generator[str, None, None]:
""" List existing model names
Returns
Expand All @@ -82,7 +82,7 @@ def list_models(self) -> Generator[str, None, None]:
"""

@abstractmethod
def list_scenarios(self) -> Generator[str, None, None]:
def scenarios(self) -> Generator[str, None, None]:
""" List existing scenario names
Returns
Expand Down
4 changes: 2 additions & 2 deletions ixmp/backend/jdbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ def add_model(self, name):
def add_scenario(self, name):
self.jobj.addScenario(str(name))

def list_models(self) -> Generator[str, None, None]:
def models(self) -> Generator[str, None, None]:
for model in self.jobj.listModels():
yield str(model)

def list_scenarios(self) -> Generator[str, None, None]:
def scenarios(self) -> Generator[str, None, None]:
for scenario in self.jobj.listScenarios():
yield str(scenario)

Expand Down
4 changes: 2 additions & 2 deletions ixmp/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class Platform:
'remove_meta',
'add_model',
'add_scenario',
'list_models',
'list_scenarios',
'models',
'scenarios',
]

def __init__(self, name=None, backend=None, **backend_args):
Expand Down
4 changes: 2 additions & 2 deletions ixmp/tests/backend/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class BE2(Backend):
item_set_elements = noop
last_update = noop
list_items = noop
list_models = noop
list_scenarios = noop
models = noop
scenarios = noop
run_id = noop
set_as_default = noop
set_data = noop
Expand Down
6 changes: 3 additions & 3 deletions ixmp/tests/core/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ def test_weakref():

def test_add_model(mp):
mp.add_model('new_model_name')
assert 'new_model_name' in mp.list_models()
assert 'new_model_name' in mp.models()


def test_add_scenario(mp):
mp.add_scenario('new_scenario_name')
print(list(mp.list_scenarios()))
assert 'new_scenario_name' in mp.list_scenarios()
print(list(mp.scenarios()))
assert 'new_scenario_name' in mp.scenarios()

0 comments on commit 6ce64c4

Please sign in to comment.