diff --git a/CHANGELOG.md b/CHANGELOG.md
index e35bf59a6..3d68502a4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
 
 ## Features
 
+-   Added NCA parameter set ([#824](https://github.com/pybamm-team/PyBaMM/pull/824))
+-   Added options to export a solution to matlab or csv ([#811](https://github.com/pybamm-team/PyBaMM/pull/811))
+-   Allow porosity to vary in space ([#809](https://github.com/pybamm-team/PyBaMM/pull/809))
 -   Added functionality to solve DAE models with non-smooth current inputs ([#808](https://github.com/pybamm-team/PyBaMM/pull/808))
 -   Added functionality to simulate experiments and testing protocols ([#807](https://github.com/pybamm-team/PyBaMM/pull/807))
 -   Added fuzzy string matching for parameters and variables ([#796](https://github.com/pybamm-team/PyBaMM/pull/796))
@@ -49,6 +52,7 @@
 
 ## Bug fixes
 
+-   Made `graphviz` an optional dependency ([#810](https://github.com/pybamm-team/PyBaMM/pull/810))
 -   Fixed examples to run with basic pip installation ([#800](https://github.com/pybamm-team/PyBaMM/pull/800))
 -   Added events for CasADi solver when stepping ([#800](https://github.com/pybamm-team/PyBaMM/pull/800))
 -   Improved implementation of broadcasts ([#776](https://github.com/pybamm-team/PyBaMM/pull/776))
diff --git a/examples/scripts/SPMe.py b/examples/scripts/SPMe.py
index ee87649a9..709958fd4 100644
--- a/examples/scripts/SPMe.py
+++ b/examples/scripts/SPMe.py
@@ -9,6 +9,7 @@ pybamm.set_logging_level("INFO")
 
 # load model
 model = pybamm.lithium_ion.SPMe()
+model.convert_to_format = "python"
 
 # create geometry
 geometry = model.default_geometry
diff --git a/pybamm/expression_tree/operations/simplify.py b/pybamm/expression_tree/operations/simplify.py
index 6e090db82..df033cea4 100644
--- a/pybamm/expression_tree/operations/simplify.py
+++ b/pybamm/expression_tree/operations/simplify.py
@@ -22,8 +22,10 @@ def simplify_if_constant(symbol, keep_domains=False):
     if symbol.is_constant():
         result = symbol.evaluate_ignoring_errors()
         if result is not None:
-            if isinstance(result, numbers.Number) or (
-                isinstance(result, np.ndarray) and result.ndim == 0
+            if (
+                isinstance(result, numbers.Number)
+                or (isinstance(result, np.ndarray) and result.ndim == 0)
+                or isinstance(result, np.bool_)
             ):
                 return pybamm.Scalar(result)
             elif isinstance(result, np.ndarray) or issparse(result):
diff --git a/pybamm/expression_tree/scalar.py b/pybamm/expression_tree/scalar.py
index 975c77087..b96d618c7 100644
--- a/pybamm/expression_tree/scalar.py
+++ b/pybamm/expression_tree/scalar.py
@@ -2,6 +2,7 @@
 # Scalar class
 #
 import pybamm
+import numpy as np
 
 
 class Scalar(pybamm.Symbol):
@@ -40,7 +41,7 @@ class Scalar(pybamm.Symbol):
 
     @value.setter
     def value(self, value):
-        self._value = float(value)
+        self._value = np.float64(value)
 
     def set_id(self):
         """ See :meth:`pybamm.Symbol.set_id()`. """
diff --git a/pybamm/parameters/parameter_values.py b/pybamm/parameters/parameter_values.py
index 358c50a5f..dbe21647b 100644
--- a/pybamm/parameters/parameter_values.py
+++ b/pybamm/parameters/parameter_values.py
@@ -385,8 +385,9 @@ class ParameterValues:
             model.variables[variable] = self.process_symbol(equation)
 
         for event in model.events:
-            pybamm.logger.debug("Processing parameters for event'{}''"
-                                .format(event.name))
+            pybamm.logger.debug(
+                "Processing parameters for event'{}''".format(event.name)
+            )
             event.expression = self.process_symbol(event.expression)
 
         pybamm.logger.info("Finish setting parameters for {}".format(model.name))
diff --git a/pybamm/solvers/base_solver.py b/pybamm/solvers/base_solver.py
index 450735eee..7b11c219e 100644
--- a/pybamm/solvers/base_solver.py
+++ b/pybamm/solvers/base_solver.py
@@ -217,16 +217,20 @@ class BaseSolver(object):
         # Check for heaviside functions in rhs and algebraic and add discontinuity
         # events if these exist.
         # Note: only checks for the case of t < X, t <= X, X < t, or X <= t
-        for symbol in itertools.chain(model.concatenated_rhs.pre_order(),
-                                      model.concatenated_algebraic.pre_order()):
+        for symbol in itertools.chain(
+            model.concatenated_rhs.pre_order(), model.concatenated_algebraic.pre_order()
+        ):
             if isinstance(symbol, pybamm.Heaviside):
                 if symbol.right.id == pybamm.t.id:
                     expr = symbol.left
                 elif symbol.left.id == pybamm.t.id:
                     expr = symbol.right
 
-                model.events.append(pybamm.Event(str(symbol), expr.new_copy(),
-                                                 pybamm.EventType.DISCONTINUITY))
+                model.events.append(
+                    pybamm.Event(
+                        str(symbol), expr.new_copy(), pybamm.EventType.DISCONTINUITY
+                    )
+                )
 
         # Process rhs, algebraic and event expressions
         rhs, rhs_eval, jac_rhs = process(model.concatenated_rhs, "RHS")
@@ -242,7 +246,8 @@ class BaseSolver(object):
         # discontinuity events are evaluated before the solver is called, so don't need
         # to process them
         discontinuity_events_eval = [
-            event for event in model.events
+            event
+            for event in model.events
             if event.event_type == pybamm.EventType.DISCONTINUITY
         ]
 
@@ -452,12 +457,17 @@ class BaseSolver(object):
 
         # make sure they are increasing in time
         discontinuities = sorted(discontinuities)
-        pybamm.logger.info(
-            'Discontinuity events found at t = {}'.format(discontinuities)
-        )
+        if len(discontinuities) > 0:
+            pybamm.logger.info(
+                "Discontinuity events found at t = {}".format(discontinuities)
+            )
+        else:
+            pybamm.logger.info("No discontinuity events found")
+
         # remove any identical discontinuities
         discontinuities = [
-            v for i, v in enumerate(discontinuities)
+            v
+            for i, v in enumerate(discontinuities)
             if i == len(discontinuities) - 1
             or discontinuities[i] < discontinuities[i + 1]
         ]
@@ -467,16 +477,18 @@ class BaseSolver(object):
         start_indices = [0]
         end_indices = []
         for dtime in discontinuities:
-            dindex = np.searchsorted(t_eval, dtime, side='left')
+            dindex = np.searchsorted(t_eval, dtime, side="left")
             end_indices.append(dindex + 1)
             start_indices.append(dindex + 1)
             if t_eval[dindex] == dtime:
                 t_eval[dindex] += sys.float_info.epsilon
                 t_eval = np.insert(t_eval, dindex, dtime - sys.float_info.epsilon)
             else:
-                t_eval = np.insert(t_eval, dindex,
-                                   [dtime - sys.float_info.epsilon,
-                                    dtime + sys.float_info.epsilon])
+                t_eval = np.insert(
+                    t_eval,
+                    dindex,
+                    [dtime - sys.float_info.epsilon, dtime + sys.float_info.epsilon],
+                )
         end_indices.append(len(t_eval))
 
         # integrate separatly over each time segment and accumulate into the solution
@@ -485,16 +497,21 @@ class BaseSolver(object):
         old_y0 = model.y0
         solution = None
         for start_index, end_index in zip(start_indices, end_indices):
-            pybamm.logger.info("Calling solver for {} < t < {}"
-                               .format(t_eval[start_index], t_eval[end_index - 1]))
+            pybamm.logger.info(
+                "Calling solver for {} < t < {}".format(
+                    t_eval[start_index], t_eval[end_index - 1]
+                )
+            )
             timer.reset()
             if solution is None:
                 solution = self._integrate(
-                    model, t_eval[start_index:end_index], ext_and_inputs)
+                    model, t_eval[start_index:end_index], ext_and_inputs
+                )
                 solution.solve_time = timer.time()
             else:
                 new_solution = self._integrate(
-                    model, t_eval[start_index:end_index], ext_and_inputs)
+                    model, t_eval[start_index:end_index], ext_and_inputs
+                )
                 new_solution.solve_time = timer.time()
                 solution.append(new_solution, start_index=0)
 
@@ -506,14 +523,16 @@ class BaseSolver(object):
                 y0_guess = solution.y[:, -1]
                 if model.algebraic:
                     model.y0 = self.calculate_consistent_state(
-                        model, t_eval[end_index], y0_guess)
+                        model, t_eval[end_index], y0_guess
+                    )
                 else:
                     model.y0 = y0_guess
 
                 last_state = solution.y[:, -1]
                 if len(model.algebraic) > 0:
                     model.y0 = self.calculate_consistent_state(
-                        model, t_eval[end_index], last_state)
+                        model, t_eval[end_index], last_state
+                    )
                 else:
                     model.y0 = last_state
 

Fix events with non-casadi solvers with non-casadi formats
Calling flatten on line 716 of `base_solver.py` raises error
diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py
index 0dc59f881..bf4866984 100644
--- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py
+++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py
@@ -15,6 +15,13 @@ class TestSPMe(unittest.TestCase):
         modeltest = tests.StandardModelTest(model)
         modeltest.test_all()
 
+    def test_basic_processing_python(self):
+        options = {"thermal": "isothermal"}
+        model = pybamm.lithium_ion.SPMe(options)
+        model.convert_to_format = "python"
+        modeltest = tests.StandardModelTest(model, solver=pybamm.ScipySolver())
+        modeltest.test_all()
+
     def test_basic_processing_1plus1D(self):
         options = {"current collector": "potential pair", "dimensionality": 1}
         model = pybamm.lithium_ion.SPMe(options)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest flake8 coverage
apt-get update apt-get install -y python3-dev gfortran gcc cmake libopenblas-dev
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
anyio==4.9.0
anytree==2.12.1
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==3.0.0
async-lru==2.0.5
attrs==25.3.0
autograd==1.7.0
babel==2.17.0
beautifulsoup4==4.13.3
black==25.1.0
bleach==6.2.0
casadi==3.7.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
comm==0.2.2
contourpy==1.3.0
coverage==7.8.0
cycler==0.12.1
debugpy==1.8.13
decorator==5.2.1
defusedxml==0.7.1
exceptiongroup==1.2.2
executing==2.2.0
fastjsonschema==2.21.1
flake8==7.2.0
fonttools==4.56.0
fqdn==1.5.1
h11==0.14.0
httpcore==1.0.7
httpx==0.28.1
idna==3.10
importlib_metadata==8.6.1
importlib_resources==6.5.2
iniconfig==2.1.0
ipykernel==6.29.5
ipython==8.18.1
ipywidgets==8.1.5
isoduration==20.11.0
jedi==0.19.2
Jinja2==3.1.6
json5==0.10.0
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter==1.1.1
jupyter-console==6.6.3
jupyter-events==0.12.0
jupyter-lsp==2.2.5
jupyter_client==8.6.3
jupyter_core==5.7.2
jupyter_server==2.15.0
jupyter_server_terminals==0.5.3
jupyterlab==4.3.6
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.3
jupyterlab_widgets==3.0.13
kiwisolver==1.4.7
Levenshtein==0.27.1
MarkupSafe==3.0.2
matplotlib==3.9.4
matplotlib-inline==0.1.7
mccabe==0.7.0
mistune==3.1.3
mypy-extensions==1.0.0
nbclient==0.10.2
nbconvert==7.16.6
nbformat==5.10.4
nest-asyncio==1.6.0
notebook==7.3.3
notebook_shim==0.2.4
numpy==2.0.2
overrides==7.7.0
packaging==24.2
pandas==2.2.3
pandocfilters==1.5.1
parso==0.8.4
pathspec==0.12.1
pexpect==4.9.0
pillow==11.1.0
platformdirs==4.3.7
pluggy==1.5.0
prometheus_client==0.21.1
prompt_toolkit==3.0.50
psutil==7.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
-e git+https://github.com/pybamm-team/PyBaMM.git@bc96ffd0235ce6882af48082a5185d017c3a8582#egg=pybamm
pycodestyle==2.13.0
pycparser==2.22
pyflakes==3.3.1
Pygments==2.19.1
pyparsing==3.2.3
pytest==8.3.5
python-dateutil==2.9.0.post0
python-json-logger==3.3.0
python-Levenshtein==0.27.1
pytz==2025.2
PyYAML==6.0.2
pyzmq==26.3.0
RapidFuzz==3.12.2
referencing==0.36.2
requests==2.32.3
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.24.0
scikit-fem==10.0.2
scipy==1.13.1
Send2Trash==1.8.3
six==1.17.0
sniffio==1.3.1
soupsieve==2.6
stack-data==0.6.3
terminado==0.18.1
tinycss2==1.4.0
tomli==2.2.1
tornado==6.4.2
traitlets==5.14.3
types-python-dateutil==2.9.0.20241206
typing_extensions==4.13.0
tzdata==2025.2
uri-template==1.3.0
urllib3==2.3.0
wcwidth==0.2.13
webcolors==24.11.1
webencodings==0.5.1
websocket-client==1.8.0
widgetsnbextension==4.0.13
zipp==3.21.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
  - 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=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - anyio==4.9.0
      - anytree==2.12.1
      - argon2-cffi==23.1.0
      - argon2-cffi-bindings==21.2.0
      - arrow==1.3.0
      - asttokens==3.0.0
      - async-lru==2.0.5
      - attrs==25.3.0
      - autograd==1.7.0
      - babel==2.17.0
      - beautifulsoup4==4.13.3
      - black==25.1.0
      - bleach==6.2.0
      - casadi==3.7.0
      - certifi==2025.1.31
      - cffi==1.17.1
      - charset-normalizer==3.4.1
      - click==8.1.8
      - comm==0.2.2
      - contourpy==1.3.0
      - coverage==7.8.0
      - cycler==0.12.1
      - debugpy==1.8.13
      - decorator==5.2.1
      - defusedxml==0.7.1
      - exceptiongroup==1.2.2
      - executing==2.2.0
      - fastjsonschema==2.21.1
      - flake8==7.2.0
      - fonttools==4.56.0
      - fqdn==1.5.1
      - h11==0.14.0
      - httpcore==1.0.7
      - httpx==0.28.1
      - idna==3.10
      - importlib-metadata==8.6.1
      - importlib-resources==6.5.2
      - iniconfig==2.1.0
      - ipykernel==6.29.5
      - ipython==8.18.1
      - ipywidgets==8.1.5
      - isoduration==20.11.0
      - jedi==0.19.2
      - jinja2==3.1.6
      - json5==0.10.0
      - jsonpointer==3.0.0
      - jsonschema==4.23.0
      - jsonschema-specifications==2024.10.1
      - jupyter==1.1.1
      - jupyter-client==8.6.3
      - jupyter-console==6.6.3
      - jupyter-core==5.7.2
      - jupyter-events==0.12.0
      - jupyter-lsp==2.2.5
      - jupyter-server==2.15.0
      - jupyter-server-terminals==0.5.3
      - jupyterlab==4.3.6
      - jupyterlab-pygments==0.3.0
      - jupyterlab-server==2.27.3
      - jupyterlab-widgets==3.0.13
      - kiwisolver==1.4.7
      - levenshtein==0.27.1
      - markupsafe==3.0.2
      - matplotlib==3.9.4
      - matplotlib-inline==0.1.7
      - mccabe==0.7.0
      - mistune==3.1.3
      - mypy-extensions==1.0.0
      - nbclient==0.10.2
      - nbconvert==7.16.6
      - nbformat==5.10.4
      - nest-asyncio==1.6.0
      - notebook==7.3.3
      - notebook-shim==0.2.4
      - numpy==2.0.2
      - overrides==7.7.0
      - packaging==24.2
      - pandas==2.2.3
      - pandocfilters==1.5.1
      - parso==0.8.4
      - pathspec==0.12.1
      - pexpect==4.9.0
      - pillow==11.1.0
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - prometheus-client==0.21.1
      - prompt-toolkit==3.0.50
      - psutil==7.0.0
      - ptyprocess==0.7.0
      - pure-eval==0.2.3
      - pycodestyle==2.13.0
      - pycparser==2.22
      - pyflakes==3.3.1
      - pygments==2.19.1
      - pyparsing==3.2.3
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - python-json-logger==3.3.0
      - python-levenshtein==0.27.1
      - pytz==2025.2
      - pyyaml==6.0.2
      - pyzmq==26.3.0
      - rapidfuzz==3.12.2
      - referencing==0.36.2
      - requests==2.32.3
      - rfc3339-validator==0.1.4
      - rfc3986-validator==0.1.1
      - rpds-py==0.24.0
      - scikit-fem==10.0.2
      - scipy==1.13.1
      - send2trash==1.8.3
      - six==1.17.0
      - sniffio==1.3.1
      - soupsieve==2.6
      - stack-data==0.6.3
      - terminado==0.18.1
      - tinycss2==1.4.0
      - tomli==2.2.1
      - tornado==6.4.2
      - traitlets==5.14.3
      - types-python-dateutil==2.9.0.20241206
      - typing-extensions==4.13.0
      - tzdata==2025.2
      - uri-template==1.3.0
      - urllib3==2.3.0
      - wcwidth==0.2.13
      - webcolors==24.11.1
      - webencodings==0.5.1
      - websocket-client==1.8.0
      - widgetsnbextension==4.0.13
      - zipp==3.21.0
prefix: /opt/conda/envs/PyBaMM

tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py::TestSPMe::test_basic_processing_python
tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py::TestSPMe::test_basic_processing_2plus1D
tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py::TestSPMe::test_basic_processing tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py::TestSPMe::test_basic_processing_1plus1D tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py::TestSPMe::test_optimisations tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py::TestSPMe::test_particle_fast_diffusion tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py::TestSPMe::test_set_up tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py::TestSPMe::test_thermal
pybamm/parameters/parameter_values.py pybamm/expression_tree/scalar.py CHANGELOG.md pybamm/expression_tree/operations/simplify.py pybamm/solvers/base_solver.py examples/scripts/SPMe.py
pybamm/parameters/parameter_values.py pybamm/expression_tree/scalar.py CHANGELOG.md pybamm/expression_tree/operations/simplify.py pybamm/solvers/base_solver.py examples/scripts/SPMe.py