Skip to content

Commit 677a0be

Browse files
committed
MNT: improve argument conversion in setPairMask
Avoid round-about conversion of numpy.int scalars.
1 parent 374ab55 commit 677a0be

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/extensions/wrap_PairQuantity.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#include "srreal_converters.hpp"
4141
#include "srreal_pickling.hpp"
42+
#include "srreal_validators.hpp"
4243

4344
#include <diffpy/srreal/PairQuantity.hpp>
4445

@@ -488,13 +489,13 @@ void set_pair_mask(PairQuantity& obj,
488489
python::object others)
489490
{
490491
if (!others.is_none()) mask_all_pairs(obj, others);
491-
python::extract<int> geti(i);
492-
python::extract<int> getj(j);
493492
bool mask = msk;
494-
// short circuit for normal call
495-
if (geti.check() && getj.check())
493+
// short circuit for normal call with scalar values
494+
if (!isiterable(i) && !isiterable(j))
496495
{
497-
obj.setPairMask(geti(), getj(), mask);
496+
const int i1 = extractint(i);
497+
const int j1 = extractint(j);
498+
obj.setPairMask(i1, j1, mask);
498499
return;
499500
}
500501
std::vector<int> iindices = parsepairindex(i);

0 commit comments

Comments
 (0)