Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/scripts/post-benchmark-to-github-pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ def main():
for item in release:
db.execute("INSERT OR IGNORE INTO release VALUES (?, ?)", flatten_metric(item))

rs = db.execute(
"""
rs = db.execute("""
SELECT
c.name AS name,
c.value AS cv,
Expand All @@ -118,8 +117,7 @@ def main():
current c
LEFT JOIN release r ON (r.name = c.name)
ORDER BY name
"""
)
""")

event = json.loads(Path(options.event).read_text())
sha = event["client_payload"]["pull_request"]["head"]["sha"]
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/scripts/ti_build/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from .bootstrap import get_cache_home # noqa, this is a re-export
from .escapes import escape_codes


# -- code --
options = None

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/scripts/ti_build/ospkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from .misc import banner, error, info
from .tinysh import apt


# -- code --
UBUNTU_PACKAGES = {
"git",
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ default_language_version:

exclude: ^((tests/python/test_exception)\.py$|external/)
repos:
- repo: https://github.com/psf/black
rev: 25.1.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.3.1
hooks:
- id: black
language_version: python3.12
args: ['-l', '120']

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.7
rev: v22.1.2
hooks:
- id: clang-format
exclude: .*\.json$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/PyCQA/pylint
rev: v3.3.4
rev: v4.0.5
hooks:
- id: pylint
args: ['-rn', '-sn']
Expand Down
4 changes: 1 addition & 3 deletions docs/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@

PRELUDES = {}

PRELUDES[
"init"
] = """
PRELUDES["init"] = """
import taichi as ti
import numpy as np
import math
Expand Down
4 changes: 1 addition & 3 deletions misc/copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
{file} .
{file} --check taichi/common/core.cpp taichi/ir/transforms.h
{file} benchmarks cmake docs examples misc python taichi tests
{file} --exts "cpp,py" benchmarks cmake docs examples misc python taichi tests""".format(
file=os.path.relpath(__file__)
)
{file} --exts "cpp,py" benchmarks cmake docs examples misc python taichi tests""".format(file=os.path.relpath(__file__))


class CommentStyle(Enum):
Expand Down
2 changes: 1 addition & 1 deletion python/taichi/aot/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def instantiate(self, **kwargs):

for arg in kernel.arguments:
if isinstance(arg.annotation, template):
(k, v) = template_args[anno_index]
k, v = template_args[anno_index]
key_p += k
key_p = self.keygen(v, key_p, self._aot_module._fields.items())
injected_args.append(v)
Expand Down
2 changes: 1 addition & 1 deletion python/taichi/examples/simulation/initial_value_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def init():

@ti.kernel
def paint(t: float):
(o, p) = locations_np.shape
o, p = locations_np.shape
for i in range(0, o): # Parallelized over all pixels
x = locations[i, 0]
y = locations[i, 1]
Expand Down
12 changes: 4 additions & 8 deletions python/taichi/lang/_wrap_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,8 @@ def _Python_IPython_findsource(obj):

except ImportError:
pass
raise IOError(
f"Cannot find source code for Object: {obj}, it's likely \
you are not running Taichi from command line or IPython."
)
raise IOError(f"Cannot find source code for Object: {obj}, it's likely \
you are not running Taichi from command line or IPython.")


def _REPL_findsource(obj):
Expand All @@ -154,12 +152,10 @@ def _custom_findsource(obj):
try:
return _blender_findsource(obj)
except:
raise IOError(
f"Cannot find source code for Object: {obj}, this \
raise IOError(f"Cannot find source code for Object: {obj}, this \
is possibly because of you are running Taichi in an environment that Taichi's own \
inspect module cannot find the source. Please report an issue to help us fix: \
https://github.com/taichi-dev/taichi/issues"
)
https://github.com/taichi-dev/taichi/issues")


class _InspectContextManager:
Expand Down
1 change: 1 addition & 0 deletions python/taichi/math/mathimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Math functions for glsl-like functions and other stuff.
"""

import math

from taichi.lang import impl, ops
Expand Down
6 changes: 2 additions & 4 deletions python/taichi/tools/vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ def write_vtk(scalar_field, filename):
try:
from pyevtk.hl import gridToVTK # pylint: disable=import-outside-toplevel
except ImportError:
raise RuntimeError(
"Failed to import pyevtk. Please install it via /\
`pip install pyevtk` first. "
)
raise RuntimeError("Failed to import pyevtk. Please install it via /\
`pip install pyevtk` first. ")

scalar_field_np = scalar_field.to_numpy()
field_shape = scalar_field_np.shape
Expand Down
6 changes: 2 additions & 4 deletions python/taichi/ui/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ def contour(self, scalar_field, cmap_name="plasma", normalize=False):
import numpy as np # pylint: disable=import-outside-toplevel
from matplotlib import cm # pylint: disable=import-outside-toplevel
except ImportError:
raise RuntimeError(
"Failed to import Numpy and Matplotlib. /\
Please install Numpy and Matplotlib before using contour()."
)
raise RuntimeError("Failed to import Numpy and Matplotlib. /\
Please install Numpy and Matplotlib before using contour().")

scalar_field_np = scalar_field.to_numpy()
field_shape = scalar_field_np.shape
Expand Down
6 changes: 2 additions & 4 deletions python/taichi/ui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,8 @@ def contour(self, scalar_field, normalize=False):
try:
from matplotlib import cm # pylint: disable=import-outside-toplevel
except ImportError:
raise RuntimeError(
"Failed to import Matplotlib. Please install it via /\
`pip install matplotlib` first. "
)
raise RuntimeError("Failed to import Matplotlib. Please install it via /\
`pip install matplotlib` first. ")
scalar_field_np = scalar_field.to_numpy()
if self.res != scalar_field_np.shape:
x, y = np.meshgrid(np.linspace(0, 1, self.res[1]), np.linspace(0, 1, self.res[0]))
Expand Down
1 change: 0 additions & 1 deletion python/taichi/ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from .utils import check_ggui_availability # pylint: disable=unused-import
from .window import Window # pylint: disable=unused-import


# ----------------------
ProjectionMode = _ti_core.ProjectionMode if _ti_core.GGUI_AVAILABLE else None
"""Camera projection mode, 0 for perspective and 1 for orthogonal.
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_clang_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_tidy_invocation(
start.append("-export-fixes")
# Get a temporary file. We immediately close the handle so clang-tidy can
# overwrite it.
(handle, name) = tempfile.mkstemp(suffix=".yaml", dir=tmpdir)
handle, name = tempfile.mkstemp(suffix=".yaml", dir=tmpdir)
os.close(handle)
start.append(name)
for arg in extra_arg:
Expand Down
13 changes: 10 additions & 3 deletions taichi/rhi/public_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ enum class BufferFormat : uint32_t {
#undef PER_BUFFER_FORMAT
};

class RHI_DLL_EXPORT Pipeline{public : virtual ~Pipeline(){}};
class RHI_DLL_EXPORT Pipeline {
public:
virtual ~Pipeline() {
}
};

using UPipeline = std::unique_ptr<Pipeline>;

Expand Down Expand Up @@ -554,8 +558,11 @@ enum class AllocUsage : int {

MAKE_ENUM_FLAGS(AllocUsage)

class RHI_DLL_EXPORT
StreamSemaphoreObject{public : virtual ~StreamSemaphoreObject(){}};
class RHI_DLL_EXPORT StreamSemaphoreObject {
public:
virtual ~StreamSemaphoreObject() {
}
};

using StreamSemaphore = std::shared_ptr<StreamSemaphoreObject>;

Expand Down
10 changes: 8 additions & 2 deletions taichi/ui/gui/cocoa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ std::string str_tolower(std::string s) {

std::optional<std::string> try_get_alnum(ushort keycode) {
// Can someone tell me the reason why Apple didn't make these consecutive...
#define CASE(i) {kVK_ANSI_##i, str_tolower(#i)}
#define CASE(i) \
{ \
kVK_ANSI_##i, str_tolower(#i) \
}
static const std::unordered_map<ushort, std::string> key2str = {
CASE(0), CASE(1), CASE(2), CASE(3), CASE(4), CASE(5), CASE(6), CASE(7),
CASE(8), CASE(9), CASE(A), CASE(B), CASE(C), CASE(D), CASE(E), CASE(F),
Expand All @@ -60,7 +63,10 @@ std::optional<std::string> try_get_alnum(ushort keycode) {
std::optional<std::string> try_get_fnkey(ushort keycode) {
// Or these...
#define STRINGIFY(x) #x
#define CASE(i) {kVK_F##i, STRINGIFY(F##i)}
#define CASE(i) \
{ \
kVK_F##i, STRINGIFY(F##i) \
}
static const std::unordered_map<ushort, std::string> key2str = {
CASE(1), CASE(2), CASE(3), CASE(4), CASE(5), CASE(6),
CASE(7), CASE(8), CASE(9), CASE(10), CASE(11), CASE(12),
Expand Down
6 changes: 2 additions & 4 deletions tests/pytest_hardtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@

# Modified from pytest-timeout
tle_cffi = cffi.FFI()
tle_cffi.cdef(
"""
tle_cffi.cdef("""
void init(void);
void set(int seconds, char *message);
void cancel(void);
"""
)
""")

TLE_WIN32 = r"""
#include <string.h>
Expand Down
4 changes: 2 additions & 2 deletions tests/python/test_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def func_basic():
def test_assign_unpack():
@ti.kernel
def func_unpack():
(a, b) = (1, 2)
a, b = (1, 2)
assert a == 1
assert b == 2

Expand All @@ -40,7 +40,7 @@ def func_chained():
def test_assign_chained_unpack():
@ti.kernel
def func_chained_unpack():
(a, b) = (c, d) = (1, 2)
a, b = (c, d) = (1, 2)
assert a == 1
assert b == 2
assert c == 1
Expand Down
Loading