Skip to content

Commit

Permalink
fixup format
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreMarchand20 committed Jan 30, 2024
1 parent 48212c7 commit 97d37cb
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 64 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,9 @@ jobs:
make cmake-format
git diff --exit-code
- name: Check module imports with isort
if: matrix.CODE_COVERAGE == 'ON'
- name: Check with ruff
run: |
python3 -m pip install isort
python3 -m isort example --check-only --diff
python3 -m isort tests --check-only --diff
- name: Check formatting with black
if: matrix.CODE_COVERAGE == 'ON'
uses: psf/black@stable
with:
src: "./example ./tests"
ruff .
- name: Generate coverage reports
if: matrix.CODE_COVERAGE == 'ON'
Expand Down
3 changes: 1 addition & 2 deletions example/ddm_solver.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Htool
import matplotlib.pyplot as plt
import mpi4py
import numpy as np
from create_geometry import create_random_geometries
from define_custom_generators import CustomGeneratorWithPermutation

import Htool

# Random geometry
size = 500
dimension = 3
Expand Down
2 changes: 1 addition & 1 deletion example/define_custom_local_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(
def add_vector_product(
self, trans, alpha, input: np.array, beta, output: np.array
) -> None:
# Beware, you need to use inplace operation for output to keep the underlying data
# Beware, inplace operation needed for output to keep the underlying data
output *= beta
if trans == "N":
output += alpha * self.data.dot(input)
Expand Down
3 changes: 1 addition & 2 deletions example/use_block_jacobi_solver_with_default_build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Htool
import matplotlib.pyplot as plt
import mpi4py
import numpy as np
from create_geometry import create_random_geometries
from define_custom_generators import CustomGenerator

import Htool

# Random geometry
size = 500
dimension = 3
Expand Down
3 changes: 1 addition & 2 deletions example/use_block_jacobi_solver_with_no_default_build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Htool
import matplotlib.pyplot as plt
import mpi4py
import numpy as np
from create_geometry import create_partitionned_geometries
from define_custom_generators import CustomGenerator

import Htool

# Random geometry
size = 500
dimension = 3
Expand Down
3 changes: 1 addition & 2 deletions example/use_cluster_with_given_partition.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Htool
import matplotlib.pyplot as plt
import mpi4py
from create_geometry import create_partitionned_geometries

import Htool

# Random geometry
nb_rows = 500
nb_cols = 500
Expand Down
3 changes: 1 addition & 2 deletions example/use_custom_dense_block_generator.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Htool
import mpi4py
import numpy as np
from create_geometry import create_partitionned_geometries
from define_custom_dense_blocks_generator import CustomDenseBlocksGenerator
from define_custom_generators import CustomGenerator

import Htool

# Random geometry
nb_rows = 500
nb_cols = 500
Expand Down
3 changes: 1 addition & 2 deletions example/use_custom_local_operator.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Htool
import mpi4py
import numpy as np
from create_geometry import create_partitionned_geometries
from define_custom_generators import CustomGenerator
from define_custom_local_operator import CustomLocalOperator

import Htool

# Random geometry
nb_rows = 500
nb_cols = 500
Expand Down
4 changes: 1 addition & 3 deletions example/use_default_build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

import Htool
import matplotlib.pyplot as plt
import mpi4py
import numpy as np
from create_geometry import create_partitionned_geometries
from define_custom_generators import CustomGenerator

import Htool

# Random geometry
nb_rows = 500
nb_cols = 500
Expand Down
4 changes: 1 addition & 3 deletions example/use_local_build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@

import Htool
import matplotlib.pyplot as plt
import mpi4py
import numpy as np
from create_geometry import create_random_geometries
from define_custom_generators import CustomGenerator
from define_custom_local_operator import CustomLocalOperator

import Htool

# Random geometry
target_size = 500
source_size = 500
Expand Down
3 changes: 1 addition & 2 deletions example/use_no_default_build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Htool
import matplotlib.pyplot as plt
import mpi4py
import numpy as np
from create_geometry import create_partitionned_geometries
from define_custom_generators import CustomGenerator

import Htool

# Random geometry
nb_rows = 500
nb_cols = 500
Expand Down
22 changes: 17 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,25 @@ test = ["matplotlib>=3.0.0", "pytest"]
"Homepage" = "https://github.com/htool-ddm/htool_python"
"Bug Tracker" = "https://github.com/htool-ddm/htool_python/issues"

[tool.black]
[tool.ruff]
line-length = 88
indent-width = 4
exclude = ["lib", "cmake-format.py"]

[tool.ruff.lint]
select = [
"E", # pycodestyle
"F", # Pyflakes
"UP", # pyupgrade
"B", # flake8-bugbear
"SIM", # flake8-simplify
"I", # isort
]
ignore = []

[tool.isort]
profile = "black"
known_local_folder = 'Htool,example'
skip = "lib"
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []


[build-system]
Expand Down
14 changes: 9 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ def build_extension(self, ext):

# Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
# across all generators.
if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ:
if (
"CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ
and hasattr(self, "parallel")
and self.parallel
):
# self.parallel is a Python 3 only way to set parallel jobs by hand
# using -j in the build_ext call, not supported by pip or PyPA-build.
if hasattr(self, "parallel") and self.parallel:
# CMake 3.12+ only.
build_args += [f"-j{self.parallel}"]

# CMake 3.12+ only.
build_args += [f"-j{self.parallel}"]

build_temp = Path(self.build_temp) / ext.name
if not build_temp.exists():
Expand Down Expand Up @@ -161,7 +165,7 @@ def build_extension(self, ext):
version="0.9.0",
author="Pierre Marchand",
author_email="",
description="A pybind11 interface to Htool, a header only c++ library that provides Hierarchical matrices.",
description="""A pybind11 interface to Htool.""",
long_description="",
ext_modules=[CMakeExtension("Htool")],
cmdclass=dict(build_ext=CMakeBuild),
Expand Down
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def load_data_solver(symmetry, mu):
"rb",
) as input:
data = input.read()
l = struct.unpack("@I", data[:4])
# l = struct.unpack("@I", data[:4])
rhs = np.frombuffer(data[4:], dtype=np.dtype("complex128"))
f = np.zeros(len(rhs), dtype="complex128")
if mu > 1:
Expand Down Expand Up @@ -375,7 +375,9 @@ def load_data_solver(symmetry, mu):
(m, n) = struct.unpack("@II", data[:8])
# print(m,n)
local_neumann_matrix = np.frombuffer(data[8:], dtype=np.dtype("complex128"))
local_neumann_matrix = np.transpose(local_neumann_matrix.reshape((m, n),order='C')).copy("F")
local_neumann_matrix = np.transpose(
local_neumann_matrix.reshape((m, n), order="C")
).copy("F")
return [
A,
x_ref,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_cluster.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Htool
import matplotlib.pyplot as plt
import mpi4py
import pytest

import Htool


@pytest.mark.parametrize(
"dimension,nb_rows,nb_cols,symmetry,is_partition_given",
Expand Down
16 changes: 1 addition & 15 deletions tests/test_ddm_solver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import time

import Htool
import mpi4py
import numpy as np
Expand Down Expand Up @@ -292,19 +290,7 @@ def test_ddm_solver(
solver.set_hpddm_args(
"-hpddm_schwarz_coarse_correction " + hpddm_schwarz_coarse_correction
)
# solver.build_coarse_space(local_neumann_matrix)
# print(default_solver_builder.block_diagonal_dense_matrix.flags)
# print(local_neumann_matrix.flags)
# geneo_space_operator_builder = (
# Htool.ComplexGeneoCoarseSpaceDenseBuilder.GeneoWithNu(
# cluster.get_cluster_on_partition(mpi4py.MPI.COMM_WORLD.rank).get_size(),
# default_solver_builder.block_diagonal_dense_matrix,
# local_neumann_matrix,
# symmetry,
# UPLO,
# 2,
# )
# )

geneo_space_operator_builder = None
if geneo_type == "geneo_nu":
geneo_space_operator_builder = Htool.ComplexGeneoCoarseSpaceDenseBuilder(
Expand Down
3 changes: 0 additions & 3 deletions tests/test_distributed_operator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import mpi4py
import numpy as np
import pytest

import Htool


@pytest.mark.parametrize("epsilon", [1e-3, 1e-6])
@pytest.mark.parametrize("eta", [10])
Expand Down

0 comments on commit 97d37cb

Please sign in to comment.