pyopencl 2024.3__cp38-cp38-macosx_10_14_x86_64.whl → 2025.1__cp38-cp38-macosx_10_14_x86_64.whl

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.

Potentially problematic release.


This version of pyopencl might be problematic. Click here for more details.

Binary file
pyopencl/array.py CHANGED
@@ -32,7 +32,7 @@ import builtins
32
32
  from dataclasses import dataclass
33
33
  from functools import reduce
34
34
  from numbers import Number
35
- from typing import Any, Dict, Hashable, List, Optional, Tuple, Union
35
+ from typing import Any, Dict, List, Optional, Tuple, Union
36
36
  from warnings import warn
37
37
 
38
38
  import numpy as np
@@ -58,20 +58,14 @@ else:
58
58
  _SVMPointer_or_nothing = ()
59
59
 
60
60
 
61
- _NUMPY_PRE_2 = np.__version__.startswith("1.")
62
-
63
-
64
61
  # {{{ _get_common_dtype
65
62
 
66
- _COMMON_DTYPE_CACHE: Dict[Tuple[Hashable, ...], np.dtype] = {}
67
-
68
-
69
63
  class DoubleDowncastWarning(UserWarning):
70
64
  pass
71
65
 
72
66
 
73
67
  _DOUBLE_DOWNCAST_WARNING = (
74
- "The operation you requested would result in a double-precisision "
68
+ "The operation you requested would result in a double-precision "
75
69
  "quantity according to numpy semantics. Since your device does not "
76
70
  "support double precision, a single-precision quantity is being returned.")
77
71
 
@@ -81,78 +75,12 @@ def _get_common_dtype(obj1, obj2, queue):
81
75
  raise ValueError("PyOpenCL array has no queue; call .with_queue() to "
82
76
  "add one in order to be able to perform operations")
83
77
 
84
- allow_double = has_double_support(queue.device)
85
- cache_key = None
86
- o1_is_array = isinstance(obj1, Array)
87
- o2_is_array = isinstance(obj2, Array)
88
-
89
- if o1_is_array and o2_is_array:
90
- o1_dtype = obj1.dtype
91
- o2_dtype = obj2.dtype
92
- cache_key = (obj1.dtype, obj2.dtype, allow_double)
93
- else:
94
- o1_dtype = getattr(obj1, "dtype", type(obj1))
95
- o2_dtype = getattr(obj2, "dtype", type(obj2))
96
-
97
- o1_is_integral = np.issubdtype(o1_dtype, np.integer)
98
- o2_is_integral = np.issubdtype(o1_dtype, np.integer)
99
-
100
- o1_key = obj1 if o1_is_integral and not o1_is_array else o1_dtype
101
- o2_key = obj2 if o2_is_integral and not o2_is_array else o2_dtype
78
+ # Note: We are calling np.result_type with pyopencl arrays here.
79
+ # Luckily, np.result_type only looks at the dtype of input arrays up until
80
+ # at least numpy v2.1.
81
+ result = np.result_type(obj1, obj2)
102
82
 
103
- cache_key = (o1_key, o2_key, o1_is_array, o2_is_array, allow_double)
104
-
105
- try:
106
- return _COMMON_DTYPE_CACHE[cache_key]
107
- except KeyError:
108
- pass
109
-
110
- # Numpy's behavior around integers is a bit bizarre, and definitely value-
111
- # and not just type-sensitive when it comes to scalars. We'll just do our
112
- # best to emulate it.
113
- #
114
- # Some samples that are true as of numpy 1.23.1.
115
- #
116
- # >>> a = np.zeros(1, dtype=np.int16)
117
- # >>> (a + 123123123312).dtype
118
- # dtype('int64')
119
- # >>> (a + 12312).dtype
120
- # dtype('int16')
121
- # >>> (a + 12312444).dtype
122
- # dtype('int32')
123
- # >>> (a + np.int32(12312444)).dtype
124
- # dtype('int32')
125
- # >>> (a + np.int32(1234)).dtype
126
- # dtype('int16')
127
- #
128
- # Note that np.find_common_type, while appealing, won't be able to tell
129
- # the full story.
130
-
131
- if (_NUMPY_PRE_2
132
- and not (o1_is_array and o2_is_array)
133
- and o1_is_integral and o2_is_integral):
134
- if o1_is_array:
135
- obj1 = np.zeros(1, dtype=o1_dtype)
136
- if o2_is_array:
137
- obj2 = np.zeros(1, dtype=o2_dtype)
138
-
139
- result = (obj1 + obj2).dtype
140
- else:
141
- array_types = []
142
- scalars = []
143
-
144
- if o1_is_array:
145
- array_types.append(o1_dtype)
146
- else:
147
- scalars.append(obj1)
148
- if o2_is_array:
149
- array_types.append(o2_dtype)
150
- else:
151
- scalars.append(obj2)
152
-
153
- result = np.result_type(*array_types, *scalars)
154
-
155
- if not allow_double:
83
+ if not has_double_support(queue.device):
156
84
  if result == np.float64:
157
85
  result = np.dtype(np.float32)
158
86
  warn(_DOUBLE_DOWNCAST_WARNING, DoubleDowncastWarning, stacklevel=3)
@@ -160,9 +88,6 @@ def _get_common_dtype(obj1, obj2, queue):
160
88
  result = np.dtype(np.complex64)
161
89
  warn(_DOUBLE_DOWNCAST_WARNING, DoubleDowncastWarning, stacklevel=3)
162
90
 
163
- if cache_key is not None:
164
- _COMMON_DTYPE_CACHE[cache_key] = result
165
-
166
91
  return result
167
92
 
168
93
  # }}}
@@ -2518,7 +2443,7 @@ def arange(queue, *args, **kwargs):
2518
2443
  raise TypeError("arange requires a dtype argument")
2519
2444
 
2520
2445
  from math import ceil
2521
- size = int(ceil((stop-start)/step))
2446
+ size = ceil((stop-start)/step)
2522
2447
 
2523
2448
  result = Array(queue, (size,), dtype, allocator=inf.allocator)
2524
2449
  result.add_event(_arange_knl(result, start, step, queue=queue))
pyopencl/cltypes.py CHANGED
@@ -50,7 +50,7 @@ double = np.float64
50
50
  # {{{ vector types
51
51
 
52
52
  def _create_vector_types():
53
- _mapping = [(k, globals()[k]) for k in
53
+ mapping = [(k, globals()[k]) for k in
54
54
  ["char", "uchar", "short", "ushort", "int",
55
55
  "uint", "long", "ulong", "float", "double"]]
56
56
 
@@ -64,7 +64,7 @@ def _create_vector_types():
64
64
 
65
65
  counts = [2, 3, 4, 8, 16]
66
66
 
67
- for base_name, base_type in _mapping:
67
+ for base_name, base_type in mapping:
68
68
  for count in counts:
69
69
  name = "%s%d" % (base_name, count)
70
70
 
pyopencl/version.py CHANGED
@@ -3,7 +3,7 @@ from importlib import metadata
3
3
 
4
4
 
5
5
  VERSION_TEXT = metadata.version("pyopencl")
6
- _match = re.match("^([0-9.]+)([a-z0-9]*?)$", VERSION_TEXT)
6
+ _match = re.match(r"^([0-9.]+)([a-z0-9]*?)$", VERSION_TEXT)
7
7
  assert _match is not None
8
8
  VERSION_STATUS = _match.group(2)
9
9
  VERSION = tuple(int(nr) for nr in _match.group(1).split("."))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyopencl
3
- Version: 2024.3
3
+ Version: 2025.1
4
4
  Summary: Python wrapper for OpenCL
5
5
  Author-Email: Andreas Kloeckner <inform@tiker.net>
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -1,20 +1,20 @@
1
1
  pyopencl/algorithm.py,sha256=8qqD_GqvuQguSCDWcrJCeA05xFMj8mpJH1y5O0tUqmM,51293
2
2
  pyopencl/clmath.py,sha256=lOxQzE6BEp5-nVRuGu0hgxzk_gcx7aTiy_hRFxAPmcI,8222
3
- pyopencl/_cl.cpython-38-darwin.so,sha256=G9k2mYFK-OnbaZljsSBa8QyPZo-4Z0Wc4F85ONMc0LI,470176
4
- pyopencl/version.py,sha256=PhHAIjtUGVQ2wTVlqgoOrcC_2rkvNMmqvy1rRDqWOhg,267
3
+ pyopencl/_cl.cpython-38-darwin.so,sha256=gjiWlyOPcMcChs7jagr1RMjnzh3NVvm_Jpm0MG3Qhz4,551536
4
+ pyopencl/version.py,sha256=k4ev2_LuJAomsl8CUq1IHcINH3DUnLqTuGkf5q-ua10,268
5
5
  pyopencl/capture_call.py,sha256=B2d4SkPrj4f8j5jLDmKHSmSLxK0k9646gKL2FYZkejQ,5694
6
6
  pyopencl/reduction.py,sha256=CrWJPDYNy4hxtCGgwq2fkWAQXjJ8zMLxV5CEbAh3Wb8,25533
7
7
  pyopencl/tools.py,sha256=eZdKtkwY34kPbMR9FuFAmQbDQG8vJdv1az_UPiGNxjE,45940
8
8
  pyopencl/elementwise.py,sha256=HxSSpC944TeJkok8LGeNjqRgfKucbjpLEw3IoGOqLGc,38625
9
9
  pyopencl/cache.py,sha256=EbTTIxXmrdcgjzqWQl7O_1EG1RqniHg5sjJQS_5LXIs,16000
10
10
  pyopencl/__init__.py,sha256=BDkk5adIO4tHSYxxx_O7W4cyTHALwJB1aPpX5BrKep8,81443
11
- pyopencl/cltypes.py,sha256=DdBVPBU2bRuIbT8ImhWFIQosrefMOkAa4mY4yoSnurc,4818
11
+ pyopencl/cltypes.py,sha256=Pkr7_oTkQhVHP-1JyfIWiE8ORpkQ3molOL986Sodvl0,4816
12
12
  pyopencl/invoker.py,sha256=hL5qMYOJpXEh2X1xbkkDaoYWRXgP-9fISY0N5VtL--8,14060
13
13
  pyopencl/ipython_ext.py,sha256=TUgxJa_w7tvXaKj6kPjiXNEKlxrwsJScQCD0khAA1kk,1915
14
14
  pyopencl/scan.py,sha256=Z4Ew6NE0VRNhxPItM4M8oCtPdif0yCclW-CcsFqScu0,65638
15
15
  pyopencl/_cluda.py,sha256=KKUxizD1iQEuZ_TmmFZNJ8IdXa8x8uT9HgB0nmAlYLw,2074
16
16
  pyopencl/_mymako.py,sha256=WzmwJ-9EyenDo6RNOcXZmVum886PsmPS2gLNmUBORsA,620
17
- pyopencl/array.py,sha256=tw-OcXsRyStFcpLEjq64aiuX9rvlcMzu4qtshyJOWY4,111773
17
+ pyopencl/array.py,sha256=tENUt-t3tso0LjQS4o6s2nXFwIOxzazOeTS3V-YpN2M,109612
18
18
  pyopencl/bitonic_sort.py,sha256=cHd7PHX0arDGJbhaB7AJVI9THVJE69lGuGiB08zeZJ0,8021
19
19
  pyopencl/bitonic_sort_templates.py,sha256=x2hJaR-9AO74C_X7bVTTSxQxGqoDrF2-nQxzmMCSCXs,16151
20
20
  pyopencl/clrandom.py,sha256=BciZJkcKaNzmqP8tfGdb5SPI4qMACSUtLbQTJaOT5kE,13044
@@ -36,7 +36,7 @@ pyopencl/cl/pyopencl-random123/threefry.cl,sha256=2WmQGxx5gPSv22UL9_MlXv0eMug91k
36
36
  pyopencl/cl/pyopencl-random123/philox.cl,sha256=vYcQH7Vw13Q3qkW5Nhy1HTUDbWLGKoloE1YP0VWk6vU,21740
37
37
  pyopencl/cl/pyopencl-random123/array.h,sha256=nIV0zDWYuybldNgtsh79icNtDXHYdDsSpFaWIvDTyw4,17088
38
38
  pyopencl/cl/pyopencl-random123/openclfeatures.h,sha256=pAPbl7JkQgJxulSuGGevpaI43P7PwiH2mYxtNfHq59M,2881
39
- pyopencl-2024.3.dist-info/RECORD,,
40
- pyopencl-2024.3.dist-info/WHEEL,sha256=g6j9D0VaV4Lw1YN2ZmRnyoaGI-oh_05KWJISEVoyO9o,114
41
- pyopencl-2024.3.dist-info/METADATA,sha256=3Y2AW8BahKcnAPNcX0jR65xiQPsUluv8sTbrVsCtZZc,4783
42
- pyopencl-2024.3.dist-info/licenses/LICENSE,sha256=wiBvs-UC54bB5DswWuvB66B96b4hkYw_VLt8IR0cBPI,15284
39
+ pyopencl-2025.1.dist-info/RECORD,,
40
+ pyopencl-2025.1.dist-info/WHEEL,sha256=g6j9D0VaV4Lw1YN2ZmRnyoaGI-oh_05KWJISEVoyO9o,114
41
+ pyopencl-2025.1.dist-info/METADATA,sha256=WUY6JEb89dxhMwOVvX9OJVBYPqzlqPNt1TypeIxsCkQ,4783
42
+ pyopencl-2025.1.dist-info/licenses/LICENSE,sha256=wiBvs-UC54bB5DswWuvB66B96b4hkYw_VLt8IR0cBPI,15284