Skip to content

Commit

Permalink
Update Test config, fix util.plot test
Browse files Browse the repository at this point in the history
  • Loading branch information
morganjwilliams committed Mar 24, 2019
1 parent 14b2be5 commit 97d3a0d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
test=pytest

[tool:pytest]
addopts = ./test/ --cov=pyrolite --cov-report html --cov-config .coveragerc --cov-report term-missing --ignore=draft
addopts = test --cov=pyrolite --cov-report html --cov-report term-missing --cov-config .coveragerc
python_files = *.py

[versioneer]
Expand Down
2 changes: 2 additions & 0 deletions test/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
python_files = *.py
23 changes: 12 additions & 11 deletions test/util/util_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,31 +208,32 @@ def tearDown(self):

class TestPlotStDevEllipses(unittest.TestCase):
def setUp(self):
self.comp2d = random_composition(size=100, D=2)

self.comp3d = random_composition(size=100, D=3)
self.T = ILRTransform()
self.comp2d = self.T.transform(self.comp3d)

def test_default(self):
for comp in [self.comp2d]:
with self.subTest(comp=comp):
plot_stdev_ellipses(comp)
plot_stdev_ellipses(comp, transform=self.T.inverse_transform)

def test_axis_specified(self):
for comp in [self.comp2d]:
with self.subTest(comp=comp):
fig, ax = plt.subplots()
plot_stdev_ellipses(comp, ax=ax)
fig, ax = plt.subplots(1)
plot_stdev_ellipses(comp, ax=ax, transform=self.T.inverse_transform)

def test_transform(self):
for tfm in [None, ILRTransform, ALRTransform]:
with self.subTest(tfm=tfm):
if callable(tfm):
T = tfm()
to = T.transform
comp = T.transform(self.comp3d)
transform = T.inverse_transform
comp = to(self.comp3d)
else:
comp = self.comp2d
transform = None
comp = self.comp2d

plot_stdev_ellipses(comp, transform=transform)

Expand All @@ -243,8 +244,9 @@ def tearDown(self):
@unittest.skipUnless(HAVE_SKLEARN, "Requires Scikit-learn")
class TestPlotPCAVectors(unittest.TestCase):
def setUp(self):
self.comp2d = random_composition(size=100, D=2)
self.comp3d = random_composition(size=100, D=3)
self.T = ILRTransform()
self.comp2d = self.T.transform(self.comp3d)

def test_default(self):
for comp in [self.comp2d, self.comp3d]:
Expand All @@ -262,12 +264,11 @@ def test_transform(self):
with self.subTest(tfm=tfm):
if callable(tfm):
T = tfm()
to = T.transform
comp = T.transform(self.comp3d)
transform = T.inverse_transform
comp = to(self.comp3d)
else:
comp = self.comp2d
transform = None
comp = self.comp2d

plot_pca_vectors(comp, transform=transform)

Expand Down

0 comments on commit 97d3a0d

Please sign in to comment.