Skip to content

Commit

Permalink
pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Oct 19, 2022
1 parent cad9151 commit 23503cd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Redistribution and use in source and binary forms, with or without modification,

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 2 additions & 0 deletions ciso/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Cythonized ISOsurface calculation (CISO)."""

from ciso.ciso import zslice

__all__ = ["zslice"]
Expand Down
20 changes: 10 additions & 10 deletions ciso/ciso.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Compute iso-surface slices on 3D fields."""

import numpy as np

from ciso._ciso import _zslice


def zslice(q, p, p0):
"""
Returns a 2D slice of the variable `q` from a 3D field defined by `p`,
along an iso-surface at `p0` using a linear interpolation.
Return a 2D slice of the variable `q` from a 3D field defined by `p`.
The slice is defined along an iso-surface at `p0` using a linear interpolation.
The result `q_iso` is a projection of variable at property == iso-value
in the first non-singleton dimension.
Expand All @@ -24,16 +26,15 @@ def zslice(q, p, p0):
"""
if q.shape != p.shape:
msg = "Arrays q {} and p {} must be of the same shape.".format
raise ValueError(msg(q.shape, p.shape))
raise ValueError(
f"Arrays q {q.shape} and p {p.shape} must be of the same shape.",
)

if np.array(p0).squeeze().ndim != 0:
msg = "p0 must be a float number or 0-dim array. Got {!r}.".format
raise ValueError(msg(p0))
raise ValueError(f"p0 must be a float number or 0-dim array. Got {p0!r}.")

if p0 < p.min() or p.max() < p0:
msg = "p0 {} is outise p bounds ({}, {}).".format
raise ValueError(msg(p0, p.min(), p.max()))
raise ValueError(f"p0 {p0} is outside p bounds ({p.min}, {p.max}).")

q = np.asfarray(q)
p = np.asfarray(p)
Expand All @@ -45,5 +46,4 @@ def zslice(q, p, p0):
elif q.ndim == 2:
return _zslice(q, p, p0)
else:
msg = "Expected 2D (UGRID) or 3D (S/RGRID) arrays. Got {}D.".format
raise ValueError(msg(q.ndim))
raise ValueError(f"Expected 2D (UGRID) or 3D (S/RGRID) arrays. Got {q.ndim}D.")
10 changes: 6 additions & 4 deletions ciso/tests/test_ciso.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import absolute_import, division, print_function

import os
import sys

import numpy as np
import pytest

Expand Down Expand Up @@ -39,13 +38,16 @@ def test_bad_dtypes(data):
zslice(np.empty_like(data["q"], dtype=np.str_), data["p"], p0=0)


@pytest.mark.parametrize("dtype", [int, float, np.int32, np.int64, np.float16, np.float32, np.float64])
@pytest.mark.parametrize(
"dtype",
[int, float, np.int32, np.int64, np.float16, np.float32, np.float64],
)
def test_good_dtypes(data, dtype):
zslice(np.empty_like(data["q"], dtype=dtype), data["p"], p0=0)


@pytest.mark.skipif(
sys.platform in ["win32"],
sys.platform == "win32",
reason="Windows doesn't provide float128",
)
def test_good_dtypes_float128(data):
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
from Cython.Build import cythonize
from setuptools import Extension, setup


extensions = [
Extension(
"ciso._ciso", ["ciso/_ciso.pyx"], include_dirs=[numpy.get_include()]
)
Extension("ciso._ciso", ["ciso/_ciso.pyx"], include_dirs=[numpy.get_include()]),
]

setup(
Expand Down

0 comments on commit 23503cd

Please sign in to comment.