Skip to content

Error in spd_to_jab_t_r when loading luxpy #40

Description

@olafmersmann

When loading luxpy on Python 3.13 I get the following error

Traceback (most recent call last):
  File "/home/olafm/tmp/luxpy-bug/foo.py", line 1, in <module>
    import luxpy as lx
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/__init__.py", line 267, in <module>
    from .color.cri import colorrendition as cri
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/color/cri/__init__.py", line 216, in <module>
    from .colorrendition import *
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/color/cri/colorrendition.py", line 245, in <module>
    from .VFPX import VF_PX_models as VFPX
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/color/cri/VFPX/__init__.py", line 18, in <module>
    from .VF_PX_models import *
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/color/cri/VFPX/VF_PX_models.py", line 94, in <module>
    from .vectorshiftmodel import *
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/color/cri/VFPX/vectorshiftmodel.py", line 902, in <module>
    _VF_PCOLORSHIFT = initialize_VF_hue_angles(determine_hue_angles = _DETERMINE_HUE_ANGLES, modeltype = _VF_MODEL_TYPE)
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/color/cri/VFPX/vectorshiftmodel.py", line 884, in initialize_VF_hue_angles
    outM = VF_colorshift_model(IllC, cri_type = cri_type, sampleset = rflM, vfcolor = 'g',pool = pool,
                                interp_settings = interp_settings)
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/color/cri/VFPX/vectorshiftmodel.py", line 479, in VF_colorshift_model
    Rf, Rfi, Jabt, Jabr,cct,duv,cri_type  = spd_to_cri(S, cri_type= cri_type,out='Rf,Rfi,jabt,jabr,cct,duv,cri_type', sampleset=sampleset,
                                            ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                       interp_settings = interp_settings)
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/color/cri/utils/helpers.py", line 1506, in spd_to_cri
    cct,duv,St,Sr) = spd_to_jab_t_r(St, wl = wl, cri_type = cri_type,
                     ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                    out = 'jabt,jabr,xyzti,xyztw,xyzri,xyzrw,xyztw_cct,cct,duv,St,Sr',
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                    interp_settings = interp_settings)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/color/cri/utils/helpers.py", line 721, in spd_to_jab_t_r
    Sr = cri_ref(cct, ref_type = ref_type, cieobs = cieobs['cct'], wl3 = St[0], interp_settings = interp_settings)
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/spectrum/basics/illuminants.py", line 786, in cri_ref
    SrBB = blackbody(cct, wl3, n = n)
  File "/home/olafm/tmp/luxpy-bug/.venv/lib/python3.13/site-packages/luxpy/spectrum/basics/illuminants.py", line 143, in blackbody
    cct = float(cct)
TypeError: only 0-dimensional arrays can be converted to Python scalars

Steps to reproduce

In an empty directory, run

uv init --bare .
uv add luxpy matplotlib
echo "import luxpy as lx" > foo.py
uv run python foo.py

On my machine these are the exact dependencies that are installed:

luxpy v1.12.5
├── numpy v2.4.2
└── scipy v1.17.0
    └── numpy v2.4.2
matplotlib v3.10.8
├── contourpy v1.3.3
│   └── numpy v2.4.2
├── cycler v0.12.1
├── fonttools v4.61.1
├── kiwisolver v1.4.9
├── numpy v2.4.2
├── packaging v26.0
├── pillow v12.1.0
├── pyparsing v3.3.2
└── python-dateutil v2.9.0.post0
    └── six v1.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions