Skip to content

Commit

Permalink
Simplify. Every subclass of GPUObjectBase has a device in its _device…
Browse files Browse the repository at this point in the history
… field.
  • Loading branch information
fyellin committed Oct 5, 2024
1 parent 457b123 commit 078a672
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions tests_mem/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,13 @@ def core_test_func():
cls = objects[0].__class__
assert all(isinstance(objects[i], cls) for i in range(len(objects)))

# Test that everything that's a subclass of GPUObjectBase is either a
# GPUDevice and has None it its _device field, or is something else and has
# a GPUDevice in the _device field.
# Test that everything that's a subclass of GPUObjectBase has a device
# in its _device field.
if issubclass(cls, GPUObjectBase):
if issubclass(cls, GPUDevice):
assert all(objects[i]._device is None for i in range(len(objects)))
else:
assert all(
isinstance(objects[i]._device, GPUDevice)
for i in range(len(objects))
)
assert all(
isinstance(objects[i]._device, GPUDevice)
for i in range(len(objects))
)

# Test that class matches function name (should prevent a group of copy-paste errors)
assert ob_name == cls.__name__[3:]
Expand Down
2 changes: 1 addition & 1 deletion wgpu/_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ class GPUDevice(GPUObjectBase):
"""

def __init__(self, label, internal, adapter, features, limits, queue):
super().__init__(label, internal, None)
super().__init__(label, internal, self)

assert isinstance(adapter, GPUAdapter)
assert isinstance(features, set)
Expand Down

0 comments on commit 078a672

Please sign in to comment.