Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of box2f in python module #1944

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/wrappers/python/PyOpenEXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1660,11 +1660,8 @@ objectToBox2f(const py::object& object, Box2f& b)
{
auto tup = object.cast<py::tuple>();
if (tup.size() == 2)
{
Box2f box;
if (objectToV2f(tup[0], box.min) && objectToV2f(tup[1], box.max))
if (objectToV2f(tup[0], b.min) && objectToV2f(tup[1], b.max))
return true;
}
}

return false;
Expand Down
14 changes: 7 additions & 7 deletions src/wrappers/python/PyOpenEXR_old.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ channel (PyObject* self, PyObject* args, PyObject* kw)
PyExc_TypeError, "There is no channel '%s' in the image", cname);
}

Imf::PixelType pt;
PixelType pt;
if (pixel_type != NULL)
{
if (PyObject_GetAttrString (pixel_type, "v") == NULL)
Expand Down Expand Up @@ -500,7 +500,7 @@ channels (PyObject* self, PyObject* args, PyObject* kw)
cname);
}

Imf::PixelType pt;
PixelType pt;
if (pixel_type != NULL)
{
pt = PixelType (
Expand Down Expand Up @@ -1013,7 +1013,7 @@ outwrite (PyObject* self, PyObject* args)
PyDict_GetItem (pixeldata, PyUnicode_FromString (i.name ()));
if (channel_spec != NULL)
{
Imf::PixelType pt = i.channel ().type;
PixelType pt = i.channel ().type;
int typeSize = 4;
switch (pt)
{
Expand Down Expand Up @@ -1289,7 +1289,7 @@ makeOutputFile (PyObject* self, PyObject* args, PyObject* kwds)
PreviewImage pi (
PyLong_AsLong (PyObject_StealAttrString (value, "width")),
PyLong_AsLong (PyObject_StealAttrString (value, "height")),
(Imf::PreviewRgba*) PyString_AsString (
(PreviewRgba*) PyString_AsString (
PyObject_StealAttrString (value, "pixels")));
header.insert (ks, PreviewImageAttribute (pi));
}
Expand Down Expand Up @@ -1398,9 +1398,9 @@ makeOutputFile (PyObject* self, PyObject* args, PyObject* kwds)
TileDescription td (
PyInt_AsLong (PyObject_StealAttrString (value, "xSize")),
PyInt_AsLong (PyObject_StealAttrString (value, "ySize")),
(Imf::LevelMode) PyInt_AsLong (PyObject_StealAttrString (
(LevelMode) PyInt_AsLong (PyObject_StealAttrString (
PyObject_StealAttrString (value, "mode"), "v")),
(Imf::LevelRoundingMode) PyInt_AsLong (
(LevelRoundingMode) PyInt_AsLong (
PyObject_StealAttrString (
PyObject_StealAttrString (value, "roundingMode"),
"v")));
Expand Down Expand Up @@ -1511,7 +1511,7 @@ isOpenExrFile (const char fileName[])
std::ifstream f (fileName, std::ios_base::binary);
char bytes[4];
f.read (bytes, sizeof (bytes));
return !!f && Imf::isImfMagic (bytes);
return !!f && isImfMagic (bytes);
}

PyObject*
Expand Down
6 changes: 3 additions & 3 deletions src/wrappers/python/tests/test_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def test_write_float(self):
header["stringvector"] = ["do", "re", "me"]
header["chromaticities"] = (1.0,2.0, 3.0,4.0, 5.0,6.0,7.0,8.0)
header["box2i"] = ((0,1), (2,3))
header["box2f"] = ((0,1), (2,3))
header["box2f"] = ((0.0,1.0), (2.0,3.0))
header["compression"] = OpenEXR.ZIPS_COMPRESSION
header["double"] = np.array([42000.0], 'float64')
header["float"] = 4.2
Expand Down Expand Up @@ -484,7 +484,7 @@ def test_write_float(self):
# Verify reading it back gives the same data
with OpenEXR.File(outfilename, separate_channels=True) as infile:
compare_files (infile, outfile)

def test_write_2part(self):

#
Expand Down Expand Up @@ -523,7 +523,7 @@ def make_header():
header["stringvector"] = ["do", "re", "me"]
header["chromaticities"] = (1.0,2.0, 3.0,4.0, 5.0,6.0,7.0,8.0)
header["box2i"] = ((0,1),(2,3))
header["box2f"] = ((0,1),(2,3))
header["box2f"] = ((0.0,1.0),(2.0,3.0))
header["compression"] = OpenEXR.ZIPS_COMPRESSION
header["double"] = np.array([42000.0], 'float64')
header["float"] = 4.2
Expand Down
Loading