diff --git a/CHANGELOG.md b/CHANGELOG.md
index d40f40642..6e455c961 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,7 @@
 
 ## Bug fixes
 
+-   Fixed bug raised if function returns a scalar ([#919](https://github.com/pybamm-team/PyBaMM/pull/919))
 -   Updated Getting started notebook 2 ([#903](https://github.com/pybamm-team/PyBaMM/pull/903))
 -   Reformatted external circuit submodels ([#879](https://github.com/pybamm-team/PyBaMM/pull/879))
 -   Some bug fixes to generalize specifying models that aren't battery models, see [#846](https://github.com/pybamm-team/PyBaMM/issues/846)
diff --git a/pybamm/parameters/parameter_values.py b/pybamm/parameters/parameter_values.py
index 81a6c6861..7b2b1756b 100644
--- a/pybamm/parameters/parameter_values.py
+++ b/pybamm/parameters/parameter_values.py
@@ -524,6 +524,9 @@ class ParameterValues:
                 # return differentiated function
                 new_diff_variable = self.process_symbol(symbol.diff_variable)
                 function_out = function.diff(new_diff_variable)
+            # Convert possible float output to a pybamm scalar
+            if isinstance(function_out, numbers.Number):
+                return pybamm.Scalar(function_out)
             # Process again just to be sure
             return self.process_symbol(function_out)
 

Use of constant parameter functions throws an error
If one uses any model (inbuilt or self-made) with a function parameter that doesn't process any of the variables, its output won't be a Symbol, but a float.

Steps ro reproduce the error most easily:
1. Load up the example notebook/script for e.g. the DFN model.
2. Add/Update the following parameter in the default parameter set:
    "Electrolyte diffusivity [m2.s-1]": lambda c_e, T, T_ref, E_D_e, R: 2.72e-10,
3. Run the notebook/script.
4. See beautiful error message at the end. It basically fails at the step where 2.72e-10 obviously has no ".id" field, since it's not a Symbol.

While this is easily fixed by multiplying the 2.72e-10 by (0 * T_ref + 1) or replacing it with pybamm.Scalar(2.72e-10), I think this might be a common issue for beginners when using a model with more complexity than needed. Thus I'd like a helpful error message that hints me at my error. Or even better: constant parameter functions get converted to an appropriate Symbol automatically, just like it happens with scalar parameters already.

I monkey-patched the following hint-giver in my local copy (0.2.0 pip install) for my purposes:
in file pybamm/parameters/parameter_values.py, after line 472:
        except AttributeError:
            raise ValueError("A parameter was not given as a 'Symbol': " + repr(symbol)) from None
This displays "A parameter was not given as a 'Symbol': 2.72e-10" in the example case. I didn't figure out how to get the parameter name in this context.



Beautiful error message:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 467, in process_symbol
    return self._processed_symbols[symbol.id]
KeyError: -1310443411252241803

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 467, in process_symbol
    return self._processed_symbols[symbol.id]
KeyError: 6247489124244137513

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 467, in process_symbol
    return self._processed_symbols[symbol.id]
KeyError: -5616125575659663777

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 467, in process_symbol
    return self._processed_symbols[symbol.id]
KeyError: -9191736092148201685

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 467, in process_symbol
    return self._processed_symbols[symbol.id]
KeyError: -8136991043322325845

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 467, in process_symbol
    return self._processed_symbols[symbol.id]
KeyError: -5859718582323950464

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "solve.py", line 86, in <module>
    parameters.process_model(model)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 350, in process_model
    model.rhs[variable] = self.process_symbol(equation)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 469, in process_symbol
    processed_symbol = self._process_symbol(symbol)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 531, in _process_symbol
    new_child = self.process_symbol(symbol.child)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 469, in process_symbol
    processed_symbol = self._process_symbol(symbol)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 531, in _process_symbol
    new_child = self.process_symbol(symbol.child)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 469, in process_symbol
    processed_symbol = self._process_symbol(symbol)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 522, in _process_symbol
    new_left = self.process_symbol(symbol.left)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 469, in process_symbol
    processed_symbol = self._process_symbol(symbol)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 522, in _process_symbol
    new_left = self.process_symbol(symbol.left)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 469, in process_symbol
    processed_symbol = self._process_symbol(symbol)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 523, in _process_symbol
    new_right = self.process_symbol(symbol.right)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 469, in process_symbol
    processed_symbol = self._process_symbol(symbol)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 518, in _process_symbol
    return self.process_symbol(function_out)
  File "/usr/local/lib/python3.7/dist-packages/pybamm/parameters/parameter_values.py", line 467, in process_symbol
    return self._processed_symbols[symbol.id]
AttributeError: 'float' object has no attribute 'id'

diff --git a/tests/unit/test_parameters/test_parameter_values.py b/tests/unit/test_parameters/test_parameter_values.py
index 30a75ddd4..c9d81797d 100644
--- a/tests/unit/test_parameters/test_parameter_values.py
+++ b/tests/unit/test_parameters/test_parameter_values.py
@@ -300,6 +300,7 @@ class TestParameterValues(unittest.TestCase):
                 "a": 3,
                 "func": pybamm.load_function("process_symbol_test_function.py"),
                 "const": 254,
+                "float_func": lambda x: 42,
             }
         )
         a = pybamm.InputParameter("a")
@@ -320,6 +321,11 @@ class TestParameterValues(unittest.TestCase):
         processed_diff_func = parameter_values.process_symbol(diff_func)
         self.assertEqual(processed_diff_func.evaluate(u={"a": 3}), 123)
 
+        # function parameter that returns a python float
+        func = pybamm.FunctionParameter("float_func", a)
+        processed_func = parameter_values.process_symbol(func)
+        self.assertEqual(processed_func.evaluate(), 42)
+
         # function itself as input (different to the variable being an input)
         parameter_values = pybamm.ParameterValues({"func": "[input]"})
         a = pybamm.Scalar(3)

pip install -e .[dev,docs]
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc gfortran libopenblas-dev liblapack-dev graphviz
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
anyio==3.7.1
anytree==2.12.1
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
attrs==24.2.0
autograd==1.6.2
Babel==2.14.0
backcall==0.2.0
beautifulsoup4==4.13.3
black==23.3.0
bleach==6.0.0
casadi==3.7.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
click==8.1.8
comm==0.1.4
cycler==0.11.0
debugpy==1.7.0
decorator==5.1.1
defusedxml==0.7.1
docutils==0.17.1
entrypoints==0.4
exceptiongroup==1.2.2
fastjsonschema==2.21.1
flake8==5.0.4
fonttools==4.38.0
future==1.0.0
guzzle-sphinx-theme==0.7.11
idna==3.10
imagesize==1.4.1
importlib-metadata==4.2.0
importlib-resources==5.12.0
iniconfig==2.0.0
ipykernel==6.16.2
ipython==7.34.0
ipython-genutils==0.2.0
ipywidgets==8.1.5
jedi==0.19.2
Jinja2==3.1.6
json5==0.9.16
jsonschema==4.17.3
jupyter==1.1.1
jupyter-console==6.6.3
jupyter-server==1.24.0
jupyter_client==7.4.9
jupyter_core==4.12.0
jupyterlab==3.5.3
jupyterlab-pygments==0.2.2
jupyterlab_server==2.15.2
jupyterlab_widgets==3.0.13
kiwisolver==1.4.5
MarkupSafe==2.1.5
matplotlib==3.5.3
matplotlib-inline==0.1.6
mccabe==0.7.0
mistune==3.0.2
mypy-extensions==1.0.0
nbclassic==1.2.0
nbclient==0.7.4
nbconvert==7.6.0
nbformat==5.8.0
nest-asyncio==1.6.0
notebook==6.5.7
notebook_shim==0.2.4
numpy==1.21.6
packaging==24.0
pandas==1.3.5
pandocfilters==1.5.1
parso==0.8.4
pathspec==0.11.2
pexpect==4.9.0
pickleshare==0.7.5
Pillow==9.5.0
pkgutil_resolve_name==1.3.10
platformdirs==4.0.0
pluggy==1.2.0
prometheus-client==0.17.1
prompt_toolkit==3.0.48
psutil==7.0.0
ptyprocess==0.7.0
-e git+https://github.com/pybamm-team/PyBaMM.git@dca1f307ac10568467e87659a5df1ae66a1c30a8#egg=pybamm
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
Pygments==2.17.2
pyparsing==3.1.4
pyrsistent==0.19.3
pytest==7.4.4
python-dateutil==2.9.0.post0
pytz==2025.2
pyzmq==26.2.1
requests==2.31.0
scikit-fem==8.1.0
scipy==1.7.3
Send2Trash==1.8.3
six==1.17.0
sniffio==1.3.1
snowballstemmer==2.2.0
soupsieve==2.4.1
Sphinx==4.3.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
terminado==0.17.1
tinycss2==1.2.1
tomli==2.0.1
tornado==6.2
traitlets==5.9.0
typed-ast==1.5.5
typing_extensions==4.7.1
urllib3==2.0.7
wcwidth==0.2.13
webencodings==0.5.1
websocket-client==1.6.1
widgetsnbextension==4.0.13
zipp==3.15.0

name: PyBaMM
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - anyio==3.7.1
      - anytree==2.12.1
      - argon2-cffi==23.1.0
      - argon2-cffi-bindings==21.2.0
      - attrs==24.2.0
      - autograd==1.6.2
      - babel==2.14.0
      - backcall==0.2.0
      - beautifulsoup4==4.13.3
      - black==23.3.0
      - bleach==6.0.0
      - casadi==3.7.0
      - cffi==1.15.1
      - charset-normalizer==3.4.1
      - click==8.1.8
      - comm==0.1.4
      - cycler==0.11.0
      - debugpy==1.7.0
      - decorator==5.1.1
      - defusedxml==0.7.1
      - docutils==0.17.1
      - entrypoints==0.4
      - exceptiongroup==1.2.2
      - fastjsonschema==2.21.1
      - flake8==5.0.4
      - fonttools==4.38.0
      - future==1.0.0
      - guzzle-sphinx-theme==0.7.11
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.2.0
      - importlib-resources==5.12.0
      - iniconfig==2.0.0
      - ipykernel==6.16.2
      - ipython==7.34.0
      - ipython-genutils==0.2.0
      - ipywidgets==8.1.5
      - jedi==0.19.2
      - jinja2==3.1.6
      - json5==0.9.16
      - jsonschema==4.17.3
      - jupyter==1.1.1
      - jupyter-client==7.4.9
      - jupyter-console==6.6.3
      - jupyter-core==4.12.0
      - jupyter-server==1.24.0
      - jupyterlab==3.5.3
      - jupyterlab-pygments==0.2.2
      - jupyterlab-server==2.15.2
      - jupyterlab-widgets==3.0.13
      - kiwisolver==1.4.5
      - markupsafe==2.1.5
      - matplotlib==3.5.3
      - matplotlib-inline==0.1.6
      - mccabe==0.7.0
      - mistune==3.0.2
      - mypy-extensions==1.0.0
      - nbclassic==1.2.0
      - nbclient==0.7.4
      - nbconvert==7.6.0
      - nbformat==5.8.0
      - nest-asyncio==1.6.0
      - notebook==6.5.7
      - notebook-shim==0.2.4
      - numpy==1.21.6
      - packaging==24.0
      - pandas==1.3.5
      - pandocfilters==1.5.1
      - parso==0.8.4
      - pathspec==0.11.2
      - pexpect==4.9.0
      - pickleshare==0.7.5
      - pillow==9.5.0
      - pkgutil-resolve-name==1.3.10
      - platformdirs==4.0.0
      - pluggy==1.2.0
      - prometheus-client==0.17.1
      - prompt-toolkit==3.0.48
      - psutil==7.0.0
      - ptyprocess==0.7.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - pygments==2.17.2
      - pyparsing==3.1.4
      - pyrsistent==0.19.3
      - pytest==7.4.4
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyzmq==26.2.1
      - requests==2.31.0
      - scikit-fem==8.1.0
      - scipy==1.7.3
      - send2trash==1.8.3
      - six==1.17.0
      - sniffio==1.3.1
      - snowballstemmer==2.2.0
      - soupsieve==2.4.1
      - sphinx==4.3.2
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - terminado==0.17.1
      - tinycss2==1.2.1
      - tomli==2.0.1
      - tornado==6.2
      - traitlets==5.9.0
      - typed-ast==1.5.5
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - wcwidth==0.2.13
      - webencodings==0.5.1
      - websocket-client==1.6.1
      - widgetsnbextension==4.0.13
      - zipp==3.15.0
prefix: /opt/conda/envs/PyBaMM

tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_process_function_parameter
tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_check_and_update_parameter_values tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_evaluate tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_init tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_inplace tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_interpolant_against_function tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_multi_var_function_parameter tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_multi_var_function_with_parameters tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_process_complex_expression tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_process_empty_model tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_process_inline_function_parameters tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_process_input_parameter tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_process_interpolant tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_process_model tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_process_symbol tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_read_parameters_csv tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_update tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_update_from_chemistry tests/unit/test_parameters/test_parameter_values.py::TestParameterValues::test_update_model
pybamm/parameters/parameter_values.py CHANGELOG.md
pybamm/parameters/parameter_values.py CHANGELOG.md