Source
return PyArray_New( &PyArray_Type, shape.nelements( ), (npy_intp*) shape.storage( ), NPY_UNICODE, nullptr, mem, non_zero(stringlen)*sizeof(uint32_t), NPY_ARRAY_OWNDATA | NPY_ARRAY_FARRAY, nullptr );
//# tablerow_cmpt.cc
//# Copyright (C) 2022
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
using std::function;
using casa::toRecord;
using casa::fromRecord;
using casacore::LogIO;
using casacore::LogOrigin;
using casacore::AipsError;
using casacore::TableRowProxy;
using casacore::Array;
using casacore::Record;
using casacore::Complex;
using casacore::DComplex;
using casacore::String;
static bool _tablerow_initialize_numpy( ) {
static bool initialized = false;
if ( initialized == false ) {
import_array();
initialized = true;
}
return initialized;
}
static bool numpy_initialized = _tablerow_initialize_numpy( );
inline size_t non_zero( size_t val ) {
return val <= 0 ? 5 : val;
}
namespace casac {
// constructor used by from python to construct a tablerow object
tablerow::tablerow( const casac::table *_table, const std::vector<std::string> &_columnnames, bool _exclude ) :
itsLog(new casacore::LogIO)
{
if ( ! _table ||
! _table->itsTable ||
! _table->itsTable->isReadable( ) ) throw AipsError( "invalid table passed for parameter one" );
itsTable = (table*) _table;
itsProxy = _table->itsTable;
itsRow.reset( new TableRowProxy( *itsProxy, static_cast<casacore::Vector<casacore::String>>(_columnnames), _exclude ) );
}
// constructor used by table class (in table_cmpt.cc) to return a
// tablerow for fetching one or more rows
tablerow::tablerow( table *tb, std::shared_ptr<casacore::TableProxy> myTable,
const std::vector<std::string> &columnnames, bool exclude ) :
itsLog(new casacore::LogIO), itsProxy(myTable), itsTable(tb)