Commit d17668b
authored
Add __repr__ to core API classes and consolidate object protocol tests (#1538)
* Add __repr__ to core API classes and consolidate object protocol tests
- Add __repr__ methods to Stream, Event, Context, Buffer, ObjectCode, Kernel
- Create test_object_protocols.py with comprehensive tests for:
- Weak references (weakref.ref, WeakValueDict, WeakKeyDict, WeakSet)
- Hash consistency, distinctness, and small value guards
- Equality (reflexive, cross-type, same-type distinct objects)
- Collection usage (dict, set, weak collections)
- repr format validation with regex patterns
- Remove test_hashable.py, test_comparable.py, test_weakref.py (consolidated)
* Update __repr__ to use angle-bracket format for consistency
Change repr format from ClassName(...) to <ClassName ...> with
space-separated attributes for Stream, Event, Context, Buffer,
ObjectCode, and Kernel. This aligns with Device's existing format.
- Stream: add context handle to repr
- Buffer: show is_mapped=True for IPC-imported buffers
- Update test patterns to match new format
- Add comments to hash distinctness tests explaining rationale
* Add test for equality of objects created via from_handle
Verify that Stream, Buffer, and Kernel objects created via from_handle
compare equal (and have equal hashes) when wrapping the same underlying
handle. This addresses the review comment about testing same-handle equality.
* Remove test_hash_not_small and explicit assert messages
Address review feedback:
- Remove test_hash_not_small (not adding much value per cpcloud/rwgk)
- Remove explicit assert messages to let pytest provide better output
* Empty commit to retrigger CI1 parent e5e30e8 commit d17668b
22 files changed
Lines changed: 365 additions & 539 deletions
File tree
- cuda_core
- cuda/core
- _cpp
- _memory
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
337 | 341 | | |
338 | 342 | | |
339 | 343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
0 commit comments