Commit 93f9a3fe authored by Josef Brandt's avatar Josef Brandt

Improved tests

parent f47f09ed
......@@ -26,11 +26,11 @@ SET GEPARD TO EVALUATION BRANCH (WITHOUT THE TILING STUFF), OTHERWISE SOME OF TH
# save_results('results1.res', results)
results: TotalResults = load_results('results1.res')
results.update_all(force=True)
# save_results('results1.res', results)
save_results('results1.res', results)
plt.clf()
errorPerFraction: dict = results.get_error_vs_fraction_data(attributes=['air', 'water'],
methods=[])
methods=['chemo', 'random'])
# methods=['spiral', 'cross'])
plt.subplot(121)
for methodLabel in errorPerFraction.keys():
......@@ -47,7 +47,7 @@ plt.ylabel('mpCountError (%)', fontsize=12)
plt.legend()
errorPerFraction: dict = results.get_error_vs_fraction_data(attributes=['sediment', 'soil', 'beach', 'slush'],
methods=[])
methods=['chemo', 'random'])
plt.subplot(122)
for methodLabel in errorPerFraction.keys():
fractions: list = list(errorPerFraction[methodLabel].keys())
......
......@@ -53,7 +53,7 @@ class TestKennardStone(unittest.TestCase):
self.kennardStone: cmeth.KennardStone = cmeth.KennardStone(np.array([]), 0.1)
def test_get_sampled_indices(self):
numDataSets: int = 4000
numDataSets: int = 1000
self.kennardStone.data = np.random.rand(numDataSets, 2)
self.kennardStone.fraction = 0.1
selectedIndices = self.kennardStone.get_sampled_indices()
......
......@@ -13,8 +13,9 @@ import numpy as np
import gepard
from gepard.analysis.particleContainer import ParticleContainer
from gepard.analysis.particleAndMeasurement import Particle
from methods import RandomSampling, SizeBinFractioning
from methods import SubsamplingMethod, RandomSampling, SizeBinFractioning
import geometricMethods as gmeth
import chemometricMethods as cmeth
from helpers import ParticleBinSorter
......@@ -24,6 +25,24 @@ def get_default_particle_container(numParticles=1000):
return particleContainer
class TestAllMethodsGeneric(unittest.TestCase):
allMethodClasses : list = [RandomSampling, SizeBinFractioning,
gmeth.CrossBoxSubSampling, gmeth.SpiralBoxSubsampling,
cmeth.ChemometricSubsampling]
def setUp(self) -> None:
self.methods = []
for methClass in self.allMethodClasses:
self.methods.append(methClass(None, 0.1))
def test_basic_methods(self):
for method in self.methods:
method: SubsamplingMethod = method
label: str = method.label
self.assertEqual(type(label), str)
class TestRandomParticles(unittest.TestCase):
def test_get_number_of_random_particles(self):
randomSampling = RandomSampling(None, desiredFraction=0.1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment