Skip to content
Merged
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ os:
- osx
env:
matrix:
- CONDA_ENV=3.8
- CONDA_ENV=3.7
- CONDA_ENV=3.6
sudo: false
Expand Down
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
BMI for Python
==============

Python bindings for the CSDMS `Basic Model Interface <https://bmi-spec.readthedocs.io>`_.

Install
-------

Expand All @@ -17,6 +19,13 @@ with conda from the *conda-forge* channel,

$ conda install bmipy -c conda-forge

To build and install *bmipy* from source,

.. code-block:: bash

$ git clone https://github.com/csdms/bmi-python
$ cd bmi-python
$ pip install .

Usage
-----
Expand All @@ -30,3 +39,7 @@ Usage

def initialize(self, config_file):
# Your implementation goes here

A complete sample implementation is given in the
https://github.com/csdms/bmi-example-python
repository.
51 changes: 51 additions & 0 deletions bmipy/bmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ def update(self) -> None:
"""
...

@abstractmethod
def update_until(self, time: float) -> None:
"""Advance model state until the given time.

Parameters
----------
time : float
A model time later than the current model time.
"""
...

@abstractmethod
def finalize(self) -> None:
"""Perform tear-down tasks for the model.
Expand All @@ -62,6 +73,28 @@ def get_component_name(self) -> str:
"""
...

@abstractmethod
def get_input_item_count(self) -> int:
"""Count of a model's input variables.

Returns
-------
int
The number of input variables.
"""
...

@abstractmethod
def get_output_item_count(self) -> int:
"""Count of a model's output variables.

Returns
-------
int
The number of output variables.
"""
...

@abstractmethod
def get_input_var_names(self) -> Tuple[str]:
"""List of a model's input variables.
Expand Down Expand Up @@ -621,6 +654,24 @@ def get_grid_edge_nodes(self, grid: int, edge_nodes: np.ndarray) -> np.ndarray:
"""
...

@abstractmethod
def get_grid_face_edges(self, grid: int, face_edges: np.ndarray) -> np.ndarray:
"""Get the face-edge connectivity.

Parameters
----------
grid : int
A grid identifier.
face_edges : ndarray of int
A numpy array to place the face-edge connectivity.

Returns
-------
ndarray of int
The input numpy array that holds the face-edge connectivity.
"""
...

@abstractmethod
def get_grid_face_nodes(self, grid: int, face_nodes: np.ndarray) -> np.ndarray:
"""Get the face-node connectivity.
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering :: Physics",
],
Expand Down
9 changes: 9 additions & 0 deletions tests/test_bmipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def set_value_at_indices(self, var_name, src, indices):
def get_component_name(self):
pass

def get_input_item_count(self):
pass

def get_output_item_count(self):
pass

def get_input_var_names(self):
pass

Expand Down Expand Up @@ -106,6 +112,9 @@ def get_grid_face_count(self, grid):
def get_grid_face_nodes(self, grid, face_nodes):
pass

def get_grid_face_edges(self, grid, face_edges):
pass

def get_grid_node_count(self, grid):
pass

Expand Down