Skip to content

Commit

Permalink
CUDA stubs docstring: Replace illegal escape sequence
Browse files Browse the repository at this point in the history
The escape sequence `\|` was added to the documentation for `or_` to
prevent Sphinx interpreting the pipe as the start of an inline
substitution start string, but this is an illegal escape sequence that
causes a warning, due to:

   python/cpython#77093

This causes further issues for tests that treat warnings as errors, see
e.g.:

   numba#8095

This commit resolves the issue by rewriting the expression as inline
code, and rewriting all other expressions in the docstrings for atomics
as inline code for consistency.
  • Loading branch information
gmarkall committed Jul 4, 2022
1 parent 77882b1 commit 215bcba
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions numba/cuda/stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ class atomic(Stub):
class add(Stub):
"""add(ary, idx, val)
Perform atomic ary[idx] += val. Supported on int32, float32, and
Perform atomic ``ary[idx] += val``. Supported on int32, float32, and
float64 operands only.
Returns the old value at the index location as if it is loaded
Expand All @@ -449,7 +449,7 @@ class add(Stub):
class sub(Stub):
"""sub(ary, idx, val)
Perform atomic ary[idx] -= val. Supported on int32, float32, and
Perform atomic ``ary[idx] -= val``. Supported on int32, float32, and
float64 operands only.
Returns the old value at the index location as if it is loaded
Expand All @@ -459,8 +459,8 @@ class sub(Stub):
class and_(Stub):
"""and_(ary, idx, val)
Perform atomic ary[idx] &= val. Supported on int32, int64, uint32 and
uint64 operands only.
Perform atomic ``ary[idx] &= val``. Supported on int32, int64, uint32
and uint64 operands only.
Returns the old value at the index location as if it is loaded
atomically.
Expand All @@ -469,18 +469,18 @@ class and_(Stub):
class or_(Stub):
"""or_(ary, idx, val)
Perform atomic ary[idx] \|= val. Supported on int32, int64, uint32 and
uint64 operands only.
Perform atomic ``ary[idx] |= val``. Supported on int32, int64, uint32
and uint64 operands only.
Returns the old value at the index location as if it is loaded
atomically.
""" # noqa: W605
"""

class xor(Stub):
"""xor(ary, idx, val)
Perform atomic ary[idx] ^= val. Supported on int32, int64, uint32 and
uint64 operands only.
Perform atomic ``ary[idx] ^= val``. Supported on int32, int64, uint32
and uint64 operands only.
Returns the old value at the index location as if it is loaded
atomically.
Expand All @@ -489,7 +489,7 @@ class xor(Stub):
class inc(Stub):
"""inc(ary, idx, val)
Perform atomic ary[idx] += 1 up to val, then reset to 0. Supported
Perform atomic ``ary[idx] += 1`` up to val, then reset to 0. Supported
on uint32, and uint64 operands only.
Returns the old value at the index location as if it is loaded
Expand All @@ -499,8 +499,10 @@ class inc(Stub):
class dec(Stub):
"""dec(ary, idx, val)
Perform ary[idx] = (value if (array[idx] == 0) or
(array[idx] > value) else array[idx] - 1).
Performs::
ary[idx] = (value if (array[idx] == 0) or
(array[idx] > value) else array[idx] - 1)
Supported on uint32, and uint64 operands only.
Expand All @@ -511,7 +513,7 @@ class dec(Stub):
class exch(Stub):
"""exch(ary, idx, val)
Perform atomic ary[idx] = val. Supported on int32, int64, uint32 and
Perform atomic ``ary[idx] = val``. Supported on int32, int64, uint32 and
uint64 operands only.
Returns the old value at the index location as if it is loaded
Expand All @@ -521,7 +523,7 @@ class exch(Stub):
class max(Stub):
"""max(ary, idx, val)
Perform atomic ary[idx] = max(ary[idx], val).
Perform atomic ``ary[idx] = max(ary[idx], val)``.
Supported on int32, int64, uint32, uint64, float32, float64 operands
only.
Expand All @@ -533,7 +535,7 @@ class max(Stub):
class min(Stub):
"""min(ary, idx, val)
Perform atomic ary[idx] = min(ary[idx], val).
Perform atomic ``ary[idx] = min(ary[idx], val)``.
Supported on int32, int64, uint32, uint64, float32, float64 operands
only.
Expand All @@ -545,7 +547,7 @@ class min(Stub):
class nanmax(Stub):
"""nanmax(ary, idx, val)
Perform atomic ary[idx] = max(ary[idx], val).
Perform atomic ``ary[idx] = max(ary[idx], val)``.
NOTE: NaN is treated as a missing value such that:
nanmax(NaN, n) == n, nanmax(n, NaN) == n
Expand All @@ -560,7 +562,7 @@ class nanmax(Stub):
class nanmin(Stub):
"""nanmin(ary, idx, val)
Perform atomic ary[idx] = min(ary[idx], val).
Perform atomic ``ary[idx] = min(ary[idx], val)``.
NOTE: NaN is treated as a missing value, such that:
nanmin(NaN, n) == n, nanmin(n, NaN) == n
Expand Down

0 comments on commit 215bcba

Please sign in to comment.