Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Commit

Permalink
Bugfix: edge-case in slice; pybind11-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed May 30, 2018
1 parent b23f448 commit 3322746
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/cppmat/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
#include "pybind11_var_regular_vector.h"
#include "pybind11_var_symmetric_matrix.h"
#include "pybind11_var_diagonal_matrix.h"
#include "pybind11_var_periodic_array.h"
#include "pybind11_var_periodic_matrix.h"
#include "pybind11_var_periodic_vector.h"
#include "pybind11_var_cartesian_tensor4.h"
#include "pybind11_var_cartesian_tensor2.h"
#include "pybind11_var_cartesian_tensor2s.h"
Expand All @@ -32,9 +29,6 @@
#include "pybind11_fix_regular_vector.h"
#include "pybind11_fix_symmetric_matrix.h"
#include "pybind11_fix_diagonal_matrix.h"
#include "pybind11_fix_periodic_array.h"
#include "pybind11_fix_periodic_matrix.h"
#include "pybind11_fix_periodic_vector.h"
#include "pybind11_fix_cartesian_tensor4.h"
#include "pybind11_fix_cartesian_tensor2.h"
#include "pybind11_fix_cartesian_tensor2s.h"
Expand Down
4 changes: 4 additions & 0 deletions src/cppmat/var_regular_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,8 @@ array<X> array<X>::slice(
if ( D.size() > 1 and mRank > 3 ) shape.push_back(D.size());
if ( E.size() > 1 and mRank > 4 ) shape.push_back(E.size());
if ( F.size() > 1 and mRank > 5 ) shape.push_back(F.size());
// - correct for edge case
if ( shape.size() == 0 ) shape.push_back(1);

// contract
out.resize(shape);
Expand Down Expand Up @@ -2055,6 +2057,8 @@ array<X> array<X>::slice(
if ( D.size() > 1 and mRank > 3 ) shape.push_back(D.size());
if ( E.size() > 1 and mRank > 4 ) shape.push_back(E.size());
if ( F.size() > 1 and mRank > 5 ) shape.push_back(F.size());
// - correct for edge case
if ( shape.size() == 0 ) shape.push_back(1);

// contract
out.resize(shape);
Expand Down

0 comments on commit 3322746

Please sign in to comment.