Scheduled maintenance on Monday 2019-06-24 between 10:00-11:00 CEST

Commit cab2176b authored by Simon Perkins's avatar Simon Perkins

just use py::objects and py::none

parent 1618af65
......@@ -634,22 +634,18 @@ template<typename T> class Helper
template<typename T> pyarr_c<complex<T>> vis2grid_c(
const Baselines<T> &baselines, const GridderConfig<T> &gconf,
const pyarr_c<uint32_t> &idx_, const pyarr_c<complex<T>> &vis_,
pyarr_c<complex<T>> * user_grid)
py::object user_grid)
checkArray(vis_, "vis", {0});
size_t nvis = size_t(vis_.shape(0));
size_t nu=gconf.Nu(), nv=gconf.Nv();
checkArray(idx_, "idx", {nvis});
printf("user_grid %p %d\n", user_grid, user_grid == nullptr);
{ checkArray(*user_grid, "user_grid", {nu, nv}); }
auto idx =;
auto res = user_grid ? makeArray<complex<T>>({nu, nv}) : *user_grid;
auto res = ! ? user_grid.cast<pyarr_c<complex<T>>>()
: makeArray<complex<T>>({nu, nv});
auto grid = res.mutable_data();
py::gil_scoped_release release;
......@@ -690,8 +686,7 @@ template<typename T> pyarr_c<T> vis2grid(const Baselines<T> &baselines,
const pyarr_c<complex<T>> &vis_)
return complex2hartley(vis2grid_c(baselines, gconf,
idx_, vis_,
static_cast<pyarr_c<std::complex<T>> *>(nullptr)));
idx_, vis_, py::none()));
template<typename T> pyarr_c<complex<T>> ms2grid_c(
import nifty_gridder as ng
import numpy as np
import pytest
from numpy.testing import assert_, assert_allclose
from numpy.testing import assert_, assert_allclose, assert_array_almost_equal
pmp = pytest.mark.parametrize
......@@ -62,12 +62,12 @@ def test_hoisted_grid_allocation(nxdirty, nydirty, nrow, nchan, epsilon):
vis = baselines.ms2vis(ms, idx)
user_grid = np.zeros((gconf.Nu(), gconf.Nv()),
grid = ng.vis2grid_c(baselines, gconf, idx, vis, user_grid=user_grid)
grid = ng.vis2grid_c(baselines, gconf, idx, vis, user_grid=None)
# Same base array under the hood
assert grid.base is user_grid.base
grid2 = ng.vis2grid_c(baselines, gconf, idx, vis, user_grid=user_grid)
ng.vis2grid_c(baselines, gconf, idx, vis, user_grid=None)
assert_array_almost_equal(grid, grid2)
assert id(grid2) == id(user_grid)
def test_pickling():
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment