lsst.afw  13.0-98-g5a654715e+2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
schemaMapper.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008-2017 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #include "pybind11/pybind11.h"
24 #include "pybind11/stl.h"
25 
26 #include "lsst/afw/table/Field.h"
27 #include "lsst/afw/table/Key.h"
28 #include "lsst/afw/table/Schema.h"
31 
32 namespace py = pybind11;
33 using namespace pybind11::literals;
34 
35 namespace lsst {
36 namespace afw {
37 namespace table {
38 namespace {
39 
40 using PySchemaMapper = py::class_<SchemaMapper, std::shared_ptr<SchemaMapper>>;
41 
42 template <typename T>
43 void declareSchemaMapperOverloads(PySchemaMapper &cls, std::string const &suffix) {
44  cls.def("getMapping", (Key<T> (SchemaMapper::*)(Key<T> const &) const) & SchemaMapper::getMapping);
45 };
46 
47 PYBIND11_PLUGIN(schemaMapper) {
48  py::module mod("schemaMapper");
49  py::module::import("lsst.afw.table.schema");
50 
51  PySchemaMapper cls(mod, "SchemaMapper");
52 
53  cls.def(py::init<>());
54  cls.def(py::init<Schema const &, Schema const &>());
55  cls.def(py::init<Schema const &, bool>(), "input"_a, "shareAliasMap"_a = false);
56 
57  cls.def("getInputSchema", &SchemaMapper::getInputSchema);
58  cls.def("getOutputSchema", &SchemaMapper::getOutputSchema);
59  cls.def("editOutputSchema", &SchemaMapper::editOutputSchema, py::return_value_policy::reference_internal);
60  cls.def("addMinimalSchema", &SchemaMapper::addMinimalSchema, "minimal"_a, "doMap"_a = true);
61  cls.def_static("removeMinimalSchema", &SchemaMapper::removeMinimalSchema);
62  cls.def_static("join", &SchemaMapper::join, "inputs"_a, "prefixes"_a = std::vector<std::string>());
63  declareSchemaMapperOverloads<std::uint16_t>(cls, "U");
64  declareSchemaMapperOverloads<std::int32_t>(cls, "I");
65  declareSchemaMapperOverloads<std::int64_t>(cls, "L");
66  declareSchemaMapperOverloads<float>(cls, "F");
67  declareSchemaMapperOverloads<double>(cls, "D");
68  declareSchemaMapperOverloads<std::string>(cls, "String");
69  declareSchemaMapperOverloads<lsst::afw::geom::Angle>(cls, "Angle");
70  declareSchemaMapperOverloads<lsst::afw::table::Flag>(cls, "Flag");
71  declareSchemaMapperOverloads<lsst::afw::table::Array<std::uint16_t>>(cls, "ArrayU");
72  declareSchemaMapperOverloads<lsst::afw::table::Array<int>>(cls, "ArrayI");
73  declareSchemaMapperOverloads<lsst::afw::table::Array<float>>(cls, "ArrayF");
74  declareSchemaMapperOverloads<lsst::afw::table::Array<double>>(cls, "ArrayD");
75 
76  return mod.ptr();
77 }
78 }
79 }
80 }
81 } // namespace lsst::afw::table::<anonymous>
PYBIND11_PLUGIN(_cameraPoint)
Definition: cameraPoint.cc:35
double const _a
Definition: RandomImage.cc:77