From d5a7f5ed582b7033cad9b29e0e2872c56cdab5df Mon Sep 17 00:00:00 2001 From: Tuomas Karna Date: Thu, 7 Nov 2024 13:54:55 +0200 Subject: [PATCH] pre-commit code formatting --- .pre-commit-config.yaml | 6 ++--- src/_sharpy.cpp | 2 +- src/idtr.cpp | 2 +- src/include/sharpy/CppTypes.hpp | 44 ++++++++++++++++++++++++--------- test/test_manip.py | 2 +- test/test_spmd.py | 2 +- 6 files changed, 40 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index edaea21..b51ace9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-ast - id: check-builtin-literals @@ -19,13 +19,13 @@ repos: - id: trailing-whitespace exclude: '.*\.patch' - repo: https://github.com/psf/black - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black args: ["--line-length", "80"] language_version: python3 - repo: https://github.com/PyCQA/bandit - rev: '1.7.9' + rev: '1.7.10' hooks: - id: bandit args: ["-c", ".bandit.yml"] diff --git a/src/_sharpy.cpp b/src/_sharpy.cpp index 81f40b3..5c0b189 100644 --- a/src/_sharpy.cpp +++ b/src/_sharpy.cpp @@ -149,7 +149,7 @@ void init(bool cw, const std::string &libidtr) { VT(VT_begin, vtWaitSym); \ py::gil_scoped_release release; \ Service::run(); \ - auto r = (_f).get().get()->_a(); \ + auto r = (_f).get().get() -> _a(); \ VT(VT_end, vtWaitSym); \ return r diff --git a/src/idtr.cpp b/src/idtr.cpp index 11869ea..94c7671 100644 --- a/src/idtr.cpp +++ b/src/idtr.cpp @@ -525,7 +525,7 @@ WaitHandleBase *_idtr_copy_reshape(SHARPY::DTypeId sharpytype, if (isStrided) { unpack(rBuff, sharpytype, oDataShapePtr, oDataStridesPtr, oNDims, oDataPtr); - delete[](char *) rBuff; + delete[] (char *)rBuff; } }; assert(sendbuff.empty() && sszs.empty() && soffs.empty() && rszs.empty() && diff --git a/src/include/sharpy/CppTypes.hpp b/src/include/sharpy/CppTypes.hpp index a823d20..1ed8495 100644 --- a/src/include/sharpy/CppTypes.hpp +++ b/src/include/sharpy/CppTypes.hpp @@ -63,17 +63,39 @@ enum _RANKS : rank_type { }; template struct DTYPE {}; -template <> struct DTYPE { constexpr static DTypeId value = FLOAT64; }; -template <> struct DTYPE { constexpr static DTypeId value = FLOAT32; }; -template <> struct DTYPE { constexpr static DTypeId value = INT64; }; -template <> struct DTYPE { constexpr static DTypeId value = INT32; }; -template <> struct DTYPE { constexpr static DTypeId value = INT16; }; -template <> struct DTYPE { constexpr static DTypeId value = INT8; }; -template <> struct DTYPE { constexpr static DTypeId value = UINT64; }; -template <> struct DTYPE { constexpr static DTypeId value = UINT32; }; -template <> struct DTYPE { constexpr static DTypeId value = UINT16; }; -template <> struct DTYPE { constexpr static DTypeId value = UINT8; }; -template <> struct DTYPE { constexpr static DTypeId value = BOOL; }; +template <> struct DTYPE { + constexpr static DTypeId value = FLOAT64; +}; +template <> struct DTYPE { + constexpr static DTypeId value = FLOAT32; +}; +template <> struct DTYPE { + constexpr static DTypeId value = INT64; +}; +template <> struct DTYPE { + constexpr static DTypeId value = INT32; +}; +template <> struct DTYPE { + constexpr static DTypeId value = INT16; +}; +template <> struct DTYPE { + constexpr static DTypeId value = INT8; +}; +template <> struct DTYPE { + constexpr static DTypeId value = UINT64; +}; +template <> struct DTYPE { + constexpr static DTypeId value = UINT32; +}; +template <> struct DTYPE { + constexpr static DTypeId value = UINT16; +}; +template <> struct DTYPE { + constexpr static DTypeId value = UINT8; +}; +template <> struct DTYPE { + constexpr static DTypeId value = BOOL; +}; template struct TYPE {}; template <> struct TYPE { diff --git a/test/test_manip.py b/test/test_manip.py index f2e6bcd..cae47cc 100644 --- a/test/test_manip.py +++ b/test/test_manip.py @@ -3,10 +3,10 @@ import numpy import pytest -from mpi4py import MPI from utils import device, runAndCompare import sharpy as sp +from mpi4py import MPI class TestManip: diff --git a/test/test_spmd.py b/test/test_spmd.py index a39eb23..e0fd5cb 100644 --- a/test/test_spmd.py +++ b/test/test_spmd.py @@ -1,9 +1,9 @@ import numpy as np import pytest -from mpi4py import MPI from utils import device import sharpy as sp +from mpi4py import MPI from sharpy import _sharpy_cw