No solution found

AssertionError: Override list has odd length

AssertionError: Override list has odd length: ['MODEL.WEIGHTS', 'checkpoints/ovseg_swinbase_vitL14_ft_mpt.pthuv', 'run', 'ovsam3-demo.py', '--config-file', 'configs/ovsam_seg_swinB_vitL.yaml', '--input', 'katomoko.png', '--class-names', 'person', 'dog', 'cat', 'car', 'tree', 'sky', '--output', 'output/result.png', 'MODEL.WEIGHTS', 'checkpoints/ovseg_swinbase_vitL14_ft_mpt.pth']; it must be a list of pairs
AssertionError: Override list has odd length: ['MODEL.WEIGHTS', 'checkpoints/ovseg_swinbase_vitL14_ft_mpt.pthuv', 'run', 'ovsam3-demo.py', '--config-file', 'configs/ovsam_seg_swinB_vitL.yaml', '--input', 'katomoko.png', '--class-names', 'person', 'dog', 'cat', 'car', 'tree', 'sky', '--output', 'output/result.png', 'MODEL.WEIGHTS', 'checkpoints/ovseg_swinbase_vitL14_ft_mpt.pth']; it must be a list of pairs

AssertionError even though they should be equal

assert c == engine.Value(-2.0)
       ^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Cause

In Python, == for custom classes compares memory addresses.

Solution

  1. Compare by value: assert obj.data = expected
  2. Implement __eq__: define the behavior when == is called

uv sync was unable to install the package because of a package name and build backend configuration mistake

uv run pytest
> from micrograd.engine import Value
E   ModuleNotFoundError: No module named 'micrograd'

Cause

There were three issues in pyproject.toml, so uv sync did not install the package into .venv.

  1. [build-systems] (plural) → should be [build-system] (singular) The PEP 517 table name must be build-system. With the plural form, uv cannot recognize the build configuration and the package is not installed.
  2. hatching → should be hatchling A package named hatching does exist on PyPI, but it is something else (with a requests dependency). Hatch's official build backend is hatchling.doc
  3. Missing packages = ["micrograd"] By default, Hatchling looks for a directory with the same name as the project (neural_networks/), but this project's directory is micrograd/, so auto-detection fails. You need to explicitly specify the package directory.doc

Solution

Modify pyproject.toml as follows and run uv sync again.

[tool.hatch.build.targets.wheel]
packages = ["micrograd"]              # ← Added: explicitly specify the package directory

[build-system]
requires = ["hatchling"]              # ← corrected: hatching → hatchling
build-backend = "hatchling.build"     # ← corrected: hatching → hatchling
[tool.hatch.build.targets.wheel]
packages = ["micrograd"]              # ← Added: explicitly specify the package directory

[build-system]
requires = ["hatchling"]              # ← corrected: hatching → hatchling
build-backend = "hatchling.build"     # ← corrected: hatching → hatchling

→ After uv sync, micrograd will be installed into the .venv site-packages, and pytest will pass.