{"id":21474,"library":"isosurfaces","title":"isosurfaces","description":"Construct isolines/isosurfaces over a 2D/3D scalar field defined by a function (not a uniform grid). Current version: 0.1.2. Release cadence: irregular, minor patches.","status":"active","version":"0.1.2","language":"python","source_language":"en","source_url":"https://github.com/jared-hughes/isosurfaces","tags":["isosurface","marching-squares","marching-cubes","scalar-field","contour"],"install":[{"cmd":"pip install isosurfaces","lang":"bash","label":"standard"}],"dependencies":[],"imports":[{"note":"The library exposes functions at top level, not in submodules.","wrong":"from isosurfaces.marching_squares import marching_squares","symbol":"marching_squares","correct":"from isosurfaces import marching_squares"},{"note":"Same as above; use top-level import.","wrong":"from isosurfaces.marching_cubes import marching_cubes","symbol":"marching_cubes","correct":"from isosurfaces import marching_cubes"}],"quickstart":{"code":"from isosurfaces import marching_squares\nimport numpy as np\n\ndef f(x, y):\n    return x**2 + y**2 - 1\n\n# Sample the function on a grid\nxs = np.linspace(-2, 2, 100)\nys = np.linspace(-2, 2, 100)\nvalues = np.array([[f(x, y) for x in xs] for y in ys])\n\n# Extract isoline at value 0\nverts, edges = marching_squares(values, 0)\nprint(f\"Found {len(verts)} vertices, {len(edges)} edges\")","lang":"python","description":"Basic usage: sample a scalar field on a grid, then call marching_squares or marching_cubes."},"warnings":[{"fix":"Generate a regular grid of values (e.g., using np.meshgrid) before calling the function.","message":"The input to marching_squares/marching_cubes must be a 2D/3D numpy array of scalar values on a rectangular grid, not a function. The library does not handle adaptive sampling; you must pre-sample the field.","severity":"gotcha","affected_versions":"all"},{"fix":"Map indices to world coordinates: x_world = x_min + (idx / (shape[0]-1)) * (x_max - x_min).","message":"The output vertices are in pixel/grid coordinates (indices), not world coordinates. You must scale/transform them yourself if needed.","severity":"gotcha","affected_versions":"all"},{"fix":"Pin version in requirements: isosurfaces==0.1.2","message":"Library is in early development (v0.1.x); API may change without notice. Expect breaking changes in minor versions.","severity":"gotcha","affected_versions":"0.1.x"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Upgrade to latest: pip install --upgrade isosurfaces. Use: from isosurfaces import marching_squares","cause":"Outdated version or incorrect import path.","error":"ImportError: cannot import name 'marching_squares' from 'isosurfaces'"},{"fix":"Call marching_squares(values, level) where level is a float, e.g., 0.0.","cause":"The second argument is the contour level (isovalue), not optional.","error":"TypeError: marching_squares() missing 1 required positional argument: 'level'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}