[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M69BKH5QHBR3DRWWHFT460DA":3,"skill-same:01M69BKH5QHBR3DRWWHFT460DA":58},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":30,"linkOnly":31,"markdownContent":32,"markdownBody":33,"frontMatter":34,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":41,"ownerDescription":42,"updatedAt":43,"install":44,"resources":57},"01M69BKH5QHBR3DRWWHFT460DA","python-testing",null,"Write and run Python tests for the VoxelPic library. USE FOR: adding new pytest test cases, understanding the Python API and test patterns, debugging Python test failures, or running the existing Python test suite.","microsoft\u002Fvoxelpic","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M69BKC93BJ9THG518QPTVV4F",0,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fvoxelpic\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fpython-testing\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[24,25,26,27,28,29],"testing","python","python testing","test","debugging","run","2026-11-10 10:12:30",false,"---\ndescription: \"Write and run Python tests for the VoxelPic library. USE FOR: adding new pytest test cases, understanding the Python API and test patterns, debugging Python test failures, or running the existing Python test suite.\"\n---\n\n# Testing the Python Library\n\n## Test Suite Overview\n\nPython tests live in `test\u002Ftest_python_api.py` and run with pytest. The test\nfile exercises the public API exposed by the `voxelpic` package — `encode`,\n`decode`, `image_shape`, `voxel_size`, `PointCloud`, and `DecodeResult` — which\ndelegate to the `_voxelpic` C extension module.\n\n| Test Function    | Parametrized | What It Tests                              |\n|------------------|--------------|--------------------------------------------|\n| `test_transcode` | depth 7,8,9  | Full encode → decode → re-encode round-trip |\n| `test_io`        | no           | `PointCloud.save()` \u002F `PointCloud.load()` binary I\u002FO |\n\n## Installing and Running\n\n```sh\npip install -e .[test]    # editable install with test dependencies\npytest -vv                # run all tests from repo root\n```\n\nThe `[test]` extra installs `pytest`, `pytest-md`, `pytest-emoji`, and\n`pytest-cov`.\n\n### Useful Commands\n\n```sh\npytest test\u002Ftest_python_api.py -vv                 # run only Python tests\npytest test\u002Ftest_python_api.py::test_transcode -vv # single test function\npytest test\u002Ftest_python_api.py::test_transcode[9]  # single parametrized case\npytest --cov=voxelpic --cov-report=term-missing    # with coverage\n```\n\n## Python API Surface\n\nThe C extension `_voxelpic` exposes four functions consumed by `src\u002Fvoxelpic.py`:\n\n| C Extension Function      | Python Wrapper              | Purpose                                |\n|---------------------------|-----------------------------|----------------------------------------|\n| `_voxelpic.encode()`      | `voxelpic.encode()`         | Point cloud → RGBA image               |\n| `_voxelpic.decode()`      | `voxelpic.decode()`         | RGBA image → `DecodeResult`            |\n| `_voxelpic.image_shape()` | `voxelpic.image_shape()`    | Image (height, width) for a depth      |\n| `_voxelpic.voxel_size()`  | `voxelpic.voxel_size()`     | Voxel side length for a depth          |\n\n### Key Types\n\n- `PointCloud` — `NamedTuple` with `positions` (Nx4 float32) and `colors`\n  (Nx4 uint8). Has `to3()` \u002F `to4()` conversion methods and `save()` \u002F `load()`\n  for binary I\u002FO.\n- `DecodeResult` — `NamedTuple` with `positions`, `colors`, `count`, `depth`.\n  Has a `.cloud` property that returns a `PointCloud`.\n\n### Array Constraints (validated in the C extension)\n\n- Positions: Nx4, dtype `float32`, C-contiguous.\n- Colors: Nx4, dtype `uint8`, C-contiguous.\n- Images: HxWx4, dtype `uint8`, C-contiguous.\n- Position and color arrays must have the same N dimension.\n\n## Conventions for Writing a New Test\n\n### File and Imports\n\nAdd tests to `test\u002Ftest_python_api.py` (or create a new `test\u002Ftest_*.py` file).\n\n```python\nimport numpy as np\nimport voxelpic as vp\nimport pytest\n```\n\n### Generating Test Data\n\nTests generate random data inline rather than reading from files:\n\n```python\npositions = np.random.rand(1000, 4).astype(np.float32) * 2 - 1\npositions[:, 3] = 1  # homogeneous w coordinate\ncolors = np.random.randint(0, 255, (1000, 4)).astype(np.uint8)\ncolors[:, 3] = 255   # alpha channel\ncloud = vp.PointCloud(positions, colors)\n```\n\n### Parametrization\n\nUse `@pytest.mark.parametrize` for depth variation:\n\n```python\n@pytest.mark.parametrize(\"depth\", [7, 8, 9])\ndef test_something(depth):\n    ...\n```\n\n### Assertions\n\nUse NumPy testing assertions for array comparisons:\n\n```python\nnp.testing.assert_array_equal(actual, expected)          # exact (uint8, int)\nnp.testing.assert_array_almost_equal(actual, expected)    # float tolerance\n```\n\nUse standard `assert` for scalar values:\n\n```python\nassert result.depth == depth\nassert image.shape == (height, width, 4)\n```\n\n### Fixtures\n\nUse pytest built-in fixtures. `tmp_path` provides a temporary directory per\ntest, useful for I\u002FO tests:\n\n```python\ndef test_io(tmp_path):\n    path = str(tmp_path \u002F \"cloud.dat\")\n    cloud.save(path)\n    loaded = vp.PointCloud.load(path)\n```\n\nNo custom fixtures or `conftest.py` exist — tests are self-contained.\n\n### Round-Trip Testing Pattern\n\nThe primary pattern is encode → decode → re-encode, verifying that the second\nencode produces an identical image:\n\n```python\nimage = vp.encode(cloud, depth=depth)\nresult = vp.decode(image)\nimage2 = vp.encode(result.cloud, depth=depth)\nnp.testing.assert_array_equal(image, image2)\n```\n\n### Testing Preallocated Buffers\n\nBoth `encode` and `decode` accept optional preallocated output arrays. Test both\nthe default allocation path and the preallocated path:\n\n```python\n# Default allocation\nimage = vp.encode(cloud, depth=depth)\n\n# Preallocated output\nh, w = vp.image_shape(depth)\nout = np.empty((h, w, 4), dtype=np.uint8)\nimage2 = vp.encode(cloud, depth=depth, out_image=out)\n```\n\n## Configuration\n\nThere is no `pytest.ini`, `conftest.py`, or `[tool.pytest.ini_options]` section.\nPytest uses default discovery: files matching `test_*.py` with functions matching\n`test_*`.\n","# Testing the Python Library\n\n## Test Suite Overview\n\nPython tests live in `test\u002Ftest_python_api.py` and run with pytest. The test\nfile exercises the public API exposed by the `voxelpic` package — `encode`,\n`decode`, `image_shape`, `voxel_size`, `PointCloud`, and `DecodeResult` — which\ndelegate to the `_voxelpic` C extension module.\n\n| Test Function    | Parametrized | What It Tests                              |\n|------------------|--------------|--------------------------------------------|\n| `test_transcode` | depth 7,8,9  | Full encode → decode → re-encode round-trip |\n| `test_io`        | no           | `PointCloud.save()` \u002F `PointCloud.load()` binary I\u002FO |\n\n## Installing and Running\n\n```sh\npip install -e .[test]    # editable install with test dependencies\npytest -vv                # run all tests from repo root\n```\n\nThe `[test]` extra installs `pytest`, `pytest-md`, `pytest-emoji`, and\n`pytest-cov`.\n\n### Useful Commands\n\n```sh\npytest test\u002Ftest_python_api.py -vv                 # run only Python tests\npytest test\u002Ftest_python_api.py::test_transcode -vv # single test function\npytest test\u002Ftest_python_api.py::test_transcode[9]  # single parametrized case\npytest --cov=voxelpic --cov-report=term-missing    # with coverage\n```\n\n## Python API Surface\n\nThe C extension `_voxelpic` exposes four functions consumed by `src\u002Fvoxelpic.py`:\n\n| C Extension Function      | Python Wrapper              | Purpose                                |\n|---------------------------|-----------------------------|----------------------------------------|\n| `_voxelpic.encode()`      | `voxelpic.encode()`         | Point cloud → RGBA image               |\n| `_voxelpic.decode()`      | `voxelpic.decode()`         | RGBA image → `DecodeResult`            |\n| `_voxelpic.image_shape()` | `voxelpic.image_shape()`    | Image (height, width) for a depth      |\n| `_voxelpic.voxel_size()`  | `voxelpic.voxel_size()`     | Voxel side length for a depth          |\n\n### Key Types\n\n- `PointCloud` — `NamedTuple` with `positions` (Nx4 float32) and `colors`\n  (Nx4 uint8). Has `to3()` \u002F `to4()` conversion methods and `save()` \u002F `load()`\n  for binary I\u002FO.\n- `DecodeResult` — `NamedTuple` with `positions`, `colors`, `count`, `depth`.\n  Has a `.cloud` property that returns a `PointCloud`.\n\n### Array Constraints (validated in the C extension)\n\n- Positions: Nx4, dtype `float32`, C-contiguous.\n- Colors: Nx4, dtype `uint8`, C-contiguous.\n- Images: HxWx4, dtype `uint8`, C-contiguous.\n- Position and color arrays must have the same N dimension.\n\n## Conventions for Writing a New Test\n\n### File and Imports\n\nAdd tests to `test\u002Ftest_python_api.py` (or create a new `test\u002Ftest_*.py` file).\n\n```python\nimport numpy as np\nimport voxelpic as vp\nimport pytest\n```\n\n### Generating Test Data\n\nTests generate random data inline rather than reading from files:\n\n```python\npositions = np.random.rand(1000, 4).astype(np.float32) * 2 - 1\npositions[:, 3] = 1  # homogeneous w coordinate\ncolors = np.random.randint(0, 255, (1000, 4)).astype(np.uint8)\ncolors[:, 3] = 255   # alpha channel\ncloud = vp.PointCloud(positions, colors)\n```\n\n### Parametrization\n\nUse `@pytest.mark.parametrize` for depth variation:\n\n```python\n@pytest.mark.parametrize(\"depth\", [7, 8, 9])\ndef test_something(depth):\n    ...\n```\n\n### Assertions\n\nUse NumPy testing assertions for array comparisons:\n\n```python\nnp.testing.assert_array_equal(actual, expected)          # exact (uint8, int)\nnp.testing.assert_array_almost_equal(actual, expected)    # float tolerance\n```\n\nUse standard `assert` for scalar values:\n\n```python\nassert result.depth == depth\nassert image.shape == (height, width, 4)\n```\n\n### Fixtures\n\nUse pytest built-in fixtures. `tmp_path` provides a temporary directory per\ntest, useful for I\u002FO tests:\n\n```python\ndef test_io(tmp_path):\n    path = str(tmp_path \u002F \"cloud.dat\")\n    cloud.save(path)\n    loaded = vp.PointCloud.load(path)\n```\n\nNo custom fixtures or `conftest.py` exist — tests are self-contained.\n\n### Round-Trip Testing Pattern\n\nThe primary pattern is encode → decode → re-encode, verifying that the second\nencode produces an identical image:\n\n```python\nimage = vp.encode(cloud, depth=depth)\nresult = vp.decode(image)\nimage2 = vp.encode(result.cloud, depth=depth)\nnp.testing.assert_array_equal(image, image2)\n```\n\n### Testing Preallocated Buffers\n\nBoth `encode` and `decode` accept optional preallocated output arrays. Test both\nthe default allocation path and the preallocated path:\n\n```python\n# Default allocation\nimage = vp.encode(cloud, depth=depth)\n\n# Preallocated output\nh, w = vp.image_shape(depth)\nout = np.empty((h, w, 4), dtype=np.uint8)\nimage2 = vp.encode(cloud, depth=depth, out_image=out)\n```\n\n## Configuration\n\nThere is no `pytest.ini`, `conftest.py`, or `[tool.pytest.ini_options]` section.\nPytest uses default discovery: files matching `test_*.py` with functions matching\n`test_*`.\n",{"description":7},"main","2b1cba0f161069e2a8986c6ccbb2c35d1d6c0bf6",".github\u002Fskills\u002Fpython-testing",4,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fvoxelpic","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-03-21 08:43:05",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add microsoft\u002Fvoxelpic --skill python-testing",{"tool":50,"command":51},"bunx","bunx skills add microsoft\u002Fvoxelpic --skill python-testing",{"tool":53,"command":54},"pnpm","pnpm dlx skills add microsoft\u002Fvoxelpic --skill python-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fvoxelpic\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fpython-testing\u002FSKILL.md",true,[],[59,68],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":66,"publishedAt":30},"01M69BKFBK0EN21QYM79JV7W3H","c-testing","Write, build, and run C tests for the VoxelPic library. USE FOR: adding new C test cases, understanding the test data format, debugging test failures, or running the existing C test suite.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fvoxelpic\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fc-testing\u002FSKILL.md",[65],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[24,67,27,28,29],"c testing",{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":30},"01M69BKE3X494X2E5HQB3437FZ","bump-version","Bump the VoxelPic version to a user-specified value. USE FOR: setting or updating the project version across all files that embed it. Applies to requests like 'bump version to X.Y.Z', 'set version', or 'update version'.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fvoxelpic\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fbump-version\u002FSKILL.md",[],[75,76],"bump version","update"]