Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The example "ball with mesh refinement" prints errors: TypeError: <lambda>() takes 5 positional arguments but 6 were given #565

Open
yurivict opened this issue Dec 20, 2022 · 1 comment

Comments

@yurivict
Copy link

yurivict commented Dec 20, 2022

Exception ignored on calling ctypes callback function: <function model.mesh.setSizeCallback.<locals>.<lambda> at 0x8452fc1f0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gmsh.py", line 3940, in <lambda>
    api_callback_ = api_callback_type_(lambda dim, tag, x, y, z, lc, _ : callback(dim, tag, x, y, z, lc))
TypeError: <lambda>() takes 5 positional arguments but 6 were given
Exception ignored on calling ctypes callback function: <function model.mesh.setSizeCallback.<locals>.<lambda> at 0x8452fc1f0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gmsh.py", line 3940, in <lambda>
    api_callback_ = api_callback_type_(lambda dim, tag, x, y, z, lc, _ : callback(dim, tag, x, y, z, lc))
TypeError: <lambda>() takes 5 positional arguments but 6 were given

Version: 7.1.17
gmsh-4.11.0
Python-3.9
FreeBSD 13.1

@mbarbie1
Copy link

mbarbie1 commented Aug 9, 2024

Adding an extra argument "lc" in the lambda definition of the example removed the issue in my case.

# ball with mesh refinement
from math import sqrt
import pygmsh

with pygmsh.occ.Geometry() as geom:
    geom.add_ball([0.0, 0.0, 0.0], 1.0)

    geom.set_mesh_size_callback(
        lambda dim, tag, x, y, z, lc: abs(sqrt(x ** 2 + y ** 2 + z ** 2) - 0.5) + 0.1
    )
    mesh = geom.generate_mesh()

Version: 7.1.17
gmsh-4.13.1
python-3.12
Windows 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants