summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2019-09-20 16:13:52 -0700
committerGitHub <noreply@github.com>2019-09-20 16:13:52 -0700
commit4ff3af387f93ff37f04f42458d4590c33f61fb9e (patch)
treeea7f6e2f50d7d6be6b74552b3957d616f222cfd0
parent61289fbb779f4b5faaf26e17902bb5e9683e745e (diff)
parente4bc314e28f1b2b5ab7283942efda1288dc7f02f (diff)
downloadnumpy-4ff3af387f93ff37f04f42458d4590c33f61fb9e.tar.gz
Merge pull request #14558 from WarrenWeckesser/update-doc-code
DOC: Fix code that generates the table in the 'Casting Rules' section.
-rw-r--r--doc/source/reference/ufuncs.rst68
1 files changed, 35 insertions, 33 deletions
diff --git a/doc/source/reference/ufuncs.rst b/doc/source/reference/ufuncs.rst
index d00e88b34..30e9a9171 100644
--- a/doc/source/reference/ufuncs.rst
+++ b/doc/source/reference/ufuncs.rst
@@ -228,45 +228,47 @@ can generate this table for your system with the code given in the Figure.
.. admonition:: Figure
- Code segment showing the "can cast safely" table for a 32-bit system.
+ Code segment showing the "can cast safely" table for a 64-bit system.
+ Generally the output depends on the system; your system might result in
+ a different table.
+ >>> mark = {False: ' -', True: ' ✓'}
>>> def print_table(ntypes):
- ... print 'X',
- ... for char in ntypes: print char,
- ... print
+ ... print('X ' + ' '.join(ntypes))
... for row in ntypes:
- ... print row,
+ ... print(row, end='')
... for col in ntypes:
- ... print int(np.can_cast(row, col)),
- ... print
+ ... print(mark[np.can_cast(row, col)], end='')
+ ... print()
+ ...
>>> print_table(np.typecodes['All'])
X ? b h i l q p B H I L Q P e f d g F D G S U V O M m
- ? 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
- b 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0
- h 0 0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0
- i 0 0 0 1 1 1 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 1 0 0
- V 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0
- O 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0
- M 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
- m 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
+ ? ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ b - ✓ ✓ ✓ ✓ ✓ ✓ - - - - - - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ h - - ✓ ✓ ✓ ✓ ✓ - - - - - - - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ i - - - ✓ ✓ ✓ ✓ - - - - - - - - ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ l - - - - ✓ ✓ ✓ - - - - - - - - ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ q - - - - ✓ ✓ ✓ - - - - - - - - ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ p - - - - ✓ ✓ ✓ - - - - - - - - ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ B - - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ H - - - ✓ ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ I - - - - ✓ ✓ ✓ - - ✓ ✓ ✓ ✓ - - ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ L - - - - - - - - - - ✓ ✓ ✓ - - ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ Q - - - - - - - - - - ✓ ✓ ✓ - - ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ P - - - - - - - - - - ✓ ✓ ✓ - - ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ - ✓
+ e - - - - - - - - - - - - - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - -
+ f - - - - - - - - - - - - - - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - -
+ d - - - - - - - - - - - - - - - ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ - -
+ g - - - - - - - - - - - - - - - - ✓ - - ✓ ✓ ✓ ✓ ✓ - -
+ F - - - - - - - - - - - - - - - - - ✓ ✓ ✓ ✓ ✓ ✓ ✓ - -
+ D - - - - - - - - - - - - - - - - - - ✓ ✓ ✓ ✓ ✓ ✓ - -
+ G - - - - - - - - - - - - - - - - - - - ✓ ✓ ✓ ✓ ✓ - -
+ S - - - - - - - - - - - - - - - - - - - - ✓ ✓ ✓ ✓ - -
+ U - - - - - - - - - - - - - - - - - - - - - ✓ ✓ ✓ - -
+ V - - - - - - - - - - - - - - - - - - - - - - ✓ ✓ - -
+ O - - - - - - - - - - - - - - - - - - - - - - ✓ ✓ - -
+ M - - - - - - - - - - - - - - - - - - - - - - ✓ ✓ ✓ -
+ m - - - - - - - - - - - - - - - - - - - - - - ✓ ✓ - ✓
You should note that, while included in the table for completeness,