Skip to content

Commit

Permalink
Update bindings for jigsaw-0.9.15.xx
Browse files Browse the repository at this point in the history
- Swap Exception for TypeError, ValueError, etc.
  • Loading branch information
dengwirda committed Jun 8, 2022
1 parent 2558ca5 commit da9e256
Show file tree
Hide file tree
Showing 22 changed files with 227 additions and 188 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ python:
- 3.7
- 3.8
- 3.9
- 3.10

os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-8
- g++-8
- gcc-9
- g++-9

script:
- export CC=gcc-8
- export CXX=g++-8
- export CC=gcc-9
- export CXX=g++-9
- python3 -m pip install --force-reinstall numpy scipy
- python3 setup.py build_external
- python3 setup.py install
Expand Down
4 changes: 2 additions & 2 deletions jigsawpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* JIGSAW: Interface to the JIGSAW meshing library.
------------------------------------------------------------
*
* Last updated: 19 Apr., 2021
* Last updated: 07 Jun., 2022
*
* Copyright 2019-2021
* Copyright 2019-2022
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda
Expand Down
2 changes: 1 addition & 1 deletion jigsawpy/bisect.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def bisect(mesh):
"""

if (not isinstance(mesh, jigsaw_msh_t)):
raise Exception(
raise TypeError(
"Incorrect type: MESH.")

certify(mesh)
Expand Down
68 changes: 34 additions & 34 deletions jigsawpy/certify.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,44 @@ def certifyarray(data, stag):

return data.size >= +1

raise Exception("Invalid " + stag + " type.")
raise TypeError("Invalid " + stag + " type.")

return False


def certifyradii(data, stag):

if (data.size != +3):
raise Exception("Invalid " + stag + " size.")
raise ValueError("Invalid " + stag + " size.")

if (data.ndim != +1):
raise Exception("Invalid " + stag + " size.")
raise ValueError("Invalid " + stag + " size.")

if (data.dtype != jigsaw_msh_t.REALS_t):
raise Exception("Invalid " + stag + " type.")
raise TypeError("Invalid " + stag + " type.")

if (not np.isfinite(data).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

if (np.any(data <= 0.)):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

return


def certifypoint(data, stag, KIND):

if (data.ndim != +1):
raise Exception("Invalid " + stag + " size.")
raise ValueError("Invalid " + stag + " size.")

if (data.dtype != KIND):
raise Exception("Invalid " + stag + " type.")
raise TypeError("Invalid " + stag + " type.")

if (not np.isfinite(data["coord"]).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

if (not np.isfinite(data["IDtag"]).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

return

Expand All @@ -56,56 +56,56 @@ def certifyvalue(vals, stag):

if (vals.dtype != jigsaw_msh_t.REALS_t and
vals.dtype != jigsaw_msh_t.FLT32_t):
raise Exception("Invalid " + stag + " type.")
raise TypeError("Invalid " + stag + " type.")

if (not np.isfinite(vals).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

return


def certifycells(cell, stag, KIND):

if (cell.ndim != +1):
raise Exception("Invalid " + stag + " size.")
raise ValueError("Invalid " + stag + " size.")

if (cell.dtype != KIND):
raise Exception("Invalid " + stag + " type.")
raise TypeError("Invalid " + stag + " type.")

if (not np.isfinite(cell["index"]).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

if (np.any(cell["index"] < +0)):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

if (not np.isfinite(cell["IDtag"]).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

return


def certifyindex(data, stag, KIND):

if (data.ndim != +1):
raise Exception("Invalid " + stag + " size.")
raise ValueError("Invalid " + stag + " size.")

if (data.dtype != KIND):
raise Exception("Invalid " + stag + " type.")
raise TypeError("Invalid " + stag + " type.")

if (not np.isfinite(data["IDtag"]).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

if (not np.isfinite(data["index"]).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

if (np.any(data["index"] < +0)):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

if (not np.isfinite(data["cells"]).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

if (np.any(data["cells"] < +0)):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

return

Expand Down Expand Up @@ -194,13 +194,13 @@ def certifymesht(mesh):
def certifycoord(data, stag):

if (data.ndim != +1):
raise Exception("Invalid " + stag + " size.")
raise ValueError("Invalid " + stag + " size.")

if (data.dtype != jigsaw_msh_t.REALS_t):
raise Exception("Invalid " + stag + " type.")
raise TypeError("Invalid " + stag + " type.")

if (not np.isfinite(data).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

return

Expand All @@ -209,18 +209,18 @@ def certifyNDmat(data, stag, dims):

if (data.size > 1 and
data.ndim != len(dims)):
raise Exception("Invalid " + stag + " size.")
raise ValueError("Invalid " + stag + " size.")

if (data.size > 1 and
data.size != np.prod(dims)):
raise Exception("Invalid " + stag + " size.")
raise ValueError("Invalid " + stag + " size.")

if (data.dtype != jigsaw_msh_t.REALS_t and
data.dtype != jigsaw_msh_t.FLT32_t):
raise Exception("Invalid " + stag + " type.")
raise TypeError("Invalid " + stag + " type.")

if (not np.isfinite(data).all()):
raise Exception("Invalid " + stag + " data.")
raise ValueError("Invalid " + stag + " data.")

return

Expand Down Expand Up @@ -273,10 +273,10 @@ def certify(mesh):
if (mesh is None): return

if (not isinstance(mesh, jigsaw_msh_t)):
raise Exception("Invalid MESH structure.")
raise TypeError("Invalid MESH structure.")

if (not isinstance(mesh.mshID, str)):
raise Exception("Invalid MESH.MSHID tag.")
raise TypeError("Invalid MESH.MSHID tag.")

if (mesh.mshID.lower() in
["euclidean-mesh", "ellipsoid-mesh"]):
Expand All @@ -291,6 +291,6 @@ def certify(mesh):
certifygridt(mesh)

else:
raise Exception("Invalid MESH.MSHID tag.")
raise ValueError("Invalid MESH.MSHID tag.")

return
10 changes: 9 additions & 1 deletion jigsawpy/def_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@
class jigsaw_def_t:
#--------------------------------- return codes for JIGSAW .

JIGSAW_UNKNOWN_ERROR = +1
JIGSAW_UNKNOWN_ERROR = -1

JIGSAW_NO_ERROR = +0

JIGSAW_FILE_NOT_LOCATED = +2
JIGSAW_FILE_NOT_CREATED = +3

JIGSAW_NETCDF_NOT_FOUND = +9

JIGSAW_INVALID_ARGUMENT = +4
JIGSAW_INVALID_INDEXING = +5
JIGSAW_INVALID_USEROPTS = +6
JIGSAW_INVALID_ARRAYDIM = +7

#--------------------------------- constants for libJIGSAW .

Expand Down Expand Up @@ -51,3 +56,6 @@ class jigsaw_def_t:
JIGSAW_KERN_ODT_DQDX = +404
JIGSAW_KERN_CVT_DQDX = +405
JIGSAW_KERN_H95_DQDX = +406

JIGSAW_KERN_AREA_LEN = +410
JIGSAW_KERN_SKEW_COS = +411
12 changes: 12 additions & 0 deletions jigsawpy/jig_l.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ class libsaw_jig_t(ct.Structure):

("optm_iter", indx_t),

# OPTM_COST - {default='area-len'} mesh optimisation
# cost metric, choice of area-length (COST='area-len')
# or skewed-cosine (COST='skew-cos') functions.
# The area-length metric is symmetric wrt. both small
# and large cell angles, and is typically appropriate
# for simplex-only meshes. The skewed-cosine metric
# is based on an asymmetric penalisation of large cell
# angles, and may be useful for staggered primal-dual
# tessellations.

("optm_cost", indx_t),

# OPTM_QTOL - {default=1.E-04} tolerance on mesh cost
# function for convergence. Iteration on a given node
# is terminated if adjacent element cost-functions are
Expand Down
14 changes: 13 additions & 1 deletion jigsawpy/jig_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@
isation iterations. Set ITER=N to see progress after
N iterations.
OPTS.OPTM_COST - {default='area-len'} mesh optimisation
cost metric, choice of area-length (COST='area-len')
or skewed-cosine (COST='skew-cos') functions.
The area-length metric is symmetric wrt. both small
and large cell angles, and is typically appropriate
for simplex-only meshes. The skewed-cosine metric
is based on an asymmetric penalisation of large cell
angles, and may be useful for staggered primal-dual
tessellations.
OPTS.OPTM_QTOL - {default=1.E-04} tolerance on mesh cost
function for convergence. Iteration on a given node
is terminated if adjacent element cost-functions are
Expand Down Expand Up @@ -283,9 +293,11 @@ def __init__(self):

#------------------------------------------ OPTM options
self.optm_kern = None

self.optm_iter = None

self.optm_cost = None

self.optm_qtol = None
self.optm_qlim = None

Expand Down

0 comments on commit da9e256

Please sign in to comment.