xobjects 0.4.3__tar.gz → 0.4.5__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 (92) hide show
  1. {xobjects-0.4.3 → xobjects-0.4.5}/PKG-INFO +1 -1
  2. xobjects-0.4.5/xobjects/_version.py +1 -0
  3. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/capi.py +1 -1
  4. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/context.py +14 -3
  5. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/context_cpu.py +6 -0
  6. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/context_cupy.py +0 -1
  7. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects.egg-info/PKG-INFO +1 -1
  8. xobjects-0.4.3/xobjects/_version.py +0 -1
  9. {xobjects-0.4.3 → xobjects-0.4.5}/.github/workflows/black.yml +0 -0
  10. {xobjects-0.4.3 → xobjects-0.4.5}/.gitignore +0 -0
  11. {xobjects-0.4.3 → xobjects-0.4.5}/.pre-commit-config.yaml +0 -0
  12. {xobjects-0.4.3 → xobjects-0.4.5}/.readthedocs.yaml +0 -0
  13. {xobjects-0.4.3 → xobjects-0.4.5}/Architecture.md +0 -0
  14. {xobjects-0.4.3 → xobjects-0.4.5}/LICENSE +0 -0
  15. {xobjects-0.4.3 → xobjects-0.4.5}/Readme.md +0 -0
  16. {xobjects-0.4.3 → xobjects-0.4.5}/contributors_and_credits.txt +0 -0
  17. {xobjects-0.4.3 → xobjects-0.4.5}/docs/Makefile +0 -0
  18. {xobjects-0.4.3 → xobjects-0.4.5}/docs/architecture/contexts.rst +0 -0
  19. {xobjects-0.4.3 → xobjects-0.4.5}/docs/architecture/types.rst +0 -0
  20. {xobjects-0.4.3 → xobjects-0.4.5}/docs/architecture.rst +0 -0
  21. {xobjects-0.4.3 → xobjects-0.4.5}/docs/conf.py +0 -0
  22. {xobjects-0.4.3 → xobjects-0.4.5}/docs/index.rst +0 -0
  23. {xobjects-0.4.3 → xobjects-0.4.5}/docs/make.bat +0 -0
  24. {xobjects-0.4.3 → xobjects-0.4.5}/docs/quickstart.rst +0 -0
  25. {xobjects-0.4.3 → xobjects-0.4.5}/docs/reference.rst +0 -0
  26. {xobjects-0.4.3 → xobjects-0.4.5}/examples/api_def.py +0 -0
  27. {xobjects-0.4.3 → xobjects-0.4.5}/examples/api_init.py +0 -0
  28. {xobjects-0.4.3 → xobjects-0.4.5}/examples/capi_example.c +0 -0
  29. {xobjects-0.4.3 → xobjects-0.4.5}/examples/check_assembly.c +0 -0
  30. {xobjects-0.4.3 → xobjects-0.4.5}/examples/ex_array_init_perf.py +0 -0
  31. {xobjects-0.4.3 → xobjects-0.4.5}/examples/ex_cpugpu.py +0 -0
  32. {xobjects-0.4.3 → xobjects-0.4.5}/examples/ex_nested_ref.py +0 -0
  33. {xobjects-0.4.3 → xobjects-0.4.5}/examples/ex_ref_cpu.py +0 -0
  34. {xobjects-0.4.3 → xobjects-0.4.5}/examples/ex_struct_cpu.py +0 -0
  35. {xobjects-0.4.3 → xobjects-0.4.5}/examples/ex_unionref_cpu.py +0 -0
  36. {xobjects-0.4.3 → xobjects-0.4.5}/examples/ex_unionref_method.py +0 -0
  37. {xobjects-0.4.3 → xobjects-0.4.5}/examples/init_soa.py +0 -0
  38. {xobjects-0.4.3 → xobjects-0.4.5}/examples/issue_with_two_pyopencl_contexts.py +0 -0
  39. {xobjects-0.4.3 → xobjects-0.4.5}/examples/kernel_basics/kernel_cffi.py +0 -0
  40. {xobjects-0.4.3 → xobjects-0.4.5}/examples/kernel_basics/kernel_cupy.py +0 -0
  41. {xobjects-0.4.3 → xobjects-0.4.5}/examples/kernel_basics/kernel_pyopencl.py +0 -0
  42. {xobjects-0.4.3 → xobjects-0.4.5}/examples/opencl_offsets.py +0 -0
  43. {xobjects-0.4.3 → xobjects-0.4.5}/examples/simple_kernel.py +0 -0
  44. {xobjects-0.4.3 → xobjects-0.4.5}/examples/sixtracklib.py +0 -0
  45. {xobjects-0.4.3 → xobjects-0.4.5}/mktest +0 -0
  46. {xobjects-0.4.3 → xobjects-0.4.5}/pyproject.toml +0 -0
  47. {xobjects-0.4.3 → xobjects-0.4.5}/release.sh +0 -0
  48. {xobjects-0.4.3 → xobjects-0.4.5}/requirements.txt +0 -0
  49. {xobjects-0.4.3 → xobjects-0.4.5}/setup.cfg +0 -0
  50. {xobjects-0.4.3 → xobjects-0.4.5}/setup.py +0 -0
  51. {xobjects-0.4.3 → xobjects-0.4.5}/tests/__init__.py +0 -0
  52. {xobjects-0.4.3 → xobjects-0.4.5}/tests/__pycache__/test_context.cpython-37-pytest-6.2.1.pyc +0 -0
  53. {xobjects-0.4.3 → xobjects-0.4.5}/tests/notest_capi.py +0 -0
  54. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_align.py +0 -0
  55. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_array.py +0 -0
  56. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_buffer.py +0 -0
  57. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_capi.py +0 -0
  58. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_chunk.py +0 -0
  59. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_context_opencl.py +0 -0
  60. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_hybrid_class.py +0 -0
  61. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_kernel.py +0 -0
  62. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_linked_array.py +0 -0
  63. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_nplike_arrays.py +0 -0
  64. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_ref.py +0 -0
  65. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_scalars.py +0 -0
  66. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_shared_memory.py +0 -0
  67. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_strides.py +0 -0
  68. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_string.py +0 -0
  69. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_struct.py +0 -0
  70. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_to_json.py +0 -0
  71. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_typeutils.py +0 -0
  72. {xobjects-0.4.3 → xobjects-0.4.5}/tests/test_unionref.py +0 -0
  73. {xobjects-0.4.3 → xobjects-0.4.5}/update_cprght_statement.py +0 -0
  74. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/__init__.py +0 -0
  75. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/_patch_pyopencl_array.py +0 -0
  76. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/array.py +0 -0
  77. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/context_pyopencl.py +0 -0
  78. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/general.py +0 -0
  79. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/hybrid_class.py +0 -0
  80. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/linkedarray.py +0 -0
  81. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/ref.py +0 -0
  82. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/scalar.py +0 -0
  83. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/specialize_source.py +0 -0
  84. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/string.py +0 -0
  85. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/struct.py +0 -0
  86. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/test_helpers.py +0 -0
  87. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/typeutils.py +0 -0
  88. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects/union.py +0 -0
  89. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects.egg-info/SOURCES.txt +0 -0
  90. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects.egg-info/dependency_links.txt +0 -0
  91. {xobjects-0.4.3 → xobjects-0.4.5}/xobjects.egg-info/requires.txt +0 -0
  92. {xobjects-0.4.3 → xobjects-0.4.5}/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.4.3
3
+ Version: 0.4.5
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
@@ -0,0 +1 @@
1
+ __version__ = "0.4.5"
@@ -471,7 +471,7 @@ def gen_method_switch(cls, path, conf, method):
471
471
  #endif"""
472
472
  )
473
473
  lst.append(" }")
474
- lst.append(" return 0;")
474
+ lst.append(f" return{'' if method.ret is None else ' 0'};")
475
475
  lst.append("}")
476
476
  return "\n".join(lst), kernel
477
477
 
@@ -210,19 +210,30 @@ class XContext(ABC):
210
210
 
211
211
  def __init__(self):
212
212
  self._kernels = KernelDict()
213
- self._buffers = []
213
+ self._buffers = weakref.WeakSet()
214
+ self._allocations = 0
214
215
 
215
216
  def __str__(self):
216
217
  return type(self).__name__
217
218
 
218
219
  def new_buffer(self, capacity=1048576):
219
220
  buf = self._make_buffer(capacity=capacity)
220
- self.buffers.append(weakref.finalize(buf, log.debug, "free buf"))
221
+ self._buffers.add(buf)
222
+ self._allocations += 1
221
223
  return buf
222
224
 
225
+ def __getstate__(self):
226
+ state = self.__dict__
227
+ del state["_buffers"]
228
+ return state
229
+
230
+ def __setstate__(self, state):
231
+ self.__dict__.update(state)
232
+ self._buffers = weakref.WeakSet()
233
+
223
234
  @property
224
235
  def buffers(self):
225
- return self._buffers
236
+ return list(self._buffers)
226
237
 
227
238
  @property
228
239
  def kernels(self):
@@ -10,6 +10,7 @@ import sysconfig
10
10
  import uuid
11
11
  from pathlib import Path
12
12
  from typing import Callable, Dict, List, Sequence, Tuple
13
+ import weakref
13
14
 
14
15
  from .general import _print
15
16
 
@@ -106,6 +107,9 @@ class LinkedArrayCpu(BaseLinkedArray, np.ndarray):
106
107
  order="C",
107
108
  )
108
109
 
110
+ def copy(self):
111
+ return np.array(self)
112
+
109
113
 
110
114
  def _so_for_module_name(name, containing_dir=".") -> Path:
111
115
  # The so file name is something like:
@@ -642,10 +646,12 @@ class ContextCpu(XContext):
642
646
  def __getstate__(self):
643
647
  state = self.__dict__.copy()
644
648
  state["_kernels"] = {}
649
+ del state["_buffers"]
645
650
  return state
646
651
 
647
652
  def __setstate__(self, state):
648
653
  self.__dict__.update(state)
654
+ self._buffers = weakref.WeakSet()
649
655
 
650
656
 
651
657
  class BufferByteArray(XBuffer):
@@ -634,7 +634,6 @@ class KernelCupy(object):
634
634
  def __init__(
635
635
  self, function, description, block_size, context, shared_mem_size_bytes
636
636
  ):
637
-
638
637
  self.function = function
639
638
  self.description = description
640
639
  self.block_size = block_size
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xobjects
3
- Version: 0.4.3
3
+ Version: 0.4.5
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.4.3"
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
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