Skip to content

Commit

Permalink
Updating pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Mar 7, 2022
1 parent 0a79d4c commit 0446c70
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 60 deletions.
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
repos:
# - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
# rev: v2.1.0
# hooks:
# - id: pretty-format-yaml
# args: [--autofix, --indent, '2']
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.1.0
hooks:
- id: black
args: [--safe, --quiet, --line-length=100]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.3.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2', --preserve-quotes]
- repo: https://github.com/humitos/mirrors-autoflake.git
rev: v1.1
hooks:
- id: autoflake
args: [--in-place, --remove-unused-variable]
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
rev: v2.7.1
hooks:
- id: reorder-python-imports
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.1
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
args: ["--ignore=E722", --max-line-length=110, "--per-file-ignores=*/__init__.py:F401"]
args: [--max-line-length=100, "--ignore=E722", "--per-file-ignores=*/__init__.py:F401"]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.20.0
hooks:
Expand Down
6 changes: 3 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

sphinx:
configuration: docs/conf.py
configuration: docs/conf.py

version: 2

Expand All @@ -12,6 +12,6 @@ conda:

python:
install:
- method: pip
path: .
- method: pip
path: .
system_packages: true
79 changes: 47 additions & 32 deletions GooseMPL/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ def latex_float(number, fmt="{0:.2g}"):
if "e" in float_str:
base, exponent = float_str.split("e")
if base == "1":
return fr"10^{{{int(exponent)}}}"
return rf"10^{{{int(exponent)}}}"
else:
return fr"{base} \times 10^{{{int(exponent)}}}"
return rf"{base} \times 10^{{{int(exponent)}}}"

return float_str

Expand Down Expand Up @@ -254,7 +254,7 @@ def log_ticks(

exp_lower, exp_upper = lim
ticks = np.logspace(exp_lower, exp_upper, exp_upper - exp_lower + 1, base=base)
labels = [fr"${base}^{{{np.log10(i):.0f}}}$" for i in ticks]
labels = [rf"${base}^{{{np.log10(i):.0f}}}$" for i in ticks]

if keep is not None:
keep = np.array(keep)
Expand Down Expand Up @@ -356,7 +356,7 @@ def log_minorticks(

for i in range(exp_lower, exp_upper):

t = (10 ** i) * np.arange(2, 10, dtype=float)
t = (10**i) * np.arange(2, 10, dtype=float)

if i < 0:
t = np.around(t, -i)
Expand Down Expand Up @@ -743,9 +743,10 @@ def plot(x, y, units="absolute", axis=None, **kwargs):
:options:
**units** ([``'absolute'``] | ``'relative'``)
The type of units in which the coordinates are specified. Relative coordinates correspond
to a fraction of the relevant axis. If you use relative coordinates, be sure to set the
limits and scale before calling this function!
The type of units in which the coordinates are specified.
Relative coordinates correspond to a fraction of the relevant axis.
If you use relative coordinates, be sure to set the limits and scale before calling
this function!
...
Any ``plt.plot(...)`` option.
Expand Down Expand Up @@ -783,9 +784,10 @@ def text(x, y, text, units="absolute", axis=None, **kwargs):
:options:
**units** ([``'absolute'``] | ``'relative'``)
The type of units in which the coordinates are specified. Relative coordinates correspond
to a fraction of the relevant axis. If you use relative coordinates, be sure to set the
limits and scale before calling this function!
The type of units in which the coordinates are specified.
Relative coordinates correspond to a fraction of the relevant axis.
If you use relative coordinates, be sure to set the limits and scale before calling
this function!
...
Any ``plt.text(...)`` option.
Expand Down Expand Up @@ -820,7 +822,8 @@ def diagonal_powerlaw(
The power-law exponent.
**ll, lr, tl, tr** (``<list>``)
Coordinates of the lower-left, or the lower-right, or the top-left, or the top-right corner.
Coordinates of the lower-left, or the lower-right, or the top-left,
or the top-right corner.
**width, height** (``<float>``)
Width or the height.
Expand Down Expand Up @@ -912,9 +915,10 @@ def annotate_powerlaw(text, exp, startx, starty, width=None, rx=0.5, ry=0.5, **k
E.g. ``rx = 0.5, ry = 0.5`` corresponds to the middle of the line.
**units** ([``'relative'``] | ``'absolute'``)
The type of units in which the coordinates are specified. Relative coordinates correspond
to a fraction of the relevant axis. If you use relative coordinates, be sure to set the
limits and scale before calling this function!
The type of units in which the coordinates are specified.
Relative coordinates correspond to a fraction of the relevant axis.
If you use relative coordinates, be sure to set the limits and scale before calling
this function!
**axis** ([``plt.gca()``] | ...)
Specify the axis to which to apply the limits.
Expand Down Expand Up @@ -965,11 +969,11 @@ def annotate_powerlaw(text, exp, startx, starty, width=None, rx=0.5, ry=0.5, **k
[starty, endy] = rel2abs_y([starty, endy], axis)

# determine multiplication constant
const = starty / (startx ** exp)
const = starty / (startx**exp)

# get end x/y-coordinate
if endx is not None:
endy = const * endx ** exp
endy = const * endx**exp
else:
endx = (endy / const) ** (1 / exp)

Expand Down Expand Up @@ -999,9 +1003,10 @@ def plot_powerlaw(exp, startx, starty, width=None, **kwargs):
Definition of the end coordinate (only on of these options is needed).
**units** ([``'relative'``] | ``'absolute'``)
The type of units in which the coordinates are specified. Relative coordinates correspond
to a fraction of the relevant axis. If you use relative coordinates, be sure to set the
limits and scale before calling this function!
The type of units in which the coordinates are specified.
Relative coordinates correspond to a fraction of the relevant axis.
If you use relative coordinates, be sure to set the limits and scale before calling
this function!
**axis** ([``plt.gca()``] | ...)
Specify the axis to which to apply the limits.
Expand Down Expand Up @@ -1057,11 +1062,11 @@ def plot_powerlaw(exp, startx, starty, width=None, **kwargs):
[starty, endy] = rel2abs_y([starty, endy], axis)

# determine multiplication constant
const = starty / (startx ** exp)
const = starty / (startx**exp)

# get end x/y-coordinate
if endx is not None:
endy = const * endx ** exp
endy = const * endx**exp
else:
endx = (endy / const) ** (1 / exp)

Expand All @@ -1075,8 +1080,8 @@ def plot_powerlaw(exp, startx, starty, width=None, **kwargs):

def grid_powerlaw(exp, insert=0, skip=0, end=-1, step=0, axis=None, **kwargs):
r"""
Draw a power-law grid: a grid that respects a certain power-law exponent. The grid-lines start from
the positions of the ticks.
Draw a power-law grid: a grid that respects a certain power-law exponent.
The grid-lines start from the positions of the ticks.
:arguments:
Expand Down Expand Up @@ -1399,9 +1404,9 @@ def fit_powerlaw(
xl = np.logspace(np.log10(xl[0]), np.log10(xl[-1]), 1000)
xu = np.logspace(np.log10(xu[0]), np.log10(xu[-1]), 1000)

yp = prefactor * xp ** exponent
yl = prefactor * xl ** exponent
yu = prefactor * xu ** exponent
yp = prefactor * xp**exponent
yl = prefactor * xl**exponent
yu = prefactor * xu**exponent

details["handle"] = axis.plot(xp, yp, **kwargs)

Expand Down Expand Up @@ -2016,7 +2021,8 @@ def histogram(data, return_edges=True, **kwargs):
def histogram_cumulative(data, **kwargs):
r"""
Compute cumulative histogram.
See `numpy.histrogram <https://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html>`__
See `numpy.histrogram
<https://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html>`__
:extra options:
Expand Down Expand Up @@ -2204,8 +2210,16 @@ def patch(*args, **kwargs):
fig,ax = plt.subplots()
p = gplt.patch(coor=coor+disp,conn=conn,axis=ax,cindex=stress,cmap='YlOrRd',edgecolor=None)
_ = gplt.patch(coor=coor ,conn=conn,axis=ax)
p = gplt.patch(
coor=coor + disp,
conn=conn,
axis=ax,
cindex=stress,
cmap='YlOrRd',
edgecolor=None
)
_ = gplt.patch(coor=coor, conn=conn, axis=ax)
cbar = fig.colorbar(p,axis=ax,aspect=10)
Expand All @@ -2222,7 +2236,8 @@ def patch(*args, **kwargs):
Matrix with on each row the coordinates (positions) of each node.
**conn** (``<numpy.ndarray>`` | ``<list>`` (nested))
Matrix with on each row the number numbers (rows in ``coor``) which form an element (patch).
Matrix with on each row the number numbers (rows in ``coor``)
which form an element (patch).
:options:
Expand All @@ -2233,8 +2248,8 @@ def patch(*args, **kwargs):
Specify an axis to include to plot in. By default the current axis is used.
**autoscale** ([``True``] | ``False``)
Automatically update the limits of the plot (currently automatic limits of Collections are
not supported by matplotlib).
Automatically update the limits of the plot
(currently automatic limits of Collections are not supported by matplotlib).
:recommended options:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/goosempl/fit_powerlaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
ax.set_ylim([1e-2, 1e4])

x = np.logspace(1, 3, 1000)
y = 0.001 * x ** 2.0
y = 0.001 * x**2.0
y = y + 0.1 * np.random.random(x.shape) - 0.05

ax.plot(x, y)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/goosempl/fit_powerlaw_yerr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
ax.set_ylim([1e-2, 1e4])

x = np.logspace(1, 3, 10)
y = 0.001 * x ** 2.0
y = 0.001 * x**2.0
yerr = 0.1 * np.random.random(x.shape) * x
sign = np.random.random(x.shape)
sign = sign / np.abs(sign)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/goosempl/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def distribution(a=100, b=3, g=-0.3, size=10000):

r = np.random.random(size=size)

return (a ** g + (b ** g - a ** g) * r) ** (1.0 / g)
return (a**g + (b**g - a**g) * r) ** (1.0 / g)


data = distribution()
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/goosempl/histogram_powerlaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def distribution(a=100, b=3, g=-0.3, size=10000):

r = np.random.random(size=size)

return (a ** g + (b ** g - a ** g) * r) ** (1.0 / g)
return (a**g + (b**g - a**g) * r) ** (1.0 / g)


data = distribution()
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/goosempl/ticks_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
fig, ax = plt.subplots()

x = np.logspace(1, 3, 1000)
y = 0.001 * x ** 2.0
y = 0.001 * x**2.0

ax.plot(x, y)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/pyplot/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
plt.style.use(["goose", "goose-latex"])

x, y = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 100))
d = np.sqrt(x ** 2 + y ** 2)
d = np.sqrt(x**2 + y**2)

fig, ax = plt.subplots()

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/pyplot/image_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# --- some data ----

a, b = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 100))
d = np.sqrt(a ** 2 + b ** 2)
d = np.sqrt(a**2 + b**2)

# --- open figure with three axes ---

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/pyplot/image_subplots_bottom.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# --- some data ----

a, b = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 100))
d = np.sqrt(a ** 2 + b ** 2)
d = np.sqrt(a**2 + b**2)

# --- open figure with three axes ---

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/pyplot/legend_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
for i in range(10):
x = [0, 1]
y = [i / 10, (i + 10) / 10]
ax.plot(x, y, label=fr"$i = {i:d}$")
ax.plot(x, y, label=rf"$i = {i:d}$")

ax.legend(loc="center right", facecolor="white", framealpha=1)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/pyplot/plot-cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
fig, ax = plt.subplots()

for i, n in enumerate(np.linspace(0, 2, N)):
y = np.sin(x) * x ** n
y = np.sin(x) * x**n
ax.plot(x, y, color=cmap(i))

ax.set_xlabel(r"$x$")
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/pyplot/plot-cycler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
fig, ax = plt.subplots()

for n in np.linspace(0, 2, N):
y = np.sin(x) * x ** n
y = np.sin(x) * x**n
ax.plot(x, y)

ax.set_xlabel(r"$x$")
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/pyplot/tick-formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
plt.style.use(["goose", "goose-latex"])

x = np.linspace(0, 10, 101)
y = x ** 2.0
y = x**2.0

fig, ax = plt.subplots()

Expand Down
Loading

0 comments on commit 0446c70

Please sign in to comment.