xobjects 0.5.2__tar.gz → 0.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {xobjects-0.5.2/xobjects.egg-info → xobjects-0.5.3}/PKG-INFO +1 -1
  2. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_buffer.py +30 -0
  3. xobjects-0.5.3/xobjects/_version.py +1 -0
  4. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/context.py +5 -1
  5. {xobjects-0.5.2 → xobjects-0.5.3/xobjects.egg-info}/PKG-INFO +1 -1
  6. xobjects-0.5.2/xobjects/_version.py +0 -1
  7. {xobjects-0.5.2 → xobjects-0.5.3}/LICENSE +0 -0
  8. {xobjects-0.5.2 → xobjects-0.5.3}/pyproject.toml +0 -0
  9. {xobjects-0.5.2 → xobjects-0.5.3}/setup.cfg +0 -0
  10. {xobjects-0.5.2 → xobjects-0.5.3}/setup.py +0 -0
  11. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_align.py +0 -0
  12. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_array.py +0 -0
  13. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_capi.py +0 -0
  14. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_chunk.py +0 -0
  15. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_context_opencl.py +0 -0
  16. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_hybrid_class.py +0 -0
  17. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_kernel.py +0 -0
  18. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_linked_array.py +0 -0
  19. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_nplike_arrays.py +0 -0
  20. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_ref.py +0 -0
  21. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_scalars.py +0 -0
  22. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_shared_memory.py +0 -0
  23. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_strides.py +0 -0
  24. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_string.py +0 -0
  25. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_struct.py +0 -0
  26. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_to_json.py +0 -0
  27. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_typeutils.py +0 -0
  28. {xobjects-0.5.2 → xobjects-0.5.3}/tests/test_unionref.py +0 -0
  29. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/__init__.py +0 -0
  30. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/_patch_pyopencl_array.py +0 -0
  31. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/array.py +0 -0
  32. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/capi.py +0 -0
  33. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/context_cpu.py +0 -0
  34. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/context_cupy.py +0 -0
  35. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/context_pyopencl.py +0 -0
  36. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/general.py +0 -0
  37. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/hybrid_class.py +0 -0
  38. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/linkedarray.py +0 -0
  39. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/ref.py +0 -0
  40. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/scalar.py +0 -0
  41. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/specialize_source.py +0 -0
  42. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/string.py +0 -0
  43. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/struct.py +0 -0
  44. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/test_helpers.py +0 -0
  45. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/typeutils.py +0 -0
  46. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects/union.py +0 -0
  47. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects.egg-info/SOURCES.txt +0 -0
  48. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects.egg-info/dependency_links.txt +0 -0
  49. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects.egg-info/requires.txt +0 -0
  50. {xobjects-0.5.2 → xobjects-0.5.3}/xobjects.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xobjects
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: In-memory serialization and code generator for CPU and GPU
5
5
  Home-page: https://xsuite.readthedocs.io/
6
6
  Download-URL: https://pypi.python.org/pypi/xobjects
@@ -4,6 +4,7 @@
4
4
  # ########################################### #
5
5
 
6
6
  import numpy as np
7
+ import pytest
7
8
 
8
9
  import xobjects as xo
9
10
  from xobjects.test_helpers import for_all_test_contexts, requires_context
@@ -94,6 +95,35 @@ def test_free_simple(test_context):
94
95
  ch.free_string(offset)
95
96
  ch.check()
96
97
 
98
+ @for_all_test_contexts
99
+ def test_free(test_context):
100
+ class CheckFree(xo.Struct):
101
+ a = xo.Float64
102
+ ch = CheckFree(a=5, _context=test_context)
103
+ assert ch._buffer.capacity == 8
104
+ assert ch._buffer.chunks == []
105
+ with pytest.raises(ValueError, match="Cannot free outside of buffer"):
106
+ ch._buffer.free(-2, 8)
107
+ with pytest.raises(ValueError, match="Cannot free outside of buffer"):
108
+ ch._buffer.free(0, 10)
109
+ with pytest.raises(ValueError, match="Cannot free outside of buffer"):
110
+ ch._buffer.free(7,2)
111
+ ch._buffer.free(0,4)
112
+ assert len(ch._buffer.chunks) == 1
113
+ assert ch._buffer.chunks[0].start == 0
114
+ assert ch._buffer.chunks[0].end == 4
115
+ ch._buffer.free(0,4) # Does nothing
116
+ ch._buffer.free(2,4) # Increases free chunk
117
+ assert len(ch._buffer.chunks) == 1
118
+ assert ch._buffer.chunks[0].start == 0
119
+ assert ch._buffer.chunks[0].end == 6
120
+ ch._buffer.free(7,1)
121
+ assert len(ch._buffer.chunks) == 2
122
+ assert ch._buffer.chunks[0].start == 0
123
+ assert ch._buffer.chunks[0].end == 6
124
+ assert ch._buffer.chunks[1].start == 7
125
+ assert ch._buffer.chunks[1].end == 8
126
+
97
127
 
98
128
  @for_all_test_contexts
99
129
  def test_grow(test_context):
@@ -0,0 +1 @@
1
+ __version__ = "0.5.3"
@@ -472,9 +472,13 @@ class XBuffer(ABC):
472
472
  self.capacity = newcapacity
473
473
 
474
474
  def free(self, offset, size):
475
+ if offset < 0 or offset + size > self.capacity:
476
+ raise ValueError("Cannot free outside of buffer")
475
477
  nch = Chunk(offset, offset + size)
476
478
  # insert sorted
477
- if offset > self.chunks[-1].start: # new chuck at the end
479
+ if len(self.chunks) == 0:
480
+ self.chunks.append(nch)
481
+ elif offset > self.chunks[-1].start: # new chuck at the end
478
482
  self.chunks.append(nch)
479
483
  else: # new chuck needs to be inserted
480
484
  for ic, ch in enumerate(self.chunks):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xobjects
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: In-memory serialization and code generator for CPU and GPU
5
5
  Home-page: https://xsuite.readthedocs.io/
6
6
  Download-URL: https://pypi.python.org/pypi/xobjects
@@ -1 +0,0 @@
1
- __version__ = "0.5.2"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes