Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Josef Brandt
Subsampling
Commits
93f9a3fe
Commit
93f9a3fe
authored
Mar 20, 2020
by
Josef Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved tests
parent
f47f09ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
+24
-5
subsampling.py
subsampling.py
+3
-3
tests/test_chemometricMethods.py
tests/test_chemometricMethods.py
+1
-1
tests/test_methods.py
tests/test_methods.py
+20
-1
No files found.
subsampling.py
View file @
93f9a3fe
...
...
@@ -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
())
...
...
tests/test_chemometricMethods.py
View file @
93f9a3fe
...
...
@@ -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
=
4
000
numDataSets
:
int
=
1
000
self
.
kennardStone
.
data
=
np
.
random
.
rand
(
numDataSets
,
2
)
self
.
kennardStone
.
fraction
=
0.1
selectedIndices
=
self
.
kennardStone
.
get_sampled_indices
()
...
...
tests/test_methods.py
View file @
93f9a3fe
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment