Skip to content

Commit

Permalink
[misc] Sort python import order (#2247)
Browse files Browse the repository at this point in the history
* [misc] Sort python import order

* add isort

* fix import isort
  • Loading branch information
taichi-gardener authored Apr 4, 2021
1 parent 6a2c017 commit dc0be64
Show file tree
Hide file tree
Showing 61 changed files with 186 additions and 106 deletions.
3 changes: 2 additions & 1 deletion benchmarks/async_advection.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import taichi as ti
import math

from utils import benchmark_async

import taichi as ti

# TODO: staggerred grid


Expand Down
8 changes: 4 additions & 4 deletions benchmarks/async_cases.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import taichi as ti
import math
import os
import sys

sys.path.append(os.path.join(ti.core.get_repo_dir(), 'tests', 'python'))
import taichi as ti

from fuse_test_template import template_fuse_dense_x2y2z, \
template_fuse_reduction
sys.path.append(os.path.join(ti.core.get_repo_dir(), 'tests', 'python'))

from fuse_test_template import (template_fuse_dense_x2y2z,
template_fuse_reduction)
from utils import *


Expand Down
6 changes: 3 additions & 3 deletions benchmarks/benchmark_async.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import taichi as ti

from async_cases import *
from async_advection import *
from async_cases import *

import taichi as ti

rerun = True

Expand Down
6 changes: 4 additions & 2 deletions benchmarks/mpm2d.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import taichi as ti
import numpy as np
import time

import numpy as np

import taichi as ti


@ti.all_archs
def benchmark_range():
Expand Down
1 change: 1 addition & 0 deletions benchmarks/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

import taichi as ti


Expand Down
3 changes: 2 additions & 1 deletion benchmarks/summarize_async.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import yaml
import math

import yaml

with open('benchmark.yml') as f:
data = yaml.load(f)

Expand Down
3 changes: 2 additions & 1 deletion benchmarks/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import taichi as ti
import functools
import os

import taichi as ti


def benchmark_async(func):
@functools.wraps(func)
Expand Down
2 changes: 1 addition & 1 deletion misc/appveyor_filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import os
import sys

msg = os.environ["APPVEYOR_REPO_COMMIT_MESSAGE"]
if msg.startswith('[release]') or sys.version_info[1] == 6:
Expand Down
4 changes: 3 additions & 1 deletion misc/async_mgpcg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import time

import numpy as np

import taichi as ti
import time

real = ti.f32
ti.init(default_fp=real,
Expand Down
4 changes: 3 additions & 1 deletion misc/benchmark_bls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import taichi as ti
import sys

import taichi as ti

sys.path.append('../tests/python/')

from bls_test_template import bls_test_template
Expand Down
5 changes: 3 additions & 2 deletions misc/benchmark_compile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import taichi as ti
from pytest import approx
import autograd.numpy as np
from autograd import grad
from pytest import approx

import taichi as ti


@ti.all_archs
Expand Down
1 change: 1 addition & 0 deletions misc/benchmark_parallel_compilation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This file has a kernel with 16 equal offloaded tasks.

import taichi as ti

ti.init(arch=ti.x64)
quality = 1 # Use a larger value for higher-res simulations
n_particles, n_grid = 9000 * quality**2, 128 * quality
Expand Down
4 changes: 3 additions & 1 deletion misc/benchmark_reduction_tmps.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import taichi as ti
import time

from pytest import approx

import taichi as ti

# TODO: make this a real benchmark and set up regression
# TODO: merge this file into benchmark_reduction.py
ti.init(arch=ti.gpu,
Expand Down
4 changes: 3 additions & 1 deletion misc/benchmark_scatter_bls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import taichi as ti
import sys

import taichi as ti

sys.path.append('../tests/python/')

from bls_test_template import bls_particle_grid
Expand Down
5 changes: 3 additions & 2 deletions misc/benchmark_tensor_access.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import taichi as ti
import time
import ctypes
import math
import time

import taichi as ti

libm = ctypes.CDLL('libm.so.6')

Expand Down
7 changes: 6 additions & 1 deletion misc/ci_check_pr_title.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import sys, os, json, semver, git
import json
import os
import sys

import git
import semver


def get_old_ver():
Expand Down
2 changes: 1 addition & 1 deletion misc/ci_check_previous_run.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import argparse
import json
import logging
import sys
import time
import urllib.request as ur
import sys

API_PREFIX = 'https://api.github.com/repos/taichi-dev/taichi'
SHA = 'sha'
Expand Down
3 changes: 1 addition & 2 deletions misc/ci_setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
print("* Taichi Installer")

import os
import sys
import platform
import subprocess
import sys
from os import environ
import platform

print(platform.architecture())
build_type = 'default'
Expand Down
2 changes: 1 addition & 1 deletion misc/copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import argparse
import os
import re
import time
import subprocess
import sys
import time
from datetime import datetime
from enum import Enum
from typing import List
Expand Down
4 changes: 3 additions & 1 deletion misc/count_tags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sys, os
import os
import sys

from git import Repo

commits = list(Repo('.').iter_commits('master'))
Expand Down
1 change: 1 addition & 0 deletions misc/demo_constant_fold.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# https://github.com/taichi-dev/taichi/pull/839#issuecomment-626217806
import taichi as ti

ti.init(print_ir=True)
#ti.core.toggle_advanced_optimization(False)

Expand Down
1 change: 1 addition & 0 deletions misc/demo_excepthook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import taichi as ti

ti.init()
ti.enable_excepthook()

Expand Down
5 changes: 3 additions & 2 deletions misc/demo_external_func.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import taichi as ti
import os
import ctypes
import os

import taichi as ti

ti.init()

Expand Down
3 changes: 2 additions & 1 deletion misc/demo_launch_overhead.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import taichi as ti
import time

import taichi as ti

ti.init()


Expand Down
5 changes: 3 additions & 2 deletions misc/format_server.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import argparse
from http.server import HTTPServer, BaseHTTPRequestHandler
import requests
import subprocess
from http.server import BaseHTTPRequestHandler, HTTPServer

import requests

# TODO: remove these globals?
server_addr, server_port = None, None
Expand Down
4 changes: 3 additions & 1 deletion misc/generate_commit_hash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from git import Repo
import os

from git import Repo

repo_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../')
repo = Repo(repo_dir)
commit_hash = str(repo.head.commit)
Expand Down
4 changes: 3 additions & 1 deletion misc/generate_ir_design_doc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import taichi as ti
import os

import yaml

import taichi as ti


def extract_doc(doc_filename=None):
repo_dir = ti.get_repo_directory()
Expand Down
3 changes: 2 additions & 1 deletion misc/minimal_timed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import taichi as ti
import time

import taichi as ti

t = time.time()
ti.init(arch=ti.cuda, print_kernel_llvm_ir_optimized=True)

Expand Down
3 changes: 2 additions & 1 deletion misc/test_gpu_async.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import taichi as ti
import time

import taichi as ti

ti.init(arch=ti.cuda)

a = ti.field(ti.f32, shape=(1024 * 1024 * 1024))
Expand Down
3 changes: 2 additions & 1 deletion misc/test_gui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import taichi as ti
import math

import taichi as ti

gui = ti.GUI("Test GUI", (512, 512), background_color=0xFFFFFF)
t = 0

Expand Down
4 changes: 2 additions & 2 deletions misc/test_poly_timed.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from autograd import grad

import taichi as ti
from taichi import approx

from autograd import grad


# Note: test happens at v = 0.2
def grad_test(tifunc, npfunc=None, default_fp=ti.f32):
Expand Down
3 changes: 2 additions & 1 deletion misc/test_without_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import taichi as ti
import pytest

import taichi as ti


@pytest.mark.tryfirst
def test_without_init():
Expand Down
7 changes: 4 additions & 3 deletions misc/visualize_quant_types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import taichi as ti
import math
from struct import pack, unpack
import argparse
import math
import os
from struct import pack, unpack

import taichi as ti

ti.init()

Expand Down
3 changes: 2 additions & 1 deletion python/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import argparse
import os
import platform
import sys
import shutil
import sys

import taichi as ti


Expand Down
5 changes: 3 additions & 2 deletions python/make_release.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import requests
import zipfile
import shutil
import zipfile

import requests

projects = ['nightly', 'nightly-cuda-10-0', 'nightly-cuda-10-1']

Expand Down
6 changes: 3 additions & 3 deletions python/taichi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from .core import *
from .misc import *
from .lang import * # TODO(archibate): It's `taichi.lang.core` overriding `taichi.core`
from .tools import *
from .main import main
from .torch_io import from_torch, to_torch
from .misc import *
from .testing import *
from .tools import *
from .torch_io import from_torch, to_torch

__all__ = ['core', 'misc', 'lang', 'tools', 'main', 'torch_io']

Expand Down
1 change: 1 addition & 0 deletions python/taichi/__main__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .main import main

main()
5 changes: 3 additions & 2 deletions python/taichi/cc_compose.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import yaml
import warnings
import sys
import warnings

import yaml


class ComposerBase:
Expand Down
Loading

0 comments on commit dc0be64

Please sign in to comment.