Skip to content

Commit

Permalink
Merge pull request #78 from keurfonluu/devel
Browse files Browse the repository at this point in the history
Add register functions
  • Loading branch information
keurfonluu authored Oct 9, 2020
2 parents 4c6fe52 + a0a3d67 commit 9a827ca
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ install:
- git lfs pull
- pip install -e .[full]
- pip install -r doc/requirements.txt
# for pygmsh >= 7.0
# - sudo apt install libglu1

script:
- set -e
Expand Down
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pygmsh
pygmsh==6.1.1
seaborn
sphinx
sphinx-argparse
Expand Down
4 changes: 4 additions & 0 deletions doc/source/api/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Input parameters

.. autofunction:: toughio.write_input

.. autofunction:: toughio.register_input


Simulation outputs
------------------
Expand All @@ -17,3 +19,5 @@ Simulation outputs
.. autofunction:: toughio.read_output

.. autofunction:: toughio.write_output

.. autofunction:: toughio.register_output
2 changes: 2 additions & 0 deletions doc/source/api/mesh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ I/O

.. autofunction:: toughio.write_mesh

.. autofunction:: toughio.register_mesh

.. autofunction:: toughio.read_time_series

.. autofunction:: toughio.write_time_series
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.. code-block:: bash
pip install pygmsh --user
pip install pygmsh==6.1.1 --user
The mesh can also be generated from scratch directly in Gmsh either using its GUI and/or its internal scripting language.
Expand Down
2 changes: 1 addition & 1 deletion toughio/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.4.2"
__version__ = "1.4.3"
__author__ = "Keurfon Luu"
__author_email__ = "[email protected]"
__website__ = "https://github.com/keurfonluu/toughio"
Expand Down
6 changes: 6 additions & 0 deletions toughio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
read_history,
read_input,
read_output,
register_input,
register_output,
write_input,
write_output,
)
from ._mesh import CellBlock, Mesh, from_meshio, from_pyvista
from ._mesh import read as read_mesh
from ._mesh import read_time_series
from ._mesh import register as register_mesh
from ._mesh import write as write_mesh
from ._mesh import write_time_series

Expand All @@ -25,6 +28,9 @@
"CellBlock",
"Output",
"meshmaker",
"register_input",
"register_output",
"register_mesh",
"read_history",
"read_input",
"read_output",
Expand Down
4 changes: 4 additions & 0 deletions toughio/_io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from .input import read as read_input
from .input import register as register_input
from .input import write as write_input
from .output import Output
from .output import read as read_output
from .output import read_history
from .output import register as register_output
from .output import write as write_output

__all__ = [
"Output",
"register_input",
"register_output",
"read_input",
"write_input",
"read_output",
Expand Down
3 changes: 2 additions & 1 deletion toughio/_io/input/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from . import json, tough
from ._helpers import read, write
from ._helpers import read, register, write

__all__ = [
"register",
"read",
"write",
]
17 changes: 16 additions & 1 deletion toughio/_io/input/_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ..._common import filetype_from_filename, register_format

__all__ = [
"register",
"read",
"write",
]
Expand All @@ -12,7 +13,21 @@


def register(file_format, extensions, reader, writer=None):
"""Register a new format."""
"""
Register a new input format.
Parameters
----------
file_format : str
File format to register.
extensions : array_like
List of extensions to associate to the new format.
reader : callable
Read fumction.
writer : callable or None, optional, default None
Write function.
"""
register_format(
fmt=file_format,
ext_to_fmt=_extension_to_filetype,
Expand Down
3 changes: 2 additions & 1 deletion toughio/_io/output/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from . import csv, petrasim, save, tecplot, tough
from ._common import Output
from ._helpers import read, read_history, write
from ._helpers import read, read_history, register, write

__all__ = [
"Output",
"register",
"read",
"write",
"read_history",
Expand Down
17 changes: 16 additions & 1 deletion toughio/_io/output/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ._common import Output

__all__ = [
"register",
"read",
"write",
"read_history",
Expand All @@ -18,7 +19,21 @@


def register(file_format, extensions, reader, writer=None):
"""Register a new format."""
"""
Register a new output format.
Parameters
----------
file_format : str
File format to register.
extensions : array_like
List of extensions to associate to the new format.
reader : callable
Read fumction.
writer : callable or None, optional, default None
Write function.
"""
register_format(
fmt=file_format,
ext_to_fmt=_extension_to_filetype,
Expand Down
3 changes: 2 additions & 1 deletion toughio/_mesh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import meshio

from . import avsucd, flac3d, pickle, tecplot, tough
from ._helpers import read, read_time_series, write, write_time_series
from ._helpers import read, read_time_series, register, write, write_time_series
from ._mesh import CellBlock, Mesh, from_meshio, from_pyvista

__all__ = [
"register",
"read",
"write",
"read_time_series",
Expand Down
19 changes: 18 additions & 1 deletion toughio/_mesh/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ._mesh import from_meshio

__all__ = [
"register",
"read",
"write",
"read_time_series",
Expand All @@ -21,7 +22,23 @@


def register(file_format, extensions, reader, writer=None, material=None):
"""Register a new format."""
"""
Register a new mesh format.
Parameters
----------
file_format : str
File format to register.
extensions : array_like
List of extensions to associate to the new format.
reader : callable
Read fumction.
writer : callable or None, optional, default None
Write function.
material : str or None, optional, default None
Cell data key associated to material.
"""
register_format(
fmt=file_format,
ext_to_fmt=_extension_to_filetype,
Expand Down

0 comments on commit 9a827ca

Please sign in to comment.