Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add isort (import sorting) to pre-commit hooks #25099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 9, 2023
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ repos:
"--skip",
"doc/users/project/credits.rst"
]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
files: ^tutorials/|^examples/
3 changes: 2 additions & 1 deletion examples/animation/animate_decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@

import itertools

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.animation as animation


Expand Down
2 changes: 1 addition & 1 deletion examples/animation/animated_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
histogram.
"""

import matplotlib.pyplot as plt
import numpy as np

import matplotlib.pyplot as plt
import matplotlib.animation as animation

# Fixing random state for reproducibility
Expand Down
3 changes: 2 additions & 1 deletion examples/animation/bayes_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@

import math

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

from matplotlib.animation import FuncAnimation


Expand Down
8 changes: 5 additions & 3 deletions examples/animation/double_pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
Output generate via `matplotlib.animation.Animation.to_jshtml`.
"""

from numpy import sin, cos
import numpy as np
from collections import deque

import matplotlib.pyplot as plt
import numpy as np
from numpy import cos, sin

import matplotlib.animation as animation
from collections import deque

G = 9.8 # acceleration due to gravity, in m/s^2
L1 = 1.0 # length of pendulum 1 in m
Expand Down
3 changes: 2 additions & 1 deletion examples/animation/dynamic_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
Output generate via `matplotlib.animation.Animation.to_jshtml`.
"""

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.animation as animation

fig, ax = plt.subplots()
Expand Down
3 changes: 3 additions & 0 deletions examples/animation/frame_grabbing_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
"""

import numpy as np

import matplotlib

matplotlib.use("Agg")
import matplotlib.pyplot as plt

from matplotlib.animation import FFMpegWriter

# Fixing random state for reproducibility
Expand Down
3 changes: 2 additions & 1 deletion examples/animation/multiple_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
Output generate via `matplotlib.animation.Animation.to_jshtml`.
"""

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.animation as animation
from matplotlib.patches import ConnectionPatch

Expand Down
3 changes: 2 additions & 1 deletion examples/animation/pause_resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
"""

import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np

import matplotlib.animation as animation


class PauseAnimation:
def __init__(self):
Expand Down
3 changes: 2 additions & 1 deletion examples/animation/rain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
Output generate via `matplotlib.animation.Animation.to_jshtml`.
"""

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

from matplotlib.animation import FuncAnimation

# Fixing random state for reproducibility
Expand Down
3 changes: 2 additions & 1 deletion examples/animation/random_walk.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
Output generate via `matplotlib.animation.Animation.to_jshtml`.
"""

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.animation as animation

# Fixing random state for reproducibility
Expand Down
3 changes: 2 additions & 1 deletion examples/animation/simple_anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
Output generate via `matplotlib.animation.Animation.to_jshtml`.
"""

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.animation as animation

fig, ax = plt.subplots()
Expand Down
3 changes: 2 additions & 1 deletion examples/animation/simple_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

Output generate via `matplotlib.animation.Animation.to_jshtml`.
"""
import numpy as np
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.animation as animation

fig, ax = plt.subplots()
Expand Down
5 changes: 3 additions & 2 deletions examples/animation/strip_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
Output generate via `matplotlib.animation.Animation.to_jshtml`.
"""

import numpy as np
from matplotlib.lines import Line2D
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.animation as animation
from matplotlib.lines import Line2D


class Scope:
Expand Down
3 changes: 2 additions & 1 deletion examples/animation/unchained.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
Output generate via `matplotlib.animation.Animation.to_jshtml`.
"""

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.animation as animation

# Fixing random state for reproducibility
Expand Down
4 changes: 2 additions & 2 deletions examples/axes_grid1/demo_anchored_direction_arrows.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"""
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDirectionArrows
import matplotlib.font_manager as fm

import matplotlib.font_manager as fm
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDirectionArrows

# Fixing random state for reproducibility
np.random.seed(19680801)
Expand Down
5 changes: 3 additions & 2 deletions examples/axes_grid1/demo_axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
create a divider for them using existing axes instances.
"""

from matplotlib import cbook
import matplotlib.pyplot as plt

from matplotlib import cbook


def get_demo_image():
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
Expand All @@ -27,7 +28,7 @@ def demo_simple_image(ax):

def demo_locatable_axes_hard(fig):

from mpl_toolkits.axes_grid1 import SubplotDivider, Size
from mpl_toolkits.axes_grid1 import Size, SubplotDivider
from mpl_toolkits.axes_grid1.mpl_axes import Axes

divider = SubplotDivider(fig, 2, 2, 2, aspect=True)
Expand Down
4 changes: 2 additions & 2 deletions examples/axes_grid1/demo_axes_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
Grid of 2x2 images with a single colorbar or with one colorbar per axes.
"""

from matplotlib import cbook
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid

from matplotlib import cbook
from mpl_toolkits.axes_grid1 import ImageGrid

Z = cbook.get_sample_data( # (15, 15) array
"axes_grid/bivariate_normal.npy", np_load=True)
Expand Down
3 changes: 2 additions & 1 deletion examples/axes_grid1/demo_axes_grid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
Grid of images with shared xaxis and yaxis.
"""

import matplotlib.pyplot as plt
import numpy as np

from matplotlib import cbook
import matplotlib.colors
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid


Expand Down
4 changes: 2 additions & 2 deletions examples/axes_grid1/demo_axes_hbox_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

"""

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

from mpl_toolkits.axes_grid1.axes_divider import HBoxDivider, VBoxDivider
import mpl_toolkits.axes_grid1.axes_size as Size


arr1 = np.arange(20).reshape((4, 5))
arr2 = np.arange(20).reshape((5, 4))

Expand Down
5 changes: 3 additions & 2 deletions examples/axes_grid1/demo_axes_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
channels.
"""

import matplotlib.pyplot as plt
import numpy as np

from matplotlib import cbook
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.axes_rgb import make_rgb_axes, RGBAxes
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes, make_rgb_axes


def get_rgb():
Expand Down
4 changes: 2 additions & 2 deletions examples/axes_grid1/demo_colorbar_of_inset_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
===============================
"""

from matplotlib import cbook
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes

from matplotlib import cbook
from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes

fig, ax = plt.subplots(figsize=[5, 4])
ax.set(aspect=1, xlim=(-15, 15), ylim=(-20, 5))
Expand Down
1 change: 1 addition & 0 deletions examples/axes_grid1/demo_colorbar_with_axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

import matplotlib.pyplot as plt

from mpl_toolkits.axes_grid1.axes_divider import make_axes_locatable

fig, (ax1, ax2) = plt.subplots(1, 2)
Expand Down
1 change: 1 addition & 0 deletions examples/axes_grid1/demo_colorbar_with_inset_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""

import matplotlib.pyplot as plt

from mpl_toolkits.axes_grid1.inset_locator import inset_axes

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=[6, 3])
Expand Down
3 changes: 2 additions & 1 deletion examples/axes_grid1/demo_edge_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
of an image grid.
"""

from matplotlib import cbook
import matplotlib.pyplot as plt

from matplotlib import cbook
from mpl_toolkits.axes_grid1 import AxesGrid


Expand Down
1 change: 1 addition & 0 deletions examples/axes_grid1/demo_imagegrid_aspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import matplotlib.pyplot as plt

from mpl_toolkits.axes_grid1 import ImageGrid

fig = plt.figure()
Expand Down
3 changes: 2 additions & 1 deletion examples/axes_grid1/inset_locator_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# controlled via the *borderpad* parameter.

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import inset_axes

from mpl_toolkits.axes_grid1.inset_locator import inset_axes

fig, (ax, ax2) = plt.subplots(1, 2, figsize=[5.5, 2.8])

Expand Down Expand Up @@ -136,6 +136,7 @@
# Create an inset horizontally centered in figure coordinates and vertically
# bound to line up with the axes.
from matplotlib.transforms import blended_transform_factory # noqa

transform = blended_transform_factory(fig.transFigure, ax2.transAxes)
axins4 = inset_axes(ax2, width="16%", height="34%",
bbox_to_anchor=(0, 0, 1, 1),
Expand Down
8 changes: 4 additions & 4 deletions examples/axes_grid1/inset_locator_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
:doc:`/gallery/subplots_axes_and_figures/zoom_inset_axes`.
"""

from matplotlib import cbook
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes, mark_inset
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar

import numpy as np

from matplotlib import cbook
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
from mpl_toolkits.axes_grid1.inset_locator import mark_inset, zoomed_inset_axes


def get_demo_image():
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
Expand Down
1 change: 0 additions & 1 deletion examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from mpl_toolkits.axes_grid1 import make_axes_locatable
from mpl_toolkits.axes_grid1.axes_divider import make_axes_area_auto_adjustable


fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])

Expand Down
1 change: 1 addition & 0 deletions examples/axes_grid1/parasite_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import matplotlib.pyplot as plt

from mpl_toolkits.axes_grid1 import host_subplot

host = host_subplot(111)
Expand Down
3 changes: 2 additions & 1 deletion examples/axes_grid1/parasite_simple2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
================

"""
import matplotlib.transforms as mtransforms
import matplotlib.pyplot as plt

import matplotlib.transforms as mtransforms
from mpl_toolkits.axes_grid1.parasite_axes import HostAxes

obs = [["01_S1", 3.88, 0.14, 1970, 63],
Expand Down
3 changes: 2 additions & 1 deletion examples/axes_grid1/scatter_hist_locatable_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
:doc:`/gallery/lines_bars_and_markers/scatter_hist` example.
"""

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

from mpl_toolkits.axes_grid1 import make_axes_locatable

# Fixing random state for reproducibility
Expand Down
2 changes: 1 addition & 1 deletion examples/axes_grid1/simple_anchored_artists.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def draw_circle(ax):
"""
Draw a circle in axis coordinates
"""
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDrawingArea
from matplotlib.patches import Circle
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDrawingArea
ada = AnchoredDrawingArea(20, 20, 0, 0,
loc='upper right', pad=0., frameon=False)
p = Circle((10, 10), 10)
Expand Down
Loading