Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
e3e61527
Commit
e3e61527
authored
Aug 03, 2021
by
Gemma Guest
Browse files
Set properties by correct type
parent
18ac15a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Framework/PythonInterface/mantid/api/src/Exports/Algorithm.cpp
View file @
e3e61527
...
...
@@ -97,6 +97,15 @@ template <typename T> void extractKwargs(const dict &kwargs, const std::string &
}
}
template
<
typename
T
>
boost
::
optional
<
T
>
extractObject
(
const
object
&
obj
)
{
boost
::
python
::
extract
<
T
>
extractor
(
obj
);
if
(
extractor
.
check
())
return
boost
::
optional
<
T
>
(
extractor
);
else
return
boost
::
none
;
}
// Signature createChildWithProps(self, name, startProgress, endProgress, enableLogging, version, **kwargs)
object
createChildWithProps
(
tuple
args
,
dict
kwargs
)
{
std
::
shared_ptr
<
Algorithm
>
parentAlg
=
extract
<
std
::
shared_ptr
<
Algorithm
>>
(
args
[
0
]);
...
...
@@ -129,14 +138,19 @@ object createChildWithProps(tuple args, dict kwargs) {
continue
;
object
curArg
=
kwargs
[
keys
[
i
]];
if
(
curArg
)
{
// Rather than trying to figure out which type were getting from Python
// we will "ab"use setPropertyValue to simply use strings. This currently
// doesn't handle lists, but this could be retrofitted in future work
std
::
string
propValue
=
extract
<
std
::
string
>
(
curArg
);
childAlg
->
setPropertyValue
(
propName
,
propValue
);
}
if
(
!
curArg
)
continue
;
if
(
auto
val
=
extractObject
<
bool
>
(
curArg
))
childAlg
->
setProperty
(
propName
,
val
);
if
(
auto
val
=
extractObject
<
float
>
(
curArg
))
childAlg
->
setProperty
(
propName
,
val
);
if
(
auto
val
=
extractObject
<
int
>
(
curArg
))
childAlg
->
setProperty
(
propName
,
val
);
// This currently doesn't handle lists, but this could be retrofitted in future work
std
::
string
propValue
=
extract
<
std
::
string
>
(
curArg
);
childAlg
->
setPropertyValue
(
propName
,
propValue
);
}
return
object
(
childAlg
);
}
...
...
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