Skip to content

Commit

Permalink
Bulk format
Browse files Browse the repository at this point in the history
  • Loading branch information
morganjwilliams committed Oct 29, 2024
1 parent 7650d20 commit 4afa3eb
Show file tree
Hide file tree
Showing 84 changed files with 286 additions and 159 deletions.
2 changes: 1 addition & 1 deletion docs/source/_patch/sphinx_gallery_scrapers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def alt_matplotlib_scraper(block, block_vars, gallery_conf, **kwargs):
save_at=Path(image_path).parent,
name=Path(image_path).stem,
save_fmts=["png"],
**kwargs.copy()
**kwargs.copy(),
)
image_paths.append(image_path)

Expand Down
6 changes: 2 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def reset_mpl(gallery_conf, fname):
# "jupyterlite": {"use_jupyter_lab": True},
"first_notebook_cell": "%matplotlib inline\n",
"reset_modules": (reset_mpl),
"nested_sections": False
"nested_sections": False,
}
# Remove matplotlib agg warnings from generated doc when using plt.show
warnings.filterwarnings(
Expand Down Expand Up @@ -345,9 +345,7 @@ def reset_mpl(gallery_conf, fname):
<img src="https://zenodo.org/badge/137172322.svg" alt="Archive">
</a>
""".format(
rc=refcomps, year=str(date.today().year), version=version
)
""".format(rc=refcomps, year=str(date.today().year), version=version)

rst_prolog += """
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/data/aitchison.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
(all returning a :class:`~pandas.DataFrame`).
"""

from pyrolite.data.Aitchison import load_boxite, load_coxite, load_hongite, load_kongite

df = load_boxite()
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/data/radii.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
to get radii for individual elements, using a :code:`source` keyword argument to swap
between the datasets:
"""

import matplotlib.pyplot as plt
import pandas as pd

Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/data/refcomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
contain extended descriptions and notes for some of the compositions and associated
references.
"""

import matplotlib.pyplot as plt

from pyrolite.geochem.norm import all_reference_compositions, get_reference_composition
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/data/timescale.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
specific geological ages, to look up times for known geological age names
and to access a reference table for all of these.
"""

from pyrolite.util.time import Timescale, age_name

ts = Timescale()
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/comp/logratiomeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Log Ratio Means
-----------------
"""

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
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 @@ -24,6 +24,7 @@
First let's create some example mineralogical abundance data, where at least
one of the minerals might occasionally have zero abundance:
"""

import numpy as np

from pyrolite.util.synthetic import normal_frame
Expand Down
4 changes: 2 additions & 2 deletions docs/source/gallery/examples/geochem/CIPW.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
Verma's SINCLAS/IgRoCS program. Here we can use this file to demonstrate the use
of the CIPW Norm and verify that the results should generally be comparable
between Verma's original implementation and the :mod:`pyrolite` implementation.
We import this file and do a little cleaning and registration of geochemical
We import this file and do a little cleaning and registration of geochemical
components so we can work with it in the sections to follow:
"""

import warnings

import matplotlib.pyplot as plt
Expand Down Expand Up @@ -198,7 +199,6 @@ def compare_NORMs(SINCLAS_outputs, NORM_outputs, name=""):
volcanic_filter = df.loc[:, "ROCK_TYPE"].str.lower().str.startswith("volc")
fig, ax = compare_NORMs(df.loc[volcanic_filter, :], NORM.loc[volcanic_filter])


########################################################################################
# And everything else:
#
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/geochem/convert_chemistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:func:`~pyrolite.geochem.transform.convert_chemistry` function. Note that by default
pyrolite assumes that data are in the same units.
"""

import pandas as pd

import pyrolite.geochem
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/geochem/indexes_selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
==================================
"""

import pandas as pd

import pyrolite.geochem
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/geochem/ionic_radii.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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 REE, get_ionic_radii

Cu_radii = get_ionic_radii("Cu")
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/geochem/lambdas.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Here we generate some example data, reduce these to lambda values, and visualise the
results.
"""

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/geochem/mineral_endmembers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
pyrolite includes some utilities to achieve this and a limited mineral database
for looking up endmember compositions.
"""

import numpy as np
import pandas as pd

Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/geochem/mineral_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
generates plagioclase's hallmark 'europium anomaly', and the effects of variable
europium oxidation state on bulk europium partitioning.
"""

import matplotlib.pyplot as plt
import numpy as np

Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/geochem/mineral_mindb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
pyrolite includes a limited mineral database which is useful for looking up endmember
compositions.
"""

import pandas as pd

from pyrolite.mineral.mindb import (
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/geochem/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
accessed with :func:`pyrolite.geochem.norm.get_reference_composition` (see the list
at the bottom of the page for a complete list):
"""

import matplotlib.pyplot as plt
import pandas as pd

Expand Down
5 changes: 3 additions & 2 deletions docs/source/gallery/examples/geochem/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Unit Scaling
=============
"""

import numpy as np
import pandas as pd

Expand Down Expand Up @@ -88,9 +89,9 @@
)
converted_wt_pct.head(2)
########################################################################################
# Here we rename the columns before we export them, just so we know explicitly
# Here we rename the columns before we export them, just so we know explicitly
# what the units are:
converted_wt_pct = converted_wt_pct.rename(
converted_wt_pct = converted_wt_pct.rename(
columns={c: c + "_wt%" for c in converted_wt_pct.pyrochem.list_oxides}
)
converted_wt_pct.head(2)
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/plotting/REE_v_radii.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
REE Radii Plots
============================
"""

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
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 @@ -9,6 +9,7 @@
and evaluation over a grid. The below examples highlight some of the currently
implemented features.
"""

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/plotting/heatscatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
represents the best of both worlds. A version inspired by similar existing
visualisations is implemented with :func:`~pyrolite.plot.pyroplot.heatscatter`.
"""

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down
9 changes: 5 additions & 4 deletions docs/source/gallery/examples/plotting/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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
from mpl_toolkits.axes_grid1 import make_axes_locatable
Expand Down Expand Up @@ -44,18 +45,18 @@
compdata[comp] = CLRTransform().transform(compdata[comp])
ax = compdata.loc[:, comp].pyroplot.parallel(color=compdata.Depth.values, cmap=cmap)
divider = make_axes_locatable(ax)
cax = divider.append_axes('right', size='5%', pad=0.05)
cax = divider.append_axes("right", size="5%", pad=0.05)

# we can add a meaningful colorbar to indicate one variable also, here Depth
sm = plt.cm.ScalarMappable(cmap=cmap)
sm.set_array(df.Depth)
plt.colorbar(sm, cax=cax, orientation='vertical')
plt.colorbar(sm, cax=cax, orientation="vertical")
plt.show()
########################################################################################
ax = compdata.loc[:, comp].pyroplot.parallel(
rescale=True, color=compdata.Depth.values, cmap=cmap
)
divider = make_axes_locatable(ax)
cax = divider.append_axes('right', size='5%', pad=0.05)
plt.colorbar(sm, cax=cax, orientation='vertical')
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(sm, cax=cax, orientation="vertical")
plt.show()
3 changes: 2 additions & 1 deletion docs/source/gallery/examples/plotting/spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Spiderplots & Density Spiderplots
==================================
"""

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -265,7 +266,7 @@
unity_line=True,
index_order="incompatibility",
*args,
**kwargs
**kwargs,
)

plt.tight_layout()
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/plotting/stem.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
so (such that the sampling frequency along this axis is important, which is not
emphasised by a scatter plot).
"""

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/plotting/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
be used to create new plots, or add a template to an existing
:class:`matplotlib.axes.Axes`.
"""

import matplotlib.pyplot as plt

########################################################################################
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/plotting/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Ternary Plots
=============
"""

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/plotting/ternary_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
well with some of the plot templates (:mod:`pyrolite.plot.templates`) and
associated classifiers (:mod:`pyrolite.util.classification`).
"""

import numpy as np
import matplotlib.pyplot as plt

Expand Down
17 changes: 14 additions & 3 deletions docs/source/gallery/examples/util/TAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Some simple discrimination methods are implemented,
including the Total Alkali-Silica (TAS) classification.
"""

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -54,10 +55,20 @@

fig, ax = plt.subplots(1)

cm.add_to_axes(ax, alpha=0.5, linewidth=0.0, zorder=-2, add_labels=False,
which_ids=np.unique(df["TAS"]), fill=True, facecolor=[0.9, 0.8, 1.0])
cm.add_to_axes(
ax,
alpha=0.5,
linewidth=0.0,
zorder=-2,
add_labels=False,
which_ids=np.unique(df["TAS"]),
fill=True,
facecolor=[0.9, 0.8, 1.0],
)
cm.add_to_axes(ax, alpha=0.5, linewidth=0.5, zorder=-1, add_labels=True)
df[["SiO2", "Na2O + K2O"]].pyroplot.scatter(ax=ax, c=df["TAS"], alpha=0.7, axlabels=False)
df[["SiO2", "Na2O + K2O"]].pyroplot.scatter(
ax=ax, c=df["TAS"], alpha=0.7, axlabels=False
)

########################################################################################
# Variations of the Diagram
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/examples/util/manifold_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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
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 @@ -12,6 +12,7 @@
`The ICS International Chronostratigraphic Chart <https://stratigraphy.org/chart>`__.
Episodes 36, 199–204.
"""

########################################################################################
# First we'll create a timescale:
#
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/tutorials/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Making the Logo
==================================
"""

#######################################################################################
# Having some funky ellipses in a simplex inspired some interest when I put the logo
# together for pyrolite, so I put together a cleaned-up example of how you can create
Expand Down
8 changes: 7 additions & 1 deletion docs/source/gallery/tutorials/plot_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
(and also :mod:`mpltern` for ternary diagrams), you should also check out their
documentation pages for more in-depth guides, examples and API documentation.
"""

#######################################################################################
# First let's pull in a simple dataset to use throughout these examples:
#
Expand Down Expand Up @@ -209,6 +210,11 @@

ax = df[["CaO", "MgO", "Al2O3"]].pyroplot.scatter()
ax.set_ternary_lim(
0.1, 0.5, 0.2, 0.6, 0.3, 0.7 # tmin # tmax # lmin # lmax # rmin # rmax
0.1,
0.5,
0.2,
0.6,
0.3,
0.7, # tmin # tmax # lmin # lmax # rmin # rmax
)
plt.show()
1 change: 1 addition & 0 deletions docs/source/gallery/tutorials/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Add plot.templates file
"""

#######################################################################################
# First let's pull in a simple dataset to use throughout these examples:
#
Expand Down
1 change: 1 addition & 0 deletions docs/source/gallery/tutorials/ternary_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
irregualr triangulated grid and log transforms, and how this avoids some of the
potential issues of the methods mentioned above.
"""

#######################################################################################
# Let's first get some data to deal with. :mod:`mpltern` has a conventient dataset
# which we can use here:
Expand Down
1 change: 1 addition & 0 deletions pyrolite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ def load_extensions(base="pyrolite_", replace=["util"]):
n = n.replace(r, "")
setattr(extensions, n, m)


# _export_pyrolite_mplstyle() should be called in .plot import regardless
matplotlib.style.use("pyrolite")
Loading

0 comments on commit 4afa3eb

Please sign in to comment.