Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Eisgenerator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Klemm, Carl Philipp
Eisgenerator
Commits
1f031eec
Commit
1f031eec
authored
2 years ago
by
Carl Philipp Klemm
Browse files
Options
Downloads
Patches
Plain Diff
improve fvalueEq
add test case for deduplication
parent
c933b28f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
basicmath.cpp
+5
-4
5 additions, 4 deletions
basicmath.cpp
eisgenerator/basicmath.h
+1
-1
1 addition, 1 deletion
eisgenerator/basicmath.h
test.cpp
+21
-0
21 additions, 0 deletions
test.cpp
with
27 additions
and
5 deletions
basicmath.cpp
+
5
−
4
View file @
1f031eec
#include
"basicmath.h"
#include
"basicmath.h"
#include
<algorithm>
#include
<algorithm>
#include
<random>
#include
<random>
#include
<limits>
#include
"eistype.h"
#include
"eistype.h"
...
@@ -213,15 +214,15 @@ void eis::removeDuplicates(std::vector<eis::DataPoint>& data)
...
@@ -213,15 +214,15 @@ void eis::removeDuplicates(std::vector<eis::DataPoint>& data)
std
::
sort
(
data
.
begin
(),
data
.
end
());
std
::
sort
(
data
.
begin
(),
data
.
end
());
std
::
vector
<
eis
::
DataPoint
>::
iterator
it
=
data
.
begin
();
std
::
vector
<
eis
::
DataPoint
>::
iterator
it
=
data
.
begin
();
while
((
it
=
std
::
adjacent_find
(
data
.
begin
(),
data
.
end
()))
!=
data
.
end
())
while
((
it
=
std
::
adjacent_find
(
data
.
begin
(),
data
.
end
(),
[](
const
eis
::
DataPoint
&
a
,
const
eis
::
DataPoint
&
b
){
return
fvalueEq
(
a
.
omega
,
b
.
omega
);}))
!=
data
.
end
())
{
{
std
::
cout
<<
"erase
\n
"
;
data
.
erase
(
it
);
data
.
erase
(
it
);
}
}
}
}
bool
eis
::
fvalueEq
(
fvalue
a
,
fvalue
b
,
fvalue
epsilon
)
bool
eis
::
fvalueEq
(
fvalue
a
,
fvalue
b
,
unsigned
int
ulp
)
{
{
fvalue
epsilon
=
std
::
numeric_limits
<
fvalue
>::
epsilon
()
*
std
::
fabs
(
a
+
b
)
*
ulp
;
return
a
-
epsilon
<
b
&&
a
+
epsilon
>
b
;
return
a
-
epsilon
<
b
&&
a
+
epsilon
>
b
;
}
}
This diff is collapsed.
Click to expand it.
eisgenerator/basicmath.h
+
1
−
1
View file @
1f031eec
...
@@ -18,6 +18,6 @@ namespace eis
...
@@ -18,6 +18,6 @@ namespace eis
fvalue
maximumNyquistJump
(
const
std
::
vector
<
eis
::
DataPoint
>&
data
);
fvalue
maximumNyquistJump
(
const
std
::
vector
<
eis
::
DataPoint
>&
data
);
void
noise
(
std
::
vector
<
eis
::
DataPoint
>&
data
,
double
amplitude
,
bool
relative
);
void
noise
(
std
::
vector
<
eis
::
DataPoint
>&
data
,
double
amplitude
,
bool
relative
);
void
removeDuplicates
(
std
::
vector
<
eis
::
DataPoint
>&
data
);
void
removeDuplicates
(
std
::
vector
<
eis
::
DataPoint
>&
data
);
bool
fvalueEq
(
fvalue
a
,
fvalue
b
,
fvalue
epsilon
=
0.001
);
bool
fvalueEq
(
fvalue
a
,
fvalue
b
,
unsigned
int
ulp
=
4
);
}
}
This diff is collapsed.
Click to expand it.
test.cpp
+
21
−
0
View file @
1f031eec
...
@@ -334,6 +334,24 @@ static bool testEisNyquistDistance()
...
@@ -334,6 +334,24 @@ static bool testEisNyquistDistance()
}
}
}
}
static
bool
testLoadDeduplication
()
{
const
std
::
filesystem
::
path
filePath
(
"./relaxis_rp-rp_0.csv"
);
eis
::
EisSpectra
spectra
(
filePath
);
if
(
spectra
.
data
.
empty
())
{
eis
::
Log
(
eis
::
Log
::
INFO
)
<<
__func__
<<
" Unable to load "
<<
filePath
<<
" skiping test"
;
return
true
;
}
if
(
eis
::
fvalueEq
(
spectra
.
data
[
spectra
.
data
.
size
()
-
1
].
omega
,
spectra
.
data
[
spectra
.
data
.
size
()
-
2
].
omega
+
2
))
{
eis
::
Log
(
eis
::
Log
::
ERROR
)
<<
__func__
<<
" deduplication failed"
;
return
false
;
}
return
true
;
}
static
bool
testTranslators
()
static
bool
testTranslators
()
{
{
const
std
::
string
boukamp
(
"R(RP)"
);
const
std
::
string
boukamp
(
"R(RP)"
);
...
@@ -383,6 +401,9 @@ int main(int argc, char** argv)
...
@@ -383,6 +401,9 @@ int main(int argc, char** argv)
if
(
!
modelConsistancy
())
if
(
!
modelConsistancy
())
return
2
;
return
2
;
if
(
!
testLoadDeduplication
())
return
3
;
if
(
!
runRescale
())
if
(
!
runRescale
())
return
3
;
return
3
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment