colour-science / colour

Colour Science for Python
https://www.colour-science.org
BSD 3-Clause "New" or "Revised" License
2.03k stars 257 forks source link

[BUG]: Write LUT without extension #1212

Closed remia closed 8 months ago

remia commented 9 months ago

Description

Hey,

Trying to update from version 0.3.16 to 0.4.2 or 0.4.3, I noticed it is no longer possible to write a LUT file without the correct extension for the method used. In my case I'm trying to write a file without any extension. I can work around that pretty easily for now, just wondering if this is intentional?

Thanks

Code for Reproduction

Python 3.11.4 (main, Jul 25 2023, 17:07:07) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import colour
>>> colour.__version__
'0.4.3'
>>> lut = colour.LUT3D(size=64)
>>> colour.write_LUT(lut, "test", method="Sony SPI3D")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/colour/io/luts/__init__.py", line 341, in write_LUT
    method, MAPPING_EXTENSION_TO_LUT_FORMAT[os.path.splitext(path)[-1]]
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/colour/utilities/data_structures.py", line 406, in __getitem__
    return self[dict(zip(self.canonical_keys(), self.keys()))[item]]
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: ''
>>> colour.write_LUT(lut, "test.spi3d", method="Sony SPI3D")
True

Exception Message

No response

Environment Information

No response

KelSolaar commented 9 months ago

Hi @remia,

Probably an oversight! Will try to take a look today or tomorrow.

Cheers,

Thomas

KelSolaar commented 8 months ago

Should be fixed @remia!

remia commented 8 months ago

Thanks for the quick fix @KelSolaar! Just tested and it fixes the issue.