Skip to content

Exception in docs/notesbooks/03-ODE-prototyping.ipynb #35

@david-zwicker

Description

@david-zwicker

I tried running the notebook docs/notesbooks/03-ODE-prototyping.ipynb, which failed with the following error:

TypeError                                 Traceback (most recent call last)
Cell In[5], [line 43](vscode-notebook-cell:?execution_count=5&line=43)
     42 try:
---> [43](vscode-notebook-cell:?execution_count=5&line=43)     return self.interaction(u, lib)
     44 except TypeError:

Cell In[5], [line 23](vscode-notebook-cell:?execution_count=5&line=23)
     22 if self.interaction is None:
---> [23](vscode-notebook-cell:?execution_count=5&line=23)     self.interaction = lambda u, lib=None: u[0] * u[1]**2

TypeError: 'int' object is not subscriptable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
Cell In[7], [line 4](vscode-notebook-cell:?execution_count=7&line=4)
      1 from evoxels.utils import rhs_convergence_test
      3 precision = 'float6[4](vscode-notebook-cell:?execution_count=7&line=4)'
----> 4 dx, errors, slope, order = rhs_convergence_test(
      5         ODE_class      = CoupledReactionDiffusion,
      6         problem_kwargs = {"D_A": 1.0, "D_B": 0.5},
      7         test_function  = test_funs,
      8         convention     = 'cell_center',
      9         dtype          = precision
     10     )
     12 print(f"Grid spacing: {dx}")
     13 print(f"Errors c_a:   {errors[0]}")

File [...]/evoxels/utils.py:101, in rhs_convergence_test(ODE_class, problem_kwargs, test_function, mask_function, convention, dtype, powers, backend)
     98 u = vg.bc.trim_boundary_nodes(u)
    100 ODE = ODE_class(vg, **problem_kwargs)
--> [101]([...]/evoxels/utils.py:101) rhs_numeric = ODE.rhs(0, u)
    103 if n_funcs > 1 and mask is not None:
    104     rhs_analytic = ODE.rhs_analytic(0, test_functions, mask_function)

Cell In[5], [line 68](vscode-notebook-cell:?execution_count=5&line=68)
     54 r"""Two-component reaction-diffusion system
     55 
     56 Use batch channels for multiple species:
   (...)     65     Backend array of the same shape as ``u`` containing ``du/dt``.
     66 """
     67 print(u)
---> [68](vscode-notebook-cell:?execution_count=5&line=68) interaction = self._eval_interaction(u, self.vg.lib)
     69 u_pad = self.pad_bc(u)
     70 laplace = self.vg.laplace(u_pad)

Cell In[5], [line 45](vscode-notebook-cell:?execution_count=5&line=45)
     43     return self.interaction(u, lib)
     44 except TypeError:
---> [45](vscode-notebook-cell:?execution_count=5&line=45)     return self.interaction(u)

Cell In[5], [line 23](vscode-notebook-cell:?execution_count=5&line=23)
     21 self._fourier_symbol = - max(self.D_A, self.D_B) * k_squared
     22 if self.interaction is None:
---> [23](vscode-notebook-cell:?execution_count=5&line=23)     self.interaction = lambda u, lib=None: u[0] * u[1]**2

TypeError: 'int' object is not subscriptable

This might be a simple problem with passing the wrong arguments, but I couldn't fix it quickly. In any case, it would of course be great if the supplied notebooks work out of the box.

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