diff --git a/src/utils/pybind11/ImplicitStringToEnumConversion.h b/src/utils/pybind11/ImplicitStringToEnumConversion.h index 29813821..84371f79 100644 --- a/src/utils/pybind11/ImplicitStringToEnumConversion.h +++ b/src/utils/pybind11/ImplicitStringToEnumConversion.h @@ -31,8 +31,9 @@ void make_implicitly_convertible_from_string(pybind11::enum_ &enumType) enumType.def(pybind11::init([enumType](pybind11::str value) { auto values = pybind11::dict(enumType.attr("__members__")); - if (values.contains(value)) { - return pybind11::cast(values[value]); + auto key = value.attr("upper")(); + if (values.contains(key)) { + return pybind11::cast(values[key]); } throw pybind11::value_error("\"" + pybind11::cast(value) + "\" is not a valid value for enum type " + pybind11::cast(enumType.attr("__name__"))); diff --git a/tests/test_enums.py b/tests/test_enums.py new file mode 100644 index 00000000..fe3305e7 --- /dev/null +++ b/tests/test_enums.py @@ -0,0 +1,7 @@ +import numpy as np +import parselmouth as pm + +def test_case(sound): + pitch = sound.to_pitch("CC") + pitch = sound.to_pitch("cc") + \ No newline at end of file