Skip to content

Commit

Permalink
fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
SeRealMF committed Nov 16, 2023
1 parent 6bc1963 commit 089a5c0
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 38 deletions.
4 changes: 3 additions & 1 deletion splinepy/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ def __init_subclass__(cls, *args, **kwargs):
super().__init_subclass__(*args, **kwargs)
cls._logi = _log.prepend_log("<" + cls.__qualname__ + ">", _log.info)
cls._logd = _log.prepend_log("<" + cls.__qualname__ + ">", _log.debug)
cls._logw = _log.prepend_log("<" + cls.__qualname__ + ">", _log.warning)
cls._logw = _log.prepend_log(
"<" + cls.__qualname__ + ">", _log.warning
)
return super().__new__(cls)
2 changes: 1 addition & 1 deletion splinepy/io/cats.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from splinepy.io import ioutils as _ioutils
from splinepy.utils.log import debug as _debug
from splinepy.utils.log import warning as _warning
from splinepy.utils.log import warning as _warning

# List of spline keywords (bundled here in case they change - many unused)
CATS_XML_KEY_WORDS = {
Expand Down
11 changes: 8 additions & 3 deletions splinepy/io/gismo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from splinepy.utils.log import debug as _debug
from splinepy.utils.log import warning as _warning


def _spline_to_ET(
root,
multipatch,
Expand Down Expand Up @@ -230,7 +231,7 @@ def export(
"""
from splinepy import Multipatch as _Multipatch
from splinepy.settings import NTHREADS as _NTHREADS
from splinepy.settings import TOLERANCE as _TOLERANCE
from splinepy.settings import TOLERANCE as _TOLERANCE
from splinepy.spline import Spline as _Spline
from splinepy.splinepy_core import orientations as _orientations

Expand Down Expand Up @@ -264,7 +265,9 @@ def export(
multipatch_element = _ET.SubElement(
xml_data, "MultiPatch", id=str(0), parDim=str(multipatch.para_dim)
)
patch_range = _ET.SubElement(multipatch_element, "patches", type="id_range")
patch_range = _ET.SubElement(
multipatch_element, "patches", type="id_range"
)
patch_range.text = (
f"{index_offset} " f"{len(multipatch.patches) - 1 + index_offset}"
)
Expand Down Expand Up @@ -570,7 +573,9 @@ def make_dictionary(ETelement):
if patch_element is None:
_debug("Unsupported format")
if patch_element.attrib.get("type") != "id_range":
_debug(f"Invalid patch type {patch_element.attrib.get('type')}")
_debug(
f"Invalid patch type {patch_element.attrib.get('type')}"
)
patch_range = _matrix_from_node(patch_element).astype(_np.int64)
offset = patch_range[0]
n_splines = patch_range[1] - patch_range[0] + 1
Expand Down
1 change: 0 additions & 1 deletion splinepy/io/mfem.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from splinepy.io.ioutils import make_meaningful as _make_meaningful
from splinepy.io.ioutils import next_line as _next_line


# keywords : possible assert value
_mfem_meaningful_keywords = {
"MFEM NURBS mesh v1.0": "intro",
Expand Down
8 changes: 6 additions & 2 deletions splinepy/microstructure/tiles/crossednuttile2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,9 @@ def _closing_tile(

spline_list.append(_Bezier(degrees=[1, 1], control_points=top))

spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom_right))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=bottom_right)
)

return spline_list

Expand Down Expand Up @@ -549,6 +551,8 @@ def create_tile(

spline_list.append(_Bezier(degrees=[1, 1], control_points=top))

spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom_right))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=bottom_right)
)

return spline_list
3 changes: 2 additions & 1 deletion splinepy/microstructure/tiles/cube3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def create_tile(
self.check_params(parameters)

if not (
_np.all(parameters[:, :2] > 0.0) and _np.all(parameters[:, :2] < 0.5)
_np.all(parameters[:, :2] > 0.0)
and _np.all(parameters[:, :2] < 0.5)
):
raise ValueError("The wall thickness must be in (0.0 and 0.5)")

Expand Down
1 change: 1 addition & 0 deletions splinepy/microstructure/tiles/ellipsvoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from splinepy.bezier import Bezier as _Bezier
from splinepy.microstructure.tiles.tilebase import TileBase as _TileBase


class Ellipsvoid(_TileBase):
"""Void in form of an ellipse set into a unit cell.
Expand Down
4 changes: 3 additions & 1 deletion splinepy/microstructure/tiles/inversecrosstile3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,9 @@ def create_tile(

self.check_params(parameters)

if _np.any(parameters < min_radius) or _np.any(parameters > max_radius):
if _np.any(parameters < min_radius) or _np.any(
parameters > max_radius
):
raise ValueError(
f"Radii must be in (0,{max_radius}) for "
f"center_expansion {center_expansion}"
Expand Down
8 changes: 6 additions & 2 deletions splinepy/microstructure/tiles/nuttile2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,9 @@ def _closing_tile(

spline_list.append(_Bezier(degrees=[1, 1], control_points=top))

spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom_right))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=bottom_right)
)

return (spline_list, None)

Expand Down Expand Up @@ -561,6 +563,8 @@ def create_tile(

spline_list.append(_Bezier(degrees=[1, 1], control_points=top))

spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom_right))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=bottom_right)
)

return (spline_list, None)
8 changes: 6 additions & 2 deletions splinepy/microstructure/tiles/nuttile3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ def create_tile(

spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=right))

spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=right_top))
spline_list.append(
_Bezier(degrees=[1, 1, 1], control_points=right_top)
)

spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=bottom))

Expand Down Expand Up @@ -587,6 +589,8 @@ def closing_tile(

spline_list.append(_Bezier(degrees=[1, 1], control_points=top))

spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom_right))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=bottom_right)
)

return (spline_list, None)
56 changes: 42 additions & 14 deletions splinepy/microstructure/tiles/snappytile.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def _closing_tile(
]
)

spline_list.append(_Bezier(degrees=[1, 1], control_points=spline_1))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=spline_1)
)
spline_2 = _np.array(
[
[cl_2_inv, v_zero],
Expand All @@ -89,7 +91,9 @@ def _closing_tile(
]
)

spline_list.append(_Bezier(degrees=[1, 1], control_points=spline_2))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=spline_2)
)
spline_3 = _np.array(
[
[v_zero, a_inv],
Expand All @@ -99,7 +103,9 @@ def _closing_tile(
]
)

spline_list.append(_Bezier(degrees=[1, 1], control_points=spline_3))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=spline_3)
)
spline_4 = _np.array(
[
[cl_2_inv, a_inv],
Expand All @@ -109,7 +115,9 @@ def _closing_tile(
]
)

spline_list.append(_Bezier(degrees=[1, 1], control_points=spline_4))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=spline_4)
)

spline_5 = _np.array(
[
Expand All @@ -120,7 +128,9 @@ def _closing_tile(
]
)

spline_list.append(_Bezier(degrees=[1, 1], control_points=spline_5))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=spline_5)
)

spline_6 = _np.array(
[
Expand All @@ -131,7 +141,9 @@ def _closing_tile(
]
)

spline_list.append(_Bezier(degrees=[1, 1], control_points=spline_6))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=spline_6)
)

spline_7 = _np.array(
[
Expand All @@ -146,7 +158,9 @@ def _closing_tile(
]
)

spline_list.append(_Bezier(degrees=[3, 1], control_points=spline_7))
spline_list.append(
_Bezier(degrees=[3, 1], control_points=spline_7)
)

spline_8 = _np.array(
[
Expand All @@ -161,7 +175,9 @@ def _closing_tile(
]
) + [v_one_half, v_zero]

spline_list.append(_Bezier(degrees=[3, 1], control_points=spline_8))
spline_list.append(
_Bezier(degrees=[3, 1], control_points=spline_8)
)

spline_9 = _np.array(
[
Expand All @@ -176,7 +192,9 @@ def _closing_tile(
]
)

spline_list.append(_Bezier(degrees=[3, 1], control_points=spline_9))
spline_list.append(
_Bezier(degrees=[3, 1], control_points=spline_9)
)

spline_10 = _np.array(
[
Expand Down Expand Up @@ -204,7 +222,9 @@ def _closing_tile(
[cl_2, v_one],
]
)
spline_list.append(_Bezier(degrees=[1, 1], control_points=spline_1))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=spline_1)
)
spline_2 = _np.array(
[
[cl_2_inv, v_zero],
Expand All @@ -213,7 +233,9 @@ def _closing_tile(
[v_one, v_one],
]
)
spline_list.append(_Bezier(degrees=[1, 1], control_points=spline_2))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=spline_2)
)
spline_3 = _np.array(
[
[v_one_half - cl_2, v_one_half - b],
Expand All @@ -222,7 +244,9 @@ def _closing_tile(
[v_one_half + cl_2, v_one],
]
)
spline_list.append(_Bezier(degrees=[1, 1], control_points=spline_3))
spline_list.append(
_Bezier(degrees=[1, 1], control_points=spline_3)
)
spline_4 = _np.array(
[
[cl_2, v_zero],
Expand All @@ -235,7 +259,9 @@ def _closing_tile(
[v_one_half - cl_2, v_one],
]
)
spline_list.append(_Bezier(degrees=[3, 1], control_points=spline_4))
spline_list.append(
_Bezier(degrees=[3, 1], control_points=spline_4)
)
spline_5 = _np.array(
[
[cl_2, v_one_half - b],
Expand All @@ -249,7 +275,9 @@ def _closing_tile(
]
) + [v_one_half, v_zero]

spline_list.append(_Bezier(degrees=[3, 1], control_points=spline_5))
spline_list.append(
_Bezier(degrees=[3, 1], control_points=spline_5)
)
return (spline_list, None)
else:
raise ValueError(
Expand Down
4 changes: 3 additions & 1 deletion splinepy/microstructure/tiles/tilebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def check_param_derivatives(self, derivatives):
if derivatives is None:
return False

if not (isinstance(derivatives, _np.ndarray) and derivatives.ndim == 3):
if not (
isinstance(derivatives, _np.ndarray) and derivatives.ndim == 3
):
raise TypeError("parameters must be three-dimensional np array")

if not (
Expand Down
7 changes: 4 additions & 3 deletions splinepy/multipatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
from splinepy._base import SplinepyBase as _SplinepyBase
from splinepy.helpme import visualize as _visualize
from splinepy.helpme.extract import Extractor as _Extractor
from splinepy.spline import _default_if_none
from splinepy.spline import _get_helper
from splinepy.spline import _default_if_none, _get_helper
from splinepy.splinepy_core import PyMultipatch as _PyMultipatch
from splinepy.splinepy_core import boundaries_from_continuity as _boundaries_from_continuity
from splinepy.splinepy_core import (
boundaries_from_continuity as _boundaries_from_continuity,
)
from splinepy.utils.data import MultipatchData as _MultipatchData


Expand Down
7 changes: 4 additions & 3 deletions splinepy/spline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from splinepy import helpme as _helpme
from splinepy import io as _io
from splinepy import settings as _settings
from splinepy import utils as _utils
from splinepy import splinepy_core as _core
from splinepy import utils as _utils
from splinepy._base import SplinepyBase as _SplinepyBase
from splinepy.helpme import visualize as _visualize
from splinepy.helpme.check import Checker as _Checker
Expand Down Expand Up @@ -874,7 +874,7 @@ def knot_multiplicities(self):
self._logd(
"Returning multiplicities of knots if Bezier was BSpline"
)
return [np.array([d + 1, d + 1]) for d in self.degrees]
return [_np.array([d + 1, d + 1]) for d in self.degrees]

else:
self._logd("Retrieving knot multiplicities")
Expand Down Expand Up @@ -1190,7 +1190,8 @@ def sample(self, resolutions, nthreads=None):
self._logd(f"Sampling {_np.prod(resolutions)} points from spline.")

return super().sample(
resolutions, nthreads=_default_if_none(nthreads, _settings.NTHREADS)
resolutions,
nthreads=_default_if_none(nthreads, _settings.NTHREADS),
)

def derivative(self, queries, orders, nthreads=None):
Expand Down
5 changes: 3 additions & 2 deletions splinepy/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

__all__ = [
"PhysicalSpaceArray",
"DataHolder",
"_DataHolder",
"enforce_contiguous_values",
"cartesian_product",
"SplineDataAdaptor",
Expand Down Expand Up @@ -369,7 +369,8 @@ def cartesian_product(arrays, reverse=True):

dim_reducing_views = (
*_accumulate(
_chain((_cartesian,), _repeat(0, n_arr - 1)), _np.ndarray.__getitem__
_chain((_cartesian,), _repeat(0, n_arr - 1)),
_np.ndarray.__getitem__,
),
)
idx = slice(None), *_repeat(None, n_arr - 1)
Expand Down
1 change: 1 addition & 0 deletions tests/test_creator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np

import splinepy

try:
Expand Down

0 comments on commit 089a5c0

Please sign in to comment.