Browse Source

python: expose trade.abstractImporter.imageXd_level_count().

pull/9/head
Vladimír Vondruš 6 years ago
parent
commit
45eb76446b
  1. 10
      doc/python/magnum.trade.rst
  2. 15
      src/python/magnum/test/test_trade.py
  3. 3
      src/python/magnum/trade.cpp

10
doc/python/magnum.trade.rst

@ -126,6 +126,16 @@
.. py:property:: magnum.trade.AbstractImporter.image3d_count
:raise RuntimeError: If no file is opened
.. py:function:: magnum.trade.AbstractImporter.image1d_level_count
:raise RuntimeError: If no file is opened
:raise ValueError: If :p:`id` is negative or not less than `image1d_count`
.. py:function:: magnum.trade.AbstractImporter.image2d_level_count
:raise RuntimeError: If no file is opened
:raise ValueError: If :p:`id` is negative or not less than `image2d_count`
.. py:function:: magnum.trade.AbstractImporter.image3d_level_count
:raise RuntimeError: If no file is opened
:raise ValueError: If :p:`id` is negative or not less than `image3d_count`
.. py:function:: magnum.trade.AbstractImporter.image1d_for_name
:raise RuntimeError: If no file is opened
.. py:function:: magnum.trade.AbstractImporter.image2d_for_name

15
src/python/magnum/test/test_trade.py

@ -143,6 +143,13 @@ class Importer(unittest.TestCase):
with self.assertRaisesRegex(RuntimeError, "no file opened"):
importer.image3d_count
with self.assertRaisesRegex(RuntimeError, "no file opened"):
importer.image1d_level_count(0)
with self.assertRaisesRegex(RuntimeError, "no file opened"):
importer.image2d_level_count(0)
with self.assertRaisesRegex(RuntimeError, "no file opened"):
importer.image3d_level_count(0)
with self.assertRaisesRegex(RuntimeError, "no file opened"):
importer.image1d_for_name('')
with self.assertRaisesRegex(RuntimeError, "no file opened"):
@ -178,6 +185,13 @@ class Importer(unittest.TestCase):
with self.assertRaises(IndexError):
importer.mesh3d(0)
with self.assertRaises(IndexError):
importer.image1d_level_count(0)
with self.assertRaises(IndexError):
importer.image2d_level_count(1)
with self.assertRaises(IndexError):
importer.image3d_level_count(0)
with self.assertRaises(IndexError):
importer.image1d_name(0)
with self.assertRaises(IndexError):
@ -223,6 +237,7 @@ class Importer(unittest.TestCase):
importer.open_file(os.path.join(os.path.dirname(__file__), 'rgb.png'))
self.assertEqual(importer.image2d_count, 1)
self.assertEqual(importer.image2d_level_count(0), 1)
self.assertEqual(importer.image2d_name(0), '')
self.assertEqual(importer.image2d_for_name(''), -1)

3
src/python/magnum/trade.cpp

@ -282,6 +282,9 @@ void trade(py::module& m) {
.def_property_readonly("image1d_count", checkOpened<UnsignedInt, &Trade::AbstractImporter::image1DCount>, "One-dimensional image count")
.def_property_readonly("image2d_count", checkOpened<UnsignedInt, &Trade::AbstractImporter::image2DCount>, "Two-dimensional image count")
.def_property_readonly("image3d_count", checkOpened<UnsignedInt, &Trade::AbstractImporter::image3DCount>, "Three-dimensional image count")
.def("image1d_level_count", checkOpenedBounds<UnsignedInt, &Trade::AbstractImporter::image1DLevelCount, &Trade::AbstractImporter::image1DCount>, "One-dimensional image level count", py::arg("id"))
.def("image2d_level_count", checkOpenedBounds<UnsignedInt, &Trade::AbstractImporter::image2DLevelCount, &Trade::AbstractImporter::image2DCount>, "Two-dimensional image level count", py::arg("id"))
.def("image3d_level_count", checkOpenedBounds<UnsignedInt, &Trade::AbstractImporter::image3DLevelCount, &Trade::AbstractImporter::image3DCount>, "Three-dimensional image level count", py::arg("id"))
.def("image1d_for_name", checkOpened<Int, const std::string&, &Trade::AbstractImporter::image1DForName>, "One-dimensional image ID for given name")
.def("image2d_for_name", checkOpened<Int, const std::string&, &Trade::AbstractImporter::image2DForName>, "Two-dimensional image ID for given name")
.def("image3d_for_name", checkOpened<Int, const std::string&, &Trade::AbstractImporter::image3DForName>, "Three-dimensional image ID for given name")

Loading…
Cancel
Save