Skip to content

Commit

Permalink
isort: Apply to Python files
Browse files Browse the repository at this point in the history
  • Loading branch information
EricCousineau-TRI committed Jul 19, 2020
1 parent f98a908 commit 3d5f4d6
Show file tree
Hide file tree
Showing 124 changed files with 557 additions and 510 deletions.
1 change: 0 additions & 1 deletion bindings/pydrake/common/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np


_patches = {
'numpy_formatters': {
'applied': False,
Expand Down
2 changes: 1 addition & 1 deletion bindings/pydrake/common/cpp_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
import types

from pydrake.common.cpp_param import get_param_names, get_param_canonical
from pydrake.common.cpp_param import get_param_canonical, get_param_names
from pydrake.common.deprecation import _warn_deprecated


Expand Down
3 changes: 1 addition & 2 deletions bindings/pydrake/common/test/compatibility_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import pydrake.common.compatibility as mut

from functools import partial
from threading import Thread
import unittest

import numpy as np

import pydrake.common.compatibility as mut
from pydrake.common.compatibility_test_util import invoke_callback

numpy_formatters = mut._patches["numpy_formatters"]
Expand Down
4 changes: 2 additions & 2 deletions bindings/pydrake/common/test/containers_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pydrake.common.containers import EqualToDict, namedview, NamedViewBase

import unittest

import numpy as np

from pydrake.common.containers import EqualToDict, NamedViewBase, namedview


class Comparison:
def __init__(self, lhs, rhs):
Expand Down
2 changes: 1 addition & 1 deletion bindings/pydrake/common/test/cpp_template_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import unittest

import pydrake.common.cpp_template as m
from pydrake.common.test_utilities.pickle_compare import assert_pickle
from pydrake.common.test_utilities.deprecation import catch_drake_warnings
from pydrake.common.test_utilities.pickle_compare import assert_pickle

_TEST_MODULE = "cpp_template_test"

Expand Down
12 changes: 9 additions & 3 deletions bindings/pydrake/common/test/deprecation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import warnings

from pydrake.common.deprecation import (
DrakeDeprecationWarning, _forward_callables_as_deprecated)
DrakeDeprecationWarning,
_forward_callables_as_deprecated,
)


def get_completion_suffixes(namespace, prefix, max_count=1000):
Expand Down Expand Up @@ -47,6 +49,7 @@ def test_module_nominal(self):
def test_module_import_direct(self):
# Test an import with direct access.
import deprecation_example as mod

# Check submodule access as a non-import.
self.assertTrue(isinstance(mod.sub_module, str))

Expand All @@ -68,8 +71,8 @@ def test_module_import_from_direct(self):
def test_module_import_from_all(self):
# N.B. This is done in another module because `from x import *` is not
# well supported for `exec`.
import deprecation_example.import_all
import deprecation_example
import deprecation_example.import_all
self.assertIsInstance(deprecation_example.sub_module, str)

def test_module_import_exec(self):
Expand Down Expand Up @@ -220,7 +223,9 @@ def base_deprecation():
def test_deprecation_pybind(self):
"""Test C++ usage in `deprecation_pybind.h`."""
from deprecation_example.cc_module import (
ExampleCppClass, emit_deprecation)
ExampleCppClass,
emit_deprecation,
)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("once", DrakeDeprecationWarning)
# This is a descriptor, so it will trigger on class access.
Expand Down Expand Up @@ -255,6 +260,7 @@ def test_deprecation_pybind(self):

def test_deprecated_callable(self):
import deprecation_example.cc_module as m_new

# Spoof module name.
var_dict = dict(__name__="fake_module")
_forward_callables_as_deprecated(var_dict, m_new, "2050-01-01")
Expand Down
7 changes: 3 additions & 4 deletions bindings/pydrake/common/test/eigen_geometry_test.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import pydrake.common.eigen_geometry as mut

import copy
import unittest

import numpy as np

from pydrake.autodiffutils import AutoDiffXd
from pydrake.symbolic import Expression
from pydrake.common.value import Value
import pydrake.common.eigen_geometry as mut
import pydrake.common.test.eigen_geometry_test_util as test_util
from pydrake.common.test_utilities import numpy_compare
from pydrake.common.test_utilities.deprecation import catch_drake_warnings
from pydrake.common.test_utilities.pickle_compare import assert_pickle
from pydrake.common.value import Value
from pydrake.symbolic import Expression


def normalize(x):
Expand Down
4 changes: 2 additions & 2 deletions bindings/pydrake/common/test/pybind11_version_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"""


import pydrake.common.pybind11_version as mut

import unittest

import pydrake.common.pybind11_version as mut


class TestPybind11Version(unittest.TestCase):
def test_values(self):
Expand Down
5 changes: 2 additions & 3 deletions bindings/pydrake/common/test/value_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
import unittest

from pydrake.common.cpp_param import List
from pydrake.common.value import AbstractValue, Value

from pydrake.common.test.value_test_util import (
make_abstract_value_cc_type_unregistered,
CustomType,
MoveOnlyType,
make_abstract_value_cc_type_unregistered,
)
from pydrake.common.value import AbstractValue, Value


class TestValue(unittest.TestCase):
Expand Down
6 changes: 3 additions & 3 deletions bindings/pydrake/common/test/wrap_pybind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import unittest

from pydrake.common.test.wrap_test_util import (
CheckTypeConversionExample,
MakeTypeConversionExample,
MakeTypeConversionExampleBadRvp,
MyContainerRawPtr,
MyContainerUniquePtr,
MyValue,
MakeTypeConversionExample,
MakeTypeConversionExampleBadRvp,
CheckTypeConversionExample,
)


Expand Down
9 changes: 7 additions & 2 deletions bindings/pydrake/common/test_utilities/numpy_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
import numpy as np

from pydrake.autodiffutils import AutoDiffXd
from pydrake.symbolic import (
Expression, Formula, Monomial, Polynomial, Variable)
from pydrake.polynomial import Polynomial as RawPolynomial
from pydrake.symbolic import (
Expression,
Formula,
Monomial,
Polynomial,
Variable,
)


class _UnwantedEquality(AssertionError):
Expand Down
11 changes: 4 additions & 7 deletions bindings/pydrake/doc/gen_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
from os.path import abspath, dirname, isabs, join
import sys

from drake.doc.sphinx_base import gen_main

import pydrake.all
# TODO(eric.cousineau): Indicate these as deprecated.
from pydrake.common import cpp_const, cpp_param, cpp_template
# TODO(eric.cousineau): Make an optional `.all` module.
from pydrake.examples import (
acrobot,
Expand All @@ -17,13 +21,6 @@
van_der_pol,
)
from pydrake.examples.multibody import cart_pole_passive_simulation
# TODO(eric.cousineau): Indicate these as deprecated.
from pydrake.common import (
cpp_const,
cpp_param,
cpp_template,
)
from drake.doc.sphinx_base import gen_main

EXCLUDE = [
"pydrake.third_party",
Expand Down
4 changes: 2 additions & 2 deletions bindings/pydrake/doc/pydrake_sphinx_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

from collections import namedtuple
import re
import warnings
from typing import Any, Tuple
import warnings

from sphinx import version_info as sphinx_version
from sphinx.locale import _
import sphinx.domains.python as pydoc
from sphinx.ext import autodoc
from sphinx.locale import _

from pydrake.common.cpp_template import TemplateBase
from pydrake.common.deprecation import DrakeDeprecationWarning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import argparse

from pydrake.common import FindResourceOrThrow
from pydrake.geometry import (ConnectDrakeVisualizer, SceneGraph)
from pydrake.geometry import ConnectDrakeVisualizer, SceneGraph
from pydrake.lcm import DrakeLcm
from pydrake.multibody.plant import MultibodyPlant
from pydrake.multibody.parsing import Parser
from pydrake.systems.framework import DiagramBuilder
from pydrake.multibody.plant import MultibodyPlant
from pydrake.systems.analysis import Simulator
from pydrake.systems.framework import DiagramBuilder


def main():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,22 @@

import numpy as np

from pydrake.common import (
RandomGenerator,
FindResourceOrThrow
)
from pydrake.common import FindResourceOrThrow, RandomGenerator
from pydrake.multibody.parsing import Parser
from pydrake.multibody.plant import MultibodyPlant
from pydrake.symbolic import (
Expression,
Variable
)
from pydrake.symbolic import Expression, Variable
from pydrake.systems.analysis import (
MonteCarloSimulation,
RandomSimulationResult,
RandomSimulation,
Simulator
RandomSimulationResult,
Simulator,
)
from pydrake.systems.controllers import LinearQuadraticRegulator
from pydrake.systems.framework import (
Context,
Diagram,
DiagramBuilder
)
from pydrake.systems.framework import Context, Diagram, DiagramBuilder
from pydrake.systems.primitives import (
ConstantVectorSource,
Linearize,
Saturation
Saturation,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from pydrake.systems.analysis import Simulator
from pydrake.systems.framework import DiagramBuilder
from pydrake.systems.planar_scenegraph_visualizer import (
PlanarSceneGraphVisualizer)
PlanarSceneGraphVisualizer,
)


def run_pendulum_example(args):
Expand Down
11 changes: 8 additions & 3 deletions bindings/pydrake/examples/test/acrobot_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import unittest

from pydrake.examples.acrobot import (
AcrobotGeometry, AcrobotInput, AcrobotParams, AcrobotPlant,
AcrobotSpongController, AcrobotState, SpongControllerParams
)
AcrobotGeometry,
AcrobotInput,
AcrobotParams,
AcrobotPlant,
AcrobotSpongController,
AcrobotState,
SpongControllerParams,
)
from pydrake.geometry import SceneGraph
from pydrake.systems.analysis import Simulator
from pydrake.systems.framework import DiagramBuilder
Expand Down
6 changes: 4 additions & 2 deletions bindings/pydrake/examples/test/compass_gait_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import unittest

from pydrake.examples.compass_gait import (
CompassGait, CompassGaitContinuousState,
CompassGaitGeometry, CompassGaitParams
CompassGait,
CompassGaitContinuousState,
CompassGaitGeometry,
CompassGaitParams,
)
from pydrake.geometry import SceneGraph
from pydrake.systems.analysis import Simulator
Expand Down
5 changes: 3 additions & 2 deletions bindings/pydrake/examples/test/manipulation_station_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import numpy as np

from pydrake.common import FindResourceOrThrow
Expand All @@ -7,12 +8,12 @@
CreateManipulationClassYcbObjectList,
IiwaCollisionModel,
ManipulationStation,
ManipulationStationHardwareInterface
ManipulationStationHardwareInterface,
)
from pydrake.math import RigidTransform, RollPitchYaw
from pydrake.multibody.parsing import Parser
from pydrake.multibody.plant import MultibodyPlant
from pydrake.multibody.tree import ModelInstanceIndex
from pydrake.multibody.parsing import Parser


class TestManipulationStation(unittest.TestCase):
Expand Down
9 changes: 6 additions & 3 deletions bindings/pydrake/examples/test/pendulum_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import unittest

from pydrake.examples.pendulum import (
PendulumGeometry, PendulumInput, PendulumParams, PendulumPlant,
PendulumState
)
PendulumGeometry,
PendulumInput,
PendulumParams,
PendulumPlant,
PendulumState,
)
from pydrake.geometry import SceneGraph
from pydrake.systems.analysis import Simulator
from pydrake.systems.framework import DiagramBuilder
Expand Down
8 changes: 6 additions & 2 deletions bindings/pydrake/examples/test/quadrotor_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import unittest

import numpy as np

from pydrake.geometry import SceneGraph
from pydrake.examples.quadrotor import (
QuadrotorPlant, QuadrotorGeometry, StabilizingLQRController)
QuadrotorGeometry,
QuadrotorPlant,
StabilizingLQRController,
)
from pydrake.geometry import SceneGraph
from pydrake.systems.framework import DiagramBuilder


Expand Down
11 changes: 7 additions & 4 deletions bindings/pydrake/examples/test/rimless_wheel_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import numpy as np
import unittest

import numpy as np

from pydrake.examples.rimless_wheel import (
RimlessWheel, RimlessWheelContinuousState,
RimlessWheelGeometry, RimlessWheelParams
)
RimlessWheel,
RimlessWheelContinuousState,
RimlessWheelGeometry,
RimlessWheelParams,
)
from pydrake.geometry import SceneGraph
from pydrake.systems.analysis import Simulator
from pydrake.systems.framework import DiagramBuilder
Expand Down
Loading

0 comments on commit 3d5f4d6

Please sign in to comment.