Skip to content

Commit

Permalink
Bulk black format and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
morganjwilliams committed Jul 3, 2023
1 parent 3b0d142 commit 64fac54
Show file tree
Hide file tree
Showing 122 changed files with 630 additions and 415 deletions.
3 changes: 2 additions & 1 deletion docs/source/_patch/_sphinx_gallery_patch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from sphinx_gallery import gen_rst

from .sphinx_gallery_binder import alt_gen_binder_rst
from .sphinx_gallery_scrapers import alt_matplotlib_scraper
from sphinx_gallery import gen_rst

# modify single image arrangement
gen_rst.SINGLE_IMAGE = """
Expand Down
2 changes: 1 addition & 1 deletion docs/source/_patch/sphinx_gallery_binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def alt_gen_binder_rst(
):
"""
Generate the RST + link for the Binder badge.
Parameters
----------
fpath: str
Expand Down
5 changes: 4 additions & 1 deletion docs/source/_patch/sphinx_gallery_scrapers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import re
from pathlib import Path

import matplotlib
import matplotlib.pyplot as plt
from matplotlib import _pylab_helpers
from sphinx_gallery import scrapers

from pyrolite.util.plot import save_figure

from sphinx_gallery import scrapers

def alt_matplotlib_scraper(block, block_vars, gallery_conf, **kwargs):
"""Patched matplotlib scraper which won't close figures.
Expand Down Expand Up @@ -49,4 +51,5 @@ def alt_matplotlib_scraper(block, block_vars, gallery_conf, **kwargs):

return scrapers.figure_rst(image_paths, gallery_conf["src_dir"])


scrapers._scraper_dict.update(dict(altmatplot=alt_matplotlib_scraper))
1 change: 1 addition & 0 deletions docs/source/gallery/data/aitchison.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
df.head()
########################################################################################
import matplotlib.pyplot as plt

import pyrolite.plot

fig, ax = plt.subplots(1)
Expand Down
5 changes: 3 additions & 2 deletions docs/source/gallery/data/radii.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
to get radii for individual elements, using a :code:`source` keyword argument to swap
between the datasets:
"""
import pandas as pd
import matplotlib.pyplot as plt
from pyrolite.geochem.ind import get_ionic_radii, REE
import pandas as pd

from pyrolite.geochem.ind import REE, get_ionic_radii

REE_radii = pd.Series(
get_ionic_radii(REE(), coordination=8, charge=3, source="Whittaker"), index=REE()
Expand Down
2 changes: 2 additions & 0 deletions docs/source/gallery/data/refcomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
references.
"""
import matplotlib.pyplot as plt

from pyrolite.geochem.norm import all_reference_compositions, get_reference_composition

# sphinx_gallery_thumbnail_number = 11

refcomps = all_reference_compositions()
Expand Down
9 changes: 6 additions & 3 deletions docs/source/gallery/examples/comp/logratiomeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
Log Ratio Means
-----------------
"""
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

import pyrolite.comp
from pyrolite.comp.codata import ILR, inverse_ILR, close
from pyrolite.util.synthetic import random_cov_matrix
import matplotlib.pyplot as plt
from pyrolite.comp.codata import ILR, close, inverse_ILR
from pyrolite.plot import pyroplot
from pyrolite.util.synthetic import random_cov_matrix

# sphinx_gallery_thumbnail_number = 3

np.random.seed(82)


########################################################################################
def random_compositional_trend(m1, m2, c1, c2, resolution=20, size=1000):
"""
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/comp/logtransforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
# `label_mode` parameter, for example to get nice labels for plotting:
#
import matplotlib.pyplot as plt

df.pyrocomp.ILR(label_mode="latex").iloc[:, 0:2].pyroplot.scatter()
plt.show()
########################################################################################
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/comp/sphericalcoords.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
one of the minerals might occasionally have zero abundance:
"""
import numpy as np

from pyrolite.util.synthetic import normal_frame

# sphinx_gallery_thumbnail_number = 2
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/geochem/CIPW.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

import pyrolite.geochem
from pyrolite.util.meta import pyrolite_datafolder

Expand Down
2 changes: 1 addition & 1 deletion docs/source/gallery/examples/geochem/ionic_radii.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
the :func:`~pyrolite.geochem.ind.get_ionic_radii` function. The function can be used
to get radii for individual elements:
"""
from pyrolite.geochem.ind import get_ionic_radii, REE
from pyrolite.geochem.ind import REE, get_ionic_radii

Cu_radii = get_ionic_radii("Cu")
print(Cu_radii)
Expand Down
2 changes: 2 additions & 0 deletions docs/source/gallery/examples/geochem/lambdas.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

import pyrolite.plot

# sphinx_gallery_thumbnail_number = 2
Expand Down Expand Up @@ -234,6 +235,7 @@
#
lts.head(2)
from pyrolite.geochem.ind import REE

########################################################################################
# Below we'll look at some of the potential issues of fitting lambdas and tetrads
# together - by examining the effects of i) fitting tetrads where there are none
Expand Down
5 changes: 3 additions & 2 deletions docs/source/gallery/examples/geochem/mineral_endmembers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
pyrolite includes some utilities to achieve this and a limited mineral database
for looking up endmember compositions.
"""
import pandas as pd
import numpy as np
import pandas as pd

from pyrolite.mineral.mindb import get_mineral
from pyrolite.mineral.normative import endmember_decompose

Expand Down Expand Up @@ -58,4 +59,4 @@
########################################################################################
# To make sure these compositions are within 0.01 percent:
#
assert np.allclose(recombined.values, comp.values, rtol=10 ** -4)
assert np.allclose(recombined.values, comp.values, rtol=10**-4)
9 changes: 5 additions & 4 deletions docs/source/gallery/examples/geochem/mineral_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
generates plagioclase's hallmark 'europium anomaly', and the effects of variable
europium oxidation state on bulk europium partitioning.
"""
import numpy as np
import matplotlib.pyplot as plt
import numpy as np

from pyrolite.geochem.ind import REE, get_ionic_radii
from pyrolite.mineral.lattice import strain_coefficient

Expand All @@ -40,8 +41,8 @@
D_Ca = 4.1 # Partition coefficient Plag-Melt
Tc = 900 # Temperature, °C
Tk = Tc + 273.15 # Temperature, K
E_2 = 120 * 10 ** 9 # Youngs modulus for 2+ site, Pa
E_3 = 135 * 10 ** 9 # Youngs modulus for 3+ site, Pa
E_2 = 120 * 10**9 # Youngs modulus for 2+ site, Pa
E_3 = 135 * 10**9 # Youngs modulus for 3+ site, Pa
r02, r03 = 1.196, 1.294 # fictive ideal cation radii for these sites
rCa = get_ionic_radii("Ca", charge=2, coordination=8)
rLa = get_ionic_radii("La", charge=3, coordination=8)
Expand Down Expand Up @@ -80,7 +81,7 @@
# Through a handy relationship, we can estimate :math:`D_{La}`
# based on the easier measured :math:`D_{Ca}`, :math:`D_{Na}` and temperature [#ref_2]_:
#
D_La = (D_Ca ** 2 / D_Na) * np.exp((529 / Tk) - 3.705)
D_La = (D_Ca**2 / D_Na) * np.exp((529 / Tk) - 3.705)
D_La # 0.48085
########################################################################################
# Now :math:`D_{La}` is defined, we can use it as a reference for the other REE:
Expand Down
9 changes: 7 additions & 2 deletions docs/source/gallery/examples/geochem/mineral_mindb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
"""
import pandas as pd

from pyrolite.mineral.mindb import (get_mineral, get_mineral_group,
list_formulae, list_groups, list_minerals)
from pyrolite.mineral.mindb import (
get_mineral,
get_mineral_group,
list_formulae,
list_groups,
list_minerals,
)

pd.set_option("display.precision", 3) # smaller outputs
########################################################################################
Expand Down
5 changes: 3 additions & 2 deletions docs/source/gallery/examples/geochem/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
accessed with :func:`pyrolite.geochem.norm.get_reference_composition` (see the list
at the bottom of the page for a complete list):
"""
import pandas as pd
import matplotlib.pyplot as plt
import pandas as pd

import pyrolite.plot
from pyrolite.geochem.ind import REE
from pyrolite.geochem.norm import get_reference_composition, all_reference_compositions
from pyrolite.geochem.norm import all_reference_compositions, get_reference_composition

########################################################################################
chondrite = get_reference_composition("Chondrite_PON")
Expand Down
5 changes: 3 additions & 2 deletions docs/source/gallery/examples/plotting/REE_v_radii.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
REE Radii Plots
============================
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from pyrolite.plot import pyroplot

# sphinx_gallery_thumbnail_number = 3
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/plotting/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from pyrolite.comp.codata import close
from pyrolite.plot import pyroplot
from pyrolite.plot.density import density
Expand Down
5 changes: 3 additions & 2 deletions docs/source/gallery/examples/plotting/heatscatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
represents the best of both worlds. A version inspired by similar existing
visualisations is implemented with :func:`~pyrolite.plot.pyroplot.heatscatter`.
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from pyrolite.plot import pyroplot

np.random.seed(12)
Expand Down
8 changes: 5 additions & 3 deletions docs/source/gallery/examples/plotting/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
higher dimensional data. pyrolite now includes an implementation of this which allows
a handy quick exploratory visualisation.
"""
import matplotlib.axes
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.axes
import pyrolite.plot

import pyrolite.data.Aitchison
import pyrolite.plot

# sphinx_gallery_thumbnail_number = 3

########################################################################################
Expand Down
2 changes: 1 addition & 1 deletion docs/source/gallery/examples/plotting/spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Spiderplots & Density Spiderplots
==================================
"""
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# sphinx_gallery_thumbnail_number = 4

Expand Down
5 changes: 3 additions & 2 deletions docs/source/gallery/examples/plotting/stem.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
so (such that the sampling frequency along this axis is important, which is not
emphasised by a scatter plot).
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from pyrolite.plot import pyroplot
from pyrolite.plot.stem import stem

Expand Down
2 changes: 1 addition & 1 deletion docs/source/gallery/examples/plotting/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# based on their whole-rock geochemistry (:func:`~pyrolite.plot.templates.Pettijohn`,
# :func:`~pyrolite.plot.templates.Herron`):
#
from pyrolite.plot.templates import Pettijohn, Herron
from pyrolite.plot.templates import Herron, Pettijohn

fig, ax = plt.subplots(1, 2, figsize=(10, 4))
share_axes(ax, which="x") # these diagrams have the same x axis
Expand Down
5 changes: 3 additions & 2 deletions docs/source/gallery/examples/plotting/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
Ternary Plots
=============
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from pyrolite.plot import pyroplot

np.random.seed(82)
Expand Down
8 changes: 4 additions & 4 deletions docs/source/gallery/examples/util/TAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
# Variations of the Diagram
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# To use a different variation of the TAS diagram, you can pass the relevant keyword
# To use a different variation of the TAS diagram, you can pass the relevant keyword
# :code:`which_model` allowing you to access the other available variants.
#
# Currently, the Le Bas/Le Maitre alternative and a T1-T2 combined variant of it are
# available as alternatives to the Middlemost version. Each of these can be used as a
# Currently, the Le Bas/Le Maitre alternative and a T1-T2 combined variant of it are
# available as alternatives to the Middlemost version. Each of these can be used as a
# classifier model as for the default above.
#
fig, ax = plt.subplots(1, 3, figsize=(20, 4))
Expand Down Expand Up @@ -94,4 +94,4 @@
# of Terms : Recommendations of International Union of Geological
# ciences Subcommission on the Systematics of Igneous Rocks.
# Cambridge University Press, 236pp.
# `doi: 10.1017/CBO9780511535581 <https://doi.org/10.1017/CBO9780511535581>`__.
# `doi: 10.1017/CBO9780511535581 <https://doi.org/10.1017/CBO9780511535581>`__.
9 changes: 4 additions & 5 deletions docs/source/gallery/examples/util/manifold_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
predictions and relative prediction certainty (using entropy across predicted
probability for each individual class) for a toy :mod:`sklearn` dataset.
"""
import matplotlib.pyplot as plt
import numpy as np
import sklearn.datasets
import matplotlib.pyplot as plt

from pyrolite.util.plot import DEFAULT_DISC_COLORMAP
from pyrolite.util.skl.pipeline import SVC_pipeline
from pyrolite.util.skl.vis import plot_mapping
from pyrolite.util.plot import DEFAULT_DISC_COLORMAP

np.random.seed(82)
########################################################################################
Expand All @@ -30,9 +31,7 @@
# %% Plot
fig, ax = plt.subplots(1, 2, figsize=(8, 4))

a, tfm, mapped = plot_mapping(
data, gs.best_estimator_, ax=ax[1], s=50, init="pca"
)
a, tfm, mapped = plot_mapping(data, gs.best_estimator_, ax=ax[1], s=50, init="pca")
ax[0].scatter(*mapped.T, c=DEFAULT_DISC_COLORMAP(gs.predict(data)), s=50)

ax[0].set_title("Predicted Classes")
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/util/timescale.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# First we'll create a timescale:
#
from pyrolite.util.time import Timescale

# sphinx_gallery_thumbnail_number = 2
ts = Timescale()

Expand Down
Loading

0 comments on commit 64fac54

Please sign in to comment.