Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 13, 2023
1 parent 006e8a3 commit 38b4f23
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
14 changes: 7 additions & 7 deletions src/amrex/Array4.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ def array4_to_cupy(self, copy=False, order="F"):

def register_Array4_extension(amr):
"""Array4 helper methods"""
import inspect, sys
import inspect
import sys

# register member functions for every Array4_* type
for _, Array4_type in inspect.getmembers(
sys.modules[amr.__name__],
lambda member:
inspect.isclass(member) and
member.__module__ == amr.__name__ and
member.__name__.startswith("Array4_")
):
sys.modules[amr.__name__],
lambda member: inspect.isclass(member)
and member.__module__ == amr.__name__
and member.__name__.startswith("Array4_"),
):
Array4_type.to_numpy = array4_to_numpy
Array4_type.to_cupy = array4_to_cupy
14 changes: 7 additions & 7 deletions src/amrex/PODVector.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ def podvector_to_cupy(self, copy=False):

def register_PODVector_extension(amr):
"""PODVector helper methods"""
import inspect, sys
import inspect
import sys

# register member functions for every PODVector_* type
for _, POD_type in inspect.getmembers(
sys.modules[amr.__name__],
lambda member:
inspect.isclass(member) and
member.__module__ == amr.__name__ and
member.__name__.startswith("PODVector_")
):
sys.modules[amr.__name__],
lambda member: inspect.isclass(member)
and member.__module__ == amr.__name__
and member.__name__.startswith("PODVector_"),
):
POD_type.to_numpy = podvector_to_numpy
POD_type.to_cupy = podvector_to_cupy
26 changes: 10 additions & 16 deletions src/amrex/StructOfArrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ def soa_to_numpy(self, copy=False):
of 1D numpy arrays.
"""
import numpy as np

SoA_np = namedtuple(
type(self).__name__ + "_np",
['real', 'int']
)

SoA_np = namedtuple(type(self).__name__ + "_np", ["real", "int"])

soa_view = SoA_np([], [])

Expand Down Expand Up @@ -70,10 +67,7 @@ def soa_to_cupy(self, copy=False):
"""
import cupy as cp

SoA_cp = namedtuple(
type(self).__name__ + "_cp",
['real', 'int']
)
SoA_cp = namedtuple(type(self).__name__ + "_cp", ["real", "int"])

soa_view = SoA_cp([], [])

Expand All @@ -91,15 +85,15 @@ def soa_to_cupy(self, copy=False):

def register_SoA_extension(amr):
"""StructOfArrays helper methods"""
import inspect, sys
import inspect
import sys

# register member functions for every StructOfArrays_* type
for _, SoA_type in inspect.getmembers(
sys.modules[amr.__name__],
lambda member:
inspect.isclass(member) and
member.__module__ == amr.__name__ and
member.__name__.startswith("StructOfArrays_")
):
sys.modules[amr.__name__],
lambda member: inspect.isclass(member)
and member.__module__ == amr.__name__
and member.__name__.startswith("StructOfArrays_"),
):
SoA_type.to_numpy = soa_to_numpy
SoA_type.to_cupy = soa_to_cupy

0 comments on commit 38b4f23

Please sign in to comment.