Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
1636981a
Commit
1636981a
authored
6 years ago
by
Roman Tolchenov
Browse files
Options
Downloads
Patches
Plain Diff
Allow loading of logs after duplicate detected
Re #22963.
parent
03a2bf32
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/DataHandling/src/LoadLog.cpp
+20
-12
20 additions, 12 deletions
Framework/DataHandling/src/LoadLog.cpp
Framework/DataHandling/test/LoadLogTest.h
+39
-6
39 additions, 6 deletions
Framework/DataHandling/test/LoadLogTest.h
with
59 additions
and
18 deletions
Framework/DataHandling/src/LoadLog.cpp
+
20
−
12
View file @
1636981a
...
...
@@ -39,6 +39,24 @@ using API::WorkspaceProperty;
using
DataObjects
::
Workspace2D_sptr
;
using
Types
::
Core
::
DateAndTime
;
namespace
{
template
<
class
MapClass
,
class
LoggerType
>
void
addLogDataToRun
(
Mantid
::
API
::
Run
&
run
,
MapClass
&
aMap
,
LoggerType
&
logger
)
{
for
(
auto
&
itr
:
aMap
)
{
try
{
run
.
addLogData
(
itr
.
second
.
release
());
}
catch
(
std
::
invalid_argument
&
e
)
{
logger
.
warning
()
<<
e
.
what
()
<<
'\n'
;
}
catch
(
Exception
::
ExistsError
&
e
)
{
logger
.
warning
()
<<
e
.
what
()
<<
'\n'
;
}
}
}
}
// namespace
/// Empty default constructor
LoadLog
::
LoadLog
()
{}
...
...
@@ -288,18 +306,8 @@ void LoadLog::loadThreeColumnLogFile(std::ifstream &logFileStream,
}
}
}
try
{
for
(
auto
&
itr
:
dMap
)
{
run
.
addLogData
(
itr
.
second
.
release
());
}
for
(
auto
&
sitr
:
sMap
)
{
run
.
addLogData
(
sitr
.
second
.
release
());
}
}
catch
(
std
::
invalid_argument
&
e
)
{
g_log
.
warning
()
<<
e
.
what
();
}
catch
(
Exception
::
ExistsError
&
e
)
{
g_log
.
warning
()
<<
e
.
what
();
}
addLogDataToRun
(
run
,
dMap
,
g_log
);
addLogDataToRun
(
run
,
sMap
,
g_log
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Framework/DataHandling/test/LoadLogTest.h
+
39
−
6
View file @
1636981a
...
...
@@ -3,23 +3,25 @@
#include
<cxxtest/TestSuite.h>
#include
"MantidDataHandling/LoadLog.h"
#include
"MantidAPI/WorkspaceFactory.h"
#include
"MantidGeometry/Instrument.h"
#include
"MantidDataObjects/Workspace2D.h"
#include
"MantidAPI/Algorithm.h"
#include
"MantidAPI/AnalysisDataService.h"
#include
"MantidKernel/Exception.h"
#include
"MantidAPI/FrameworkManager.h"
#include
"MantidAPI/Workspace.h"
#include
"MantidAPI/Algorithm.h"
#include
"MantidAPI/WorkspaceFactory.h"
#include
"MantidDataHandling/LoadLog.h"
#include
"MantidDataObjects/Workspace2D.h"
#include
"MantidGeometry/Instrument.h"
#include
"MantidGeometry/Instrument/Component.h"
#include
"MantidKernel/Exception.h"
#include
"MantidKernel/TimeSeriesProperty.h"
#include
"MantidTestHelpers/ScopedFileHelper.h"
#include
<vector>
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
Kernel
;
using
namespace
Mantid
::
DataHandling
;
using
namespace
Mantid
::
DataObjects
;
using
namespace
ScopedFileHelper
;
using
Mantid
::
Types
::
Core
::
DateAndTime
;
class
LoadLogTest
:
public
CxxTest
::
TestSuite
{
...
...
@@ -135,6 +137,37 @@ public:
AnalysisDataService
::
Instance
().
remove
(
outputSpace
);
}
void
test_log_file_has_error
()
{
std
::
string
logFileText
(
"2007-11-16T13:25:48 i1 0
\n
"
"2007-11-16T13:29:36 str1 a
\n
"
"2007-11-16T13:29:49 i2 1
\n
"
"2007-11-16T13:30:21 str2 b
\n
"
"2007-11-16T13:32:38 num1 3
\n
"
"2007-11-16T13:43:40 nspectra 12
\n
"
"2007-11-16T13:44:33 num2 4
\n
"
"2007-11-16T14:00:21 str3 c
\n
"
);
ScopedFile
file
(
logFileText
,
"test_log_file.log"
);
MatrixWorkspace_sptr
ws
=
WorkspaceFactory
::
Instance
().
create
(
"Workspace2D"
,
1
,
1
,
1
);
ws
->
mutableRun
().
addProperty
(
"nspectra"
,
1
);
// "nspectra" is already in the logs when LoadLog runs
LoadLog
alg
;
alg
.
initialize
();
alg
.
setPropertyValue
(
"Filename"
,
file
.
getFileName
());
alg
.
setProperty
(
"Workspace"
,
ws
);
alg
.
execute
();
auto
props
=
ws
->
run
().
getProperties
();
TS_ASSERT_EQUALS
(
props
.
size
(),
8
);
TS_ASSERT
(
ws
->
run
().
hasProperty
(
"nspectra"
));
TS_ASSERT
(
ws
->
run
().
hasProperty
(
"i1"
));
TS_ASSERT
(
ws
->
run
().
hasProperty
(
"i2"
));
TS_ASSERT
(
ws
->
run
().
hasProperty
(
"num1"
));
TS_ASSERT
(
ws
->
run
().
hasProperty
(
"num2"
));
TS_ASSERT
(
ws
->
run
().
hasProperty
(
"str1"
));
TS_ASSERT
(
ws
->
run
().
hasProperty
(
"str2"
));
TS_ASSERT
(
ws
->
run
().
hasProperty
(
"str3"
));
}
void
do_test_SNSTextFile
(
std
::
string
names
,
std
::
string
units
,
bool
willFail
,
bool
createWorkspace
=
true
,
std
::
string
expectedLastUnit
=
"Furlongs"
)
{
...
...
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