Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
xerus
xerus
Commits
81952ee5
Commit
81952ee5
authored
Apr 09, 2020
by
Philipp Trunschke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve error messages
parent
8cddbe6e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
src/xerus/applications/uqAdf.cpp
src/xerus/applications/uqAdf.cpp
+4
-4
src/xerus/python/tensor.cpp
src/xerus/python/tensor.cpp
+6
-3
No files found.
src/xerus/applications/uqAdf.cpp
View file @
81952ee5
...
...
@@ -106,17 +106,17 @@ namespace xerus { namespace uq { namespace impl_uqRaAdf {
static
std
::
vector
<
std
::
vector
<
Tensor
>>
transpose_positions
(
const
TTTensor
&
_x
,
const
std
::
vector
<
std
::
vector
<
Tensor
>>&
_positions
,
const
std
::
vector
<
Tensor
>&
_solutions
)
{
REQUIRE
(
_positions
.
size
()
==
_solutions
.
size
(),
"Incompatible positions and solutions vector
"
);
REQUIRE
(
_positions
.
size
()
==
_solutions
.
size
(),
"Incompatible positions and solutions vector
: "
<<
_positions
.
size
()
<<
" vs "
<<
_solutions
.
size
()
);
for
(
size_t
sample
=
0
;
sample
<
_positions
.
size
();
++
sample
)
{
REQUIRE
(
_positions
[
sample
].
size
()
==
_x
.
order
()
-
1
,
"Invalid measurement"
);
REQUIRE
(
_positions
[
sample
].
size
()
==
_x
.
order
()
-
1
,
"Invalid measurement
: "
<<
_positions
[
sample
].
size
()
<<
" vs "
<<
_x
.
order
()
-
1
<<
" (at sample "
<<
sample
<<
")
"
);
}
std
::
vector
<
std
::
vector
<
Tensor
>>
positions
(
_x
.
order
());
for
(
size_t
corePosition
=
1
;
corePosition
<
_x
.
order
();
++
corePosition
)
{
positions
[
corePosition
].
reserve
(
_positions
.
size
());
for
(
size_t
sample
=
0
;
sample
<
_positions
.
size
();
++
sample
)
{
REQUIRE
(
_positions
[
sample
][
corePosition
-
1
].
dimensions
.
size
()
==
1
,
"Invalid measurement component"
);
REQUIRE
(
_positions
[
sample
][
corePosition
-
1
].
size
==
_x
.
dimensions
[
corePosition
],
"Invalid measurement component"
);
REQUIRE
(
_positions
[
sample
][
corePosition
-
1
].
dimensions
.
size
()
==
1
,
"Invalid measurement component
: len("
<<
_positions
[
sample
][
corePosition
-
1
].
dimensions
<<
") != 1 (at sample "
<<
sample
<<
" & position "
<<
corePosition
<<
")
"
);
REQUIRE
(
_positions
[
sample
][
corePosition
-
1
].
size
==
_x
.
dimensions
[
corePosition
],
"Invalid measurement component"
);
// << _positions[sample][corePosition-1].size == _x.dimensions[corePosition]);
positions
[
corePosition
].
push_back
(
_positions
[
sample
][
corePosition
-
1
]);
}
}
...
...
src/xerus/python/tensor.cpp
View file @
81952ee5
...
...
@@ -64,7 +64,9 @@ void expose_tensor(module& m) {
throw
std
::
runtime_error
(
"Incompatible format: expected a double array!"
);
}
if
(
info
.
itemsize
!=
sizeof
(
value_t
))
{
throw
std
::
runtime_error
(
"Incompatible size"
);
std
::
ostringstream
msg
;
msg
<<
"Incompatible size: "
<<
info
.
itemsize
<<
" (got) vs "
<<
sizeof
(
value_t
)
<<
" (expected)"
;
throw
std
::
runtime_error
(
msg
.
str
());
}
if
(
info
.
shape
.
size
()
==
1
and
info
.
shape
[
0
]
==
0
)
{
return
Tensor
({},
Tensor
::
Representation
::
Dense
,
Tensor
::
Initialisation
::
None
);
...
...
@@ -73,8 +75,9 @@ void expose_tensor(module& m) {
std
::
vector
<
size_t
>
dims
(
info
.
shape
.
begin
(),
info
.
shape
.
end
());
std
::
vector
<
size_t
>
strides
(
info
.
strides
.
begin
(),
info
.
strides
.
end
());
if
(
strides
!=
strides_from_dimensions_and_item_size
(
dims
,
info
.
itemsize
))
{
/* std::cerr << "Incompatible strides: " << strides << " (got) vs " << strides_from_dimensions_and_item_size(dims, info.itemsize) << " (expected)" << std::endl; */
throw
std
::
runtime_error
(
"Incompatible strides"
);
std
::
ostringstream
msg
;
msg
<<
"Incompatible strides: "
<<
strides
<<
" (got) vs "
<<
strides_from_dimensions_and_item_size
(
dims
,
info
.
itemsize
)
<<
" (expected). Make sure your buffer is C contiguous."
<<
std
::
endl
;
throw
std
::
runtime_error
(
msg
.
str
());
}
Tensor
result
(
dims
,
Tensor
::
Representation
::
Dense
,
Tensor
::
Initialisation
::
None
);
...
...
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