diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 266d91be4..5aabb1c96 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -6,3 +6,4 @@ bb473f6ff4a23e4fd5205eacdef713db15decadf 8d00b416689c428b2bafdaad61ed3ec660ca06c2 d6b447cab8c40aa47dc675a0f4349ae254e8b3ce d8966d848af75751823e825eb76c5bbff58f5c07 +9980f7a61b32515a92a09fdcc27e21a2521a0467 diff --git a/advanced/advanced_numpy/examples/mandelplot.py b/advanced/advanced_numpy/examples/mandelplot.py index fa9bb2044..2541b3c43 100644 --- a/advanced/advanced_numpy/examples/mandelplot.py +++ b/advanced/advanced_numpy/examples/mandelplot.py @@ -6,8 +6,8 @@ """ -import numpy as np import mandel +import numpy as np x = np.linspace(-1.7, 0.6, 1000) y = np.linspace(-1.4, 1.4, 1000) diff --git a/advanced/advanced_numpy/examples/pilbuffer-answer.py b/advanced/advanced_numpy/examples/pilbuffer-answer.py index 62e6255e8..6478525ef 100644 --- a/advanced/advanced_numpy/examples/pilbuffer-answer.py +++ b/advanced/advanced_numpy/examples/pilbuffer-answer.py @@ -6,8 +6,8 @@ the buffer interface. """ -import numpy as np import Image +import numpy as np # Let's make a sample image, RGBA format diff --git a/advanced/advanced_numpy/examples/pilbuffer.py b/advanced/advanced_numpy/examples/pilbuffer.py index d1a60a960..e51fae566 100644 --- a/advanced/advanced_numpy/examples/pilbuffer.py +++ b/advanced/advanced_numpy/examples/pilbuffer.py @@ -5,8 +5,8 @@ Skeletton of the code to do an exercise using the buffer protocole. """ -import numpy as np import Image +import numpy as np # Let's make a sample image, RGBA format diff --git a/advanced/advanced_numpy/examples/plots/plot_maskedstats.py b/advanced/advanced_numpy/examples/plots/plot_maskedstats.py index e6c4198d5..7b0ef95a1 100644 --- a/advanced/advanced_numpy/examples/plots/plot_maskedstats.py +++ b/advanced/advanced_numpy/examples/plots/plot_maskedstats.py @@ -6,8 +6,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np data = np.loadtxt("../../../../data/populations.txt") populations = np.ma.masked_array(data[:, 1:]) diff --git a/advanced/advanced_numpy/examples/setup.py b/advanced/advanced_numpy/examples/setup.py index 9b799488b..350ad51b3 100644 --- a/advanced/advanced_numpy/examples/setup.py +++ b/advanced/advanced_numpy/examples/setup.py @@ -8,8 +8,9 @@ import os import sys -from os.path import join from distutils.sysconfig import get_python_inc +from os.path import join + import numpy from numpy.distutils.misc_util import get_numpy_include_dirs diff --git a/advanced/advanced_numpy/examples/setup_myobject.py b/advanced/advanced_numpy/examples/setup_myobject.py index d3e930fc3..f86a1ed51 100644 --- a/advanced/advanced_numpy/examples/setup_myobject.py +++ b/advanced/advanced_numpy/examples/setup_myobject.py @@ -6,7 +6,7 @@ """ -from distutils.core import setup, Extension +from distutils.core import Extension, setup setup( name="myobject", diff --git a/advanced/advanced_numpy/examples/wavreader.py b/advanced/advanced_numpy/examples/wavreader.py index 5e32b01b3..8322cb6fa 100644 --- a/advanced/advanced_numpy/examples/wavreader.py +++ b/advanced/advanced_numpy/examples/wavreader.py @@ -6,6 +6,7 @@ """ import sys + import numpy as np wav_header_dtype = np.dtype( diff --git a/advanced/debugging/wiener_filtering.py b/advanced/debugging/wiener_filtering.py index 6e805b0ea..27ed1eda5 100644 --- a/advanced/debugging/wiener_filtering.py +++ b/advanced/debugging/wiener_filtering.py @@ -1,8 +1,8 @@ """Wiener filtering a noisy raccoon face: this module is buggy""" +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt def local_mean(img, size=3): diff --git a/advanced/image_processing/examples/plot_GMM.py b/advanced/image_processing/examples/plot_GMM.py index 53cc84ee2..05365c9ce 100644 --- a/advanced/image_processing/examples/plot_GMM.py +++ b/advanced/image_processing/examples/plot_GMM.py @@ -8,9 +8,9 @@ """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt from sklearn.mixture import GaussianMixture rng = np.random.default_rng(27446968) diff --git a/advanced/image_processing/examples/plot_block_mean.py b/advanced/image_processing/examples/plot_block_mean.py index bfd491a35..087ea0616 100644 --- a/advanced/image_processing/examples/plot_block_mean.py +++ b/advanced/image_processing/examples/plot_block_mean.py @@ -6,9 +6,9 @@ blocks of an image. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt f = sp.datasets.face(gray=True) sx, sy = f.shape diff --git a/advanced/image_processing/examples/plot_blur.py b/advanced/image_processing/examples/plot_blur.py index c54649764..bfe4369f5 100644 --- a/advanced/image_processing/examples/plot_blur.py +++ b/advanced/image_processing/examples/plot_blur.py @@ -5,8 +5,8 @@ An example showing various processes that blur an image. """ -import scipy as sp import matplotlib.pyplot as plt +import scipy as sp face = sp.datasets.face(gray=True) blurred_face = sp.ndimage.gaussian_filter(face, sigma=3) diff --git a/advanced/image_processing/examples/plot_clean_morpho.py b/advanced/image_processing/examples/plot_clean_morpho.py index 2fc05c358..fe0639b6f 100644 --- a/advanced/image_processing/examples/plot_clean_morpho.py +++ b/advanced/image_processing/examples/plot_clean_morpho.py @@ -7,9 +7,9 @@ """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) n = 10 diff --git a/advanced/image_processing/examples/plot_denoising.py b/advanced/image_processing/examples/plot_denoising.py index f20443720..bd6c2ea84 100644 --- a/advanced/image_processing/examples/plot_denoising.py +++ b/advanced/image_processing/examples/plot_denoising.py @@ -6,9 +6,9 @@ one (with the median filter) and the difference between the two. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) diff --git a/advanced/image_processing/examples/plot_display_face.py b/advanced/image_processing/examples/plot_display_face.py index 1175f043a..cb8b77004 100644 --- a/advanced/image_processing/examples/plot_display_face.py +++ b/advanced/image_processing/examples/plot_display_face.py @@ -5,8 +5,8 @@ An example that displays a raccoon face with matplotlib. """ -import scipy as sp import matplotlib.pyplot as plt +import scipy as sp f = sp.datasets.face(gray=True) diff --git a/advanced/image_processing/examples/plot_face.py b/advanced/image_processing/examples/plot_face.py index 560da8eeb..8e2916475 100644 --- a/advanced/image_processing/examples/plot_face.py +++ b/advanced/image_processing/examples/plot_face.py @@ -5,8 +5,8 @@ Small example to plot a raccoon face. """ -import scipy as sp import imageio.v3 as iio +import scipy as sp f = sp.datasets.face() iio.imwrite("face.png", f) # uses the Image module (PIL) diff --git a/advanced/image_processing/examples/plot_face_denoise.py b/advanced/image_processing/examples/plot_face_denoise.py index c6760596c..4bf53cb4f 100644 --- a/advanced/image_processing/examples/plot_face_denoise.py +++ b/advanced/image_processing/examples/plot_face_denoise.py @@ -5,9 +5,9 @@ This example demoes image denoising on a Raccoon face. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) diff --git a/advanced/image_processing/examples/plot_face_tv_denoise.py b/advanced/image_processing/examples/plot_face_tv_denoise.py index 2f0e2c187..a5b25e49c 100644 --- a/advanced/image_processing/examples/plot_face_tv_denoise.py +++ b/advanced/image_processing/examples/plot_face_tv_denoise.py @@ -5,10 +5,9 @@ This example demoes Total-Variation (TV) denoising on a Raccoon face. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt - from skimage.restoration import denoise_tv_chambolle rng = np.random.default_rng(27446968) diff --git a/advanced/image_processing/examples/plot_find_edges.py b/advanced/image_processing/examples/plot_find_edges.py index bd3d77fe9..b2fa3d667 100644 --- a/advanced/image_processing/examples/plot_find_edges.py +++ b/advanced/image_processing/examples/plot_find_edges.py @@ -5,9 +5,9 @@ The Sobel filter is one of the simplest way of finding edges. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) diff --git a/advanced/image_processing/examples/plot_find_object.py b/advanced/image_processing/examples/plot_find_object.py index 0a0e351c1..4789cd252 100644 --- a/advanced/image_processing/examples/plot_find_object.py +++ b/advanced/image_processing/examples/plot_find_object.py @@ -6,9 +6,9 @@ """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) n = 10 diff --git a/advanced/image_processing/examples/plot_geom_face.py b/advanced/image_processing/examples/plot_geom_face.py index b388f069e..9eaebb80d 100644 --- a/advanced/image_processing/examples/plot_geom_face.py +++ b/advanced/image_processing/examples/plot_geom_face.py @@ -5,9 +5,9 @@ This examples demos some simple geometrical transformations on a Raccoon face. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt face = sp.datasets.face(gray=True) lx, ly = face.shape diff --git a/advanced/image_processing/examples/plot_granulo.py b/advanced/image_processing/examples/plot_granulo.py index d6989bb58..9129d2397 100644 --- a/advanced/image_processing/examples/plot_granulo.py +++ b/advanced/image_processing/examples/plot_granulo.py @@ -5,9 +5,9 @@ This example performs a simple granulometry analysis. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt def disk_structure(n): diff --git a/advanced/image_processing/examples/plot_greyscale_dilation.py b/advanced/image_processing/examples/plot_greyscale_dilation.py index 39289756c..2cf9c6f7c 100644 --- a/advanced/image_processing/examples/plot_greyscale_dilation.py +++ b/advanced/image_processing/examples/plot_greyscale_dilation.py @@ -5,9 +5,9 @@ This example illustrates greyscale mathematical morphology. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt im = np.zeros((64, 64)) rng = np.random.default_rng(27446968) diff --git a/advanced/image_processing/examples/plot_histo_segmentation.py b/advanced/image_processing/examples/plot_histo_segmentation.py index c2be12baf..4673765e4 100644 --- a/advanced/image_processing/examples/plot_histo_segmentation.py +++ b/advanced/image_processing/examples/plot_histo_segmentation.py @@ -5,9 +5,9 @@ This example does simple histogram analysis to perform segmentation. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) n = 10 diff --git a/advanced/image_processing/examples/plot_interpolation_face.py b/advanced/image_processing/examples/plot_interpolation_face.py index 0b6406e83..d6eaf6e3b 100644 --- a/advanced/image_processing/examples/plot_interpolation_face.py +++ b/advanced/image_processing/examples/plot_interpolation_face.py @@ -5,8 +5,8 @@ The example demonstrates image interpolation on a Raccoon face. """ -import scipy as sp import matplotlib.pyplot as plt +import scipy as sp f = sp.datasets.face(gray=True) diff --git a/advanced/image_processing/examples/plot_measure_data.py b/advanced/image_processing/examples/plot_measure_data.py index f18ed1a3e..f7bdd4c24 100644 --- a/advanced/image_processing/examples/plot_measure_data.py +++ b/advanced/image_processing/examples/plot_measure_data.py @@ -6,9 +6,9 @@ """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) n = 10 diff --git a/advanced/image_processing/examples/plot_numpy_array.py b/advanced/image_processing/examples/plot_numpy_array.py index 3837a94b3..f695aa956 100644 --- a/advanced/image_processing/examples/plot_numpy_array.py +++ b/advanced/image_processing/examples/plot_numpy_array.py @@ -7,9 +7,9 @@ """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt face = sp.datasets.face(gray=True) face[10:13, 20:23] diff --git a/advanced/image_processing/examples/plot_propagation.py b/advanced/image_processing/examples/plot_propagation.py index a0598a09c..852c1e1c0 100644 --- a/advanced/image_processing/examples/plot_propagation.py +++ b/advanced/image_processing/examples/plot_propagation.py @@ -5,9 +5,9 @@ This example shows simple operations of mathematical morphology. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt square = np.zeros((32, 32)) square[10:-10, 10:-10] = 1 diff --git a/advanced/image_processing/examples/plot_radial_mean.py b/advanced/image_processing/examples/plot_radial_mean.py index 9e36962c6..307f874ba 100644 --- a/advanced/image_processing/examples/plot_radial_mean.py +++ b/advanced/image_processing/examples/plot_radial_mean.py @@ -5,9 +5,9 @@ This example shows how to do a radial mean with scikit-image. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt f = sp.datasets.face(gray=True) sx, sy = f.shape diff --git a/advanced/image_processing/examples/plot_sharpen.py b/advanced/image_processing/examples/plot_sharpen.py index 07816f296..d6e9023e9 100644 --- a/advanced/image_processing/examples/plot_sharpen.py +++ b/advanced/image_processing/examples/plot_sharpen.py @@ -6,8 +6,8 @@ applying the filter inverse to the blur. """ -import scipy as sp import matplotlib.pyplot as plt +import scipy as sp f = sp.datasets.face(gray=True).astype(float) blurred_f = sp.ndimage.gaussian_filter(f, 3) diff --git a/advanced/image_processing/examples/plot_spectral_clustering.py b/advanced/image_processing/examples/plot_spectral_clustering.py index 9f72018ad..303768554 100644 --- a/advanced/image_processing/examples/plot_spectral_clustering.py +++ b/advanced/image_processing/examples/plot_spectral_clustering.py @@ -5,11 +5,10 @@ This example uses spectral clustering to do segmentation. """ -import numpy as np import matplotlib.pyplot as plt - -from sklearn.feature_extraction import image +import numpy as np from sklearn.cluster import spectral_clustering +from sklearn.feature_extraction import image ################################################################################ l = 100 diff --git a/advanced/image_processing/examples/plot_synthetic_data.py b/advanced/image_processing/examples/plot_synthetic_data.py index 31059bb56..5baf903b4 100644 --- a/advanced/image_processing/examples/plot_synthetic_data.py +++ b/advanced/image_processing/examples/plot_synthetic_data.py @@ -5,9 +5,9 @@ The example generates and displays simple synthetic data. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) n = 10 diff --git a/advanced/image_processing/examples/plot_watershed_segmentation.py b/advanced/image_processing/examples/plot_watershed_segmentation.py index a08e111d6..dd47e396a 100644 --- a/advanced/image_processing/examples/plot_watershed_segmentation.py +++ b/advanced/image_processing/examples/plot_watershed_segmentation.py @@ -5,11 +5,11 @@ This example shows how to do segmentation with watershed. """ -import numpy as np -from skimage.segmentation import watershed -from skimage.feature import peak_local_max import matplotlib.pyplot as plt +import numpy as np import scipy as sp +from skimage.feature import peak_local_max +from skimage.segmentation import watershed # Generate an initial image with two overlapping circles x, y = np.indices((80, 80)) diff --git a/advanced/interfacing_with_c/ctypes/cos_module.py b/advanced/interfacing_with_c/ctypes/cos_module.py index 23e60a624..4c729aad4 100644 --- a/advanced/interfacing_with_c/ctypes/cos_module.py +++ b/advanced/interfacing_with_c/ctypes/cos_module.py @@ -3,7 +3,6 @@ import ctypes # find and load the library - # OSX or linux from ctypes.util import find_library diff --git a/advanced/interfacing_with_c/ctypes_numpy/cos_doubles.py b/advanced/interfacing_with_c/ctypes_numpy/cos_doubles.py index 92d7d998d..65375021a 100644 --- a/advanced/interfacing_with_c/ctypes_numpy/cos_doubles.py +++ b/advanced/interfacing_with_c/ctypes_numpy/cos_doubles.py @@ -1,9 +1,10 @@ """Example of wrapping a C library function that accepts a C double array as input using the numpy.ctypeslib.""" +from ctypes import c_int + import numpy as np import numpy.ctypeslib as npct -from ctypes import c_int # input type for the cos_doubles function # must be a double array, with single dimension that is contiguous diff --git a/advanced/interfacing_with_c/cython/setup.py b/advanced/interfacing_with_c/cython/setup.py index 332f8f94f..c03e4010f 100644 --- a/advanced/interfacing_with_c/cython/setup.py +++ b/advanced/interfacing_with_c/cython/setup.py @@ -1,4 +1,5 @@ -from distutils.core import setup, Extension +from distutils.core import Extension, setup + from Cython.Distutils import build_ext setup( diff --git a/advanced/interfacing_with_c/cython_numpy/setup.py b/advanced/interfacing_with_c/cython_numpy/setup.py index 78d6f28df..054800bfe 100644 --- a/advanced/interfacing_with_c/cython_numpy/setup.py +++ b/advanced/interfacing_with_c/cython_numpy/setup.py @@ -1,4 +1,5 @@ -from distutils.core import setup, Extension +from distutils.core import Extension, setup + import numpy from Cython.Distutils import build_ext diff --git a/advanced/interfacing_with_c/cython_simple/setup.py b/advanced/interfacing_with_c/cython_simple/setup.py index 332f8f94f..c03e4010f 100644 --- a/advanced/interfacing_with_c/cython_simple/setup.py +++ b/advanced/interfacing_with_c/cython_simple/setup.py @@ -1,4 +1,5 @@ -from distutils.core import setup, Extension +from distutils.core import Extension, setup + from Cython.Distutils import build_ext setup( diff --git a/advanced/interfacing_with_c/numpy_c_api/setup.py b/advanced/interfacing_with_c/numpy_c_api/setup.py index bb4ff1528..4a0f04fe5 100644 --- a/advanced/interfacing_with_c/numpy_c_api/setup.py +++ b/advanced/interfacing_with_c/numpy_c_api/setup.py @@ -1,4 +1,5 @@ -from distutils.core import setup, Extension +from distutils.core import Extension, setup + import numpy # define the extension module diff --git a/advanced/interfacing_with_c/numpy_c_api/test_cos_module_np.py b/advanced/interfacing_with_c/numpy_c_api/test_cos_module_np.py index fa29b7693..dee80e560 100644 --- a/advanced/interfacing_with_c/numpy_c_api/test_cos_module_np.py +++ b/advanced/interfacing_with_c/numpy_c_api/test_cos_module_np.py @@ -1,6 +1,6 @@ import cos_module_np -import numpy as np import matplotlib.pyplot as plt +import numpy as np x = np.arange(0, 2 * np.pi, 0.1) y = cos_module_np.cos_func_np(x) diff --git a/advanced/interfacing_with_c/numpy_shared/test_cos_doubles.py b/advanced/interfacing_with_c/numpy_shared/test_cos_doubles.py index 752ac15ef..6007a002e 100644 --- a/advanced/interfacing_with_c/numpy_shared/test_cos_doubles.py +++ b/advanced/interfacing_with_c/numpy_shared/test_cos_doubles.py @@ -1,6 +1,6 @@ -import numpy as np -import matplotlib.pyplot as plt import cos_doubles +import matplotlib.pyplot as plt +import numpy as np x = np.arange(0, 2 * np.pi, 0.1) y = np.empty_like(x) diff --git a/advanced/interfacing_with_c/python_c_api/setup.py b/advanced/interfacing_with_c/python_c_api/setup.py index f4d70524f..b6fabf17d 100644 --- a/advanced/interfacing_with_c/python_c_api/setup.py +++ b/advanced/interfacing_with_c/python_c_api/setup.py @@ -1,4 +1,4 @@ -from distutils.core import setup, Extension +from distutils.core import Extension, setup # define the extension module cos_module = Extension("cos_module", sources=["cos_module.c"]) diff --git a/advanced/interfacing_with_c/swig/setup.py b/advanced/interfacing_with_c/swig/setup.py index b257c15f3..a39ad63ca 100644 --- a/advanced/interfacing_with_c/swig/setup.py +++ b/advanced/interfacing_with_c/swig/setup.py @@ -1,3 +1,3 @@ -from distutils.core import setup, Extension +from distutils.core import Extension, setup setup(ext_modules=[Extension("_cos_module", sources=["cos_module.c", "cos_module.i"])]) diff --git a/advanced/interfacing_with_c/swig_numpy/setup.py b/advanced/interfacing_with_c/swig_numpy/setup.py index 874295cb3..876b83d89 100644 --- a/advanced/interfacing_with_c/swig_numpy/setup.py +++ b/advanced/interfacing_with_c/swig_numpy/setup.py @@ -1,4 +1,5 @@ -from distutils.core import setup, Extension +from distutils.core import Extension, setup + import numpy setup( diff --git a/advanced/mathematical_optimization/examples/helper/compare_optimizers.py b/advanced/mathematical_optimization/examples/helper/compare_optimizers.py index f298e73ab..ed9e60755 100644 --- a/advanced/mathematical_optimization/examples/helper/compare_optimizers.py +++ b/advanced/mathematical_optimization/examples/helper/compare_optimizers.py @@ -11,18 +11,18 @@ import numpy as np import scipy as sp -from joblib import Memory - from cost_functions import ( - mk_quad, + CountingFunction, + LoggingFunction, mk_gauss, + mk_quad, rosenbrock, - rosenbrock_prime, rosenbrock_hessian, - LoggingFunction, - CountingFunction, + rosenbrock_prime, ) +from joblib import Memory + def my_partial(**kwargs): function = sp.optimize.minimize diff --git a/advanced/mathematical_optimization/examples/plot_1d_optim.py b/advanced/mathematical_optimization/examples/plot_1d_optim.py index cedc15395..11bae8cbe 100644 --- a/advanced/mathematical_optimization/examples/plot_1d_optim.py +++ b/advanced/mathematical_optimization/examples/plot_1d_optim.py @@ -5,8 +5,8 @@ Illustration of 1D optimization: Brent's method """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np import scipy as sp x = np.linspace(-1, 3, 100) diff --git a/advanced/mathematical_optimization/examples/plot_compare_optimizers.py b/advanced/mathematical_optimization/examples/plot_compare_optimizers.py index 2e75f75f8..f4f65d38b 100644 --- a/advanced/mathematical_optimization/examples/plot_compare_optimizers.py +++ b/advanced/mathematical_optimization/examples/plot_compare_optimizers.py @@ -9,8 +9,8 @@ import pickle import sys -import numpy as np import matplotlib.pyplot as plt +import numpy as np results = pickle.load( open(f"helper/compare_optimizers_py{sys.version_info[0]}.pkl", "rb") diff --git a/advanced/mathematical_optimization/examples/plot_constraints.py b/advanced/mathematical_optimization/examples/plot_constraints.py index d1388d15b..35f61a699 100644 --- a/advanced/mathematical_optimization/examples/plot_constraints.py +++ b/advanced/mathematical_optimization/examples/plot_constraints.py @@ -5,8 +5,8 @@ A small figure explaining optimization with constraints """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np import scipy as sp x, y = np.mgrid[-2.9:5.8:0.05, -2.5:5:0.05] diff --git a/advanced/mathematical_optimization/examples/plot_convex.py b/advanced/mathematical_optimization/examples/plot_convex.py index c835d4047..f4c88cc8c 100644 --- a/advanced/mathematical_optimization/examples/plot_convex.py +++ b/advanced/mathematical_optimization/examples/plot_convex.py @@ -5,8 +5,8 @@ A figure showing the definition of a convex function """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np x = np.linspace(-1, 2) diff --git a/advanced/mathematical_optimization/examples/plot_curve_fitting.py b/advanced/mathematical_optimization/examples/plot_curve_fitting.py index 2495f0347..0f6124639 100644 --- a/advanced/mathematical_optimization/examples/plot_curve_fitting.py +++ b/advanced/mathematical_optimization/examples/plot_curve_fitting.py @@ -5,9 +5,9 @@ A curve fitting example """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) diff --git a/advanced/mathematical_optimization/examples/plot_exercise_flat_minimum.py b/advanced/mathematical_optimization/examples/plot_exercise_flat_minimum.py index 56cb87ac8..ecae5b5a5 100644 --- a/advanced/mathematical_optimization/examples/plot_exercise_flat_minimum.py +++ b/advanced/mathematical_optimization/examples/plot_exercise_flat_minimum.py @@ -15,9 +15,9 @@ solution. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt def f(x): diff --git a/advanced/mathematical_optimization/examples/plot_exercise_ill_conditioned.py b/advanced/mathematical_optimization/examples/plot_exercise_ill_conditioned.py index dbffbcc07..e0eaec007 100644 --- a/advanced/mathematical_optimization/examples/plot_exercise_ill_conditioned.py +++ b/advanced/mathematical_optimization/examples/plot_exercise_ill_conditioned.py @@ -10,9 +10,9 @@ import time +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) diff --git a/advanced/mathematical_optimization/examples/plot_gradient_descent.py b/advanced/mathematical_optimization/examples/plot_gradient_descent.py index 812215b9a..3687e96fc 100644 --- a/advanced/mathematical_optimization/examples/plot_gradient_descent.py +++ b/advanced/mathematical_optimization/examples/plot_gradient_descent.py @@ -6,22 +6,22 @@ evolution of the optimizer. """ -import numpy as np +import os +import sys + import matplotlib.pyplot as plt +import numpy as np import scipy as sp -import sys -import os - sys.path.append(os.path.abspath("helper")) from cost_functions import ( - mk_quad, + CountingFunction, + LoggingFunction, mk_gauss, + mk_quad, rosenbrock, - rosenbrock_prime, rosenbrock_hessian, - LoggingFunction, - CountingFunction, + rosenbrock_prime, ) x_min, x_max = -1, 2 diff --git a/advanced/mathematical_optimization/examples/plot_noisy.py b/advanced/mathematical_optimization/examples/plot_noisy.py index 9e39aa02f..297658de2 100644 --- a/advanced/mathematical_optimization/examples/plot_noisy.py +++ b/advanced/mathematical_optimization/examples/plot_noisy.py @@ -5,8 +5,8 @@ Draws a figure explaining noisy vs non-noisy optimization """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np rng = np.random.default_rng(27446968) diff --git a/advanced/mathematical_optimization/examples/plot_non_bounds_constraints.py b/advanced/mathematical_optimization/examples/plot_non_bounds_constraints.py index 08af6f4d5..bcda83e26 100644 --- a/advanced/mathematical_optimization/examples/plot_non_bounds_constraints.py +++ b/advanced/mathematical_optimization/examples/plot_non_bounds_constraints.py @@ -6,8 +6,8 @@ SLSQP and cobyla. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np import scipy as sp x, y = np.mgrid[-2.03:4.2:0.04, -1.6:3.2:0.04] diff --git a/advanced/mathematical_optimization/examples/plot_smooth.py b/advanced/mathematical_optimization/examples/plot_smooth.py index 073810d8c..f44e53ec0 100644 --- a/advanced/mathematical_optimization/examples/plot_smooth.py +++ b/advanced/mathematical_optimization/examples/plot_smooth.py @@ -5,8 +5,8 @@ Draws a figure to explain smooth versus non smooth optimization. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np x = np.linspace(-1.5, 1.5, 101) diff --git a/advanced/optimizing/demo.py b/advanced/optimizing/demo.py index e5eb025b8..1edac0fcf 100644 --- a/advanced/optimizing/demo.py +++ b/advanced/optimizing/demo.py @@ -2,7 +2,6 @@ import numpy as np import scipy as sp - from ica import fastica diff --git a/advanced/optimizing/demo_opt.py b/advanced/optimizing/demo_opt.py index 410e52ddf..8d882bf28 100644 --- a/advanced/optimizing/demo_opt.py +++ b/advanced/optimizing/demo_opt.py @@ -2,7 +2,6 @@ import numpy as np import scipy as sp - from ica import fastica diff --git a/advanced/optimizing/ica.py b/advanced/optimizing/ica.py index 298ee703c..a9542d078 100644 --- a/advanced/optimizing/ica.py +++ b/advanced/optimizing/ica.py @@ -3,9 +3,9 @@ # License: GPL unless permission obtained otherwise # Look at algorithms in Tables 8.3 and 8.4 page 196 in the book: Independent Component Analysis, by Aapo et al. -import numpy as np import types +import numpy as np __all__ = ["fastica"] diff --git a/advanced/scipy_sparse/examples/direct_solve.py b/advanced/scipy_sparse/examples/direct_solve.py index e342618bf..c91213d1c 100644 --- a/advanced/scipy_sparse/examples/direct_solve.py +++ b/advanced/scipy_sparse/examples/direct_solve.py @@ -7,9 +7,9 @@ direct solver. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt rng = np.random.default_rng(27446968) diff --git a/advanced/scipy_sparse/examples/lobpcg_sakurai.py b/advanced/scipy_sparse/examples/lobpcg_sakurai.py index 1ec24b2af..3139b42f0 100644 --- a/advanced/scipy_sparse/examples/lobpcg_sakurai.py +++ b/advanced/scipy_sparse/examples/lobpcg_sakurai.py @@ -6,9 +6,10 @@ """ import time + +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt np.set_printoptions(precision=8, linewidth=90) diff --git a/advanced/scipy_sparse/examples/pyamg_with_lobpcg.py b/advanced/scipy_sparse/examples/pyamg_with_lobpcg.py index a7eb4a271..81f3a57a3 100644 --- a/advanced/scipy_sparse/examples/pyamg_with_lobpcg.py +++ b/advanced/scipy_sparse/examples/pyamg_with_lobpcg.py @@ -7,9 +7,8 @@ Dirichlet boundary conditions. """ -import scipy as sp import matplotlib.pyplot as plt - +import scipy as sp from pyamg import smoothed_aggregation_solver from pyamg.gallery import poisson diff --git a/conf.py b/conf.py index 464943baf..fde94da2c 100644 --- a/conf.py +++ b/conf.py @@ -1,6 +1,6 @@ +import os from datetime import date from subprocess import PIPE, Popen -import os import sphinx_gallery from pygments import formatters diff --git a/guide/examples/plot_simple.py b/guide/examples/plot_simple.py index a10e9e38d..b9ee6c00d 100644 --- a/guide/examples/plot_simple.py +++ b/guide/examples/plot_simple.py @@ -4,8 +4,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np X = np.linspace(-np.pi, np.pi, 100) Y = np.sin(X) diff --git a/intro/matplotlib/examples/exercises/plot_exercise_1.py b/intro/matplotlib/examples/exercises/plot_exercise_1.py index d4a05e17f..8ad5d9394 100644 --- a/intro/matplotlib/examples/exercises/plot_exercise_1.py +++ b/intro/matplotlib/examples/exercises/plot_exercise_1.py @@ -5,8 +5,8 @@ Solution of the exercise 1 with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 256 X = np.linspace(-np.pi, np.pi, 256) diff --git a/intro/matplotlib/examples/exercises/plot_exercise_10.py b/intro/matplotlib/examples/exercises/plot_exercise_10.py index 94aa03cec..51fabaa5e 100644 --- a/intro/matplotlib/examples/exercises/plot_exercise_10.py +++ b/intro/matplotlib/examples/exercises/plot_exercise_10.py @@ -5,8 +5,8 @@ Exercises with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.figure(figsize=(8, 5), dpi=80) plt.subplot(111) diff --git a/intro/matplotlib/examples/exercises/plot_exercise_2.py b/intro/matplotlib/examples/exercises/plot_exercise_2.py index bd934ccf4..ac195ec03 100644 --- a/intro/matplotlib/examples/exercises/plot_exercise_2.py +++ b/intro/matplotlib/examples/exercises/plot_exercise_2.py @@ -5,8 +5,8 @@ Exercise 2 with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Create a new figure of size 8x6 points, using 100 dots per inch plt.figure(figsize=(8, 6), dpi=80) diff --git a/intro/matplotlib/examples/exercises/plot_exercise_3.py b/intro/matplotlib/examples/exercises/plot_exercise_3.py index f2011f03a..9c7ea436f 100644 --- a/intro/matplotlib/examples/exercises/plot_exercise_3.py +++ b/intro/matplotlib/examples/exercises/plot_exercise_3.py @@ -5,8 +5,8 @@ Exercise 3 with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.figure(figsize=(8, 5), dpi=80) plt.subplot(111) diff --git a/intro/matplotlib/examples/exercises/plot_exercise_4.py b/intro/matplotlib/examples/exercises/plot_exercise_4.py index 2ea03614f..0bde11922 100644 --- a/intro/matplotlib/examples/exercises/plot_exercise_4.py +++ b/intro/matplotlib/examples/exercises/plot_exercise_4.py @@ -5,8 +5,8 @@ Exercise 4 with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.figure(figsize=(8, 5), dpi=80) plt.subplot(111) diff --git a/intro/matplotlib/examples/exercises/plot_exercise_5.py b/intro/matplotlib/examples/exercises/plot_exercise_5.py index ed9906da8..c73d464aa 100644 --- a/intro/matplotlib/examples/exercises/plot_exercise_5.py +++ b/intro/matplotlib/examples/exercises/plot_exercise_5.py @@ -5,8 +5,8 @@ Exercise 5 with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.figure(figsize=(8, 5), dpi=80) plt.subplot(111) diff --git a/intro/matplotlib/examples/exercises/plot_exercise_6.py b/intro/matplotlib/examples/exercises/plot_exercise_6.py index 237ddebaf..ef9f8627a 100644 --- a/intro/matplotlib/examples/exercises/plot_exercise_6.py +++ b/intro/matplotlib/examples/exercises/plot_exercise_6.py @@ -5,8 +5,8 @@ Exercise 6 with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.figure(figsize=(8, 5), dpi=80) plt.subplot(111) diff --git a/intro/matplotlib/examples/exercises/plot_exercise_7.py b/intro/matplotlib/examples/exercises/plot_exercise_7.py index 98f7a1ab9..a6d2c763d 100644 --- a/intro/matplotlib/examples/exercises/plot_exercise_7.py +++ b/intro/matplotlib/examples/exercises/plot_exercise_7.py @@ -5,8 +5,8 @@ Exercise 7 with matplotlib """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.figure(figsize=(8, 5), dpi=80) plt.subplot(111) diff --git a/intro/matplotlib/examples/exercises/plot_exercise_8.py b/intro/matplotlib/examples/exercises/plot_exercise_8.py index aaf15103a..358dcac41 100644 --- a/intro/matplotlib/examples/exercises/plot_exercise_8.py +++ b/intro/matplotlib/examples/exercises/plot_exercise_8.py @@ -5,8 +5,8 @@ Exercise 8 with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.figure(figsize=(8, 5), dpi=80) plt.subplot(111) diff --git a/intro/matplotlib/examples/exercises/plot_exercise_9.py b/intro/matplotlib/examples/exercises/plot_exercise_9.py index 58fb21725..bec6923d8 100644 --- a/intro/matplotlib/examples/exercises/plot_exercise_9.py +++ b/intro/matplotlib/examples/exercises/plot_exercise_9.py @@ -5,8 +5,8 @@ Exercise 9 with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.figure(figsize=(8, 5), dpi=80) plt.subplot(111) diff --git a/intro/matplotlib/examples/options/plot_colormaps.py b/intro/matplotlib/examples/options/plot_colormaps.py index 46ee73b25..c8557eb16 100644 --- a/intro/matplotlib/examples/options/plot_colormaps.py +++ b/intro/matplotlib/examples/options/plot_colormaps.py @@ -5,8 +5,8 @@ An example plotting the matplotlib colormaps. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.rc("text", usetex=False) a = np.outer(np.arange(0, 1, 0.01), np.ones(10)) diff --git a/intro/matplotlib/examples/options/plot_dash_capstyle.py b/intro/matplotlib/examples/options/plot_dash_capstyle.py index 4224a0d84..f9f2d4657 100644 --- a/intro/matplotlib/examples/options/plot_dash_capstyle.py +++ b/intro/matplotlib/examples/options/plot_dash_capstyle.py @@ -5,8 +5,8 @@ An example demoing the dash capstyle. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np size = 256, 16 dpi = 72.0 diff --git a/intro/matplotlib/examples/options/plot_dash_joinstyle.py b/intro/matplotlib/examples/options/plot_dash_joinstyle.py index 84a7847c7..516130c95 100644 --- a/intro/matplotlib/examples/options/plot_dash_joinstyle.py +++ b/intro/matplotlib/examples/options/plot_dash_joinstyle.py @@ -5,8 +5,8 @@ Example demoing the dash join style. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np size = 256, 16 dpi = 72.0 diff --git a/intro/matplotlib/examples/options/plot_linestyles.py b/intro/matplotlib/examples/options/plot_linestyles.py index 6ab9e38be..cb8f6f213 100644 --- a/intro/matplotlib/examples/options/plot_linestyles.py +++ b/intro/matplotlib/examples/options/plot_linestyles.py @@ -5,8 +5,8 @@ Plot the different line styles. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def linestyle(ls, i): diff --git a/intro/matplotlib/examples/options/plot_markers.py b/intro/matplotlib/examples/options/plot_markers.py index e694f6b94..4cfe4e6c7 100644 --- a/intro/matplotlib/examples/options/plot_markers.py +++ b/intro/matplotlib/examples/options/plot_markers.py @@ -5,8 +5,8 @@ Show the different markers of matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def marker(m, i): diff --git a/intro/matplotlib/examples/options/plot_mec.py b/intro/matplotlib/examples/options/plot_mec.py index 598cd9418..ecab43dc3 100644 --- a/intro/matplotlib/examples/options/plot_mec.py +++ b/intro/matplotlib/examples/options/plot_mec.py @@ -5,8 +5,8 @@ Demo the marker edge color of matplotlib's markers. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np size = 256, 16 dpi = 72.0 diff --git a/intro/matplotlib/examples/options/plot_mfc.py b/intro/matplotlib/examples/options/plot_mfc.py index d50661199..d8e0bae69 100644 --- a/intro/matplotlib/examples/options/plot_mfc.py +++ b/intro/matplotlib/examples/options/plot_mfc.py @@ -5,8 +5,8 @@ Demo the marker face color of matplotlib's markers. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np size = 256, 16 dpi = 72.0 diff --git a/intro/matplotlib/examples/options/plot_solid_capstyle.py b/intro/matplotlib/examples/options/plot_solid_capstyle.py index 3d8b8caa7..6f8f51b4f 100644 --- a/intro/matplotlib/examples/options/plot_solid_capstyle.py +++ b/intro/matplotlib/examples/options/plot_solid_capstyle.py @@ -5,8 +5,8 @@ An example demoing the solide cap style in matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np size = 256, 16 dpi = 72.0 diff --git a/intro/matplotlib/examples/options/plot_solid_joinstyle.py b/intro/matplotlib/examples/options/plot_solid_joinstyle.py index dbb82fc4e..13f1b3fe6 100644 --- a/intro/matplotlib/examples/options/plot_solid_joinstyle.py +++ b/intro/matplotlib/examples/options/plot_solid_joinstyle.py @@ -5,8 +5,8 @@ An example showing the different solid joint styles in matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np size = 256, 16 dpi = 72.0 diff --git a/intro/matplotlib/examples/options/plot_ticks.py b/intro/matplotlib/examples/options/plot_ticks.py index 6fd3f5925..9dbb1a234 100644 --- a/intro/matplotlib/examples/options/plot_ticks.py +++ b/intro/matplotlib/examples/options/plot_ticks.py @@ -6,8 +6,8 @@ matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def tickline(): diff --git a/intro/matplotlib/examples/plot_bad.py b/intro/matplotlib/examples/plot_bad.py index 00755bd6a..7fbbbdf48 100644 --- a/intro/matplotlib/examples/plot_bad.py +++ b/intro/matplotlib/examples/plot_bad.py @@ -5,8 +5,8 @@ A plotting example with a few simple tweaks """ -import numpy as np import matplotlib +import numpy as np matplotlib.use("Agg") import matplotlib.pyplot as plt diff --git a/intro/matplotlib/examples/plot_bar.py b/intro/matplotlib/examples/plot_bar.py index c1ff47a15..a41f64ab1 100644 --- a/intro/matplotlib/examples/plot_bar.py +++ b/intro/matplotlib/examples/plot_bar.py @@ -5,8 +5,8 @@ An example of bar plots with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 12 X = np.arange(n) diff --git a/intro/matplotlib/examples/plot_contour.py b/intro/matplotlib/examples/plot_contour.py index 90441e2cd..6a7935639 100644 --- a/intro/matplotlib/examples/plot_contour.py +++ b/intro/matplotlib/examples/plot_contour.py @@ -6,8 +6,8 @@ matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def f(x, y): diff --git a/intro/matplotlib/examples/plot_good.py b/intro/matplotlib/examples/plot_good.py index 4a3486f60..795c74475 100644 --- a/intro/matplotlib/examples/plot_good.py +++ b/intro/matplotlib/examples/plot_good.py @@ -5,8 +5,8 @@ Demoing some simple features of matplotlib """ -import numpy as np import matplotlib +import numpy as np matplotlib.use("Agg") import matplotlib.pyplot as plt diff --git a/intro/matplotlib/examples/plot_imshow.py b/intro/matplotlib/examples/plot_imshow.py index d196da2db..f2377afc2 100644 --- a/intro/matplotlib/examples/plot_imshow.py +++ b/intro/matplotlib/examples/plot_imshow.py @@ -5,8 +5,8 @@ An example demoing imshow and styling the figure. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def f(x, y): diff --git a/intro/matplotlib/examples/plot_pie.py b/intro/matplotlib/examples/plot_pie.py index 3bd1f63c7..797717fae 100644 --- a/intro/matplotlib/examples/plot_pie.py +++ b/intro/matplotlib/examples/plot_pie.py @@ -5,8 +5,8 @@ A simple pie chart example with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 20 Z = np.ones(n) diff --git a/intro/matplotlib/examples/plot_plot.py b/intro/matplotlib/examples/plot_plot.py index 7a2cd4fe0..f18aff4b8 100644 --- a/intro/matplotlib/examples/plot_plot.py +++ b/intro/matplotlib/examples/plot_plot.py @@ -5,8 +5,8 @@ Simple example of plots and filling between them with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 256 X = np.linspace(-np.pi, np.pi, n) diff --git a/intro/matplotlib/examples/plot_plot3d.py b/intro/matplotlib/examples/plot_plot3d.py index 3576bc318..6ecb7c70c 100644 --- a/intro/matplotlib/examples/plot_plot3d.py +++ b/intro/matplotlib/examples/plot_plot3d.py @@ -5,8 +5,8 @@ A simple example of 3D plotting. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np from mpl_toolkits.mplot3d import Axes3D ax = plt.figure().add_subplot(projection="3d") diff --git a/intro/matplotlib/examples/plot_polar.py b/intro/matplotlib/examples/plot_polar.py index b610e962c..ee61cf8d8 100644 --- a/intro/matplotlib/examples/plot_polar.py +++ b/intro/matplotlib/examples/plot_polar.py @@ -6,8 +6,8 @@ matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np ax = plt.axes([0.025, 0.025, 0.95, 0.95], polar=True) diff --git a/intro/matplotlib/examples/plot_quiver.py b/intro/matplotlib/examples/plot_quiver.py index 9634d7109..9d99799fd 100644 --- a/intro/matplotlib/examples/plot_quiver.py +++ b/intro/matplotlib/examples/plot_quiver.py @@ -6,8 +6,8 @@ matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 8 X, Y = np.mgrid[0:n, 0:n] diff --git a/intro/matplotlib/examples/plot_scatter.py b/intro/matplotlib/examples/plot_scatter.py index 853ef4532..b81b0c212 100644 --- a/intro/matplotlib/examples/plot_scatter.py +++ b/intro/matplotlib/examples/plot_scatter.py @@ -5,8 +5,8 @@ A simple example showing how to plot a scatter of points with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 1024 rng = np.random.default_rng() diff --git a/intro/matplotlib/examples/plot_subplot-vertical.py b/intro/matplotlib/examples/plot_subplot-vertical.py index 4f93f4e97..c3d85ce59 100644 --- a/intro/matplotlib/examples/plot_subplot-vertical.py +++ b/intro/matplotlib/examples/plot_subplot-vertical.py @@ -7,7 +7,6 @@ import matplotlib.pyplot as plt - plt.figure(figsize=(6, 4)) plt.subplot(1, 2, 1) plt.xticks([]) diff --git a/intro/matplotlib/examples/plot_text.py b/intro/matplotlib/examples/plot_text.py index 0871b7833..fc4d60cc0 100644 --- a/intro/matplotlib/examples/plot_text.py +++ b/intro/matplotlib/examples/plot_text.py @@ -5,9 +5,8 @@ A example showing off elaborate text printing with matplotlib. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np eqs = [] eqs.append( diff --git a/intro/matplotlib/examples/plot_ugly.py b/intro/matplotlib/examples/plot_ugly.py index ad4ddcc4e..6d0b39d24 100644 --- a/intro/matplotlib/examples/plot_ugly.py +++ b/intro/matplotlib/examples/plot_ugly.py @@ -5,8 +5,8 @@ An "ugly" example of plotting. """ -import numpy as np import matplotlib +import numpy as np matplotlib.use("Agg") import matplotlib.pyplot as plt diff --git a/intro/matplotlib/examples/pretty_plots/plot_bar_ext.py b/intro/matplotlib/examples/pretty_plots/plot_bar_ext.py index dc5ecba66..f88276e7c 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_bar_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_bar_ext.py @@ -5,8 +5,8 @@ An more elaborate bar plot example """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 16 X = np.arange(n) diff --git a/intro/matplotlib/examples/pretty_plots/plot_boxplot_ext.py b/intro/matplotlib/examples/pretty_plots/plot_boxplot_ext.py index ff844eba2..c06da507e 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_boxplot_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_boxplot_ext.py @@ -6,9 +6,8 @@ """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np fig = plt.figure(figsize=(8, 5)) axes = plt.subplot(111) diff --git a/intro/matplotlib/examples/pretty_plots/plot_contour_ext.py b/intro/matplotlib/examples/pretty_plots/plot_contour_ext.py index f64f9784b..7996dfc81 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_contour_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_contour_ext.py @@ -7,8 +7,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def f(x, y): diff --git a/intro/matplotlib/examples/pretty_plots/plot_imshow_ext.py b/intro/matplotlib/examples/pretty_plots/plot_imshow_ext.py index ab8545fef..dc91d4476 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_imshow_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_imshow_ext.py @@ -5,8 +5,8 @@ Demoing imshow """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def f(x, y): diff --git a/intro/matplotlib/examples/pretty_plots/plot_pie_ext.py b/intro/matplotlib/examples/pretty_plots/plot_pie_ext.py index 0d781ab8b..7d689ba25 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_pie_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_pie_ext.py @@ -5,8 +5,8 @@ Demo pie chart with matplotlib and style the figure. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 20 X = np.ones(n) diff --git a/intro/matplotlib/examples/pretty_plots/plot_plot3d_ext.py b/intro/matplotlib/examples/pretty_plots/plot_plot3d_ext.py index 595dd8351..034296df2 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_plot3d_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_plot3d_ext.py @@ -5,8 +5,8 @@ Demo 3D plotting with matplotlib and decorate the figure. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() diff --git a/intro/matplotlib/examples/pretty_plots/plot_plot_ext.py b/intro/matplotlib/examples/pretty_plots/plot_plot_ext.py index 96febc34f..f5189a5df 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_plot_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_plot_ext.py @@ -5,8 +5,8 @@ An example of plots with matplotlib, and added annotations. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 256 X = np.linspace(0, 2, n) diff --git a/intro/matplotlib/examples/pretty_plots/plot_polar_ext.py b/intro/matplotlib/examples/pretty_plots/plot_polar_ext.py index 7d5765b64..b5ade46c1 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_polar_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_polar_ext.py @@ -6,8 +6,8 @@ decorations. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.subplot(1, 1, 1, polar=True) diff --git a/intro/matplotlib/examples/pretty_plots/plot_quiver_ext.py b/intro/matplotlib/examples/pretty_plots/plot_quiver_ext.py index 81d20ea14..e9deef98d 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_quiver_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_quiver_ext.py @@ -5,8 +5,8 @@ An example showing quiver with decorations. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 8 X, Y = np.mgrid[0:n, 0:n] diff --git a/intro/matplotlib/examples/pretty_plots/plot_scatter_ext.py b/intro/matplotlib/examples/pretty_plots/plot_scatter_ext.py index 3420c0f50..e1f876301 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_scatter_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_scatter_ext.py @@ -5,8 +5,8 @@ An example showing the scatter function, with decorations. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np n = 1024 rng = np.random.default_rng() diff --git a/intro/matplotlib/examples/pretty_plots/plot_text_ext.py b/intro/matplotlib/examples/pretty_plots/plot_text_ext.py index cc54ee166..dd9103144 100644 --- a/intro/matplotlib/examples/pretty_plots/plot_text_ext.py +++ b/intro/matplotlib/examples/pretty_plots/plot_text_ext.py @@ -5,8 +5,8 @@ An example showing text printing and decorating the resulting figure. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np fig = plt.figure() plt.xticks([]) diff --git a/intro/numpy/examples/plot_basic1dplot.py b/intro/numpy/examples/plot_basic1dplot.py index 49b2f1764..529a0bcd8 100644 --- a/intro/numpy/examples/plot_basic1dplot.py +++ b/intro/numpy/examples/plot_basic1dplot.py @@ -6,8 +6,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np x = np.linspace(0, 3, 20) y = np.linspace(0, 9, 20) diff --git a/intro/numpy/examples/plot_basic2dplot.py b/intro/numpy/examples/plot_basic2dplot.py index 050a91bec..6484f6fda 100644 --- a/intro/numpy/examples/plot_basic2dplot.py +++ b/intro/numpy/examples/plot_basic2dplot.py @@ -6,8 +6,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np rng = np.random.default_rng() image = rng.random((30, 30)) diff --git a/intro/numpy/examples/plot_chebyfit.py b/intro/numpy/examples/plot_chebyfit.py index aef27f6ce..401b56541 100644 --- a/intro/numpy/examples/plot_chebyfit.py +++ b/intro/numpy/examples/plot_chebyfit.py @@ -6,8 +6,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np rng = np.random.default_rng(27446968) diff --git a/intro/numpy/examples/plot_distances.py b/intro/numpy/examples/plot_distances.py index f461dde31..b3d6f4bb7 100644 --- a/intro/numpy/examples/plot_distances.py +++ b/intro/numpy/examples/plot_distances.py @@ -6,8 +6,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np x, y = np.arange(5), np.arange(5)[:, np.newaxis] distance = np.sqrt(x**2 + y**2) diff --git a/intro/numpy/examples/plot_elephant.py b/intro/numpy/examples/plot_elephant.py index 60c3696fc..98555fc56 100644 --- a/intro/numpy/examples/plot_elephant.py +++ b/intro/numpy/examples/plot_elephant.py @@ -6,8 +6,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np ################################# # original figure diff --git a/intro/numpy/examples/plot_mandelbrot.py b/intro/numpy/examples/plot_mandelbrot.py index bf0921d26..60086b3df 100644 --- a/intro/numpy/examples/plot_mandelbrot.py +++ b/intro/numpy/examples/plot_mandelbrot.py @@ -6,10 +6,11 @@ """ -import numpy as np +import warnings + import matplotlib.pyplot as plt +import numpy as np from numpy import newaxis -import warnings def compute_mandelbrot(N_max, some_threshold, nx, ny): diff --git a/intro/numpy/examples/plot_polyfit.py b/intro/numpy/examples/plot_polyfit.py index b39c57682..4c30219bd 100644 --- a/intro/numpy/examples/plot_polyfit.py +++ b/intro/numpy/examples/plot_polyfit.py @@ -6,8 +6,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np rng = np.random.default_rng(27446968) diff --git a/intro/numpy/examples/plot_populations.py b/intro/numpy/examples/plot_populations.py index f918ac3a1..f07292f27 100644 --- a/intro/numpy/examples/plot_populations.py +++ b/intro/numpy/examples/plot_populations.py @@ -6,8 +6,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np data = np.loadtxt("../../../data/populations.txt") year, hares, lynxes, carrots = data.T diff --git a/intro/numpy/examples/plot_randomwalk.py b/intro/numpy/examples/plot_randomwalk.py index eaa4dccf6..efb33f8b0 100644 --- a/intro/numpy/examples/plot_randomwalk.py +++ b/intro/numpy/examples/plot_randomwalk.py @@ -7,8 +7,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # We create 1000 realizations with 200 steps each n_stories = 1000 diff --git a/intro/numpy/solutions/2_4_mandelbrot.py b/intro/numpy/solutions/2_4_mandelbrot.py index 415ca0e25..d80133f84 100644 --- a/intro/numpy/solutions/2_4_mandelbrot.py +++ b/intro/numpy/solutions/2_4_mandelbrot.py @@ -2,8 +2,8 @@ Compute the Mandelbrot fractal """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np from numpy import newaxis diff --git a/intro/numpy/solutions/2_a_call_fortran.py b/intro/numpy/solutions/2_a_call_fortran.py index c72fb8348..a6bea36be 100644 --- a/intro/numpy/solutions/2_a_call_fortran.py +++ b/intro/numpy/solutions/2_a_call_fortran.py @@ -1,5 +1,5 @@ -import numpy as np import fortran_module +import numpy as np def some_function(input): diff --git a/intro/scipy/examples/plot_connect_measurements.py b/intro/scipy/examples/plot_connect_measurements.py index 2bfa3bfff..34cdf9933 100644 --- a/intro/scipy/examples/plot_connect_measurements.py +++ b/intro/scipy/examples/plot_connect_measurements.py @@ -6,8 +6,8 @@ Extracting and labeling connected components in a 2D array """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np ############################################################ # Generate some binary data diff --git a/intro/scipy/examples/plot_fftpack.py b/intro/scipy/examples/plot_fftpack.py index fd171ca51..64d354987 100644 --- a/intro/scipy/examples/plot_fftpack.py +++ b/intro/scipy/examples/plot_fftpack.py @@ -13,9 +13,9 @@ """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt ############################################################ # Generate the signal diff --git a/intro/scipy/examples/plot_image_filters.py b/intro/scipy/examples/plot_image_filters.py index 52a3764b8..c5924d9c9 100644 --- a/intro/scipy/examples/plot_image_filters.py +++ b/intro/scipy/examples/plot_image_filters.py @@ -14,7 +14,6 @@ # Apply a variety of filters import matplotlib.pyplot as plt - import numpy as np noisy_face = np.copy(face).astype(float) diff --git a/intro/scipy/examples/plot_normal_distribution.py b/intro/scipy/examples/plot_normal_distribution.py index 0ee0f2d76..0c58ec534 100644 --- a/intro/scipy/examples/plot_normal_distribution.py +++ b/intro/scipy/examples/plot_normal_distribution.py @@ -7,9 +7,9 @@ PDF (probability density function). """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt dist = sp.stats.norm(loc=0, scale=1) # standard normal distribution sample = dist.rvs(size=100000) # "random variate sample" diff --git a/intro/scipy/examples/plot_optimize_example1.py b/intro/scipy/examples/plot_optimize_example1.py index 41b7cc780..3911f5391 100644 --- a/intro/scipy/examples/plot_optimize_example1.py +++ b/intro/scipy/examples/plot_optimize_example1.py @@ -6,8 +6,8 @@ Demos various methods to find the minimum of a function. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def f(x): diff --git a/intro/scipy/examples/plot_solve_ivp_damped_spring_mass.py b/intro/scipy/examples/plot_solve_ivp_damped_spring_mass.py index b3bb0af8a..771046d9c 100644 --- a/intro/scipy/examples/plot_solve_ivp_damped_spring_mass.py +++ b/intro/scipy/examples/plot_solve_ivp_damped_spring_mass.py @@ -6,9 +6,9 @@ """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt m = 0.5 # kg k = 4 # N/m diff --git a/intro/scipy/examples/plot_solve_ivp_simple.py b/intro/scipy/examples/plot_solve_ivp_simple.py index b30f17cd2..c2eb7b7b2 100644 --- a/intro/scipy/examples/plot_solve_ivp_simple.py +++ b/intro/scipy/examples/plot_solve_ivp_simple.py @@ -7,9 +7,9 @@ y(t=0) = 1. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt def f(t, y): diff --git a/intro/scipy/examples/plot_spectrogram.py b/intro/scipy/examples/plot_spectrogram.py index 988d618e2..6c44b1702 100644 --- a/intro/scipy/examples/plot_spectrogram.py +++ b/intro/scipy/examples/plot_spectrogram.py @@ -6,8 +6,8 @@ Demo spectrogram and power spectral density on a frequency chirp. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np ############################################################ # Generate a chirp signal diff --git a/intro/scipy/examples/plot_t_test.py b/intro/scipy/examples/plot_t_test.py index 77258b6fd..680f2cf2a 100644 --- a/intro/scipy/examples/plot_t_test.py +++ b/intro/scipy/examples/plot_t_test.py @@ -5,8 +5,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Generates 2 sets of observations rng = np.random.default_rng(27446968) diff --git a/intro/scipy/examples/solutions/plot_fft_image_denoise.py b/intro/scipy/examples/solutions/plot_fft_image_denoise.py index ec06081d9..acc7ecfaa 100644 --- a/intro/scipy/examples/solutions/plot_fft_image_denoise.py +++ b/intro/scipy/examples/solutions/plot_fft_image_denoise.py @@ -21,8 +21,8 @@ ############################################################ # Read and plot the image ############################################################ -import numpy as np import matplotlib.pyplot as plt +import numpy as np im = plt.imread("../../../../data/moonlanding.png").astype(float) diff --git a/intro/scipy/examples/solutions/plot_image_blur.py b/intro/scipy/examples/solutions/plot_image_blur.py index 78d38faa8..051909ff2 100644 --- a/intro/scipy/examples/solutions/plot_image_blur.py +++ b/intro/scipy/examples/solutions/plot_image_blur.py @@ -11,9 +11,9 @@ """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt ##################################################################### # The original image diff --git a/intro/scipy/solutions/path_site.py b/intro/scipy/solutions/path_site.py index fab917f36..de95141d3 100644 --- a/intro/scipy/solutions/path_site.py +++ b/intro/scipy/solutions/path_site.py @@ -1,8 +1,8 @@ """Script to search the PYTHONPATH for the module site.py""" +import glob import os import sys -import glob def find_module(module): diff --git a/intro/scipy/summary-exercises/examples/plot_cumulative_wind_speed_prediction.py b/intro/scipy/summary-exercises/examples/plot_cumulative_wind_speed_prediction.py index 699268c9f..116791bfb 100644 --- a/intro/scipy/summary-exercises/examples/plot_cumulative_wind_speed_prediction.py +++ b/intro/scipy/summary-exercises/examples/plot_cumulative_wind_speed_prediction.py @@ -6,9 +6,9 @@ for the interpolate section of scipy.rst. """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt max_speeds = np.load("max-speeds.npy") years_nb = max_speeds.shape[0] diff --git a/intro/scipy/summary-exercises/examples/plot_gumbell_wind_speed_prediction.py b/intro/scipy/summary-exercises/examples/plot_gumbell_wind_speed_prediction.py index a632610b0..3f2930dc2 100644 --- a/intro/scipy/summary-exercises/examples/plot_gumbell_wind_speed_prediction.py +++ b/intro/scipy/summary-exercises/examples/plot_gumbell_wind_speed_prediction.py @@ -5,9 +5,9 @@ Generate the exercise results on the Gumbell distribution """ +import matplotlib.pyplot as plt import numpy as np import scipy as sp -import matplotlib.pyplot as plt def gumbell_dist(arr): diff --git a/intro/scipy/summary-exercises/examples/plot_optimize_lidar_complex_data.py b/intro/scipy/summary-exercises/examples/plot_optimize_lidar_complex_data.py index 11caf2b63..2defa8799 100644 --- a/intro/scipy/summary-exercises/examples/plot_optimize_lidar_complex_data.py +++ b/intro/scipy/summary-exercises/examples/plot_optimize_lidar_complex_data.py @@ -5,8 +5,8 @@ Generate a chart of more complex data recorded by the lidar system """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np waveform_2 = np.load("waveform_2.npy") diff --git a/intro/scipy/summary-exercises/examples/plot_optimize_lidar_complex_data_fit.py b/intro/scipy/summary-exercises/examples/plot_optimize_lidar_complex_data_fit.py index 89a596dcd..046a66731 100644 --- a/intro/scipy/summary-exercises/examples/plot_optimize_lidar_complex_data_fit.py +++ b/intro/scipy/summary-exercises/examples/plot_optimize_lidar_complex_data_fit.py @@ -5,8 +5,8 @@ Generate a chart of the data fitted by Gaussian curve """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np import scipy as sp diff --git a/intro/scipy/summary-exercises/examples/plot_optimize_lidar_data.py b/intro/scipy/summary-exercises/examples/plot_optimize_lidar_data.py index b7bde0fb4..d7bc04b74 100644 --- a/intro/scipy/summary-exercises/examples/plot_optimize_lidar_data.py +++ b/intro/scipy/summary-exercises/examples/plot_optimize_lidar_data.py @@ -5,8 +5,8 @@ Generate a chart of the data recorded by the lidar system """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np waveform_1 = np.load("waveform_1.npy") diff --git a/intro/scipy/summary-exercises/examples/plot_optimize_lidar_data_fit.py b/intro/scipy/summary-exercises/examples/plot_optimize_lidar_data_fit.py index 8eafe5e6f..dab5f1b20 100644 --- a/intro/scipy/summary-exercises/examples/plot_optimize_lidar_data_fit.py +++ b/intro/scipy/summary-exercises/examples/plot_optimize_lidar_data_fit.py @@ -5,8 +5,8 @@ Generate a chart of the data fitted by Gaussian curve """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np import scipy as sp diff --git a/intro/scipy/summary-exercises/examples/plot_sprog_annual_maxima.py b/intro/scipy/summary-exercises/examples/plot_sprog_annual_maxima.py index c2f7fc1d0..bccb37a2c 100644 --- a/intro/scipy/summary-exercises/examples/plot_sprog_annual_maxima.py +++ b/intro/scipy/summary-exercises/examples/plot_sprog_annual_maxima.py @@ -5,8 +5,8 @@ Generate the exercise results on the Gumbell distribution """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np years_nb = 21 wspeeds = np.load("sprog-windspeeds.npy") diff --git a/packages/scikit-image/examples/plot_boundaries.py b/packages/scikit-image/examples/plot_boundaries.py index 7c6df30f0..10f3aaff6 100644 --- a/packages/scikit-image/examples/plot_boundaries.py +++ b/packages/scikit-image/examples/plot_boundaries.py @@ -5,10 +5,9 @@ Visualize segmentation contours on original grayscale image. """ -from skimage import data, segmentation -from skimage import filters import matplotlib.pyplot as plt import numpy as np +from skimage import data, filters, segmentation coins = data.coins() mask = coins > filters.threshold_otsu(coins) diff --git a/packages/scikit-image/examples/plot_check.py b/packages/scikit-image/examples/plot_check.py index 79e7a5b47..6400cc949 100644 --- a/packages/scikit-image/examples/plot_check.py +++ b/packages/scikit-image/examples/plot_check.py @@ -7,8 +7,8 @@ This examples show how to create a simple checkerboard. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np check = np.zeros((8, 8)) check[::2, 1::2] = 1 diff --git a/packages/scikit-image/examples/plot_equalize_hist.py b/packages/scikit-image/examples/plot_equalize_hist.py index 9696b5e1c..3f67a1f0e 100644 --- a/packages/scikit-image/examples/plot_equalize_hist.py +++ b/packages/scikit-image/examples/plot_equalize_hist.py @@ -5,8 +5,8 @@ Histogram equalizing makes images have a uniform histogram. """ -from skimage import data, exposure import matplotlib.pyplot as plt +from skimage import data, exposure camera = data.camera() camera_equalized = exposure.equalize_hist(camera) diff --git a/packages/scikit-image/examples/plot_features.py b/packages/scikit-image/examples/plot_features.py index 74cda9f2d..a139ddc5b 100644 --- a/packages/scikit-image/examples/plot_features.py +++ b/packages/scikit-image/examples/plot_features.py @@ -6,11 +6,9 @@ """ import matplotlib.pyplot as plt - from skimage import data -from skimage.feature import corner_harris, corner_subpix, corner_peaks -from skimage.transform import warp, AffineTransform - +from skimage.feature import corner_harris, corner_peaks, corner_subpix +from skimage.transform import AffineTransform, warp tform = AffineTransform(scale=(1.3, 1.1), rotation=1, shear=0.7, translation=(210, 50)) image = warp(data.checkerboard(), tform.inverse, output_shape=(350, 350)) diff --git a/packages/scikit-image/examples/plot_filter_coins.py b/packages/scikit-image/examples/plot_filter_coins.py index f44d8324d..b6a6ad0c8 100644 --- a/packages/scikit-image/examples/plot_filter_coins.py +++ b/packages/scikit-image/examples/plot_filter_coins.py @@ -6,11 +6,9 @@ a Gaussian filter, a median filter, and total variation denoising. """ -import numpy as np import matplotlib.pyplot as plt -from skimage import data -from skimage import filters -from skimage import restoration +import numpy as np +from skimage import data, filters, restoration coins = data.coins() gaussian_filter_coins = filters.gaussian(coins, sigma=2) diff --git a/packages/scikit-image/examples/plot_labels.py b/packages/scikit-image/examples/plot_labels.py index 1b99701fd..18f2fabd0 100644 --- a/packages/scikit-image/examples/plot_labels.py +++ b/packages/scikit-image/examples/plot_labels.py @@ -6,10 +6,9 @@ the dedicated skimage.measure.label function. """ -from skimage import measure -from skimage import filters import matplotlib.pyplot as plt import numpy as np +from skimage import filters, measure n = 12 l = 256 diff --git a/packages/scikit-image/examples/plot_segmentations.py b/packages/scikit-image/examples/plot_segmentations.py index 16896c987..8028d0462 100644 --- a/packages/scikit-image/examples/plot_segmentations.py +++ b/packages/scikit-image/examples/plot_segmentations.py @@ -10,13 +10,12 @@ background are used as seeds. """ -import numpy as np -from skimage.segmentation import watershed -from skimage.feature import peak_local_max -from skimage import measure -from skimage.segmentation import random_walker import matplotlib.pyplot as plt +import numpy as np import scipy as sp +from skimage import measure +from skimage.feature import peak_local_max +from skimage.segmentation import random_walker, watershed # Generate an initial image with two overlapping circles x, y = np.indices((80, 80)) diff --git a/packages/scikit-image/examples/plot_sobel.py b/packages/scikit-image/examples/plot_sobel.py index c1d7a3195..fae0350f9 100644 --- a/packages/scikit-image/examples/plot_sobel.py +++ b/packages/scikit-image/examples/plot_sobel.py @@ -6,9 +6,8 @@ horizontal gradients. """ -from skimage import data -from skimage import filters import matplotlib.pyplot as plt +from skimage import data, filters text = data.text() hsobel_text = filters.sobel_h(text) diff --git a/packages/scikit-image/examples/plot_threshold.py b/packages/scikit-image/examples/plot_threshold.py index b03c75df4..e2227af53 100644 --- a/packages/scikit-image/examples/plot_threshold.py +++ b/packages/scikit-image/examples/plot_threshold.py @@ -6,9 +6,7 @@ """ import matplotlib.pyplot as plt -from skimage import data -from skimage import filters -from skimage import exposure +from skimage import data, exposure, filters camera = data.camera() val = filters.threshold_otsu(camera) diff --git a/packages/scikit-learn/examples/plot_ML_flow_chart.py b/packages/scikit-learn/examples/plot_ML_flow_chart.py index b986ab8de..9bfb641c1 100644 --- a/packages/scikit-learn/examples/plot_ML_flow_chart.py +++ b/packages/scikit-learn/examples/plot_ML_flow_chart.py @@ -5,9 +5,9 @@ This script plots the flow-charts used in the scikit-learn tutorials. """ -import numpy as np import matplotlib.pyplot as plt -from matplotlib.patches import Circle, Rectangle, Polygon, Arrow, FancyArrow +import numpy as np +from matplotlib.patches import Arrow, Circle, FancyArrow, Polygon, Rectangle def create_base(box_bg="#CCCCCC", arrow1="#88CCFF", arrow2="#88FF88", supervised=True): diff --git a/packages/scikit-learn/examples/plot_bias_variance.py b/packages/scikit-learn/examples/plot_bias_variance.py index 16a54b54c..cace8321f 100644 --- a/packages/scikit-learn/examples/plot_bias_variance.py +++ b/packages/scikit-learn/examples/plot_bias_variance.py @@ -11,8 +11,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def generating_func(x, rng=None, error=0.5): @@ -22,8 +22,8 @@ def generating_func(x, rng=None, error=0.5): ############################################################ # A polynomial regression -from sklearn.pipeline import make_pipeline from sklearn.linear_model import LinearRegression +from sklearn.pipeline import make_pipeline from sklearn.preprocessing import PolynomialFeatures ############################################################ diff --git a/packages/scikit-learn/examples/plot_compare_classifiers.py b/packages/scikit-learn/examples/plot_compare_classifiers.py index 40aec4156..7a5c330c4 100644 --- a/packages/scikit-learn/examples/plot_compare_classifiers.py +++ b/packages/scikit-learn/examples/plot_compare_classifiers.py @@ -6,10 +6,10 @@ digits data. """ -from sklearn import model_selection, datasets, metrics -from sklearn.svm import LinearSVC +from sklearn import datasets, metrics, model_selection from sklearn.naive_bayes import GaussianNB from sklearn.neighbors import KNeighborsClassifier +from sklearn.svm import LinearSVC digits = datasets.load_digits() X = digits.data diff --git a/packages/scikit-learn/examples/plot_digits_simple_classif.py b/packages/scikit-learn/examples/plot_digits_simple_classif.py index 0f823dd54..52ac0185e 100644 --- a/packages/scikit-learn/examples/plot_digits_simple_classif.py +++ b/packages/scikit-learn/examples/plot_digits_simple_classif.py @@ -45,8 +45,8 @@ # Classify with Gaussian naive Bayes # ---------------------------------- -from sklearn.naive_bayes import GaussianNB from sklearn.model_selection import train_test_split +from sklearn.naive_bayes import GaussianNB # split the data into training and validation sets X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target) diff --git a/packages/scikit-learn/examples/plot_iris_knn.py b/packages/scikit-learn/examples/plot_iris_knn.py index ea52c92ac..86c059bb2 100644 --- a/packages/scikit-learn/examples/plot_iris_knn.py +++ b/packages/scikit-learn/examples/plot_iris_knn.py @@ -6,10 +6,10 @@ with a single nearest neighbor, and then using 3 nearest neighbors. """ -import numpy as np import matplotlib.pyplot as plt -from sklearn import neighbors, datasets +import numpy as np from matplotlib.colors import ListedColormap +from sklearn import datasets, neighbors # Create color maps for 3-class classification problem, as with iris cmap_light = ListedColormap(["#FFAAAA", "#AAFFAA", "#AAAAFF"]) diff --git a/packages/scikit-learn/examples/plot_linear_model_cv.py b/packages/scikit-learn/examples/plot_linear_model_cv.py index bc7f3a467..b6d654e89 100644 --- a/packages/scikit-learn/examples/plot_linear_model_cv.py +++ b/packages/scikit-learn/examples/plot_linear_model_cv.py @@ -16,8 +16,8 @@ ############################################################ # Compute the cross-validation score with the default hyper-parameters +from sklearn.linear_model import Lasso, Ridge from sklearn.model_selection import cross_val_score -from sklearn.linear_model import Ridge, Lasso for Model in [Ridge, Lasso]: model = Model() @@ -26,8 +26,8 @@ ############################################################ # We compute the cross-validation score as a function of alpha, the # strength of the regularization for Lasso and Ridge -import numpy as np import matplotlib.pyplot as plt +import numpy as np alphas = np.logspace(-3, -1, 30) diff --git a/packages/scikit-learn/examples/plot_linear_regression.py b/packages/scikit-learn/examples/plot_linear_regression.py index 50e414694..daac74ea1 100644 --- a/packages/scikit-learn/examples/plot_linear_regression.py +++ b/packages/scikit-learn/examples/plot_linear_regression.py @@ -4,8 +4,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np from sklearn.linear_model import LinearRegression # x from 0 to 30 diff --git a/packages/scikit-learn/examples/plot_polynomial_regression.py b/packages/scikit-learn/examples/plot_polynomial_regression.py index a2037771d..b067bfce7 100644 --- a/packages/scikit-learn/examples/plot_polynomial_regression.py +++ b/packages/scikit-learn/examples/plot_polynomial_regression.py @@ -7,10 +7,9 @@ to be preferred """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np from matplotlib.colors import ListedColormap - from sklearn import linear_model # Create color maps for 3-class classification problem, as with iris diff --git a/packages/scikit-learn/examples/plot_separator.py b/packages/scikit-learn/examples/plot_separator.py index abd4c4c6e..9d6a315e9 100644 --- a/packages/scikit-learn/examples/plot_separator.py +++ b/packages/scikit-learn/examples/plot_separator.py @@ -6,10 +6,10 @@ separating hyperplane on them. """ -import numpy as np import matplotlib.pyplot as plt -from sklearn.linear_model import SGDClassifier +import numpy as np from sklearn.datasets import make_blobs +from sklearn.linear_model import SGDClassifier # we create 50 separable synthetic points X, Y = make_blobs(n_samples=50, centers=2, random_state=0, cluster_std=0.60) diff --git a/packages/scikit-learn/examples/plot_svm_non_linear.py b/packages/scikit-learn/examples/plot_svm_non_linear.py index e71e8dff2..818f058eb 100644 --- a/packages/scikit-learn/examples/plot_svm_non_linear.py +++ b/packages/scikit-learn/examples/plot_svm_non_linear.py @@ -6,12 +6,10 @@ of the support vector machine GUI. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np from sklearn import svm - rng = np.random.default_rng(27446968) ############################################################################## diff --git a/packages/scikit-learn/examples/plot_variance_linear_regr.py b/packages/scikit-learn/examples/plot_variance_linear_regr.py index 4fdf0fc0e..f3860c4a7 100644 --- a/packages/scikit-learn/examples/plot_variance_linear_regr.py +++ b/packages/scikit-learn/examples/plot_variance_linear_regr.py @@ -6,10 +6,9 @@ """ -import numpy as np - # Smaller figures import matplotlib.pyplot as plt +import numpy as np plt.rcParams["figure.figsize"] = (3, 2) diff --git a/packages/statistics/examples/plot_iris_analysis.py b/packages/statistics/examples/plot_iris_analysis.py index f00ae0259..43cdfec32 100644 --- a/packages/statistics/examples/plot_iris_analysis.py +++ b/packages/statistics/examples/plot_iris_analysis.py @@ -12,10 +12,8 @@ """ import matplotlib.pyplot as plt - import pandas from pandas import plotting - from statsmodels.formula.api import ols # Load the data diff --git a/packages/statistics/examples/plot_paired_boxplots.py b/packages/statistics/examples/plot_paired_boxplots.py index cfcd0fc74..9c1310771 100644 --- a/packages/statistics/examples/plot_paired_boxplots.py +++ b/packages/statistics/examples/plot_paired_boxplots.py @@ -10,9 +10,8 @@ """ -import pandas - import matplotlib.pyplot as plt +import pandas data = pandas.read_csv("brain_size.csv", sep=";", na_values=".") diff --git a/packages/statistics/examples/plot_regression.py b/packages/statistics/examples/plot_regression.py index c0bb5f564..bd54d305a 100644 --- a/packages/statistics/examples/plot_regression.py +++ b/packages/statistics/examples/plot_regression.py @@ -8,8 +8,8 @@ # Original author: Thomas Haslwanter -import numpy as np import matplotlib.pyplot as plt +import numpy as np import pandas # For statistics. Requires statsmodels 5.0 or more diff --git a/packages/statistics/examples/plot_regression_3d.py b/packages/statistics/examples/plot_regression_3d.py index 95f7a343b..f941f94fc 100644 --- a/packages/statistics/examples/plot_regression_3d.py +++ b/packages/statistics/examples/plot_regression_3d.py @@ -10,8 +10,8 @@ # Original author: Thomas Haslwanter -import numpy as np import matplotlib.pyplot as plt +import numpy as np import pandas # For 3d plots. This import is necessary to have 3D plotting below diff --git a/packages/statistics/examples/plot_wage_education_gender.py b/packages/statistics/examples/plot_wage_education_gender.py index e29e97117..c4975859d 100644 --- a/packages/statistics/examples/plot_wage_education_gender.py +++ b/packages/statistics/examples/plot_wage_education_gender.py @@ -15,10 +15,10 @@ ############################################################################## # Load and massage the data -import pandas - -import urllib import os +import urllib + +import pandas if not os.path.exists("wages.txt"): # Download the file if it is not present diff --git a/packages/statistics/examples/solutions/plot_brain_size.py b/packages/statistics/examples/solutions/plot_brain_size.py index b95b2ca2e..3bbf2214c 100644 --- a/packages/statistics/examples/solutions/plot_brain_size.py +++ b/packages/statistics/examples/solutions/plot_brain_size.py @@ -32,8 +32,8 @@ # This plotting is useful to get an intuitions on the relationships between # our different variables -from pandas import plotting import matplotlib.pyplot as plt +from pandas import plotting # Fill in the missing values for Height for plotting data["Height"].fillna(method="pad", inplace=True) diff --git a/pyximages/numpy_fancy_indexing.py b/pyximages/numpy_fancy_indexing.py index e331a986f..b5ebce3a5 100644 --- a/pyximages/numpy_fancy_indexing.py +++ b/pyximages/numpy_fancy_indexing.py @@ -8,6 +8,7 @@ import os import sys from math import cos, radians, sin + from pyx import canvas, color, path, text, unit diff --git a/pyximages/numpy_indexing.py b/pyximages/numpy_indexing.py index 94932928d..27a0525e3 100644 --- a/pyximages/numpy_indexing.py +++ b/pyximages/numpy_indexing.py @@ -8,6 +8,7 @@ import os import sys from math import cos, radians, sin + from pyx import canvas, color, path, text, unit diff --git a/ruff.toml b/ruff.toml index a83da8581..31505c941 100644 --- a/ruff.toml +++ b/ruff.toml @@ -8,6 +8,7 @@ select = [ "EM", # flake8-errmsg "EXE", # flake8-executable "FURB", # refurb + "I", # isort "NPY", # NumPy specific rules "PD", # pandas-vet "PGH", # pygrep-hooks