Skip to content

Commit b9d05d7

Browse files
Merge branch 'release/0.3.2' into main
2 parents ff907cc + ba2e2dd commit b9d05d7

File tree

33 files changed

+955
-240
lines changed

33 files changed

+955
-240
lines changed

.github/workflows/unittest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
name: Unit Tests
1515
runs-on: ${{ matrix.os }}
1616
strategy:
17+
fail-fast: false
1718
matrix:
1819
os: [ubuntu-latest, windows-latest, macos-latest]
1920
python-version: [3.7, 3.8, 3.9]

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ recursive-include pyrolite/data/mineral *
77
recursive-include pyrolite/data/models *
88
recursive-include pyrolite/data/radii *
99
recursive-include pyrolite/data/timescale *
10+
recursive-include pyrolite/data/testing *
1011
recursive-include pyrolite/data/_config *
1112
# global-exclude __pycache__

binder/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ dependencies:
1111
- scipy>=1.2
1212
- pandas>=0.23
1313
- pip:
14-
- -e git+git://github.com/morganjwilliams/pyrolite.git@develop#egg=pyrolite[dev,skl]
14+
- -e git+https://github.com/morganjwilliams/pyrolite.git@develop#egg=pyrolite[dev,skl]

docs/source/dev/changelog.rst

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,41 @@ All notable changes to this project will be documented here.
88

99
.. note:: Changes noted in this subsection are to be released in the next version.
1010
If you're keen to check something out before its released, you can use a
11-
`development install <development.html#development-installation>`__.
11+
`development install <development.html#development-installation>`__ .
12+
13+
`0.3.2`_
14+
--------------
15+
16+
* **New Contributor**: `Angela Rodrigues <https://github.com/AngRodrigues>`__
17+
* **Bugfix**: Edited docstrings and added ignore-warning for :mod:`numpydoc` warnings.
18+
* **Bugfix**: Updated installation instructions and Binder configuration to use
19+
secure protocols when installing via `git` (i.e. https://)
20+
* **Bugfix**: Update CI builds so that tests can be run on MacOS.
21+
22+
:mod:`pyrolite.mineral`
23+
~~~~~~~~~~~~~~~~~~~~~~~~~
24+
25+
* **Feature**: Added a TAS-based iron correction following Middlemost (1989).
26+
* **Bugfix**: Fixed some errors in mineral formulae and handling leading to
27+
inaccurate outputs from CIPW Norm.
28+
* Split out volcanic from intrusive samples in the CIPW Norm volcanic rock comparison.
29+
* Added SINCLAS abbreviations to the mineral dictionary associated with the CIPW
30+
Norm, so alternate mineral naming systems can be compared.
31+
32+
:mod:`pyrolite.util`
33+
~~~~~~~~~~~~~~~~~~~~~~~
34+
* **PR Merged**: `Louise Schoneveld <https://github.com/lavender22>`__ submitted
35+
a pull request to add bivariate and ternary classifier models for spinel
36+
compositions (:class:`~pyrolite.util.classification.SpinelFeBivariate`,
37+
:class:`~pyrolite.util.classification.SpinelTrivalentTernary`).
38+
* **PR Merged**: `Angela Rodrigues <https://github.com/AngRodrigues>`__ submitted
39+
a pull request to add the Jensen ternary cation classifier model for subalkalic
40+
volcanic rocks (:class:`~pyrolite.util.classification.JensenPlot`,
41+
:class:`~pyrolite.util.classification.JensenPlot`).
42+
* Updated :func:`pyrolite.util.skl.vis.plot_confusion_matrix` to be able to plot on
43+
existing axes, use an explicit class order and use rotation for e.g. long
44+
x-axis class label names.
45+
* Updated references to :func:`scipy.stats.gaussian_kde` after namespace deprecation.
1246

1347
`0.3.1`_
1448
--------------
@@ -21,7 +55,7 @@ All notable changes to this project will be documented here.
2155
Python 3.4). This will fix an issue blocking setting up a `conda-forge`
2256
recipe (`#51 <https://github.com/morganjwilliams/pyrolite/issues/51>`__).
2357
* Updated instances of redundant :mod:`numpy` types throughout to silence
24-
depreciation warnings (using base types :class:`float`, :class:`int` except
58+
deprecation warnings (using base types :class:`float`, :class:`int` except
2559
where specific :mod:`numpy` types are required).
2660
* Added a minimum :mod:`sympy` version requirement (v1.7) to avoid potential import
2761
errors.
@@ -192,7 +226,7 @@ All notable changes to this project will be documented here.
192226
argument.
193227
* Updated automated pyrolite :mod:`matplotlib` style export to be more reliable.
194228
* Changed the default shading for :func:`~pyrolite.plot.pyroplot.density` to suppress
195-
error about upcoming :mod:`matplotlib` depreciation.
229+
error about upcoming :mod:`matplotlib` deprecation.
196230
* Ordering for contours, contour names and contour styles is now preserved for
197231
:func:`~pyrolite.plot.density.density` and related functions.
198232
* Updated :mod:`pyrolite.plot.templates.pearce` to use ratios from
@@ -1255,7 +1289,8 @@ All notable changes to this project will be documented here.
12551289
`GitHub <https://github.com/morganjwilliams/pyrolite/releases>`__ for reference,
12561290
but were :code:`alpha` versions which were never considered stable.
12571291

1258-
.. _Development: https://github.com/morganjwilliams/pyrolite/compare/0.3.1...develop
1292+
.. _Development: https://github.com/morganjwilliams/pyrolite/compare/0.3.2...develop
1293+
.. _0.3.2: https://github.com/morganjwilliams/pyrolite/compare/0.3.1...0.3.2
12591294
.. _0.3.1: https://github.com/morganjwilliams/pyrolite/compare/0.3.0...0.3.1
12601295
.. _0.3.0: https://github.com/morganjwilliams/pyrolite/compare/0.2.8...0.3.0
12611296
.. _0.2.8: https://github.com/morganjwilliams/pyrolite/compare/0.2.7...0.2.8

docs/source/dev/contributors.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ comments, testing, bug reports, or feature requests.
1717
* `Nicolas Piette-Lauziere <https://github.com/NicolasPietteLauziere>`__
1818
* `Chetan Nathwani <https://github.com/ChetanNathwani>`__
1919
* `Martin Bentley <https://github.com/mtb-za>`__
20+
* `Tom Buckle <https://github.com/bomtuckle>`__
21+
* `Angela Rodrigues <https://github.com/AngRodrigues>`__

docs/source/dev/development.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ via pip directly from GitHub:
2525

2626
.. code-block:: bash
2727
28-
pip install --user git+git://github.com/morganjwilliams/pyrolite.git@develop#egg=pyrolite
28+
pip install --user git+https://github.com/morganjwilliams/pyrolite.git@develop#egg=pyrolite
2929
3030
3131
Tests

docs/source/gallery/examples/geochem/CIPW.py

Lines changed: 82 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,32 @@
6868
# The function accepts a few keyword arguments, all to do with the iron compositions
6969
# and related adjustment/corrections:
7070
#
71-
# :code:`Fe_correction = <callable>`
72-
# For specifying the Fe-correction method/function. Currently only Le LeMaitre's
73-
# correction method is implemented [LeMaitre1976]_ .
71+
# :code:`Fe_correction = "LeMaitre" | "Middlemost"`
72+
# For specifying the Fe-correction method/function. Currently includes LeMaitre's
73+
# correction method [LeMaitre1976]_ (the default) and Middlemost's TAS-based
74+
# correction [Middlemost1989]_ .
7475
#
7576
# :code:`Fe_correction_mode = 'volcanic'`
76-
# For specificying the Fe-correction mode where relevant
77+
# For specificying the Fe-correction mode, for LeMaitre's correction.
7778
#
7879
# :code:`adjust_all_Fe = False`
7980
# Specifying whether you want to adjust all iron compositions, or only those
8081
# which are partially specified (i.e. only have a singular value for one of
8182
# FeO, Fe2O3, FeOT, Fe2O3T).
8283
#
84+
NORM = CIPW_norm(df.pyrochem.compositional, Fe_correction="Middlemost")
85+
########################################################################################
8386
# For the purpose of establishing the congruency of our algorithm with Verma's,
84-
# we'll use :code:`adjust_all_Fe = True`. Notably, this won't make too much
85-
# difference to the format of the output, but it will adjust the estimates of
86-
# normative mineralogy depending on oxidation state.
87+
# we'll use :code:`adjust_all_Fe = True` and LeMaitre's correction. Notably, this
88+
# won't make too much difference to the format of the output, but it will adjust
89+
# the estimates of normative mineralogy depending on oxidation state.
8790
#
88-
NORM = CIPW_norm(df.pyrochem.compositional, adjust_all_Fe=True)
91+
NORM = CIPW_norm(
92+
df.pyrochem.compositional,
93+
adjust_all_Fe=True,
94+
Fe_correction="LeMaitre",
95+
Fe_correction_mode="volcanic",
96+
)
8997
########################################################################################
9098
# Now we have the normative mineralogical outputs, we can have a look to see how
9199
# these compare to some relevant geochemical inputs:
@@ -132,36 +140,70 @@
132140
k: v for (k, v) in translation.items() if (df[v] > 0).sum() and (NORM[k] > 0).sum()
133141
}
134142
########################################################################################
135-
import matplotlib.pyplot as plt
143+
# To compare SINCLAS and the :mod:`pyrolite` NORM outputs, we'll construct a grid
144+
# of plots which compare the respective mineralogical norms relative to a 1:1 line,
145+
# and highlight discrepancies. As we'll do it twice below (once for samples labelled as
146+
# volanic, and once for everything else), we may as well make a function of it.
147+
#
148+
# After that, let's take a look at the volcanic samples in isolation, which are the
149+
# the key samples for which the NORM should be applied:
150+
#
136151
from pyrolite.plot.color import process_color
137152

138-
ncols = 4
139-
nrows = len(minerals.keys()) // ncols + 1 if len(minerals.keys()) % ncols else 0
140153

141-
fig, ax = plt.subplots(
142-
nrows,
143-
ncols,
144-
figsize=(ncols * 2.5, nrows * 2),
145-
)
146-
fig.suptitle("Comparing pyrolite's CIPW Norm to SINCLAS/IgRoCS", fontsize=16)
147-
ax = ax.flat
148-
149-
for ix, (b, a) in enumerate(minerals.items()):
150-
ax[ix].set_title("\n".join(b.split()), y=0.9, va="top")
151-
if a in df.columns and b in NORM.columns:
152-
c = process_color(
153-
np.abs((df[a] / NORM[b]) - 1),
154-
cmap="RdBu_r",
155-
norm=plt.Normalize(vmin=0, vmax=0.1),
156-
)["c"]
157-
ax[ix].scatter(df[a], NORM[b], c=c)
158-
ax[ix].plot([0, df[a].max()], [0, df[a].max()], color="k", ls="--")
159-
160-
for a in ax:
161-
a.set(xticks=[], yticks=[]) # turn off the ticks
162-
if not a.collections: # turn off the axis for empty axes
163-
a.axis("off")
164-
plt.tight_layout()
154+
def compare_NORMs(SINCLAS_outputs, NORM_outputs, name=""):
155+
"""
156+
Create a grid of axes comparing the outputs of SINCLAS and `pyrolite`'s NORM,
157+
after translating the column names to the appropriate form.
158+
"""
159+
ncols = 4
160+
nrows = len(minerals.keys()) // ncols + 1 if len(minerals.keys()) % ncols else 0
161+
162+
fig, ax = plt.subplots(nrows, ncols, figsize=(ncols * 2.5, nrows * 2))
163+
fig.suptitle(
164+
" - ".join(
165+
["Comparing pyrolite's CIPW Norm to SINCLAS/IgRoCS"] + [name]
166+
if name
167+
else []
168+
),
169+
fontsize=16,
170+
y=1.01,
171+
)
172+
ax = ax.flat
173+
for ix, (b, a) in enumerate(minerals.items()):
174+
ax[ix].set_title("\n".join(b.split()), y=0.9, va="top")
175+
if a in SINCLAS_outputs.columns and b in NORM_outputs.columns:
176+
# colour by deviation from unity
177+
c = process_color(
178+
np.abs((SINCLAS_outputs[a] / NORM_outputs[b]) - 1),
179+
cmap="RdBu_r",
180+
norm=plt.Normalize(vmin=0, vmax=0.1),
181+
)["c"]
182+
ax[ix].scatter(SINCLAS_outputs[a], NORM_outputs[b], c=c)
183+
# add a 1:1 line
184+
ax[ix].plot(
185+
[0, SINCLAS_outputs[a].max()],
186+
[0, SINCLAS_outputs[a].max()],
187+
color="k",
188+
ls="--",
189+
)
190+
191+
for a in ax:
192+
a.set(xticks=[], yticks=[]) # turn off the ticks
193+
if not a.collections: # turn off the axis for empty axes
194+
a.axis("off")
195+
return fig, ax
196+
197+
198+
volcanic_filter = df.loc[:, "ROCK_TYPE"].str.lower().str.startswith("volc")
199+
fig, ax = compare_NORMs(df.loc[volcanic_filter, :], NORM.loc[volcanic_filter])
200+
201+
202+
########################################################################################
203+
# And everything else:
204+
#
205+
fig, ax = compare_NORMs(df.loc[~volcanic_filter, :], NORM.loc[~volcanic_filter])
206+
plt.show()
165207
########################################################################################
166208
# These normative mineralogical components could be input into mineralogical
167209
# classifiers, as mentioned above. For example, the IUGS QAP classifier:
@@ -219,3 +261,8 @@
219261
# Contributions to Mineralogy and Petrology 56, no. 2 (1 January 1976): 181–89.
220262
# `doi: doi.org/10.1007/BF00399603 <https://doi.org/10.1007/BF00399603>`__
221263
#
264+
# .. [Middlemost1989] Middlemost, Eric A. K. (1989). Iron Oxidation Ratios,
265+
# Norms and the Classification of Volcanic Rocks.
266+
# Chemical Geology 77, 1: 19–26.
267+
# `doi: doi.org/10.1016/0009-2541(89)90011-9. <https://doi.org/10.1016/0009-2541(89)90011-9.>`__
268+
#

docs/source/gallery/examples/geochem/convert_chemistry.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
:func:`~pyrolite.geochem.transform.convert_chemistry` function. Note that by default
88
pyrolite assumes that data are in the same units.
99
"""
10-
import pyrolite.geochem
1110
import pandas as pd
1211

13-
pd.set_option("precision", 3) # smaller outputs
12+
import pyrolite.geochem
13+
14+
pd.set_option("display.precision", 3) # smaller outputs
1415
########################################################################################
1516
# Here we create some synthetic data to work with, which has some variables in Wt% and
1617
# some in ppm. Notably some elements are present in more than one column (Ca, Na):

docs/source/gallery/examples/geochem/indexes_selectors.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
==================================
44
55
"""
6-
import pyrolite.geochem
76
import pandas as pd
87

9-
pd.set_option("precision", 3) # smaller outputs
8+
import pyrolite.geochem
9+
10+
pd.set_option("display.precision", 3) # smaller outputs
1011
########################################################################################
1112
from pyrolite.util.synthetic import normal_frame
1213

@@ -73,7 +74,7 @@
7374
########################################################################################
7475
# All elements (up to U):
7576
#
76-
from pyrolite.geochem.ind import common_elements, common_oxides, REE, REY
77+
from pyrolite.geochem.ind import REE, REY, common_elements, common_oxides
7778

7879
common_elements() # string return
7980

docs/source/gallery/examples/geochem/mineral_mindb.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@
66
compositions.
77
"""
88
import pandas as pd
9-
from pyrolite.mineral.mindb import (
10-
list_groups,
11-
list_minerals,
12-
list_formulae,
13-
get_mineral,
14-
get_mineral_group,
15-
)
169

17-
pd.set_option("precision", 3) # smaller outputs
10+
from pyrolite.mineral.mindb import (get_mineral, get_mineral_group,
11+
list_formulae, list_groups, list_minerals)
12+
13+
pd.set_option("display.precision", 3) # smaller outputs
1814
########################################################################################
1915
# From the database, you can get the list of its contents using a few utility
2016
# functions:

0 commit comments

Comments
 (0)