aosabook/500lines · error · NotImplementedError

Undefined method

Error message

Undefined method

What it means

Error "Undefined method" thrown in aosabook/500lines.

Source

Thrown at incomplete/rasterizer/rasterizer/shape.py:8

from color import Color
from itertools import product
from geometry import Vector
import random

class SceneObject:
    def draw(self, image):
        raise NotImplementedError("Undefined method")

class Shape(SceneObject):
    def __init__(self, color=None):
        self.color = color if color is not None else Color()
        self.bound = None
    def contains(self, p):
        raise NotImplementedError("Undefined method")
    def signed_distance_bound(self, p):
        raise NotImplementedError("Undefined method")
    def draw(self, image, super_sampling = 6):
        if not self.bound.overlaps(image.bounds()):
            return
        color = self.color
        r = float(image.resolution)
        jitter = [Vector((x + random.random()) / super_sampling / r,
                         (y + random.random()) / super_sampling / r)
                  for (x, y) in product(xrange(super_sampling), repeat=2)]
        lj = len(jitter)

View on GitHub (pinned to fba689d101)

Solutions

  1. Override draw(self, image) in the SceneObject subclass you are rendering.
  2. Do not call draw on SceneObject itself; it is an abstract base class.
  3. Check for typos in the subclass method name so the override actually replaces draw.

Example fix

class MyShape(SceneObject):
    def draw(self, image):
        ...  # concrete implementation

When it happens

Trigger: Thrown at incomplete/rasterizer/rasterizer/shape.py:8 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of aosabook/500lines@fba689d101 (2026-08-13). Data as JSON: /api/errors/746e5639f3df8373. Report an issue: GitHub.