Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit caaf2f1

Browse files
committed
adding precommit hook
1 parent 217e862 commit caaf2f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+4210
-4446
lines changed

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.4.0
6+
hooks:
7+
- id: end-of-file-fixer
8+
- id: trailing-whitespace
9+
- repo: https://github.com/pocc/pre-commit-hooks
10+
rev: v1.3.5
11+
hooks:
12+
- id: clang-format
13+
args: ["-i"]
14+
- repo: https://github.com/psf/black
15+
rev: 23.1.0
16+
hooks:
17+
- id: black
18+
language_version: python3.9

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
4444

4545
# ===============
4646
# Deps
47-
# ===============
47+
# ===============
4848
# Find dependent packages like IMEX, Python3 and NumPy
4949
find_package(Python3 COMPONENTS Interpreter Development.Module NumPy REQUIRED)
5050
find_package(pybind11 CONFIG)

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,11 @@ python DDPT_IDTR_SO=`pwd`/ddptensor/libidtr.so python simple.py
5757
and multi-process run is executed like
5858
```bash
5959
python DDPT_IDTR_SO=`pwd`/ddptensor/libidtr.so mpirun -n 5 python simple.py
60-
```
60+
```
61+
62+
## Contributing
63+
Please setup precommit hooks like this
64+
```
65+
pre-commit install -f -c ./.pre-commit-config.yaml
66+
pre-commit autoupdate
67+
```

ddptensor/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
FLOAT32 as float32,
2121
INT64 as int64,
2222
INT32 as int32,
23-
INT16 as int16,
23+
INT16 as int16,
2424
INT8 as int8,
2525
UINT64 as uint64,
2626
UINT32 as uint32,
@@ -29,23 +29,26 @@
2929
BOOL as bool,
3030
init as _init,
3131
fini,
32-
sync
32+
sync,
3333
)
3434

3535
from .ddptensor import dtensor
3636
from os import getenv
3737
from . import array_api as api
3838
from . import spmd
3939

40-
_ddpt_cw = _bool(int(getenv('DDPT_CW', True)))
40+
_ddpt_cw = _bool(int(getenv("DDPT_CW", True)))
41+
4142

4243
def init(cw=None):
4344
cw = _ddpt_cw if cw is None else cw
4445
_init(cw)
4546

47+
4648
def to_numpy(a):
4749
return _cdt.to_numpy(a._t)
4850

51+
4952
for op in api.api_categories["EWBinOp"]:
5053
if not op.startswith("__"):
5154
OP = op.upper()
@@ -56,9 +59,7 @@ def to_numpy(a):
5659
for op in api.api_categories["EWUnyOp"]:
5760
if not op.startswith("__"):
5861
OP = op.upper()
59-
exec(
60-
f"{op} = lambda this: dtensor(_cdt.EWUnyOp.op(_cdt.{OP}, this._t))"
61-
)
62+
exec(f"{op} = lambda this: dtensor(_cdt.EWUnyOp.op(_cdt.{OP}, this._t))")
6263

6364
for func in api.api_categories["Creator"]:
6465
FUNC = func.upper()
@@ -98,7 +99,10 @@ def to_numpy(a):
9899

99100
for func in api.api_categories["LinAlgOp"]:
100101
FUNC = func.upper()
101-
if func in ["tensordot", "vecdot",]:
102+
if func in [
103+
"tensordot",
104+
"vecdot",
105+
]:
102106
exec(
103107
f"{func} = lambda this, other, axis: dtensor(_cdt.LinAlgOp.{func}(this._t, other._t, axis))"
104108
)
@@ -107,9 +111,7 @@ def to_numpy(a):
107111
f"{func} = lambda this, other: dtensor(_cdt.LinAlgOp.vecdot(this._t, other._t, 0))"
108112
)
109113
elif func == "matrix_transpose":
110-
exec(
111-
f"{func} = lambda this: dtensor(_cdt.LinAlgOp.{func}(this._t))"
112-
)
114+
exec(f"{func} = lambda this: dtensor(_cdt.LinAlgOp.{func}(this._t))")
113115

114116
for func in api.api_categories["SortOp"]:
115117
exec(

0 commit comments

Comments
 (0)