Compare commits
428 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32da86df26 | ||
|
|
e89f86b74f | ||
|
|
5013564316 | ||
|
|
fc68878e02 | ||
|
|
cfbefe893c | ||
|
|
6f5f3b6607 | ||
|
|
cabb466057 | ||
|
|
97402f7925 | ||
|
|
668bc7c106 | ||
|
|
5f5f38fa8a | ||
|
|
cc873d9682 | ||
|
|
20de46cd0c | ||
|
|
5d7b9a0648 | ||
|
|
608ec27c4d | ||
|
|
7fd39323ac | ||
|
|
2b6f667e98 | ||
|
|
aa458d2ca9 | ||
|
|
16627261f1 | ||
|
|
303299e677 | ||
|
|
cb95b611bb | ||
|
|
b4fb28e99a | ||
|
|
867f0dddfe | ||
|
|
a40bb656ee | ||
|
|
f604eb8d0f | ||
|
|
d30c1bb7a8 | ||
|
|
3e7be69e1e | ||
|
|
cbdf1ce2a1 | ||
|
|
4fe3403584 | ||
|
|
b1b43f1e1a | ||
|
|
7b1960446b | ||
|
|
2dc5a92727 | ||
|
|
4fc3afa3ac | ||
|
|
ff0ae9b29d | ||
|
|
b988d70207 | ||
|
|
b3a28d7033 | ||
|
|
3ea0cb8501 | ||
|
|
95e53011d8 | ||
|
|
301256cf1e | ||
|
|
c76d67ef3f | ||
|
|
0102b31945 | ||
|
|
4c6f40fb82 | ||
|
|
d1910f3d65 | ||
|
|
c4e3b13dc2 | ||
|
|
a498e2458c | ||
|
|
7a3cc07042 | ||
|
|
58b1a010bb | ||
|
|
8ca8724ad9 | ||
|
|
5a8d096135 | ||
|
|
30bdbf3ae2 | ||
|
|
5a07cdb96b | ||
|
|
06fa956fe8 | ||
|
|
9ab1742c46 | ||
|
|
071b0bc964 | ||
|
|
d8d9861036 | ||
|
|
f6d20e1099 | ||
|
|
99a5352b5c | ||
|
|
1fed0824ad | ||
|
|
0474de0f6c | ||
|
|
6c3f3ecacf | ||
|
|
47d5bc76f6 | ||
|
|
508da1d198 | ||
|
|
271bcea8bf | ||
|
|
fdd3e8b2c1 | ||
|
|
a218babc8d | ||
|
|
41e208ecb5 | ||
|
|
f028aa4076 | ||
|
|
a060d43bf2 | ||
|
|
8dd1511773 | ||
|
|
909a4d1530 | ||
|
|
aee2667407 | ||
|
|
209179fa09 | ||
|
|
5e77eabb63 | ||
|
|
ecda18f01e | ||
|
|
2a82afdf6d | ||
|
|
aca3c80c4f | ||
|
|
68fa9dccde | ||
|
|
f5d14ef15e | ||
|
|
f7254f5d8a | ||
|
|
bffcb99ae7 | ||
|
|
cbd2d9f033 | ||
|
|
0f1945060f | ||
|
|
30dd3fe8b1 | ||
|
|
500194edb7 | ||
|
|
cd953cff06 | ||
|
|
5e4f6278e0 | ||
|
|
108c93f7c3 | ||
|
|
3dd6bcf39f | ||
|
|
97a8550a9f | ||
|
|
c9521a8ef5 | ||
|
|
8328a4f535 | ||
|
|
cc973263c4 | ||
|
|
f1320bf30b | ||
|
|
d9f06052e2 | ||
|
|
9ad5298d0b | ||
|
|
944fa075b3 | ||
|
|
b4fbf1840b | ||
|
|
ec402ea0d7 | ||
|
|
60405cc48c | ||
|
|
9e1132f4f5 | ||
|
|
bf824c1b98 | ||
|
|
01ab510585 | ||
|
|
5e2d55d801 | ||
|
|
17886fc296 | ||
|
|
15115eb1f8 | ||
|
|
1727b67a5a | ||
|
|
0a9b687e9e | ||
|
|
8c8b0dc215 | ||
|
|
fdc9ec760f | ||
|
|
102acf1d34 | ||
|
|
0b0c0536d6 | ||
|
|
0d0cd711a7 | ||
|
|
72e254bf8b | ||
|
|
1f1b9b6aef | ||
|
|
6bd6d71850 | ||
|
|
b9c0e58d57 | ||
|
|
4b01139720 | ||
|
|
65bfec2d97 | ||
|
|
4f6d547c0a | ||
|
|
90813b1ad7 | ||
|
|
b644946368 | ||
|
|
c7799aa44f | ||
|
|
02095af952 | ||
|
|
6f72675bff | ||
|
|
ed4776b59c | ||
|
|
ac62db1cf1 | ||
|
|
b4230e98f6 | ||
|
|
467a89eba7 | ||
|
|
28e2c6512c | ||
|
|
b0f512c15a | ||
|
|
77ff0d6bbc | ||
|
|
24313709a7 | ||
|
|
ac9fa536c8 | ||
|
|
7352c9c0f7 | ||
|
|
26ac881b9d | ||
|
|
19f6c782aa | ||
|
|
f3df1bf912 | ||
|
|
a383ecdd88 | ||
|
|
d515eb82c8 | ||
|
|
0021720a46 | ||
|
|
61591f7ad2 | ||
|
|
6b8ab7a5a3 | ||
|
|
02e079cf4d | ||
|
|
9039286937 | ||
|
|
429ac28c4a | ||
|
|
1db3871f50 | ||
|
|
66dad425aa | ||
|
|
ed3cbf8a60 | ||
|
|
2f6e728de5 | ||
|
|
65be0e0f0f | ||
|
|
d4d41d94ae | ||
|
|
660487c43f | ||
|
|
d6d54ce483 | ||
|
|
7c33ff0c59 | ||
|
|
b9d0d97499 | ||
|
|
fc978f085b | ||
|
|
ebba009a9f | ||
|
|
9ad3313d1f | ||
|
|
bf9a03399b | ||
|
|
2d9871fc5a | ||
|
|
30c9eb1fb6 | ||
|
|
7c5e478432 | ||
|
|
2b7842a39f | ||
|
|
8d37630cc8 | ||
|
|
9d2903cd5e | ||
|
|
b09d80a93e | ||
|
|
135c025484 | ||
|
|
ecf05c4a90 | ||
|
|
00b7ed03a7 | ||
|
|
fed4f0d0f9 | ||
|
|
39edfd45cf | ||
|
|
c2424bcc8f | ||
|
|
b3b67273b0 | ||
|
|
8c2a808cbe | ||
|
|
31c8b7f1b4 | ||
|
|
aeedea409a | ||
|
|
2d1f66fd19 | ||
|
|
69e38d2186 | ||
|
|
df6926551e | ||
|
|
8536e97c67 | ||
|
|
142661dac8 | ||
|
|
d6554d6c65 | ||
|
|
90829714cc | ||
|
|
664d443df3 | ||
|
|
c4fe369d69 | ||
|
|
7cfc47008e | ||
|
|
1452dfe713 | ||
|
|
3613142839 | ||
|
|
b2f53e1acf | ||
|
|
3844c4fc5f | ||
|
|
7d3df3d3a7 | ||
|
|
df16e3e55e | ||
|
|
ae747521b0 | ||
|
|
3066c73c09 | ||
|
|
edd890bd2b | ||
|
|
352792c90a | ||
|
|
47faef65ee | ||
|
|
5e4b44e0af | ||
|
|
5121fc11f9 | ||
|
|
07b1489f3b | ||
|
|
471e6181b2 | ||
|
|
44ea0562b2 | ||
|
|
60fba03e99 | ||
|
|
398e7f02b8 | ||
|
|
1e315242ce | ||
|
|
77ee91d5c5 | ||
|
|
e3c9dd78aa | ||
|
|
e670de2795 | ||
|
|
367b793ac9 | ||
|
|
8c170d9193 | ||
|
|
bd7b8ecba5 | ||
|
|
0224f54ae0 | ||
|
|
d14b8cf411 | ||
|
|
4e0b96faa8 | ||
|
|
7178a70176 | ||
|
|
aaf9022770 | ||
|
|
36bbdde2fe | ||
|
|
1df6d84b80 | ||
|
|
e968329174 | ||
|
|
07c8cbe652 | ||
|
|
163e469bc4 | ||
|
|
ac39d2ed69 | ||
|
|
264f6ae4b9 | ||
|
|
84c96447e2 | ||
|
|
dc8d68d3fc | ||
|
|
91512a971d | ||
|
|
88ea1f9626 | ||
|
|
731ba745ca | ||
|
|
080eb55be6 | ||
|
|
a3d8223b5d | ||
|
|
b9431cd326 | ||
|
|
2ccf54f091 | ||
|
|
4ce4821111 | ||
|
|
69ddfcae17 | ||
|
|
3ace4a0015 | ||
|
|
cbb3851488 | ||
|
|
127cc20a1d | ||
|
|
482219f20a | ||
|
|
061050c006 | ||
|
|
03adaee6d2 | ||
|
|
bc2f77a3db | ||
|
|
aaf0d220ae | ||
|
|
bb6f52dc35 | ||
|
|
d422058fb4 | ||
|
|
a60ab14b91 | ||
|
|
e0ee734161 | ||
|
|
444c948abe | ||
|
|
97e4b34a15 | ||
|
|
5029273ca8 | ||
|
|
63e3079a16 | ||
|
|
adfac2d139 | ||
|
|
d79b59616b | ||
|
|
8a58f716ac | ||
|
|
f3931cfc38 | ||
|
|
b0f6414269 | ||
|
|
76708620cb | ||
|
|
b877b98fee | ||
|
|
94dfa4c762 | ||
|
|
5c723e96ea | ||
|
|
b49a186b6f | ||
|
|
a5a08bfb7b | ||
|
|
e53a68defd | ||
|
|
f0d5bef32d | ||
|
|
e820537f3b | ||
|
|
c2d144ab71 | ||
|
|
55f283bf18 | ||
|
|
2e8cd3d8f2 | ||
|
|
b3e9290599 | ||
|
|
07dd8eaa55 | ||
|
|
81b3263743 | ||
|
|
7b7c4b85d5 | ||
|
|
f7d7c54173 | ||
|
|
68400823db | ||
|
|
905b34210b | ||
|
|
400f3db73a | ||
|
|
57cd933240 | ||
|
|
f399391be2 | ||
|
|
5233f45da4 | ||
|
|
63323f020f | ||
|
|
e9c265a84a | ||
|
|
f2c465ffa5 | ||
|
|
77bdbf0432 | ||
|
|
26aaa5b62e | ||
|
|
359b7f0473 | ||
|
|
52b268a8c6 | ||
|
|
e3aacc64fe | ||
|
|
f753f4bc30 | ||
|
|
9e53eb2c23 | ||
|
|
6c2e3fb487 | ||
|
|
fcbba59630 | ||
|
|
61a399e80a | ||
|
|
42b06fa3a3 | ||
|
|
f410fbd64d | ||
|
|
d18c7787e6 | ||
|
|
5dce79445d | ||
|
|
c41a1e8531 | ||
|
|
41c61dd756 | ||
|
|
0a4c76b9ac | ||
|
|
a0e849ed91 | ||
|
|
4dbb2784ee | ||
|
|
4d9ab505b0 | ||
|
|
3494381c01 | ||
|
|
bc13c4c600 | ||
|
|
73b8350e53 | ||
|
|
c509a3ab01 | ||
|
|
4c2070f39f | ||
|
|
e2c23fd5f9 | ||
|
|
7ff5465e7d | ||
|
|
e747cc9422 | ||
|
|
b46ccc4f51 | ||
|
|
be72aab254 | ||
|
|
5035f6e801 | ||
|
|
0b549aee88 | ||
|
|
bf73da1bce | ||
|
|
ca8ce585b7 | ||
|
|
81551cf6b6 | ||
|
|
e3bf3c6f51 | ||
|
|
c8798676f6 | ||
|
|
c9974daec2 | ||
|
|
b46dfd9064 | ||
|
|
956606ef0c | ||
|
|
0b59058fa2 | ||
|
|
2a41c80c58 | ||
|
|
42a57978ee | ||
|
|
4b99e6b83f | ||
|
|
49b536fbd3 | ||
|
|
2e47285fb5 | ||
|
|
45b588b85a | ||
|
|
cce7dfcf17 | ||
|
|
2f7742ffec | ||
|
|
46b959cceb | ||
|
|
ca3526c76a | ||
|
|
4ec94c676b | ||
|
|
a35cbd1af1 | ||
|
|
28a9fab278 | ||
|
|
ab2225bcbd | ||
|
|
dbe4903887 | ||
|
|
405f99cd3c | ||
|
|
313dcbb628 | ||
|
|
dca44829a6 | ||
|
|
46f6382fe4 | ||
|
|
99e6194620 | ||
|
|
4c2850cbfd | ||
|
|
029eb385ed | ||
|
|
77b89341d0 | ||
|
|
588027252b | ||
|
|
d61d41a786 | ||
|
|
1d3a535e53 | ||
|
|
65dc91f3da | ||
|
|
782ca7bf20 | ||
|
|
1a5a3e1701 | ||
|
|
00c61f4767 | ||
|
|
c20af50ae3 | ||
|
|
38e68fa2ae | ||
|
|
35a62fea52 | ||
|
|
b219376e24 | ||
|
|
1e66e33201 | ||
|
|
8f909d55ac | ||
|
|
05c21bcae1 | ||
|
|
0cb3bd7aa5 | ||
|
|
7a84a00673 | ||
|
|
9d7dfd8449 | ||
|
|
2a8823f745 | ||
|
|
beaa4b0e4d | ||
|
|
55c3b0569e | ||
|
|
2aca81bca9 | ||
|
|
32d2135462 | ||
|
|
7064cf3186 | ||
|
|
777e16e1d0 | ||
|
|
715e5cbc31 | ||
|
|
67b5b07976 | ||
|
|
7b088c9df2 | ||
|
|
3dda62f8b8 | ||
|
|
c33460c265 | ||
|
|
4c12b004ec | ||
|
|
5bed132ff8 | ||
|
|
3ffcf3335a | ||
|
|
c314274a56 | ||
|
|
437373456f | ||
|
|
7add755ae0 | ||
|
|
79182d7189 | ||
|
|
36e9e38373 | ||
|
|
45e52301e9 | ||
|
|
37a73f344b | ||
|
|
bbd9aad6e9 | ||
|
|
8fa1f9db9e | ||
|
|
9c56469358 | ||
|
|
196c9e653f | ||
|
|
c572b4db73 | ||
|
|
b2519a25a9 | ||
|
|
2979e4b062 | ||
|
|
88dd5330d0 | ||
|
|
fa51b58cd6 | ||
|
|
419b6ec973 | ||
|
|
085f574d6e | ||
|
|
69d9f34f3e | ||
|
|
36ee7d23f9 | ||
|
|
b269b4b124 | ||
|
|
20b68f2a2f | ||
|
|
2794a9bd15 | ||
|
|
0a76801936 | ||
|
|
daf466a697 | ||
|
|
718cfd468e | ||
|
|
3796825523 | ||
|
|
6904a166f7 | ||
|
|
39b9047190 | ||
|
|
930167e961 | ||
|
|
64b2c1697b | ||
|
|
f0345b2521 | ||
|
|
77ec571511 | ||
|
|
70c7fbd1d8 | ||
|
|
91a1119070 | ||
|
|
a300f7cdd0 | ||
|
|
65db10061f | ||
|
|
3d7f523384 | ||
|
|
252c3aa695 | ||
|
|
584df88fb2 | ||
|
|
ba1416fff0 | ||
|
|
42ca807c82 | ||
|
|
b988e8c45f | ||
|
|
c7db44f617 | ||
|
|
f3aecdf2f4 | ||
|
|
40bd0326f3 | ||
|
|
99d3a54ad5 | ||
|
|
c3d186e0bf | ||
|
|
e0fa8ec619 | ||
|
|
e2b2ebe862 | ||
|
|
eef2eef7dd | ||
|
|
189915bc8b |
7
.ci/faber
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# -*- python -*-
|
||||||
|
|
||||||
|
from faber.tools.boost import boostbook
|
||||||
|
from faber.tools.python import python
|
||||||
|
|
||||||
|
bb = boostbook(prefix='/usr/share/boostbook')
|
||||||
|
p = python(command='$PYTHON')
|
||||||
65
.github/get-py-env.py
vendored
Executable file
@@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# Determine info about the Python install and write shell code to stdout, to
|
||||||
|
# set env variables. This will set the variables PY_LDFLAGS, PY_CFLAGS and
|
||||||
|
# PY_INC_PATH.
|
||||||
|
#
|
||||||
|
# The python3-config tool is used as the source of this info. In theory we
|
||||||
|
# could use sysconfig as well but the setup-python action from github appears
|
||||||
|
# to patch python3-config but not patch the sysconfig info.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# eval $(python3 get-py-env.py)
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
def get_output(cmd):
|
||||||
|
rv = subprocess.run(
|
||||||
|
cmd,
|
||||||
|
capture_output=True, # Capture stdout and stderr
|
||||||
|
text=True, # Decode output as text (UTF-8)
|
||||||
|
check=True, # Raise an error if the command fails
|
||||||
|
)
|
||||||
|
return rv.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def extract_flags(cmd, prefix):
|
||||||
|
flags = []
|
||||||
|
for part in get_output(cmd).split():
|
||||||
|
part = part.strip()
|
||||||
|
if part.startswith(prefix):
|
||||||
|
flags.append(part)
|
||||||
|
return ' '.join(flags)
|
||||||
|
|
||||||
|
|
||||||
|
def find_python_h():
|
||||||
|
"""Find the include path that has Python.h contained inside.
|
||||||
|
We could use INCLUDEPY from sysconfig but github patches
|
||||||
|
python3-config but not the sysconfig info (after moving the
|
||||||
|
install).
|
||||||
|
"""
|
||||||
|
c_flags = extract_flags(['python3-config', '--cflags'], '-I')
|
||||||
|
for part in c_flags.split():
|
||||||
|
m = re.search(r'-I(\S+)', part)
|
||||||
|
if not m:
|
||||||
|
continue
|
||||||
|
inc_path = m.group(1)
|
||||||
|
if os.path.exists(os.path.join(inc_path, 'Python.h')):
|
||||||
|
return inc_path
|
||||||
|
raise SystemExit('cannot find Python.h')
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
ld_flags = extract_flags(['python3-config', '--ldflags'], '-L')
|
||||||
|
c_flags = extract_flags(['python3-config', '--cflags'], '-I')
|
||||||
|
include_path = find_python_h()
|
||||||
|
print(f'PY_LDFLAGS="{ld_flags}"')
|
||||||
|
print(f'PY_CFLAGS="{c_flags}"')
|
||||||
|
print(f'PY_INC_PATH="{include_path}"')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
46
.github/run-faber.sh
vendored
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "cxx version: $CXX $($CXX --version)"
|
||||||
|
echo "cxx std: $CXX_STD"
|
||||||
|
echo "python3 path: $(which python3)"
|
||||||
|
echo "python3 version: $(python3 --version)"
|
||||||
|
|
||||||
|
if ! which faber > /dev/null; then
|
||||||
|
echo "Installing faber..."
|
||||||
|
python3 -m pip install --upgrade pip
|
||||||
|
python3 -m pip install -U faber
|
||||||
|
fi
|
||||||
|
echo "faber version: $(faber -v)"
|
||||||
|
|
||||||
|
# find and set PY_LDFLAGS and PY_INC_PATH
|
||||||
|
eval $(python3 .github/get-py-env.py)
|
||||||
|
|
||||||
|
echo "PY_INC_PATH=$PY_INC_PATH"
|
||||||
|
echo "PY_LDFLAGS=$PY_LDFLAGS"
|
||||||
|
|
||||||
|
case $(python3-config --abiflags) in
|
||||||
|
*t*)
|
||||||
|
# When running with free-threaded, we always want to disable the GIL
|
||||||
|
# even for extensions without the mod_gil_not_used() flag
|
||||||
|
export PYTHON_GIL=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# this could be set by LD_LIBRARY_PATH but faber overrides it
|
||||||
|
prefix=$(python3-config --prefix)
|
||||||
|
echo "${prefix}/lib" > /etc/ld.so.conf.d/boost-ci.conf && ldconfig
|
||||||
|
|
||||||
|
sed -e "s/\$PYTHON/python3/g" .ci/faber > $HOME/.faber
|
||||||
|
|
||||||
|
faber \
|
||||||
|
--with-boost-include=${BOOST_PY_DEPS} \
|
||||||
|
--builddir=build \
|
||||||
|
cxx.name="${CXX}" \
|
||||||
|
cxxflags="-std=${CXX_STD}" \
|
||||||
|
cppflags="-std=${CXX_STD}" \
|
||||||
|
include="${PY_INC_PATH}" \
|
||||||
|
ldflags="${PY_LDFLAGS}" \
|
||||||
|
-j`nproc` \
|
||||||
|
"$@"
|
||||||
37
.github/workflows/deploy-documentation.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: deploy documentation
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: setup
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install \
|
||||||
|
libboost-tools-dev \
|
||||||
|
python3 \
|
||||||
|
python3-numpy \
|
||||||
|
python3-sphinx \
|
||||||
|
xsltproc \
|
||||||
|
docbook-xsl
|
||||||
|
sudo python3 -m pip install --upgrade pip
|
||||||
|
sudo python3 -m pip install faber
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
sed -e "s/\$PYTHON/python3/g" .ci/faber > ~/.faber
|
||||||
|
faber --builddir=build doc.html
|
||||||
|
if [ "${GITHUB_REF##*/}" == master ]; then
|
||||||
|
echo "destination_dir=doc/html" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "destination_dir=doc/develop/html" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
- name: deploy
|
||||||
|
uses: peaceiris/actions-gh-pages@v4
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_dir: build/doc/html
|
||||||
|
destination_dir: ${{ env.destination_dir }}
|
||||||
|
keep_files: true
|
||||||
50
.github/workflows/test-osx.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
name: Test OSX
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: macOS-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
python-version: [3.8.10]
|
||||||
|
cxx: [clang++]
|
||||||
|
std: [c++11, c++14] # TODO: c++17 is failing !
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: setup python
|
||||||
|
uses: actions/setup-python@v6
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: setup prerequisites
|
||||||
|
run: |
|
||||||
|
brew install boost
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install setuptools faber
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
python --version
|
||||||
|
${{ matrix.cxx }} --version
|
||||||
|
brew info boost
|
||||||
|
faber -v
|
||||||
|
sed -e "s/\$PYTHON/python/g" .ci/faber > ~/.faber
|
||||||
|
faber \
|
||||||
|
--with-boost-include=$(brew --prefix boost)/include \
|
||||||
|
--builddir=build \
|
||||||
|
cxx.name=${{ matrix.cxx }} \
|
||||||
|
cxxflags=-std=${{ matrix.std }} \
|
||||||
|
cppflags=-std=${{ matrix.std }} \
|
||||||
|
-j`sysctl -n hw.ncpu`
|
||||||
|
- name: test
|
||||||
|
run: |
|
||||||
|
faber \
|
||||||
|
--with-boost-include=$(brew --prefix boost)/include \
|
||||||
|
--builddir=build\
|
||||||
|
cxx.name=${{ matrix.cxx }} \
|
||||||
|
cxxflags=-std=${{ matrix.std }} \
|
||||||
|
cppflags=-std=${{ matrix.std }} \
|
||||||
|
-j`sysctl -n hw.ncpu` \
|
||||||
|
test.report
|
||||||
94
.github/workflows/test-ubuntu.yml
vendored
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# Test on Ubuntu with various compiler and language standard versions.
|
||||||
|
name: Test Ubuntu
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
python-version: ['3.14']
|
||||||
|
cxx: [g++, clang++]
|
||||||
|
std: [c++11, c++14, c++17]
|
||||||
|
include:
|
||||||
|
- python-version: '2.7'
|
||||||
|
cxx: g++
|
||||||
|
std: c++11
|
||||||
|
- python-version: '3.10'
|
||||||
|
cxx: g++
|
||||||
|
std: c++17
|
||||||
|
- python-version: '3.11'
|
||||||
|
cxx: g++
|
||||||
|
std: c++17
|
||||||
|
- python-version: '3.12'
|
||||||
|
cxx: g++
|
||||||
|
std: c++17
|
||||||
|
- python-version: '3.13'
|
||||||
|
cxx: g++
|
||||||
|
std: c++17
|
||||||
|
# Also test with free-threaded build of Python
|
||||||
|
- python-version: '3.14t'
|
||||||
|
cxx: clang++
|
||||||
|
std: c++17
|
||||||
|
|
||||||
|
container:
|
||||||
|
# Add the appropriate docker image for the compiler.
|
||||||
|
# The images from teeks99/boost-python-test already have boost::python
|
||||||
|
# pre-reqs installed, see:
|
||||||
|
# https://github.com/teeks99/boost-python-test-docker
|
||||||
|
image: ${{ matrix.cxx == 'g++' &&
|
||||||
|
'teeks99/boost-python-test:gcc-15_1.89.0' ||
|
||||||
|
'teeks99/boost-python-test:clang-21_1.89.0' }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: setup python
|
||||||
|
if: "${{ matrix.python-version != '2.7' }}"
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: setup prerequisites
|
||||||
|
run: |
|
||||||
|
# Warning: this is not necessarily the same Python version as the one configured above !
|
||||||
|
python3 -m pip install -U faber --break-system-packages
|
||||||
|
echo "CXX=${{ matrix.cxx }}" >> "$GITHUB_ENV"
|
||||||
|
echo "CXX_STD=${{ matrix.std }}" >> "$GITHUB_ENV"
|
||||||
|
- name: build-py2
|
||||||
|
if: "${{ matrix.python-version == '2.7' }}"
|
||||||
|
run: |
|
||||||
|
python --version
|
||||||
|
${{ matrix.cxx }} --version
|
||||||
|
faber -v
|
||||||
|
sed -e "s/\$PYTHON/python/g" .ci/faber > ~/.faber
|
||||||
|
faber \
|
||||||
|
--with-boost-include=${BOOST_PY_DEPS} \
|
||||||
|
--builddir=build \
|
||||||
|
cxx.name=${{ matrix.cxx }} \
|
||||||
|
cxxflags=-std=${{ matrix.std }} \
|
||||||
|
cppflags=-std=${{ matrix.std }} \
|
||||||
|
-j`nproc`
|
||||||
|
- name: build-py3
|
||||||
|
if: "${{ matrix.python-version != '2.7' }}"
|
||||||
|
run: |
|
||||||
|
.github/run-faber.sh
|
||||||
|
- name: test-py2
|
||||||
|
if: "${{ matrix.python-version == '2.7' }}"
|
||||||
|
run: |
|
||||||
|
faber \
|
||||||
|
--with-boost-include=${BOOST_PY_DEPS} \
|
||||||
|
--builddir=build \
|
||||||
|
cxx.name=${{ matrix.cxx }} \
|
||||||
|
cxxflags=-std=${{ matrix.std }} \
|
||||||
|
cppflags=-std=${{ matrix.std }} \
|
||||||
|
-j`nproc` \
|
||||||
|
test.report
|
||||||
|
- name: test-py3
|
||||||
|
if: "${{ matrix.python-version != '2.7' }}"
|
||||||
|
run: |
|
||||||
|
.github/run-faber.sh test.report
|
||||||
49
.github/workflows/test-windows.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
name: Test Windows
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
python-version: [3.7]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: actions/setup-python@v6
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- uses: microsoft/setup-msbuild@v2
|
||||||
|
- name: setup boost prerequisites
|
||||||
|
uses: lukka/run-vcpkg@v6
|
||||||
|
with:
|
||||||
|
vcpkgGitCommitId: '88b1071e39f13b632644d9d953738d345a4ac055'
|
||||||
|
vcpkgDirectory: '${{ runner.workspace }}/vcpkg'
|
||||||
|
vcpkgTriplet: x64-windows
|
||||||
|
vcpkgArguments: >
|
||||||
|
boost-config
|
||||||
|
boost-core
|
||||||
|
boost-function
|
||||||
|
boost-graph
|
||||||
|
boost-iterator
|
||||||
|
boost-lexical-cast
|
||||||
|
boost-mpl
|
||||||
|
boost-preprocessor
|
||||||
|
boost-smart-ptr
|
||||||
|
boost-static-assert
|
||||||
|
boost-align
|
||||||
|
- name: setup faber
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install setuptools faber numpy
|
||||||
|
faber --info=tools cxx
|
||||||
|
- name: build
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
faber --builddir=build cxx.name=msvc --log=commands --log=output --with-boost-include=${{ runner.workspace }}\vcpkg\installed\x64-windows\include -j4
|
||||||
|
- name: test
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
faber --builddir=build cxx.name=msvc --with-boost-include=${{ runner.workspace }}\vcpkg\installed\x64-windows\include -j4 test.report
|
||||||
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
bin.SCons
|
||||||
|
*.pyc
|
||||||
|
*~
|
||||||
|
\#*\#
|
||||||
176
CMakeLists.txt
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
# Copyright 2020, 2021 Peter Dimov
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.14...3.20)
|
||||||
|
|
||||||
|
project(boost_python VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||||
|
|
||||||
|
find_package(Python REQUIRED COMPONENTS Development OPTIONAL_COMPONENTS NumPy)
|
||||||
|
|
||||||
|
if(Python_NumPy_FOUND)
|
||||||
|
message(STATUS "Boost.Python: using Python ${Python_VERSION} with NumPy at ${Python_NumPy_INCLUDE_DIRS}")
|
||||||
|
else()
|
||||||
|
message(STATUS "Boost.Python: using Python ${Python_VERSION} without NumPy")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# boost_pythonXY
|
||||||
|
|
||||||
|
set(_pyver ${Python_VERSION_MAJOR}${Python_VERSION_MINOR})
|
||||||
|
set(_boost_python boost_python${_pyver})
|
||||||
|
|
||||||
|
add_library(${_boost_python}
|
||||||
|
src/dict.cpp
|
||||||
|
src/errors.cpp
|
||||||
|
src/exec.cpp
|
||||||
|
src/import.cpp
|
||||||
|
src/list.cpp
|
||||||
|
src/long.cpp
|
||||||
|
src/module.cpp
|
||||||
|
src/object_operators.cpp
|
||||||
|
src/object_protocol.cpp
|
||||||
|
src/slice.cpp
|
||||||
|
src/str.cpp
|
||||||
|
src/tuple.cpp
|
||||||
|
src/wrapper.cpp
|
||||||
|
src/converter/from_python.cpp
|
||||||
|
src/converter/registry.cpp
|
||||||
|
src/converter/type_id.cpp
|
||||||
|
src/converter/builtin_converters.cpp
|
||||||
|
src/converter/arg_to_python_base.cpp
|
||||||
|
src/object/enum.cpp
|
||||||
|
src/object/class.cpp
|
||||||
|
src/object/function.cpp
|
||||||
|
src/object/inheritance.cpp
|
||||||
|
src/object/life_support.cpp
|
||||||
|
src/object/pickle_support.cpp
|
||||||
|
src/object/iterator.cpp
|
||||||
|
src/object/stl_iterator.cpp
|
||||||
|
src/object_protocol.cpp
|
||||||
|
src/object_operators.cpp
|
||||||
|
src/object/function_doc_signature.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(Boost::python${_pyver} ALIAS ${_boost_python})
|
||||||
|
|
||||||
|
target_include_directories(${_boost_python} PUBLIC include)
|
||||||
|
|
||||||
|
target_link_libraries(${_boost_python}
|
||||||
|
PUBLIC
|
||||||
|
Boost::align
|
||||||
|
Boost::bind
|
||||||
|
Boost::config
|
||||||
|
Boost::conversion
|
||||||
|
Boost::core
|
||||||
|
Boost::detail
|
||||||
|
Boost::foreach
|
||||||
|
Boost::function
|
||||||
|
Boost::iterator
|
||||||
|
Boost::lexical_cast
|
||||||
|
Boost::mpl
|
||||||
|
Boost::numeric_conversion
|
||||||
|
Boost::preprocessor
|
||||||
|
Boost::smart_ptr
|
||||||
|
Boost::static_assert
|
||||||
|
Boost::tuple
|
||||||
|
Boost::type_traits
|
||||||
|
Boost::utility
|
||||||
|
|
||||||
|
Python::Module
|
||||||
|
|
||||||
|
PRIVATE
|
||||||
|
Boost::graph
|
||||||
|
Boost::integer
|
||||||
|
Boost::property_map
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(${_boost_python}
|
||||||
|
PUBLIC BOOST_PYTHON_NO_LIB
|
||||||
|
PRIVATE BOOST_PYTHON_SOURCE
|
||||||
|
)
|
||||||
|
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${_boost_python} PUBLIC BOOST_PYTHON_DYN_LINK)
|
||||||
|
else()
|
||||||
|
target_compile_definitions(${_boost_python} PUBLIC BOOST_PYTHON_STATIC_LINK BOOST_PYTHON_STATIC_LIB)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Boost::python alias
|
||||||
|
|
||||||
|
add_library(boost_python INTERFACE)
|
||||||
|
add_library(Boost::python ALIAS boost_python)
|
||||||
|
target_link_libraries(boost_python INTERFACE Boost::python${_pyver})
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
if(BOOST_SUPERPROJECT_VERSION AND NOT CMAKE_VERSION VERSION_LESS 3.13)
|
||||||
|
boost_install(TARGETS ${_boost_python} boost_python VERSION ${BOOST_SUPERPROJECT_VERSION} HEADER_DIRECTORY include)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(Python_NumPy_FOUND)
|
||||||
|
|
||||||
|
# boost_numpyXY
|
||||||
|
|
||||||
|
set(_boost_numpy boost_numpy${_pyver})
|
||||||
|
|
||||||
|
add_library(${_boost_numpy}
|
||||||
|
src/numpy/dtype.cpp
|
||||||
|
src/numpy/matrix.cpp
|
||||||
|
src/numpy/ndarray.cpp
|
||||||
|
src/numpy/numpy.cpp
|
||||||
|
src/numpy/scalars.cpp
|
||||||
|
src/numpy/ufunc.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(Boost::numpy${_pyver} ALIAS ${_boost_numpy})
|
||||||
|
|
||||||
|
target_include_directories(${_boost_numpy} PUBLIC include)
|
||||||
|
|
||||||
|
target_link_libraries(${_boost_numpy}
|
||||||
|
PUBLIC
|
||||||
|
Boost::config
|
||||||
|
Boost::core
|
||||||
|
Boost::detail
|
||||||
|
Boost::mpl
|
||||||
|
Boost::python
|
||||||
|
Boost::smart_ptr
|
||||||
|
|
||||||
|
Python::NumPy
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(${_boost_numpy}
|
||||||
|
PUBLIC BOOST_NUMPY_NO_LIB
|
||||||
|
PRIVATE BOOST_NUMPY_SOURCE
|
||||||
|
)
|
||||||
|
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${_boost_numpy} PUBLIC BOOST_NUMPY_DYN_LINK)
|
||||||
|
else()
|
||||||
|
target_compile_definitions(${_boost_numpy} PUBLIC BOOST_NUMPY_STATIC_LINK BOOST_NUMPY_STATIC_LIB)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Boost::numpy alias
|
||||||
|
|
||||||
|
add_library(boost_numpy INTERFACE)
|
||||||
|
add_library(Boost::numpy ALIAS boost_numpy)
|
||||||
|
target_link_libraries(boost_numpy INTERFACE Boost::numpy${_pyver})
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
if(BOOST_SUPERPROJECT_VERSION AND NOT CMAKE_VERSION VERSION_LESS 3.13)
|
||||||
|
boost_install(TARGETS ${_boost_numpy} boost_numpy VERSION ${BOOST_SUPERPROJECT_VERSION})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
unset(_pyver)
|
||||||
|
unset(_boost_python)
|
||||||
|
unset(_boost_numpy)
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
|
||||||
|
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||||
|
|
||||||
|
add_subdirectory(test)
|
||||||
|
|
||||||
|
endif()
|
||||||
23
LICENSE_1_0.txt
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
59
README.md
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|

|
||||||
|
|
||||||
|
# Synopsis
|
||||||
|
|
||||||
|
[](https://gitter.im/boostorg/python?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
|
Welcome to Boost.Python, a C++ library which enables seamless interoperability between C++ and the Python programming language. The library includes support for:
|
||||||
|
|
||||||
|
* References and Pointers
|
||||||
|
* Globally Registered Type Coercions
|
||||||
|
* Automatic Cross-Module Type Conversions
|
||||||
|
* Efficient Function Overloading
|
||||||
|
* C++ to Python Exception Translation
|
||||||
|
* Default Arguments
|
||||||
|
* Keyword Arguments
|
||||||
|
* Manipulating Python objects in C++
|
||||||
|
* Exporting C++ Iterators as Python Iterators
|
||||||
|
* Documentation Strings
|
||||||
|
|
||||||
|
See the [Boost.Python](http://boostorg.github.io/python) documentation for details.
|
||||||
|
|
||||||
|
**Hint :** Check out the [development version](http://boostorg.github.io/python/develop) of the documentation to see work in progress.
|
||||||
|
|
||||||
|
# Building   
|
||||||
|
|
||||||
|
While Boost.Python is part of the Boost C++ Libraries super-project, and thus can be compiled as part of Boost, it can also be compiled and installed stand-alone, i.e. against a pre-installed Boost package.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
* [Python](http://www.python.org)
|
||||||
|
* [Boost](http://www.boost.org)
|
||||||
|
* [Faber](https://stefanseefeld.github.io/faber)
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
Run
|
||||||
|
|
||||||
|
```
|
||||||
|
faber
|
||||||
|
```
|
||||||
|
to build the library.
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
Run
|
||||||
|
|
||||||
|
```
|
||||||
|
faber test.report
|
||||||
|
```
|
||||||
|
to run the tests.
|
||||||
|
|
||||||
|
## Build docs
|
||||||
|
|
||||||
|
Run
|
||||||
|
|
||||||
|
```
|
||||||
|
faber doc.html
|
||||||
|
```
|
||||||
|
to build the documentation.
|
||||||
41
build.jam
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Copyright René Ferdinand Rivera Morell 2024
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
require-b2 5.2 ;
|
||||||
|
|
||||||
|
constant boost_dependencies :
|
||||||
|
/boost/align//boost_align
|
||||||
|
/boost/bind//boost_bind
|
||||||
|
/boost/config//boost_config
|
||||||
|
/boost/conversion//boost_conversion
|
||||||
|
/boost/core//boost_core
|
||||||
|
/boost/detail//boost_detail
|
||||||
|
/boost/foreach//boost_foreach
|
||||||
|
/boost/function//boost_function
|
||||||
|
/boost/iterator//boost_iterator
|
||||||
|
/boost/lexical_cast//boost_lexical_cast
|
||||||
|
/boost/mpl//boost_mpl
|
||||||
|
/boost/numeric_conversion//boost_numeric_conversion
|
||||||
|
/boost/preprocessor//boost_preprocessor
|
||||||
|
/boost/static_assert//boost_static_assert
|
||||||
|
/boost/tuple//boost_tuple
|
||||||
|
/boost/type_traits//boost_type_traits
|
||||||
|
/boost/utility//boost_utility ;
|
||||||
|
|
||||||
|
project /boost/python
|
||||||
|
: common-requirements
|
||||||
|
<include>include
|
||||||
|
;
|
||||||
|
|
||||||
|
explicit
|
||||||
|
[ alias boost_python : build//boost_python ]
|
||||||
|
[ alias boost_numpy : build//boost_numpy ]
|
||||||
|
[ alias all : boost_python boost_numpy test ]
|
||||||
|
;
|
||||||
|
|
||||||
|
call-if : boost-library python
|
||||||
|
: install boost_python boost_numpy
|
||||||
|
;
|
||||||
|
|
||||||
175
build/Jamfile
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
# Copyright David Abrahams 2001-2006. Distributed under the Boost
|
||||||
|
# Software License, Version 1.0. (See accompanying
|
||||||
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
import os ;
|
||||||
|
import indirect ;
|
||||||
|
import modules ;
|
||||||
|
import feature ;
|
||||||
|
import property ;
|
||||||
|
import python ;
|
||||||
|
|
||||||
|
if ! [ python.configured ] && ! ( --without-python in [ modules.peek : ARGV ] )
|
||||||
|
{
|
||||||
|
# Attempt default configuration of python
|
||||||
|
import toolset : using ;
|
||||||
|
using python ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ python.configured ] || ( --without-python in [ modules.peek : ARGV ] )
|
||||||
|
{
|
||||||
|
alias config-warning ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message config-warning
|
||||||
|
: "warning: No python installation configured and autoconfiguration"
|
||||||
|
: "note: failed. See http://www.boost.org/libs/python/doc/building.html"
|
||||||
|
: "note: for configuration instructions or pass --without-python to"
|
||||||
|
: "note: suppress this message and silently skip all Boost.Python targets"
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
constant boost_dependencies_private :
|
||||||
|
/boost/graph//boost_graph
|
||||||
|
/boost/integer//boost_integer
|
||||||
|
/boost/property_map//boost_property_map
|
||||||
|
/boost/smart_ptr//boost_smart_ptr
|
||||||
|
;
|
||||||
|
|
||||||
|
project
|
||||||
|
: source-location ../src
|
||||||
|
: common-requirements <library>$(boost_dependencies)
|
||||||
|
: requirements <library>$(boost_dependencies_private)
|
||||||
|
;
|
||||||
|
|
||||||
|
rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } }
|
||||||
|
rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } }
|
||||||
|
local rule eq ( a : b ) { if $(a) = $(b) { return 1 ; } }
|
||||||
|
|
||||||
|
rule tag ( name : type ? : property-set )
|
||||||
|
{
|
||||||
|
if python-tag in [ RULENAMES $(__name__) ]
|
||||||
|
{
|
||||||
|
return [ $(__name__).python-tag $(name) : $(type) : $(property-set) ] ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ python.configured ]
|
||||||
|
{
|
||||||
|
|
||||||
|
lib boost_python
|
||||||
|
: # sources
|
||||||
|
list.cpp
|
||||||
|
long.cpp
|
||||||
|
dict.cpp
|
||||||
|
tuple.cpp
|
||||||
|
str.cpp
|
||||||
|
slice.cpp
|
||||||
|
|
||||||
|
converter/from_python.cpp
|
||||||
|
converter/registry.cpp
|
||||||
|
converter/type_id.cpp
|
||||||
|
object/enum.cpp
|
||||||
|
object/class.cpp
|
||||||
|
object/function.cpp
|
||||||
|
object/inheritance.cpp
|
||||||
|
object/life_support.cpp
|
||||||
|
object/pickle_support.cpp
|
||||||
|
errors.cpp
|
||||||
|
module.cpp
|
||||||
|
converter/builtin_converters.cpp
|
||||||
|
converter/arg_to_python_base.cpp
|
||||||
|
object/iterator.cpp
|
||||||
|
object/stl_iterator.cpp
|
||||||
|
object_protocol.cpp
|
||||||
|
object_operators.cpp
|
||||||
|
wrapper.cpp
|
||||||
|
import.cpp
|
||||||
|
exec.cpp
|
||||||
|
object/function_doc_signature.cpp
|
||||||
|
: # requirements
|
||||||
|
<link>static:<define>BOOST_PYTHON_STATIC_LIB
|
||||||
|
<define>BOOST_PYTHON_SOURCE
|
||||||
|
|
||||||
|
# On Windows, all code using Python has to link to the Python
|
||||||
|
# import library.
|
||||||
|
#
|
||||||
|
# On *nix we never link libboost_python to libpython. When
|
||||||
|
# extending Python, all Python symbols are provided by the
|
||||||
|
# Python interpreter executable. When embedding Python, the
|
||||||
|
# client executable is expected to explicitly link to
|
||||||
|
# /python//python (the target representing libpython) itself.
|
||||||
|
#
|
||||||
|
# python_for_extensions is a target defined by Boost.Build to
|
||||||
|
# provide the Python include paths, and on Windows, the Python
|
||||||
|
# import library, as usage requirements.
|
||||||
|
[ cond [ python.configured ] : <library>/python//python_for_extensions ]
|
||||||
|
|
||||||
|
# we prevent building when there is no python available
|
||||||
|
# as it's not possible anyway, and to cause dependents to
|
||||||
|
# fail to build
|
||||||
|
[ unless [ python.configured ] : <build>no ]
|
||||||
|
<dependency>config-warning
|
||||||
|
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||||
|
-<tag>@%boostcpp.tag
|
||||||
|
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
|
||||||
|
<tag>@tag
|
||||||
|
<conditional>@python.require-py
|
||||||
|
|
||||||
|
: # default build
|
||||||
|
<link>shared
|
||||||
|
: # usage requirements
|
||||||
|
<link>static:<define>BOOST_PYTHON_STATIC_LIB
|
||||||
|
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||||
|
<define>BOOST_PYTHON_NO_LIB
|
||||||
|
;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
alias boost_python : config-warning ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ python.configured ] && [ python.numpy ]
|
||||||
|
{
|
||||||
|
|
||||||
|
numpy-include = [ python.numpy-include ] ;
|
||||||
|
lib boost_numpy
|
||||||
|
: # sources
|
||||||
|
numpy/dtype.cpp
|
||||||
|
numpy/matrix.cpp
|
||||||
|
numpy/ndarray.cpp
|
||||||
|
numpy/numpy.cpp
|
||||||
|
numpy/scalars.cpp
|
||||||
|
numpy/ufunc.cpp
|
||||||
|
: # requirements
|
||||||
|
<link>static:<define>BOOST_NUMPY_STATIC_LIB
|
||||||
|
<define>BOOST_NUMPY_SOURCE
|
||||||
|
[ cond [ python.numpy ] : <library>/python//python_for_extensions ]
|
||||||
|
[ unless [ python.numpy ] : <build>no ]
|
||||||
|
<library>/python//numpy
|
||||||
|
<library>boost_python
|
||||||
|
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||||
|
-<tag>@%boostcpp.tag
|
||||||
|
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
|
||||||
|
<tag>@tag
|
||||||
|
<conditional>@python.require-py
|
||||||
|
|
||||||
|
: # default build
|
||||||
|
<link>shared
|
||||||
|
: # usage requirements
|
||||||
|
<link>static:<define>BOOST_NUMPY_STATIC_LIB
|
||||||
|
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||||
|
<define>BOOST_NUMPY_NO_LIB
|
||||||
|
;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
alias boost_numpy : config-warning ;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
index.html
|
|
||||||
rn.html
|
|
||||||
building.html
|
|
||||||
building/background.html
|
|
||||||
building/no_install_quickstart.html
|
|
||||||
building/installing_boost_python_on_your_.html
|
|
||||||
building/configuring_boost_build.html
|
|
||||||
building/choosing_a_boost_python_library_.html
|
|
||||||
building/include_issues.html
|
|
||||||
building/python_debugging_builds.html
|
|
||||||
building/testing_boost_python.html
|
|
||||||
building/notes_for_mingw_and_cygwin_with_.html
|
|
||||||
configuration.html
|
|
||||||
support.html
|
|
||||||
faq.html
|
|
||||||
faq/i_m_getting_the_attempt_to_retur.html
|
|
||||||
faq/is_return_internal_reference_eff.html
|
|
||||||
faq/how_can_i_wrap_functions_which_t.html
|
|
||||||
faq/fatal_error_c1204_compiler_limit.html
|
|
||||||
faq/how_do_i_debug_my_python_extensi.html
|
|
||||||
faq/why_doesn_t_my_operator_work.html
|
|
||||||
faq/does_boost_python_work_with_mac_.html
|
|
||||||
faq/how_can_i_find_the_existing_pyob.html
|
|
||||||
faq/how_can_i_wrap_a_function_which0.html
|
|
||||||
faq/compilation_takes_too_much_time_.html
|
|
||||||
faq/how_do_i_create_sub_packages_usi.html
|
|
||||||
faq/error_c2064_term_does_not_evalua.html
|
|
||||||
faq/how_can_i_automatically_convert_.html
|
|
||||||
faq/why_is_my_automatic_to_python_co.html
|
|
||||||
faq/is_boost_python_thread_aware_com.html
|
|
||||||
glossary.html
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Chapter 2. Building and Testing</title>
|
|
||||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="index.html" title="Boost.Python">
|
|
||||||
<link rel="prev" href="rn.html" title="Chapter 1. Release Notes">
|
|
||||||
<link rel="next" href="building/background.html" title="Background">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="rn.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="building/background.html"><img src="images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="chapter">
|
|
||||||
<div class="titlepage"><div>
|
|
||||||
<div><h1 class="title">
|
|
||||||
<a name="building"></a>Chapter 2. Building and Testing</h1></div>
|
|
||||||
<div><div class="authorgroup"><div class="author"><h3 class="author">
|
|
||||||
<span class="firstname">David</span> <span class="surname">Abrahams</span>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<div><p class="copyright">Copyright © 2002-2015 David Abrahams, Stefan Seefeld</p></div>
|
|
||||||
</div></div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="building.requirements"></a><a class="link" href="building.html#building.requirements" title="Requirements">Requirements</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
Boost.Python requires <a href="http://www.python.org/2.2" target="_top">Python 2.2</a>
|
|
||||||
<a href="#ftn.building.requirements.f0" class="footnote" name="building.requirements.f0"><sup class="footnote">[1]</sup></a> <span class="bold"><strong>or</strong></span> <a href="http://www.python.org" target="_top">newer</a>.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="footnotes">
|
|
||||||
<br><hr style="width:100; text-align:left;margin-left: 0">
|
|
||||||
<div id="ftn.building.requirements.f0" class="footnote"><p><a href="#building.requirements.f0" class="para"><sup class="para">[1] </sup></a>
|
|
||||||
Note that although we tested earlier versions of Boost.Python with Python
|
|
||||||
2.2, and we don't <span class="bold"><strong>think</strong></span> we've done anything
|
|
||||||
to break compatibility, this release of Boost.Python may not have been
|
|
||||||
tested with versions of Python earlier than 2.4, so we're not 100% sure
|
|
||||||
that python 2.2 and 2.3 are supported.
|
|
||||||
</p></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="rn.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="building/background.html"><img src="images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Background</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
|
||||||
<link rel="prev" href="../building.html" title="Chapter 2. Building and Testing">
|
|
||||||
<link rel="next" href="no_install_quickstart.html" title="No-Install Quickstart">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="../building.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="no_install_quickstart.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="building.background"></a><a class="link" href="background.html" title="Background">Background</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
There are two basic models for combining C++ and Python:
|
|
||||||
</p>
|
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
|
||||||
<li class="listitem">
|
|
||||||
<a href="http://www.python.org/doc/current/ext/intro.html" target="_top">extending</a>,
|
|
||||||
in which the end-user launches the Python interpreter executable and
|
|
||||||
imports Python “extension modules” written in C++. Think of taking
|
|
||||||
a library written in C++ and giving it a Python interface so Python programmers
|
|
||||||
can use it. From Python, these modules look just like regular Python
|
|
||||||
modules.
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<a href="http://www.python.org/doc/current/ext/embedding.html" target="_top">embedding</a>,
|
|
||||||
in which the end-user launches a program written in C++ that in turn
|
|
||||||
invokes the Python interpreter as a library subroutine. Think of adding
|
|
||||||
scriptability to an existing application.
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
|
||||||
<p>
|
|
||||||
The key distinction between extending and embedding is the location of the
|
|
||||||
C++ <code class="computeroutput"><span class="identifier">main</span><span class="special">()</span></code>
|
|
||||||
function: in the Python interpreter executable, or in some other program,
|
|
||||||
respectively. Note that even when embedding Python in another program, <a href="http://www.python.org/doc/current/ext/extending-with-embedding.html" target="_top">extension
|
|
||||||
modules are often the best way to make C/C++ functionality accessible to
|
|
||||||
Python code</a>, so the use of extension modules is really at the heart
|
|
||||||
of both models.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Except in rare cases, extension modules are built as dynamically-loaded libraries
|
|
||||||
with a single entry point, which means you can change them without rebuilding
|
|
||||||
either the other extension modules or the executable containing <code class="computeroutput"><span class="identifier">main</span><span class="special">()</span></code>.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="../building.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="no_install_quickstart.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Choosing a Boost.Python Library Binary</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
|
||||||
<link rel="prev" href="configuring_boost_build.html" title="Configuring Boost.Build">
|
|
||||||
<link rel="next" href="include_issues.html" title="#include Issues">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="configuring_boost_build.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="include_issues.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="building.choosing_a_boost_python_library_"></a><a class="link" href="choosing_a_boost_python_library_.html" title="Choosing a Boost.Python Library Binary">Choosing a
|
|
||||||
Boost.Python Library Binary</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<div class="toc"><dl class="toc">
|
|
||||||
<dt><span class="section"><a href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_dynamic_binary">The
|
|
||||||
Dynamic Binary</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_static_binary">The
|
|
||||||
Static Binary</a></span></dt>
|
|
||||||
</dl></div>
|
|
||||||
<p>
|
|
||||||
If—instead of letting Boost.Build construct and link with the right libraries
|
|
||||||
automatically—you choose to use a pre-built Boost.Python library, you'll
|
|
||||||
need to think about which one to link with. The Boost.Python binary comes
|
|
||||||
in both static and dynamic flavors. Take care to choose the right flavor
|
|
||||||
for your application. <a href="#ftn.building.choosing_a_boost_python_library_.f0" class="footnote" name="building.choosing_a_boost_python_library_.f0"><sup class="footnote">[3]</sup></a>
|
|
||||||
</p>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="building.choosing_a_boost_python_library_.the_dynamic_binary"></a><a class="link" href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_dynamic_binary" title="The Dynamic Binary">The
|
|
||||||
Dynamic Binary</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<p>
|
|
||||||
The dynamic library is the safest and most-versatile choice:
|
|
||||||
</p>
|
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
|
||||||
<li class="listitem">
|
|
||||||
A single copy of the library code is used by all extension modules
|
|
||||||
built with a given toolset. <a href="#ftn.building.choosing_a_boost_python_library_.the_dynamic_binary.f0" class="footnote" name="building.choosing_a_boost_python_library_.the_dynamic_binary.f0"><sup class="footnote">[4]</sup></a>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
The library contains a type conversion registry. Because one registry
|
|
||||||
is shared among all extension modules, instances of a class exposed
|
|
||||||
to Python in one dynamically-loaded extension module can be passed
|
|
||||||
to functions exposed in another such module.
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="building.choosing_a_boost_python_library_.the_static_binary"></a><a class="link" href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_static_binary" title="The Static Binary">The
|
|
||||||
Static Binary</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<p>
|
|
||||||
It might be appropriate to use the static Boost.Python library in any of
|
|
||||||
the following cases:
|
|
||||||
</p>
|
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
|
||||||
<li class="listitem">
|
|
||||||
You are <a href="https://docs.python.org/2/extending/extending.html" target="_top">extending</a>
|
|
||||||
python and the types exposed in your dynamically-loaded extension module
|
|
||||||
don't need to be used by any other Boost.Python extension modules,
|
|
||||||
and you don't care if the core library code is duplicated among them.
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
You are <a href="https://docs.python.org/2/extending/embedding.html" target="_top">embedding</a>
|
|
||||||
python in your application and either:
|
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
|
|
||||||
<li class="listitem">
|
|
||||||
You are targeting a Unix variant OS other than MacOS or AIX,
|
|
||||||
where the dynamically-loaded extension modules can “see”
|
|
||||||
the Boost.Python library symbols that are part of the executable.
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Or, you have statically linked some Boost.Python extension modules
|
|
||||||
into your application and you don't care if any dynamically-loaded
|
|
||||||
Boost.Python extension modules are able to use the types exposed
|
|
||||||
by your statically-linked extension modules (and vice-versa).
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
|
||||||
</div>
|
|
||||||
<div class="footnotes">
|
|
||||||
<br><hr style="width:100; text-align:left;margin-left: 0">
|
|
||||||
<div id="ftn.building.choosing_a_boost_python_library_.f0" class="footnote"><p><a href="#building.choosing_a_boost_python_library_.f0" class="para"><sup class="para">[3] </sup></a>
|
|
||||||
Information about how to identify the static and dynamic builds of Boost.Python
|
|
||||||
on <a href="http://boost.org/more/getting_started/windows.html#library-naming" target="_top">Windows</a>
|
|
||||||
/ <a href="http://boost.org/more/getting_started/unix-variants.html#library-naming" target="_top">Unix
|
|
||||||
variants</a>
|
|
||||||
</p></div>
|
|
||||||
<div id="ftn.building.choosing_a_boost_python_library_.the_dynamic_binary.f0" class="footnote"><p><a href="#building.choosing_a_boost_python_library_.the_dynamic_binary.f0" class="para"><sup class="para">[4] </sup></a>
|
|
||||||
Because of the way most *nix platforms share symbols among dynamically-loaded
|
|
||||||
objects, I'm not certain that extension modules built with different
|
|
||||||
compiler toolsets will always use different copies of the Boost.Python
|
|
||||||
library when loaded into the same Python instance. Not using different
|
|
||||||
libraries could be a good thing if the compilers have compatible
|
|
||||||
ABIs, because extension modules built with the two libraries would
|
|
||||||
be interoperable. Otherwise, it could spell disaster, since an extension
|
|
||||||
module and the Boost.Python library would have different ideas of
|
|
||||||
such things as class layout. I would appreciate someone doing the
|
|
||||||
experiment to find out what happens.
|
|
||||||
</p></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="configuring_boost_build.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="include_issues.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,252 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Configuring Boost.Build</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
|
||||||
<link rel="prev" href="installing_boost_python_on_your_.html" title="Installing Boost.Python on your System">
|
|
||||||
<link rel="next" href="choosing_a_boost_python_library_.html" title="Choosing a Boost.Python Library Binary">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="installing_boost_python_on_your_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="choosing_a_boost_python_library_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="building.configuring_boost_build"></a><a class="link" href="configuring_boost_build.html" title="Configuring Boost.Build">Configuring Boost.Build</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<div class="toc"><dl class="toc">
|
|
||||||
<dt><span class="section"><a href="configuring_boost_build.html#building.configuring_boost_build.python_configuration_parameters">Python
|
|
||||||
Configuration Parameters</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="configuring_boost_build.html#building.configuring_boost_build.examples">Examples</a></span></dt>
|
|
||||||
</dl></div>
|
|
||||||
<p>
|
|
||||||
As described in the <a href="http://www.boost.org/build/doc/html/bbv2/overview/configuration.html" target="_top">Boost.Build
|
|
||||||
Reference Manual</a>, a file called <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> in
|
|
||||||
your home directory is used to specify the tools and libraries available
|
|
||||||
to the build system. You may need to create or edit <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> to
|
|
||||||
tell Boost.Build how to invoke Python, <code class="computeroutput"><span class="preprocessor">#include</span></code>
|
|
||||||
its headers, and link with its libraries.
|
|
||||||
</p>
|
|
||||||
<div class="note"><table border="0" summary="Note">
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
|
|
||||||
<th align="left">Note</th>
|
|
||||||
</tr>
|
|
||||||
<tr><td align="left" valign="top"><p>
|
|
||||||
If you are using a unix-variant OS and you ran Boost's <code class="computeroutput"><span class="identifier">configure</span></code>
|
|
||||||
script, it may have generated a <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code>
|
|
||||||
for you. <a href="#ftn.building.configuring_boost_build.f0" class="footnote" name="building.configuring_boost_build.f0"><sup class="footnote">[2]</sup></a> If your <code class="computeroutput"><span class="identifier">configure</span></code>/<code class="computeroutput"><span class="identifier">make</span></code> sequence was successful and Boost.Python
|
|
||||||
binaries were built, your <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code>
|
|
||||||
file is probably already correct.
|
|
||||||
</p></td></tr>
|
|
||||||
</table></div>
|
|
||||||
<p>
|
|
||||||
If you have one fairly “standard” python installation for your platform,
|
|
||||||
you might not need to do anything special to describe it. If you haven't
|
|
||||||
configured python in <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> (and
|
|
||||||
you don't specify <code class="computeroutput"><span class="special">--</span><span class="identifier">without</span><span class="special">-</span><span class="identifier">python</span></code>
|
|
||||||
on the Boost.Build command line), Boost.Build will automatically execute
|
|
||||||
the equivalent of
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">import</span> <span class="identifier">toolset</span> <span class="special">:</span> <span class="keyword">using</span> <span class="special">;</span>
|
|
||||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
which automatically looks for Python in the most likely places. However,
|
|
||||||
that only happens when using the Boost.Python project file (e.g. when referred
|
|
||||||
to by another project as in the quickstart method). If instead you are linking
|
|
||||||
against separately-compiled Boost.Python binaries, you should set up a <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> file
|
|
||||||
with at least the minimal incantation above.
|
|
||||||
</p>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="building.configuring_boost_build.python_configuration_parameters"></a><a class="link" href="configuring_boost_build.html#building.configuring_boost_build.python_configuration_parameters" title="Python Configuration Parameters">Python
|
|
||||||
Configuration Parameters</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<p>
|
|
||||||
If you have several versions of Python installed, or Python is installed
|
|
||||||
in an unusual way, you may want to supply any or all of the following optional
|
|
||||||
parameters to <code class="computeroutput"><span class="keyword">using</span> <span class="identifier">python</span></code>.
|
|
||||||
</p>
|
|
||||||
<div class="variablelist">
|
|
||||||
<p class="title"><b></b></p>
|
|
||||||
<dl class="variablelist">
|
|
||||||
<dt><span class="term">version</span></dt>
|
|
||||||
<dd><p>
|
|
||||||
the version of Python to use. Should be in Major.Minor format, for
|
|
||||||
example, <code class="computeroutput"><span class="number">2.3</span></code>. Do not
|
|
||||||
include the subminor version (i.e. <span class="bold"><strong>not</strong></span>
|
|
||||||
<code class="computeroutput"><span class="number">2.5</span><span class="special">.</span><span class="number">1</span></code>). If you have multiple Python versions
|
|
||||||
installed, the version will usually be the only configuration argument
|
|
||||||
required.
|
|
||||||
</p></dd>
|
|
||||||
<dt><span class="term">cmd-or-prefix</span></dt>
|
|
||||||
<dd><p>
|
|
||||||
preferably, a command that invokes a Python interpreter. Alternatively,
|
|
||||||
the installation prefix for Python libraries and header files. Only
|
|
||||||
use the alternative formulation if there is no appropriate Python
|
|
||||||
executable available.
|
|
||||||
</p></dd>
|
|
||||||
<dt><span class="term"><span class="bold"><strong>includes</strong></span></span></dt>
|
|
||||||
<dd><p>
|
|
||||||
the <code class="computeroutput"><span class="preprocessor">#include</span></code> paths
|
|
||||||
for Python headers. Normally the correct path(s) will be automatically
|
|
||||||
deduced from <code class="computeroutput"><span class="identifier">version</span></code>
|
|
||||||
and/or <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>.
|
|
||||||
</p></dd>
|
|
||||||
<dt><span class="term"><span class="bold"><strong>libraries</strong></span></span></dt>
|
|
||||||
<dd><p>
|
|
||||||
the path to Python library binaries. On MacOS/Darwin, you can also
|
|
||||||
pass the path of the Python framework. Normally the correct path(s)
|
|
||||||
will be automatically deduced from <code class="computeroutput"><span class="identifier">version</span></code>
|
|
||||||
and/or <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>.
|
|
||||||
</p></dd>
|
|
||||||
<dt><span class="term"><span class="bold"><strong>condition</strong></span></span></dt>
|
|
||||||
<dd><p>
|
|
||||||
if specified, should be a set of Boost.Build properties that are
|
|
||||||
matched against the build configuration when Boost.Build selects
|
|
||||||
a Python configuration to use. See examples below for details.
|
|
||||||
</p></dd>
|
|
||||||
<dt><span class="term"><span class="bold"><strong>extension-suffix</strong></span></span></dt>
|
|
||||||
<dd><p>
|
|
||||||
A string to append to the name of extension modules before the true
|
|
||||||
filename extension. You almost certainly don't need to use this.
|
|
||||||
Usually this suffix is only used when targeting a Windows debug build
|
|
||||||
of Python, and will be set automatically for you based on the value
|
|
||||||
of the <a class="link" href="python_debugging_builds.html" title="Python Debugging Builds"><python-debugging></a>
|
|
||||||
feature. However, at least one Linux distribution (Ubuntu Feisty
|
|
||||||
Fawn) has a specially configured <a href="https://wiki.ubuntu.com/PyDbgBuilds" target="_top"><python-dbg></a>
|
|
||||||
package that claims to use such a suffix.
|
|
||||||
</p></dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="building.configuring_boost_build.examples"></a><a class="link" href="configuring_boost_build.html#building.configuring_boost_build.examples" title="Examples">Examples</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<p>
|
|
||||||
Note that in the examples below, case and <span class="bold"><strong>especially
|
|
||||||
whitespace</strong></span> are significant.
|
|
||||||
</p>
|
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
|
||||||
<li class="listitem">
|
|
||||||
If you have both python 2.5 and python 2.4 installed, <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> might contain
|
|
||||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">Make</span> <span class="identifier">both</span> <span class="identifier">versions</span> <span class="identifier">of</span> <span class="identifier">Python</span> <span class="identifier">available</span>
|
|
||||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.4</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">To</span> <span class="identifier">build</span> <span class="identifier">with</span> <span class="identifier">python</span> <span class="number">2.4</span><span class="special">,</span> <span class="identifier">add</span> <span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span>
|
|
||||||
<span class="preprocessor"># to</span> <span class="identifier">your</span> <span class="identifier">command</span> <span class="identifier">line</span><span class="special">.</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
The first version configured (2.5) becomes the default. To build
|
|
||||||
against python 2.4, add <code class="computeroutput"><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span></code>
|
|
||||||
to the <code class="computeroutput"><span class="identifier">bjam</span></code> command
|
|
||||||
line.
|
|
||||||
</p>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
If you have python installed in an unusual location, you might supply
|
|
||||||
the path to the interpreter in the <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>
|
|
||||||
parameter:
|
|
||||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="special">:</span> <span class="special">/</span><span class="identifier">usr</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">python</span><span class="special">-</span><span class="number">2.6</span><span class="special">-</span><span class="identifier">beta</span><span class="special">/</span><span class="identifier">bin</span><span class="special">/</span><span class="identifier">python</span> <span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
If you have a separate build of Python for use with a particular toolset,
|
|
||||||
you might supply that toolset in the <code class="computeroutput"><span class="identifier">condition</span></code>
|
|
||||||
parameter:
|
|
||||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">use</span> <span class="keyword">for</span> <span class="identifier">most</span> <span class="identifier">toolsets</span>
|
|
||||||
|
|
||||||
<span class="preprocessor"># Use</span> <span class="identifier">with</span> <span class="identifier">Intel</span> <span class="identifier">C</span><span class="special">++</span> <span class="identifier">toolset</span>
|
|
||||||
<span class="keyword">using</span> <span class="identifier">python</span>
|
|
||||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">version</span>
|
|
||||||
<span class="special">:</span> <span class="identifier">c</span><span class="special">:\\</span><span class="identifier">Devel</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">-</span><span class="identifier">IntelBuild</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python</span> <span class="special">#</span> <span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span>
|
|
||||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">includes</span>
|
|
||||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">libraries</span>
|
|
||||||
<span class="special">:</span> <span class="special"><</span><span class="identifier">toolset</span><span class="special">></span><span class="identifier">intel</span> <span class="special">#</span> <span class="identifier">condition</span>
|
|
||||||
<span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
If you have downloaded the Python sources and built both the normal
|
|
||||||
and the <a class="link" href="python_debugging_builds.html" title="Python Debugging Builds">"python
|
|
||||||
debugging"</a> builds from source on Windows, you might see:
|
|
||||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">:</span> <span class="identifier">C</span><span class="special">:\\</span><span class="identifier">src</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python</span> <span class="special">;</span>
|
|
||||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">:</span> <span class="identifier">C</span><span class="special">:\\</span><span class="identifier">src</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python_d</span>
|
|
||||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">includes</span>
|
|
||||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">libs</span>
|
|
||||||
<span class="special">:</span> <span class="special"><</span><span class="identifier">python</span><span class="special">-</span><span class="identifier">debugging</span><span class="special">></span><span class="identifier">on</span> <span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
You can set up your user-config.jam so a bjam built under Windows can
|
|
||||||
build/test both Windows and Cygwin_ python extensions. Just pass <code class="computeroutput"><span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span></code>
|
|
||||||
in the <code class="computeroutput"><span class="identifier">condition</span></code> parameter
|
|
||||||
for the cygwin python installation:
|
|
||||||
<pre class="programlisting"><span class="preprocessor"># windows</span> <span class="identifier">installation</span>
|
|
||||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span>
|
|
||||||
|
|
||||||
<span class="preprocessor"># cygwin</span> <span class="identifier">installation</span>
|
|
||||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="special">:</span> <span class="identifier">c</span><span class="special">:\\</span><span class="identifier">cygwin</span><span class="special">\\</span><span class="identifier">bin</span><span class="special">\\</span><span class="identifier">python2</span><span class="special">.</span><span class="number">5</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span> <span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
when you put target-os=cygwin in your build request, it should build
|
|
||||||
with the cygwin version of python: <a name="flavor"></a>_
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">gcc</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
This is supposed to work the other way, too (targeting windows python
|
|
||||||
with a <a href="http://cygwin.com" target="_top">Cygwin</a> bjam) but it
|
|
||||||
seems as though the support in Boost.Build's toolsets for building
|
|
||||||
that way is broken at the time of this writing.
|
|
||||||
</p>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Note that because of <a href="http://zigzag.cs.msu.su/boost.build/wiki/AlternativeSelection" target="_top">the
|
|
||||||
way Boost.Build currently selects target alternatives</a>, you
|
|
||||||
might have be very explicit in your build requests. For example, given:
|
|
||||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">a</span> <span class="identifier">regular</span> <span class="identifier">windows</span> <span class="identifier">build</span>
|
|
||||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.4</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span> <span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
building with
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
will yield an error. Instead, you'll need to write
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span><span class="special">/</span><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span>
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
|
||||||
</div>
|
|
||||||
<div class="footnotes">
|
|
||||||
<br><hr style="width:100; text-align:left;margin-left: 0">
|
|
||||||
<div id="ftn.building.configuring_boost_build.f0" class="footnote"><p><a href="#building.configuring_boost_build.f0" class="para"><sup class="para">[2] </sup></a>
|
|
||||||
<code class="computeroutput"><span class="identifier">configure</span></code> overwrites
|
|
||||||
the existing <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> in your home directory (if any)
|
|
||||||
after making a backup of the old version.
|
|
||||||
</p></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="installing_boost_python_on_your_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="choosing_a_boost_python_library_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>#include Issues</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
|
||||||
<link rel="prev" href="choosing_a_boost_python_library_.html" title="Choosing a Boost.Python Library Binary">
|
|
||||||
<link rel="next" href="python_debugging_builds.html" title="Python Debugging Builds">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="choosing_a_boost_python_library_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="python_debugging_builds.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="building.include_issues"></a><a class="link" href="include_issues.html" title="#include Issues"><code class="computeroutput"><span class="preprocessor">#include</span></code>
|
|
||||||
Issues</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
1. If you should ever have occasion to <code class="computeroutput"><span class="preprocessor">#include</span>
|
|
||||||
<span class="string">"python.h"</span></code> directly in a
|
|
||||||
translation unit of a program using Boost.Python, use <code class="computeroutput"><span class="preprocessor">#include</span>
|
|
||||||
<span class="string">"boost/python/detail/wrap_python.hpp"</span></code>
|
|
||||||
instead. It handles several issues necessary for use with Boost.Python, one
|
|
||||||
of which is mentioned in the next section.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
2. Be sure not to <code class="computeroutput"><span class="preprocessor">#include</span></code>
|
|
||||||
any system headers before <code class="computeroutput"><span class="identifier">wrap_python</span><span class="special">.</span><span class="identifier">hpp</span></code>. This
|
|
||||||
restriction is actually imposed by Python, or more properly, by Python's
|
|
||||||
interaction with your operating system. See <a href="http://docs.python.org/ext/simpleExample.html" target="_top">http://docs.python.org/ext/simpleExample.html</a>
|
|
||||||
for details.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="choosing_a_boost_python_library_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="python_debugging_builds.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Installing Boost.Python on your System</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
|
||||||
<link rel="prev" href="no_install_quickstart.html" title="No-Install Quickstart">
|
|
||||||
<link rel="next" href="configuring_boost_build.html" title="Configuring Boost.Build">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="no_install_quickstart.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="configuring_boost_build.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="building.installing_boost_python_on_your_"></a><a class="link" href="installing_boost_python_on_your_.html" title="Installing Boost.Python on your System">Installing
|
|
||||||
Boost.Python on your System</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
Since Boost.Python is a separately-compiled (as opposed to <code class="computeroutput"><span class="identifier">header</span><span class="special">-</span><span class="identifier">only</span></code>) library, its user relies on the services
|
|
||||||
of a Boost.Python library binary.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
If you need a regular installation of the Boost.Python library binaries on
|
|
||||||
your system, the Boost <a href="http://www.boost.org/more/getting_started/" target="_top">Getting
|
|
||||||
Started Guide</a> will walk you through the steps of creating one. If
|
|
||||||
building binaries from source, you might want to supply the <code class="computeroutput"><span class="special">--</span><span class="identifier">with</span><span class="special">-</span><span class="identifier">python</span></code>
|
|
||||||
argument to <code class="computeroutput"><span class="identifier">bjam</span></code> (or the
|
|
||||||
<code class="computeroutput"><span class="special">--</span><span class="identifier">with</span><span class="special">-</span><span class="identifier">libraries</span><span class="special">=</span><span class="identifier">python</span></code>
|
|
||||||
argument to <code class="computeroutput"><span class="identifier">configure</span></code>), so
|
|
||||||
only the Boost.Python binary will be built, rather than all the Boost binaries.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="no_install_quickstart.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="configuring_boost_build.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,318 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>No-Install Quickstart</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
|
||||||
<link rel="prev" href="background.html" title="Background">
|
|
||||||
<link rel="next" href="installing_boost_python_on_your_.html" title="Installing Boost.Python on your System">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="background.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="installing_boost_python_on_your_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="building.no_install_quickstart"></a><a class="link" href="no_install_quickstart.html" title="No-Install Quickstart">No-Install Quickstart</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<div class="toc"><dl class="toc">
|
|
||||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.basic_procedure">Basic
|
|
||||||
Procedure</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.in_case_of_trouble">In
|
|
||||||
Case of Trouble</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.in_case_everything_seemed_to_wor">In
|
|
||||||
Case Everything Seemed to Work</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project">Modifying
|
|
||||||
the Example Project</a></span></dt>
|
|
||||||
</dl></div>
|
|
||||||
<p>
|
|
||||||
There is no need to “install Boost” in order to get started using Boost.Python.
|
|
||||||
These instructions use <a href="http://www.boost.org/build" target="_top">Boost.Build</a>
|
|
||||||
projects, which will build those binaries as soon as they're needed. Your
|
|
||||||
first tests may take a little longer while you wait for Boost.Python to build,
|
|
||||||
but doing things this way will save you from worrying about build intricacies
|
|
||||||
like which library binaries to use for a specific compiler configuration
|
|
||||||
and figuring out the right compiler options to use yourself.
|
|
||||||
</p>
|
|
||||||
<div class="note"><table border="0" summary="Note">
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
|
|
||||||
<th align="left">Note</th>
|
|
||||||
</tr>
|
|
||||||
<tr><td align="left" valign="top">
|
|
||||||
<p>
|
|
||||||
Of course it's possible to use other build systems to build Boost.Python
|
|
||||||
and its extensions, but they are not officially supported by Boost. Moreover
|
|
||||||
<span class="bold"><strong>99% of all “I can't build Boost.Python” problems
|
|
||||||
come from trying to use another build system</strong></span> without first following
|
|
||||||
these instructions.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
If you want to use another system anyway, we suggest that you follow these
|
|
||||||
instructions, and then invoke <code class="computeroutput"><span class="identifier">bjam</span></code>
|
|
||||||
with the
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<code class="computeroutput"><span class="special">-</span><span class="identifier">a</span>
|
|
||||||
<span class="special">-</span><span class="identifier">o</span></code><span class="emphasis"><em>filename</em></span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
options to dump the build commands it executes to a file, so you can see
|
|
||||||
what your alternate build system needs to do.
|
|
||||||
</p>
|
|
||||||
</td></tr>
|
|
||||||
</table></div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="building.no_install_quickstart.basic_procedure"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.basic_procedure" title="Basic Procedure">Basic
|
|
||||||
Procedure</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<p>
|
|
||||||
1. Get Boost; see sections 1 and 2 of the Boost <a href="http://www.boost.org/more/getting_started/" target="_top">Getting
|
|
||||||
Started Guide</a>.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
2. Get the <code class="computeroutput"><span class="identifier">bjam</span></code> build driver.
|
|
||||||
See section 5 of the Boost <a href="http://www.boost.org/more/getting_started/" target="_top">Getting
|
|
||||||
Started Guide</a>.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
3. cd into the <code class="computeroutput"><span class="identifier">example</span><span class="special">/</span><span class="identifier">quickstart</span><span class="special">/</span></code> directory of your Boost.Python installation,
|
|
||||||
which contains a small example project.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
4. Invoke <code class="computeroutput"><span class="identifier">bjam</span></code>. Replace
|
|
||||||
the “<code class="computeroutput"><span class="identifier">stage</span></code>“ argument
|
|
||||||
from the example invocation from section 5 of the Boost <a href="http://www.boost.org/more/getting_started/" target="_top">Getting
|
|
||||||
Started Guide</a> with “<code class="computeroutput"><span class="identifier">test</span></code>,“
|
|
||||||
to build all the test targets. Also add the argument “<code class="computeroutput"><span class="special">--</span><span class="identifier">verbose</span><span class="special">-</span><span class="identifier">test</span></code>” to see the output generated by
|
|
||||||
the tests when they are run. On Windows, your <code class="computeroutput"><span class="identifier">bjam</span></code>
|
|
||||||
invocation might look something like:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">C</span><span class="special">:\\...\\</span><span class="identifier">quickstart</span><span class="special">></span> <span class="identifier">bjam</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">msvc</span> <span class="special">--</span><span class="identifier">verbose</span><span class="special">-</span><span class="identifier">test</span> <span class="identifier">test</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
and on Unix variants, perhaps,
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">.../</span><span class="identifier">quickstart</span><span class="error">$</span> <span class="identifier">bjam</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">gcc</span> <span class="special">--</span><span class="identifier">verbose</span><span class="special">-</span><span class="identifier">test</span> <span class="identifier">test</span>
|
|
||||||
</pre>
|
|
||||||
<div class="note"><table border="0" summary="Note">
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
|
|
||||||
<th align="left">Note</th>
|
|
||||||
</tr>
|
|
||||||
<tr><td align="left" valign="top"><p>
|
|
||||||
For the sake of concision, the rest of this guide will use unix-style
|
|
||||||
forward slashes in pathnames instead of the backslashes with which Windows
|
|
||||||
users may be more familiar. The forward slashes should work everywhere
|
|
||||||
except in <a href="http://www.boost.org/more/getting_started/windows.html#command-prompt" target="_top">Command
|
|
||||||
Prompt</a> windows, where you should use backslashes.
|
|
||||||
</p></td></tr>
|
|
||||||
</table></div>
|
|
||||||
<p>
|
|
||||||
If you followed this procedure successfully, you will have built an extension
|
|
||||||
module called <code class="computeroutput"><span class="identifier">extending</span></code>
|
|
||||||
and tested it by running a Python script called <code class="computeroutput"><span class="identifier">test_extending</span><span class="special">.</span><span class="identifier">py</span></code>.
|
|
||||||
You will also have built and run a simple application called <code class="computeroutput"><span class="identifier">embedding</span></code> that embeds python.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="building.no_install_quickstart.in_case_of_trouble"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.in_case_of_trouble" title="In Case of Trouble">In
|
|
||||||
Case of Trouble</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<p>
|
|
||||||
If you're seeing lots of compiler and/or linker error messages, it's probably
|
|
||||||
because Boost.Build is having trouble finding your Python installation.
|
|
||||||
You might want to pass the <code class="computeroutput"><span class="special">--</span><span class="identifier">debug</span><span class="special">-</span><span class="identifier">configuration</span></code> option to <code class="computeroutput"><span class="identifier">bjam</span></code> the first few times you invoke it,
|
|
||||||
to make sure that Boost.Build is correctly locating all the parts of your
|
|
||||||
Python installation. If it isn't, consider <a class="link" href="configuring_boost_build.html" title="Configuring Boost.Build">Configuring
|
|
||||||
Boost.Build</a> as detailed below.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
If you're still having trouble, Someone on one of the following mailing
|
|
||||||
lists may be able to help:
|
|
||||||
</p>
|
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
|
||||||
<li class="listitem">
|
|
||||||
The <a href="http://www.boost.org/more/mailing_lists.htm#jamboost" target="_top">Boost.Build
|
|
||||||
mailing list</a> for issues related to Boost.Build
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
The <a href="http://www.boost.org/more/mailing_lists.htm#cplussig" target="_top">Boost.Python
|
|
||||||
mailing list</a> for issues specifically related to Boost.Python
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="building.no_install_quickstart.in_case_everything_seemed_to_wor"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.in_case_everything_seemed_to_wor" title="In Case Everything Seemed to Work">In
|
|
||||||
Case Everything Seemed to Work</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<p>
|
|
||||||
Rejoice! If you're new to Boost.Python, at this point it might be a good
|
|
||||||
idea to ignore build issues for a while and concentrate on learning the
|
|
||||||
library by going through the <a href="../tutorial/index.html" target="_top">Tutorial</a>
|
|
||||||
and perhaps some of the <a href="../reference/index.html" target="_top">Reference Manual</a>,
|
|
||||||
trying out what you've learned about the API by modifying the quickstart
|
|
||||||
project.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="building.no_install_quickstart.modifying_the_example_project"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project" title="Modifying the Example Project">Modifying
|
|
||||||
the Example Project</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<div class="toc"><dl class="toc">
|
|
||||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.relocate_the_project">Relocate
|
|
||||||
the Project</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.add_new_or_change_names_of_exist">Add
|
|
||||||
New or Change Names of Existing Source Files</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.change_the_name_of_your_extensio">Change
|
|
||||||
the Name of your Extension Module</a></span></dt>
|
|
||||||
</dl></div>
|
|
||||||
<p>
|
|
||||||
If you're content to keep your extension module forever in one source file
|
|
||||||
called <code class="computeroutput"><span class="identifier">extending</span><span class="special">.</span><span class="identifier">cpp</span></code>, inside your Boost.Python distribution,
|
|
||||||
and import it forever as <code class="computeroutput"><span class="identifier">extending</span></code>,
|
|
||||||
then you can stop here. However, it's likely that you will want to make
|
|
||||||
a few changes. There are a few things you can do without having to learn
|
|
||||||
<a href="http://www.boost.org/build" target="_top">Boost.Build</a> in depth.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
The project you just built is specified in two files in the current directory:
|
|
||||||
<code class="computeroutput"><span class="identifier">boost</span><span class="special">-</span><span class="identifier">build</span><span class="special">.</span><span class="identifier">jam</span></code>, which tells <code class="computeroutput"><span class="identifier">bjam</span></code>
|
|
||||||
where it can find the interpreted code of the Boost build system, and
|
|
||||||
<code class="computeroutput"><span class="identifier">Jamroot</span></code>, which describes
|
|
||||||
the targets you just built. These files are heavily commented, so they
|
|
||||||
should be easy to modify. Take care, however, to preserve whitespace. Punctuation
|
|
||||||
such as <code class="computeroutput"><span class="special">;</span></code> will not be recognized
|
|
||||||
as intended by <code class="computeroutput"><span class="identifier">bjam</span></code> if
|
|
||||||
it is not surrounded by whitespace.
|
|
||||||
</p>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h5 class="title">
|
|
||||||
<a name="building.no_install_quickstart.modifying_the_example_project.relocate_the_project"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.relocate_the_project" title="Relocate the Project">Relocate
|
|
||||||
the Project</a>
|
|
||||||
</h5></div></div></div>
|
|
||||||
<p>
|
|
||||||
You'll probably want to copy this project elsewhere so you can change
|
|
||||||
it without modifying your Boost distribution. To do that, simply
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
a. copy the entire <code class="computeroutput"><span class="identifier">example</span><span class="special">/</span><span class="identifier">quickstart</span><span class="special">/</span></code> directory into a new directory.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
b. In the new copies of <code class="computeroutput"><span class="identifier">boost</span><span class="special">-</span><span class="identifier">build</span><span class="special">.</span><span class="identifier">jam</span></code>
|
|
||||||
and <code class="computeroutput"><span class="identifier">Jamroot</span></code>, locate the
|
|
||||||
relative path near the top of the file that is clearly marked by a comment,
|
|
||||||
and edit that path so that it refers to the same directory your Boost
|
|
||||||
distribution as it referred to when the file was in its original location
|
|
||||||
in the <code class="computeroutput"><span class="identifier">example</span><span class="special">/</span><span class="identifier">quickstart</span><span class="special">/</span></code>
|
|
||||||
directory.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
For example, if you moved the project from <code class="computeroutput"><span class="special">/</span><span class="identifier">home</span><span class="special">/</span><span class="identifier">dave</span><span class="special">/</span><span class="identifier">boost_1_34_0</span><span class="special">/</span><span class="identifier">libs</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">example</span><span class="special">/</span><span class="identifier">quickstart</span></code> to <code class="computeroutput"><span class="special">/</span><span class="identifier">home</span><span class="special">/</span><span class="identifier">dave</span><span class="special">/</span><span class="identifier">my</span><span class="special">-</span><span class="identifier">project</span></code>, you could change the first
|
|
||||||
path in <code class="computeroutput"><span class="identifier">boost</span><span class="special">-</span><span class="identifier">build</span><span class="special">.</span><span class="identifier">jam</span></code> from
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">../../../../</span><span class="identifier">tools</span><span class="special">/</span><span class="identifier">build</span><span class="special">/</span><span class="identifier">src</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
to
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">/</span><span class="identifier">home</span><span class="special">/</span><span class="identifier">dave</span><span class="special">/</span><span class="identifier">boost_1_34_0</span><span class="special">/</span><span class="identifier">tools</span><span class="special">/</span><span class="identifier">build</span><span class="special">/</span><span class="identifier">src</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
and change the first path in <code class="computeroutput"><span class="identifier">Jamroot</span></code>
|
|
||||||
from
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">../../../..</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
to
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">/</span><span class="identifier">home</span><span class="special">/</span><span class="identifier">dave</span><span class="special">/</span><span class="identifier">boost_1_34_0</span>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h5 class="title">
|
|
||||||
<a name="building.no_install_quickstart.modifying_the_example_project.add_new_or_change_names_of_exist"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.add_new_or_change_names_of_exist" title="Add New or Change Names of Existing Source Files">Add
|
|
||||||
New or Change Names of Existing Source Files</a>
|
|
||||||
</h5></div></div></div>
|
|
||||||
<p>
|
|
||||||
The names of additional source files involved in building your extension
|
|
||||||
module or embedding application can be listed in <code class="computeroutput"><span class="identifier">Jamroot</span></code>
|
|
||||||
right alongside <code class="computeroutput"><span class="identifier">extending</span><span class="special">.</span><span class="identifier">cpp</span></code>
|
|
||||||
or <code class="computeroutput"><span class="identifier">embedding</span><span class="special">.</span><span class="identifier">cpp</span></code> respectively. Just be sure to leave
|
|
||||||
whitespace around each filename:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="error">…</span> <span class="identifier">file1</span><span class="special">.</span><span class="identifier">cpp</span> <span class="identifier">file2</span><span class="special">.</span><span class="identifier">cpp</span> <span class="identifier">file3</span><span class="special">.</span><span class="identifier">cpp</span> <span class="error">…</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Naturally, if you want to change the name of a source file you can tell
|
|
||||||
Boost.Build about it by editing the name in <code class="computeroutput"><span class="identifier">Jamroot</span></code>.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h5 class="title">
|
|
||||||
<a name="building.no_install_quickstart.modifying_the_example_project.change_the_name_of_your_extensio"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.change_the_name_of_your_extensio" title="Change the Name of your Extension Module">Change
|
|
||||||
the Name of your Extension Module</a>
|
|
||||||
</h5></div></div></div>
|
|
||||||
<p>
|
|
||||||
The name of the extension module is determined by two things:
|
|
||||||
</p>
|
|
||||||
<div class="orderedlist"><ol class="orderedlist" type="1">
|
|
||||||
<li class="listitem">
|
|
||||||
the name in <code class="computeroutput"><span class="identifier">Jamroot</span></code>
|
|
||||||
immediately following <code class="computeroutput"><span class="identifier">python</span><span class="special">-</span><span class="identifier">extension</span></code>,
|
|
||||||
and
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
the name passed to <code class="computeroutput"><span class="identifier">BOOST_PYTHON_MODULE</span></code>
|
|
||||||
in <code class="computeroutput"><span class="identifier">extending</span><span class="special">.</span><span class="identifier">cpp</span></code>.
|
|
||||||
</li>
|
|
||||||
</ol></div>
|
|
||||||
<p>
|
|
||||||
To change the name of the extension module from <code class="computeroutput"><span class="identifier">extending</span></code>
|
|
||||||
to <code class="computeroutput"><span class="identifier">hello</span></code>, you'd edit
|
|
||||||
<code class="computeroutput"><span class="identifier">Jamroot</span></code>, changing
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">python</span><span class="special">-</span><span class="identifier">extension</span> <span class="identifier">extending</span> <span class="special">:</span> <span class="identifier">extending</span><span class="special">.</span><span class="identifier">cpp</span> <span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
to
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">python</span><span class="special">-</span><span class="identifier">extension</span> <span class="identifier">hello</span> <span class="special">:</span> <span class="identifier">extending</span><span class="special">.</span><span class="identifier">cpp</span> <span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
and you'd edit extending.cpp, changing
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">extending</span><span class="special">)</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
to
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">hello</span><span class="special">)</span>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="background.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="installing_boost_python_on_your_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
|
||||||
<link rel="prev" href="testing_boost_python.html" title="Testing Boost.Python">
|
|
||||||
<link rel="next" href="../configuration.html" title="Chapter 3. Configuration">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="testing_boost_python.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../configuration.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="building.notes_for_mingw_and_cygwin_with_"></a><a class="link" href="notes_for_mingw_and_cygwin_with_.html" title="Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users">Notes for
|
|
||||||
MinGW (and Cygwin with -mno-cygwin) GCC Users</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
If you are using a version of Python prior to 2.4.1 with a MinGW prior to
|
|
||||||
3.0.0 (with binutils-2.13.90-20030111-1), you will need to create a MinGW-compatible
|
|
||||||
version of the Python library; the one shipped with Python will only work
|
|
||||||
with a Microsoft-compatible linker. Follow the instructions in the “Non-Microsoft”
|
|
||||||
section of the “Building Extensions: Tips And Tricks” chapter in <a href="https://docs.python.org/2/install/index.html" target="_top">Installing Python Modules</a>
|
|
||||||
to create <code class="computeroutput"><span class="identifier">libpythonXX</span><span class="special">.</span><span class="identifier">a</span></code>, where <code class="computeroutput"><span class="identifier">XX</span></code>
|
|
||||||
corresponds to the major and minor version numbers of your Python installation.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="testing_boost_python.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../configuration.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Python Debugging Builds</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
|
||||||
<link rel="prev" href="include_issues.html" title="#include Issues">
|
|
||||||
<link rel="next" href="testing_boost_python.html" title="Testing Boost.Python">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="include_issues.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="testing_boost_python.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="building.python_debugging_builds"></a><a class="link" href="python_debugging_builds.html" title="Python Debugging Builds">Python Debugging Builds</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
Python can be built in a special “python debugging” configuration that
|
|
||||||
adds extra checks and instrumentation that can be very useful for developers
|
|
||||||
of extension modules. The data structures used by the debugging configuration
|
|
||||||
contain additional members, so <span class="bold"><strong>a Python executable
|
|
||||||
built with python debugging enabled cannot be used with an extension module
|
|
||||||
or library compiled without it, and vice-versa.</strong></span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Since pre-built “python debugging” versions of the Python executable
|
|
||||||
and libraries are not supplied with most distributions of Python, <a href="#ftn.building.python_debugging_builds.f0" class="footnote" name="building.python_debugging_builds.f0"><sup class="footnote">[5]</sup></a> and we didn't want to force our users to build them, Boost.Build
|
|
||||||
does not automatically enable python debugging in its <code class="computeroutput"><span class="identifier">debug</span></code>
|
|
||||||
build variant (which is the default). Instead there is a special build property
|
|
||||||
called <code class="computeroutput"><span class="identifier">python</span><span class="special">-</span><span class="identifier">debugging</span></code> that, when used as a build property,
|
|
||||||
will define the right preprocessor symbols and select the right libraries
|
|
||||||
to link with.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
On unix-variant platforms, the debugging versions of Python's data structures
|
|
||||||
will only be used if the symbol <code class="computeroutput"><span class="identifier">Py_DEBUG</span></code>
|
|
||||||
is defined. On many windows compilers, when extension modules are built with
|
|
||||||
the preprocessor symbol <code class="computeroutput"><span class="identifier">_DEBUG</span></code>,
|
|
||||||
Python defaults to force linking with a special debugging version of the
|
|
||||||
Python DLL. Since that symbol is very commonly used even when Python is not
|
|
||||||
present, Boost.Python temporarily undefines <code class="computeroutput"><span class="identifier">_DEBUG</span></code>
|
|
||||||
when <code class="computeroutput"><span class="identifier">Python</span><span class="special">.</span><span class="identifier">h</span></code> is #included from <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">wrap_python</span><span class="special">.</span><span class="identifier">hpp</span></code> -
|
|
||||||
unless <code class="computeroutput"><span class="identifier">BOOST_DEBUG_PYTHON</span></code>
|
|
||||||
is defined. The upshot is that if you want “python debugging”and you
|
|
||||||
aren't using Boost.Build, you should make sure <code class="computeroutput"><span class="identifier">BOOST_DEBUG_PYTHON</span></code>
|
|
||||||
is defined, or python debugging will be suppressed.
|
|
||||||
</p>
|
|
||||||
<div class="footnotes">
|
|
||||||
<br><hr style="width:100; text-align:left;margin-left: 0">
|
|
||||||
<div id="ftn.building.python_debugging_builds.f0" class="footnote"><p><a href="#building.python_debugging_builds.f0" class="para"><sup class="para">[5] </sup></a>
|
|
||||||
On Unix and similar platforms, a debugging python and associated libraries
|
|
||||||
are built by adding --with-pydebug when configuring the Python build. On
|
|
||||||
Windows, the debugging version of Python is generated by the "Win32
|
|
||||||
Debug" target of the Visual Studio project in the PCBuild subdirectory
|
|
||||||
of a full Python source code distribution.
|
|
||||||
</p></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="include_issues.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="testing_boost_python.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Testing Boost.Python</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
|
||||||
<link rel="prev" href="python_debugging_builds.html" title="Python Debugging Builds">
|
|
||||||
<link rel="next" href="notes_for_mingw_and_cygwin_with_.html" title="Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="python_debugging_builds.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="notes_for_mingw_and_cygwin_with_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="building.testing_boost_python"></a><a class="link" href="testing_boost_python.html" title="Testing Boost.Python">Testing Boost.Python</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
To run the full test suite for Boost.Python, invoke <code class="computeroutput"><span class="identifier">bjam</span></code>
|
|
||||||
in the <code class="computeroutput"><span class="identifier">test</span></code> subdirectory
|
|
||||||
of your Boost.Python distribution.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="python_debugging_builds.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="notes_for_mingw_and_cygwin_with_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,340 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Chapter 3. Configuration</title>
|
|
||||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="index.html" title="Boost.Python">
|
|
||||||
<link rel="prev" href="building/notes_for_mingw_and_cygwin_with_.html" title="Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users">
|
|
||||||
<link rel="next" href="support.html" title="Chapter 4. Support Resources">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="building/notes_for_mingw_and_cygwin_with_.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="support.html"><img src="images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="chapter">
|
|
||||||
<div class="titlepage"><div>
|
|
||||||
<div><h1 class="title">
|
|
||||||
<a name="configuration"></a>Chapter 3. Configuration</h1></div>
|
|
||||||
<div><div class="authorgroup"><div class="author"><h3 class="author">
|
|
||||||
<span class="firstname">David</span> <span class="surname">Abrahams</span>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<div><p class="copyright">Copyright © 2002-2015 David Abrahams, Stefan Seefeld</p></div>
|
|
||||||
</div></div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="configuration.configuration"></a><a class="link" href="configuration.html#configuration.configuration" title="Configuration">Configuration</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<div class="toc"><dl class="toc">
|
|
||||||
<dt><span class="section"><a href="configuration.html#configuration.configuration.introduction">Introduction</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="configuration.html#configuration.configuration.application_defined_macros">Application
|
|
||||||
Defined Macros</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="configuration.html#configuration.configuration.library_defined_defined_macros">Library
|
|
||||||
Defined Defined Macros</a></span></dt>
|
|
||||||
</dl></div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="configuration.configuration.introduction"></a><a class="link" href="configuration.html#configuration.configuration.introduction" title="Introduction">Introduction</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<p>
|
|
||||||
<span class="bold"><strong>Boost.Python</strong></span> uses several configuration
|
|
||||||
macros in <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>, as well as configuration macros meant
|
|
||||||
to be supplied by the application. These macros are documented here.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="configuration.configuration.application_defined_macros"></a><a class="link" href="configuration.html#configuration.configuration.application_defined_macros" title="Application Defined Macros">Application
|
|
||||||
Defined Macros</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<p>
|
|
||||||
These are the macros that may be defined by an application using Boost.Python.
|
|
||||||
Note that if you extend a strict interpretation of the C++ standard to
|
|
||||||
cover dynamic libraries, using different values of these macros when compiling
|
|
||||||
different libraries (including extension modules and the Boost.Python library
|
|
||||||
itself) is a violation of the <a class="link" href="glossary.html#odr">ODR</a>. However,
|
|
||||||
we know of no C++ implementations on which this particular violation is
|
|
||||||
detectable or causes any problems.
|
|
||||||
</p>
|
|
||||||
<div class="informaltable"><table class="table">
|
|
||||||
<colgroup>
|
|
||||||
<col>
|
|
||||||
<col>
|
|
||||||
<col>
|
|
||||||
</colgroup>
|
|
||||||
<thead><tr>
|
|
||||||
<th>
|
|
||||||
<p>
|
|
||||||
Macro
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<p>
|
|
||||||
Default
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<p>
|
|
||||||
Meaning
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
</tr></thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
BOOST_PYTHON_MAX_ARITY
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
15
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
The maximum arity of any function, member function, or constructor
|
|
||||||
to be wrapped, invocation of a Boost.Python function wich is
|
|
||||||
specified as taking arguments x1, x2,...Xn. This includes, in
|
|
||||||
particular, callback mechanisms such as object::operator()(...)
|
|
||||||
or call_method<R>(... ).
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
BOOST_PYTHON_MAX_BASES
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
10
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
The maximum number of template arguments to the <code class="computeroutput"><span class="identifier">bases</span><span class="special"><...></span></code>
|
|
||||||
class template, which is used to specify the bases of a wrapped
|
|
||||||
C++ class..
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
BOOST_PYTHON_STATIC_MODULE
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>not defined</em></span>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
If defined, prevents your module initialization function from
|
|
||||||
being treated as an exported symbol on platforms which support
|
|
||||||
that distinction in-code
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
BOOST_PYTHON_ENABLE_CDECL
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>not defined</em></span>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
If defined, allows functions using the <code class="computeroutput"><span class="identifier">__cdecl</span></code>
|
|
||||||
calling convention to be wrapped.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
BOOST_PYTHON_ENABLE_STDCALL
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>not defined</em></span>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
If defined, allows functions using the <code class="computeroutput"><span class="identifier">__stdcall</span></code>
|
|
||||||
calling convention to be wrapped.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
BOOST_PYTHON_ENABLE_FASTCALL
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>not defined</em></span>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
If defined, allows functions using the <code class="computeroutput"><span class="identifier">__fastcall</span></code>
|
|
||||||
calling convention to be wrapped.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table></div>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h4 class="title">
|
|
||||||
<a name="configuration.configuration.library_defined_defined_macros"></a><a class="link" href="configuration.html#configuration.configuration.library_defined_defined_macros" title="Library Defined Defined Macros">Library
|
|
||||||
Defined Defined Macros</a>
|
|
||||||
</h4></div></div></div>
|
|
||||||
<p>
|
|
||||||
These macros are defined by <span class="bold"><strong>Boost.Python</strong></span>
|
|
||||||
and are implementation details of interest only to implementors and those
|
|
||||||
porting to new platforms.
|
|
||||||
</p>
|
|
||||||
<div class="informaltable"><table class="table">
|
|
||||||
<colgroup>
|
|
||||||
<col>
|
|
||||||
<col>
|
|
||||||
<col>
|
|
||||||
</colgroup>
|
|
||||||
<thead><tr>
|
|
||||||
<th>
|
|
||||||
<p>
|
|
||||||
Macro
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<p>
|
|
||||||
Default
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<p>
|
|
||||||
Meaning
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
</tr></thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
BOOST_PYTHON_TYPE_ID_NAME
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>not defined</em></span>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
If defined, this indicates that the type_info comparison across
|
|
||||||
shared library boundaries does not work on this platform. In
|
|
||||||
other words, if shared-lib-1 passes <code class="computeroutput"><span class="keyword">typeid</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span></code> to a function in shared-lib-2
|
|
||||||
which compares it to <code class="computeroutput"><span class="keyword">typeid</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span></code>, that comparison may return
|
|
||||||
<code class="computeroutput"><span class="keyword">false</span></code>. If this macro
|
|
||||||
is #defined, Boost.Python uses and compares <code class="computeroutput"><span class="keyword">typeid</span><span class="special">(</span><span class="identifier">T</span><span class="special">).</span><span class="identifier">name</span><span class="special">()</span></code> instead of using and comparing
|
|
||||||
the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">type_info</span></code> objects directly.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
BOOST_PYTHON_NO_PY_SIGNATURES
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>not defined</em></span>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
If defined for a module no pythonic signatures are generated
|
|
||||||
for the docstrings of the module functions, and no python type
|
|
||||||
is associated with any of the converters registered by the module.
|
|
||||||
This also reduces the binary size of the module by about 14%
|
|
||||||
(gcc compiled). If defined for the boost_python runtime library,
|
|
||||||
the default for the <code class="computeroutput"><span class="identifier">docstring_options</span><span class="special">.</span><span class="identifier">enable_py_signatures</span><span class="special">()</span></code> is set to <code class="computeroutput"><span class="keyword">false</span></code>.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
BOOST_PYTHON_SUPPORTS_PY_SIGNATURES
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>defined</em></span> if <code class="computeroutput"><span class="identifier">BOOST_PYTHON_NO_PY_SIGNATURES</span></code>
|
|
||||||
is <span class="emphasis"><em>undefined</em></span>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
This macro is defined to enable a smooth transition from older
|
|
||||||
Boost.Python versions which do not support pythonic signatures.
|
|
||||||
For example usage see here.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>not defined</em></span>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
If defined the python type of <code class="computeroutput"><span class="identifier">__init__</span></code>
|
|
||||||
method "self" parameters is properly generated, otherwise
|
|
||||||
object is used. It is undefined by default because it increases
|
|
||||||
the binary size of the module by about 14% (gcc compiled).
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="building/notes_for_mingw_and_cygwin_with_.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="support.html"><img src="images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Chapter 5. Frequently Asked Questions (FAQs)</title>
|
|
||||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="index.html" title="Boost.Python">
|
|
||||||
<link rel="prev" href="support.html" title="Chapter 4. Support Resources">
|
|
||||||
<link rel="next" href="faq/i_m_getting_the_attempt_to_retur.html" title="I'm getting the "attempt to return dangling reference" error. What am I doing wrong?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="support.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="faq/i_m_getting_the_attempt_to_retur.html"><img src="images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="chapter">
|
|
||||||
<div class="titlepage"><div><div><h1 class="title">
|
|
||||||
<a name="faq"></a>Chapter 5. Frequently Asked Questions (FAQs)</h1></div></div></div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.how_can_i_wrap_a_function_which_"></a><a class="link" href="faq.html#faq.how_can_i_wrap_a_function_which_" title="How can I wrap a function which takes a function pointer as an argument?">How can I wrap
|
|
||||||
a function which takes a function pointer as an argument?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
If what you're trying to do is something like this:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</span><span class="keyword">void</span> <span class="special">(</span><span class="identifier">string</span> <span class="identifier">s</span><span class="special">)</span> <span class="special">></span> <span class="identifier">funcptr</span><span class="special">;</span>
|
|
||||||
|
|
||||||
<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">funcptr</span> <span class="identifier">fp</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">fp</span><span class="special">(</span><span class="string">"hello,world!"</span><span class="special">);</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
|
|
||||||
<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">test</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"foo"</span><span class="special">,</span><span class="identifier">foo</span><span class="special">);</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
And then:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">>>></span> <span class="identifier">def</span> <span class="identifier">hello</span><span class="special">(</span><span class="identifier">s</span><span class="special">):</span>
|
|
||||||
<span class="special">...</span> <span class="identifier">print</span> <span class="identifier">s</span>
|
|
||||||
<span class="special">...</span>
|
|
||||||
<span class="special">>>></span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">hello</span><span class="special">)</span>
|
|
||||||
<span class="identifier">hello</span><span class="special">,</span> <span class="identifier">world</span><span class="special">!</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
The short answer is: "you can't". This is not a Boost.Python limitation
|
|
||||||
so much as a limitation of C++. The problem is that a Python function is
|
|
||||||
actually data, and the only way of associating data with a C++ function pointer
|
|
||||||
is to store it in a static variable of the function. The problem with that
|
|
||||||
is that you can only associate one piece of data with every C++ function,
|
|
||||||
and we have no way of compiling a new C++ function on-the-fly for every Python
|
|
||||||
function you decide to pass to <code class="computeroutput"><span class="identifier">foo</span></code>.
|
|
||||||
In other words, this could work if the C++ function is always going to invoke
|
|
||||||
the <span class="emphasis"><em>same</em></span> Python function, but you probably don't want
|
|
||||||
that.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
If you have the luxury of changing the C++ code you're wrapping, pass it
|
|
||||||
an <code class="computeroutput"><span class="identifier">object</span></code> instead and call
|
|
||||||
that; the overloaded function call operator will invoke the Python function
|
|
||||||
you pass it behind the <code class="computeroutput"><span class="identifier">object</span></code>.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="support.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="faq/i_m_getting_the_attempt_to_retur.html"><img src="images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Compilation takes too much time and eats too much memory! What can I do to make it faster?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="how_can_i_wrap_a_function_which0.html" title="How can I wrap a function which needs to take ownership of a raw pointer?">
|
|
||||||
<link rel="next" href="how_do_i_create_sub_packages_usi.html" title="How do I create sub-packages using Boost.Python?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_can_i_wrap_a_function_which0.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_do_i_create_sub_packages_usi.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.compilation_takes_too_much_time_"></a><a class="link" href="compilation_takes_too_much_time_.html" title="Compilation takes too much time and eats too much memory! What can I do to make it faster?">Compilation takes
|
|
||||||
too much time and eats too much memory! What can I do to make it faster?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
Please refer to the <code class="computeroutput"><span class="identifier">Reducing</span> <span class="identifier">Compiling</span> <span class="identifier">Time</span></code>
|
|
||||||
section in the <a href="../tutorial/index.html" target="_top">Tutorial</a>.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_can_i_wrap_a_function_which0.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_do_i_create_sub_packages_usi.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Does Boost.Python work with Mac OS X?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="why_doesn_t_my_operator_work.html" title="Why doesn't my *= operator work?">
|
|
||||||
<link rel="next" href="how_can_i_find_the_existing_pyob.html" title="How can I find the existing PyObject that holds a C++ object?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="why_doesn_t_my_operator_work.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_find_the_existing_pyob.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.does_boost_python_work_with_mac_"></a><a class="link" href="does_boost_python_work_with_mac_.html" title="Does Boost.Python work with Mac OS X?">Does Boost.Python
|
|
||||||
work with Mac OS X?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
It is known to work under 10.2.8 and 10.3 using Apple's gcc 3.3 compiler:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">gcc</span> <span class="special">(</span><span class="identifier">GCC</span><span class="special">)</span> <span class="number">3.3</span> <span class="number">20030304</span> <span class="special">(</span><span class="identifier">Apple</span> <span class="identifier">Computer</span><span class="special">,</span> <span class="identifier">Inc</span><span class="special">.</span> <span class="identifier">build</span> <span class="number">1493</span><span class="special">)</span></pre>
|
|
||||||
<p>
|
|
||||||
Under 10.2.8 get the August 2003 gcc update (free at <a href="http://connect.apple.com" target="_top">http://connect.apple.com</a>).
|
|
||||||
Under 10.3 get the Xcode Tools v1.0 (also free).
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Python 2.3 is required. The Python that ships with 10.3 is fine. Under 10.2.8
|
|
||||||
use these commands to install Python as a framework:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">./</span><span class="identifier">configure</span> <span class="special">--</span><span class="identifier">enable</span><span class="special">-</span><span class="identifier">framework</span>
|
|
||||||
<span class="identifier">make</span>
|
|
||||||
<span class="identifier">make</span> <span class="identifier">frameworkinstall</span></pre>
|
|
||||||
<p>
|
|
||||||
The last command requires root privileges because the target directory is
|
|
||||||
<code class="computeroutput"><span class="special">/</span><span class="identifier">Library</span><span class="special">/</span><span class="identifier">Frameworks</span><span class="special">/</span><span class="identifier">Python</span><span class="special">.</span><span class="identifier">framework</span><span class="special">/</span><span class="identifier">Versions</span><span class="special">/</span><span class="number">2.3</span></code>. However,
|
|
||||||
the installation does not interfere with the Python version that ships with
|
|
||||||
10.2.8.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
It is also crucial to increase the <code class="computeroutput"><span class="identifier">stacksize</span></code>
|
|
||||||
before starting compilations, e.g.:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">limit</span> <span class="identifier">stacksize</span> <span class="number">8192</span><span class="identifier">k</span></pre>
|
|
||||||
<p>
|
|
||||||
If the <code class="computeroutput"><span class="identifier">stacksize</span></code> is too small
|
|
||||||
the build might crash with internal compiler errors.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Sometimes Apple's compiler exhibits a bug by printing an error like the following
|
|
||||||
while compiling a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">class_</span><span class="special"><</span><span class="identifier">your_type</span><span class="special">></span></code>
|
|
||||||
template instantiation:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">.../</span><span class="identifier">inheritance</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">:</span><span class="number">44</span><span class="special">:</span> <span class="identifier">error</span><span class="special">:</span> <span class="identifier">cannot</span>
|
|
||||||
<span class="keyword">dynamic_cast</span> <span class="error">`</span><span class="identifier">p</span><span class="char">' (of type `struct cctbx::boost_python::<unnamed>::add_pair*
|
|
||||||
'</span><span class="special">)</span> <span class="identifier">to</span> <span class="identifier">type</span> <span class="error">`</span><span class="keyword">void</span><span class="special">*</span><span class="error">'</span> <span class="special">(</span><span class="identifier">source</span> <span class="identifier">type</span> <span class="identifier">is</span> <span class="keyword">not</span> <span class="identifier">polymorphic</span><span class="special">)</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
We do not know a general workaround, but if the definition of <code class="computeroutput"><span class="identifier">your_type</span></code> can be modified the following
|
|
||||||
was found to work in all cases encountered so far:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">your_type</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="comment">// before defining any member data</span>
|
|
||||||
<span class="preprocessor">#if</span> <span class="identifier">defined</span><span class="special">(</span><span class="identifier">__MACH__</span><span class="special">)</span> <span class="special">&</span><span class="identifier">amp</span><span class="special">;&</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">defined</span><span class="special">(</span><span class="identifier">__APPLE_CC__</span><span class="special">)</span> <span class="special">&</span><span class="identifier">amp</span><span class="special">;&</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">__APPLE_CC__</span> <span class="special">==</span> <span class="number">1493</span>
|
|
||||||
<span class="keyword">bool</span> <span class="identifier">dummy_</span><span class="special">;</span>
|
|
||||||
<span class="preprocessor">#endif</span>
|
|
||||||
<span class="comment">// now your member data, e.g.</span>
|
|
||||||
<span class="keyword">double</span> <span class="identifier">x</span><span class="special">;</span>
|
|
||||||
<span class="keyword">int</span> <span class="identifier">j</span><span class="special">;</span>
|
|
||||||
<span class="comment">// etc.</span>
|
|
||||||
<span class="special">};</span>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="why_doesn_t_my_operator_work.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_find_the_existing_pyob.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>error C2064: term does not evaluate to a function taking 2 arguments</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="how_do_i_create_sub_packages_usi.html" title="How do I create sub-packages using Boost.Python?">
|
|
||||||
<link rel="next" href="how_can_i_automatically_convert_.html" title="How can I automatically convert my custom string type to and from a Python string?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_do_i_create_sub_packages_usi.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_automatically_convert_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.error_c2064_term_does_not_evalua"></a><a class="link" href="error_c2064_term_does_not_evalua.html" title="error C2064: term does not evaluate to a function taking 2 arguments">error C2064: term
|
|
||||||
does not evaluate to a function taking 2 arguments</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>Niall Douglas provides these notes:</em></span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
If you see Microsoft Visual C++ 7.1 (MS Visual Studio .NET 2003) issue an
|
|
||||||
error message like the following it is most likely due to a bug in the compiler:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">boost</span><span class="special">\</span><span class="identifier">boost</span><span class="special">\</span><span class="identifier">python</span><span class="special">\</span><span class="identifier">detail</span><span class="special">\</span><span class="identifier">invoke</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">(</span><span class="number">76</span><span class="special">):</span>
|
|
||||||
<span class="identifier">error</span> <span class="identifier">C2064</span><span class="special">:</span> <span class="identifier">term</span> <span class="identifier">does</span> <span class="keyword">not</span> <span class="identifier">evaluate</span> <span class="identifier">to</span> <span class="identifier">a</span> <span class="identifier">function</span> <span class="identifier">taking</span> <span class="number">2</span> <span class="identifier">arguments</span><span class="error">"</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
This message is triggered by code like the following:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
|
||||||
|
|
||||||
<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
|
|
||||||
|
|
||||||
<span class="keyword">class</span> <span class="identifier">FXThread</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="keyword">public</span><span class="special">:</span>
|
|
||||||
<span class="keyword">bool</span> <span class="identifier">setAutoDelete</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">doso</span><span class="special">)</span> <span class="keyword">throw</span><span class="special">();</span>
|
|
||||||
<span class="special">};</span>
|
|
||||||
|
|
||||||
<span class="keyword">void</span> <span class="identifier">Export_FXThread</span><span class="special">()</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">class_</span><span class="special"><</span> <span class="identifier">FXThread</span> <span class="special">>(</span><span class="string">"FXThread"</span><span class="special">)</span>
|
|
||||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"setAutoDelete"</span><span class="special">,</span> <span class="special">&</span><span class="identifier">amp</span><span class="special">;</span><span class="identifier">FXThread</span><span class="special">::</span><span class="identifier">setAutoDelete</span><span class="special">)</span>
|
|
||||||
<span class="special">;</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
The bug is related to the <code class="computeroutput"><span class="keyword">throw</span><span class="special">()</span></code> modifier. As a workaround cast off the
|
|
||||||
modifier. E.g.:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"setAutoDelete"</span><span class="special">,</span> <span class="special">(</span><span class="keyword">bool</span> <span class="special">(</span><span class="identifier">FXThread</span><span class="special">::*)(</span><span class="keyword">bool</span><span class="special">))</span> <span class="special">&</span><span class="identifier">FXThread</span><span class="special">::</span><span class="identifier">setAutoDelete</span><span class="special">)</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
(The bug has been reported to Microsoft.)
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_do_i_create_sub_packages_usi.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_automatically_convert_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>fatal error C1204:Compiler limit:internal structure overflow</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="how_can_i_wrap_functions_which_t.html" title="How can I wrap functions which take C++ containers as arguments?">
|
|
||||||
<link rel="next" href="how_do_i_debug_my_python_extensi.html" title="How do I debug my Python extensions?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_can_i_wrap_functions_which_t.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_do_i_debug_my_python_extensi.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.fatal_error_c1204_compiler_limit"></a><a class="link" href="fatal_error_c1204_compiler_limit.html" title="fatal error C1204:Compiler limit:internal structure overflow">fatal error C1204:Compiler
|
|
||||||
limit:internal structure overflow</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
<span class="bold"><strong>Q:</strong></span> <span class="emphasis"><em>I get this error message when
|
|
||||||
compiling a large source file. What can I do?</em></span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<span class="bold"><strong>A:</strong></span> You have two choices:
|
|
||||||
</p>
|
|
||||||
<div class="orderedlist"><ol class="orderedlist" type="1">
|
|
||||||
<li class="listitem">
|
|
||||||
Upgrade your compiler (preferred)
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Break your source file up into multiple translation units.
|
|
||||||
<p>
|
|
||||||
<code class="computeroutput"><span class="identifier">my_module</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">...</span>
|
|
||||||
<span class="keyword">void</span> <span class="identifier">more_of_my_module</span><span class="special">();</span>
|
|
||||||
<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">my_module</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"foo"</span><span class="special">,</span> <span class="identifier">foo</span><span class="special">);</span>
|
|
||||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,</span> <span class="identifier">bar</span><span class="special">);</span>
|
|
||||||
<span class="special">...</span>
|
|
||||||
<span class="identifier">more_of_my_module</span><span class="special">();</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
<code class="computeroutput"><span class="identifier">more_of_my_module</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">more_of_my_module</span><span class="special">()</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"baz"</span><span class="special">,</span> <span class="identifier">baz</span><span class="special">);</span>
|
|
||||||
<span class="special">...</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
If you find that a <code class="computeroutput"><span class="identifier">class_</span><span class="special"><...></span></code> declaration can't fit in
|
|
||||||
a single source file without triggering the error, you can always pass
|
|
||||||
a reference to the <code class="computeroutput"><span class="identifier">class_</span></code>
|
|
||||||
object to a function in another source file, and call some of its member
|
|
||||||
functions (e.g. <code class="computeroutput"><span class="special">.</span><span class="identifier">def</span><span class="special">(...)</span></code>) in the auxilliary source file:
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<code class="computeroutput"><span class="identifier">more_of_my_class</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">more_of_my_class</span><span class="special">(</span><span class="keyword">class</span><span class="special">&</span><span class="identifier">lt</span><span class="special">;</span><span class="identifier">my_class</span><span class="special">&</span><span class="identifier">gt</span><span class="special">;&</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">x</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">x</span>
|
|
||||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"baz"</span><span class="special">,</span> <span class="identifier">baz</span><span class="special">)</span>
|
|
||||||
<span class="special">.</span><span class="identifier">add_property</span><span class="special">(</span><span class="string">"xx"</span><span class="special">,</span> <span class="special">&</span><span class="identifier">my_class</span><span class="special">::</span><span class="identifier">get_xx</span><span class="special">,</span> <span class="special">&</span><span class="identifier">my_class</span><span class="special">::</span><span class="identifier">set_xx</span><span class="special">)</span>
|
|
||||||
<span class="special">;</span>
|
|
||||||
<span class="special">...</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
</ol></div>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_can_i_wrap_functions_which_t.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_do_i_debug_my_python_extensi.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>How can I automatically convert my custom string type to and from a Python string?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="error_c2064_term_does_not_evalua.html" title="error C2064: term does not evaluate to a function taking 2 arguments">
|
|
||||||
<link rel="next" href="why_is_my_automatic_to_python_co.html" title="Why is my automatic to-python conversion not being found?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="error_c2064_term_does_not_evalua.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="why_is_my_automatic_to_python_co.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.how_can_i_automatically_convert_"></a><a class="link" href="how_can_i_automatically_convert_.html" title="How can I automatically convert my custom string type to and from a Python string?">How can I automatically
|
|
||||||
convert my custom string type to and from a Python string?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>Ralf W. Grosse-Kunstleve provides these notes:</em></span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Below is a small, self-contained demo extension module that shows how to
|
|
||||||
do this. Here is the corresponding trivial test:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">import</span> <span class="identifier">custom_string</span>
|
|
||||||
<span class="identifier">assert</span> <span class="identifier">custom_string</span><span class="special">.</span><span class="identifier">hello</span><span class="special">()</span> <span class="special">==</span> <span class="string">"Hello world."</span>
|
|
||||||
<span class="identifier">assert</span> <span class="identifier">custom_string</span><span class="special">.</span><span class="identifier">size</span><span class="special">(</span><span class="string">"california"</span><span class="special">)</span> <span class="special">==</span> <span class="number">10</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
If you look at the code you will find:
|
|
||||||
</p>
|
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
|
||||||
<li class="listitem">
|
|
||||||
A custom <code class="computeroutput"><span class="identifier">to_python</span></code> converter
|
|
||||||
(easy): <code class="computeroutput"><span class="identifier">custom_string_to_python_str</span></code>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
A custom lvalue converter (needs more code): <code class="computeroutput"><span class="identifier">custom_string_from_python_str</span></code>
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
|
||||||
<p>
|
|
||||||
The custom converters are registered in the global Boost.Python registry
|
|
||||||
near the top of the module initialization function. Once flow control has
|
|
||||||
passed through the registration code the automatic conversions from and to
|
|
||||||
Python strings will work in any module imported in the same process.
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">module</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">def</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">to_python_converter</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
|
||||||
|
|
||||||
<span class="keyword">namespace</span> <span class="identifier">sandbox</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="special">{</span>
|
|
||||||
|
|
||||||
<span class="keyword">class</span> <span class="identifier">custom_string</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="keyword">public</span><span class="special">:</span>
|
|
||||||
<span class="identifier">custom_string</span><span class="special">()</span> <span class="special">{}</span>
|
|
||||||
<span class="identifier">custom_string</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">value_</span><span class="special">(</span><span class="identifier">value</span><span class="special">)</span> <span class="special">{}</span>
|
|
||||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">value</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">value_</span><span class="special">;</span> <span class="special">}</span>
|
|
||||||
<span class="keyword">private</span><span class="special">:</span>
|
|
||||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">value_</span><span class="special">;</span>
|
|
||||||
<span class="special">};</span>
|
|
||||||
|
|
||||||
<span class="keyword">struct</span> <span class="identifier">custom_string_to_python_str</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="keyword">static</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">convert</span><span class="special">(</span><span class="identifier">custom_string</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">s</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">incref</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span><span class="special">(</span><span class="identifier">s</span><span class="special">.</span><span class="identifier">value</span><span class="special">()).</span><span class="identifier">ptr</span><span class="special">());</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
<span class="special">};</span>
|
|
||||||
|
|
||||||
<span class="keyword">struct</span> <span class="identifier">custom_string_from_python_str</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">custom_string_from_python_str</span><span class="special">()</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">converter</span><span class="special">::</span><span class="identifier">registry</span><span class="special">::</span><span class="identifier">push_back</span><span class="special">(</span>
|
|
||||||
<span class="special">&</span><span class="identifier">convertible</span><span class="special">,</span>
|
|
||||||
<span class="special">&</span><span class="identifier">construct</span><span class="special">,</span>
|
|
||||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">type_id</span><span class="special"><</span><span class="identifier">custom_string</span><span class="special">>());</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
|
|
||||||
<span class="keyword">static</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">convertible</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">obj_ptr</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="keyword">if</span> <span class="special">(!</span><span class="identifier">PyString_Check</span><span class="special">(</span><span class="identifier">obj_ptr</span><span class="special">))</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
|
|
||||||
<span class="keyword">return</span> <span class="identifier">obj_ptr</span><span class="special">;</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
|
|
||||||
<span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">construct</span><span class="special">(</span>
|
|
||||||
<span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">obj_ptr</span><span class="special">,</span>
|
|
||||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">converter</span><span class="special">::</span><span class="identifier">rvalue_from_python_stage1_data</span><span class="special">*</span> <span class="identifier">data</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">value</span> <span class="special">=</span> <span class="identifier">PyString_AsString</span><span class="special">(</span><span class="identifier">obj_ptr</span><span class="special">);</span>
|
|
||||||
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">value</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">throw_error_already_set</span><span class="special">();</span>
|
|
||||||
<span class="keyword">void</span><span class="special">*</span> <span class="identifier">storage</span> <span class="special">=</span> <span class="special">(</span>
|
|
||||||
<span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">converter</span><span class="special">::</span><span class="identifier">rvalue_from_python_storage</span><span class="special"><</span><span class="identifier">custom_string</span><span class="special">>*)</span>
|
|
||||||
<span class="identifier">data</span><span class="special">)-></span><span class="identifier">storage</span><span class="special">.</span><span class="identifier">bytes</span><span class="special">;</span>
|
|
||||||
<span class="keyword">new</span> <span class="special">(</span><span class="identifier">storage</span><span class="special">)</span> <span class="identifier">custom_string</span><span class="special">(</span><span class="identifier">value</span><span class="special">);</span>
|
|
||||||
<span class="identifier">data</span><span class="special">-></span><span class="identifier">convertible</span> <span class="special">=</span> <span class="identifier">storage</span><span class="special">;</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
<span class="special">};</span>
|
|
||||||
|
|
||||||
<span class="identifier">custom_string</span> <span class="identifier">hello</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">custom_string</span><span class="special">(</span><span class="string">"Hello world."</span><span class="special">);</span> <span class="special">}</span>
|
|
||||||
|
|
||||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">(</span><span class="identifier">custom_string</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">s</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">value</span><span class="special">().</span><span class="identifier">size</span><span class="special">();</span> <span class="special">}</span>
|
|
||||||
|
|
||||||
<span class="keyword">void</span> <span class="identifier">init_module</span><span class="special">()</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
|
|
||||||
|
|
||||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">to_python_converter</span><span class="special"><</span>
|
|
||||||
<span class="identifier">custom_string</span><span class="special">,</span>
|
|
||||||
<span class="identifier">custom_string_to_python_str</span><span class="special">>();</span>
|
|
||||||
|
|
||||||
<span class="identifier">custom_string_from_python_str</span><span class="special">();</span>
|
|
||||||
|
|
||||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"hello"</span><span class="special">,</span> <span class="identifier">hello</span><span class="special">);</span>
|
|
||||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"size"</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
|
|
||||||
<span class="special">}}</span> <span class="comment">// namespace sandbox::<anonymous></span>
|
|
||||||
|
|
||||||
<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">custom_string</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">sandbox</span><span class="special">::</span><span class="identifier">init_module</span><span class="special">();</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="error_c2064_term_does_not_evalua.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="why_is_my_automatic_to_python_co.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>How can I find the existing PyObject that holds a C++ object?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="does_boost_python_work_with_mac_.html" title="Does Boost.Python work with Mac OS X?">
|
|
||||||
<link rel="next" href="how_can_i_wrap_a_function_which0.html" title="How can I wrap a function which needs to take ownership of a raw pointer?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="does_boost_python_work_with_mac_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_wrap_a_function_which0.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.how_can_i_find_the_existing_pyob"></a><a class="link" href="how_can_i_find_the_existing_pyob.html" title="How can I find the existing PyObject that holds a C++ object?">How can I find
|
|
||||||
the existing PyObject that holds a C++ object?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<div class="blockquote"><blockquote class="blockquote"><p>
|
|
||||||
"I am wrapping a function that always returns a pointer to an already-held
|
|
||||||
C++ object."
|
|
||||||
</p></blockquote></div>
|
|
||||||
<p>
|
|
||||||
One way to do that is to hijack the mechanisms used for wrapping a class
|
|
||||||
with virtual functions. If you make a wrapper class with an initial PyObject*
|
|
||||||
constructor argument and store that PyObject* as "self", you can
|
|
||||||
get back to it by casting down to that wrapper type in a thin wrapper function.
|
|
||||||
For example:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">X</span> <span class="special">{</span> <span class="identifier">X</span><span class="special">(</span><span class="keyword">int</span><span class="special">);</span> <span class="keyword">virtual</span> <span class="special">~</span><span class="identifier">X</span><span class="special">();</span> <span class="special">...</span> <span class="special">};</span>
|
|
||||||
<span class="identifier">X</span><span class="special">*</span> <span class="identifier">f</span><span class="special">();</span> <span class="comment">// known to return Xs that are managed by Python objects</span>
|
|
||||||
|
|
||||||
|
|
||||||
<span class="comment">// wrapping code</span>
|
|
||||||
|
|
||||||
<span class="keyword">struct</span> <span class="identifier">X_wrap</span> <span class="special">:</span> <span class="identifier">X</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">X_wrap</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">self</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">v</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">self</span><span class="special">(</span><span class="identifier">self</span><span class="special">),</span> <span class="identifier">X</span><span class="special">(</span><span class="identifier">v</span><span class="special">)</span> <span class="special">{}</span>
|
|
||||||
<span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">self</span><span class="special">;</span>
|
|
||||||
<span class="special">};</span>
|
|
||||||
|
|
||||||
<span class="identifier">handle</span><span class="special"><></span> <span class="identifier">f_wrap</span><span class="special">()</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">X_wrap</span><span class="special">*</span> <span class="identifier">xw</span> <span class="special">=</span> <span class="keyword">dynamic_cast</span><span class="special"><</span><span class="identifier">X_wrap</span><span class="special">*>(</span><span class="identifier">f</span><span class="special">());</span>
|
|
||||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">xw</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span>
|
|
||||||
<span class="keyword">return</span> <span class="identifier">handle</span><span class="special"><>(</span><span class="identifier">borrowed</span><span class="special">(</span><span class="identifier">xw</span><span class="special">-></span><span class="identifier">self</span><span class="special">));</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
|
|
||||||
<span class="special">...</span>
|
|
||||||
|
|
||||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"f"</span><span class="special">,</span> <span class="identifier">f_wrap</span><span class="special">());</span>
|
|
||||||
<span class="identifier">class_</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="identifier">X_wrap</span><span class="special">,</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span><span class="special">>(</span><span class="string">"X"</span><span class="special">,</span> <span class="identifier">init</span><span class="special"><</span><span class="keyword">int</span><span class="special">>())</span>
|
|
||||||
<span class="special">...</span>
|
|
||||||
<span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Of course, if X has no virtual functions you'll have to use <code class="computeroutput"><span class="keyword">static_cast</span></code> instead of <code class="computeroutput"><span class="keyword">dynamic_cast</span></code>
|
|
||||||
with no runtime check that it's valid. This approach also only works if the
|
|
||||||
<code class="computeroutput"><span class="identifier">X</span></code> object was constructed
|
|
||||||
from Python, because <code class="computeroutput"><span class="identifier">X</span></code>s constructed
|
|
||||||
from C++ are of course never <code class="computeroutput"><span class="identifier">X_wrap</span></code>
|
|
||||||
objects.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Another approach to this requires you to change your C++ code a bit; if that's
|
|
||||||
an option for you it might be a better way to go. work we've been meaning
|
|
||||||
to get to anyway. When a <code class="computeroutput"><span class="identifier">shared_ptr</span><span class="special"><</span><span class="identifier">X</span><span class="special">></span></code>
|
|
||||||
is converted from Python, the shared_ptr actually manages a reference to
|
|
||||||
the containing Python object. When a shared_ptr<X> is converted back
|
|
||||||
to Python, the library checks to see if it's one of those "Python object
|
|
||||||
managers" and if so just returns the original Python object. So you
|
|
||||||
could just write <code class="computeroutput"><span class="identifier">object</span><span class="special">(</span><span class="identifier">p</span><span class="special">)</span></code> to get
|
|
||||||
the Python object back. To exploit this you'd have to be able to change the
|
|
||||||
C++ code you're wrapping so that it deals with shared_ptr instead of raw
|
|
||||||
pointers.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
There are other approaches too. The functions that receive the Python object
|
|
||||||
that you eventually want to return could be wrapped with a thin wrapper that
|
|
||||||
records the correspondence between the object address and its containing
|
|
||||||
Python object, and you could have your f_wrap function look in that mapping
|
|
||||||
to get the Python object out.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="does_boost_python_work_with_mac_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_wrap_a_function_which0.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>How can I wrap a function which needs to take ownership of a raw pointer?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="how_can_i_find_the_existing_pyob.html" title="How can I find the existing PyObject that holds a C++ object?">
|
|
||||||
<link rel="next" href="compilation_takes_too_much_time_.html" title="Compilation takes too much time and eats too much memory! What can I do to make it faster?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_can_i_find_the_existing_pyob.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="compilation_takes_too_much_time_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.how_can_i_wrap_a_function_which0"></a><a class="link" href="how_can_i_wrap_a_function_which0.html" title="How can I wrap a function which needs to take ownership of a raw pointer?">How can I wrap
|
|
||||||
a function which needs to take ownership of a raw pointer?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
<span class="bold"><strong>Q:</strong></span> Part of an API that I'm wrapping goes
|
|
||||||
something like this:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">A</span> <span class="special">{};</span> <span class="keyword">struct</span> <span class="identifier">B</span> <span class="special">{</span> <span class="keyword">void</span> <span class="identifier">add</span><span class="special">(</span> <span class="identifier">A</span><span class="special">*</span> <span class="special">);</span> <span class="special">}</span>
|
|
||||||
<span class="identifier">where</span> <span class="identifier">B</span><span class="special">::</span><span class="identifier">add</span><span class="special">()</span> <span class="identifier">takes</span> <span class="identifier">ownership</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">pointer</span> <span class="identifier">passed</span> <span class="identifier">to</span> <span class="identifier">it</span><span class="special">.</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
However:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">a</span> <span class="special">=</span> <span class="identifier">mod</span><span class="special">.</span><span class="identifier">A</span><span class="special">()</span>
|
|
||||||
<span class="identifier">b</span> <span class="special">=</span> <span class="identifier">mod</span><span class="special">.</span><span class="identifier">B</span><span class="special">()</span>
|
|
||||||
<span class="identifier">b</span><span class="special">.</span><span class="identifier">add</span><span class="special">(</span> <span class="identifier">a</span> <span class="special">)</span>
|
|
||||||
<span class="identifier">del</span> <span class="identifier">a</span>
|
|
||||||
<span class="identifier">del</span> <span class="identifier">b</span>
|
|
||||||
<span class="preprocessor"># python</span> <span class="identifier">interpreter</span> <span class="identifier">crashes</span>
|
|
||||||
<span class="preprocessor"># later</span> <span class="identifier">due</span> <span class="identifier">to</span> <span class="identifier">memory</span> <span class="identifier">corruption</span><span class="special">.</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Even binding the lifetime of a to b via <code class="computeroutput"><span class="identifier">with_custodian_and_ward</span></code>
|
|
||||||
doesn't prevent the python object a from ultimately trying to delete the
|
|
||||||
object it's pointing to. Is there a way to accomplish a 'transfer-of-ownership'
|
|
||||||
of a wrapped C++ object?
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
--Bruce Lowery
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Yes: Make sure the C++ object is held by auto_ptr:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">class_</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special"><</span><span class="identifier">A</span><span class="special">></span> <span class="special">>(</span><span class="string">"A"</span><span class="special">)</span>
|
|
||||||
<span class="special">...</span>
|
|
||||||
<span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Then make a thin wrapper function which takes an auto_ptr parameter:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">b_insert</span><span class="special">(</span><span class="identifier">B</span> <span class="special">&</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special"><</span><span class="identifier">A</span><span class="special">></span> <span class="identifier">a</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">b</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">a</span><span class="special">.</span><span class="identifier">get</span><span class="special">());</span>
|
|
||||||
<span class="identifier">a</span><span class="special">.</span><span class="identifier">release</span><span class="special">();</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Wrap that as B.add. Note that pointers returned via <code class="computeroutput"><span class="identifier">manage_new_object</span></code>
|
|
||||||
will also be held by <code class="computeroutput"><span class="identifier">auto_ptr</span></code>,
|
|
||||||
so this transfer-of-ownership will also work correctly.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_can_i_find_the_existing_pyob.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="compilation_takes_too_much_time_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>How can I wrap functions which take C++ containers as arguments?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="is_return_internal_reference_eff.html" title="Is return_internal_reference efficient?">
|
|
||||||
<link rel="next" href="fatal_error_c1204_compiler_limit.html" title="fatal error C1204:Compiler limit:internal structure overflow">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="is_return_internal_reference_eff.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="fatal_error_c1204_compiler_limit.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.how_can_i_wrap_functions_which_t"></a><a class="link" href="how_can_i_wrap_functions_which_t.html" title="How can I wrap functions which take C++ containers as arguments?">How can I wrap
|
|
||||||
functions which take C++ containers as arguments?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
Ralf W. Grosse-Kunstleve provides these notes:
|
|
||||||
</p>
|
|
||||||
<div class="orderedlist"><ol class="orderedlist" type="1">
|
|
||||||
<li class="listitem">
|
|
||||||
<p>
|
|
||||||
Using the regular <code class="computeroutput"><span class="identifier">class_</span><span class="special"><></span></code> wrapper:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">class_</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="special">>(</span><span class="string">"std_vector_double"</span><span class="special">)</span>
|
|
||||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(...)</span>
|
|
||||||
<span class="special">...</span>
|
|
||||||
<span class="special">;</span>
|
|
||||||
</pre>
|
|
||||||
This can be moved to a template so that several types (<code class="computeroutput"><span class="keyword">double</span></code>, <code class="computeroutput"><span class="keyword">int</span></code>,
|
|
||||||
<code class="computeroutput"><span class="keyword">long</span></code>, etc.) can be wrapped
|
|
||||||
with the same code. This technique is used in the file <code class="computeroutput"><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">array_family</span><span class="special">/</span><span class="identifier">boost_python</span><span class="special">/</span><span class="identifier">flex_wrapper</span><span class="special">.</span><span class="identifier">h</span></code> in the "scitbx" package.
|
|
||||||
The file could easily be modified for wrapping <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><></span></code> instantiations. This type of
|
|
||||||
C++/Python binding is most suitable for containers that may contain a
|
|
||||||
large number of elements (>10000).
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<p>
|
|
||||||
Using custom rvalue converters. Boost.Python "rvalue converters"
|
|
||||||
match function signatures such as:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">array</span><span class="special">);</span> <span class="comment">// pass by const-reference</span>
|
|
||||||
<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">array</span><span class="special">);</span> <span class="comment">// pass by value</span>
|
|
||||||
</pre>
|
|
||||||
Some custom rvalue converters are implemented in the file <code class="computeroutput"><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">boost_python</span><span class="special">/</span><span class="identifier">container_conversions</span><span class="special">.</span><span class="identifier">h</span></code> This code can be used to convert
|
|
||||||
from C++ container types such as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><></span></code> or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><></span></code> to Python tuples and vice versa.
|
|
||||||
A few simple examples can be found in the file <code class="computeroutput"><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">array_family</span><span class="special">/</span><span class="identifier">boost_python</span><span class="special">/</span><span class="identifier">regression_test_module</span><span class="special">.</span><span class="identifier">cpp</span></code>
|
|
||||||
Automatic C++ container <-> Python tuple conversions are most suitable
|
|
||||||
for containers of moderate size. These converters generate significantly
|
|
||||||
less object code compared to alternative 1 above.
|
|
||||||
</li>
|
|
||||||
</ol></div>
|
|
||||||
<p>
|
|
||||||
A disadvantage of using alternative 2 is that operators such as arithmetic
|
|
||||||
+,-,*,/,% are not available. It would be useful to have custom rvalue converters
|
|
||||||
that convert to a "math_array" type instead of tuples. This is
|
|
||||||
currently not implemented but is possible within the framework of Boost.Python
|
|
||||||
V2 as it will be released in the next couple of weeks. [ed.: this was posted
|
|
||||||
on 2002/03/10]
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
It would also be useful to also have "custom lvalue converters"
|
|
||||||
such as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><></span></code>
|
|
||||||
<-> Python list. These converters would support the modification of
|
|
||||||
the Python list from C++. For example:
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
C++:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="special">&</span><span class="identifier">array</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="keyword">for</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span><span class="identifier">i</span><span class="special">&</span><span class="identifier">lt</span><span class="special">;</span><span class="identifier">array</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span><span class="identifier">i</span><span class="special">++)</span> <span class="special">{</span>
|
|
||||||
<span class="identifier">array</span><span class="special">[</span><span class="identifier">i</span><span class="special">]</span> <span class="special">*=</span> <span class="number">2</span><span class="special">;</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Python:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">>>></span> <span class="identifier">l</span> <span class="special">=</span> <span class="special">[</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">]</span>
|
|
||||||
<span class="special">>>></span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">l</span><span class="special">)</span>
|
|
||||||
<span class="special">>>></span> <span class="keyword">print</span> <span class="identifier">l</span>
|
|
||||||
<span class="special">[</span><span class="number">2</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="number">6</span><span class="special">]</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Custom lvalue converters require changes to the Boost.Python core library
|
|
||||||
and are currently not available.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
P.S.:
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
The "scitbx" files referenced above are available via anonymous
|
|
||||||
CVS:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">cvs</span> <span class="special">-</span><span class="identifier">d</span><span class="special">:</span><span class="identifier">pserver</span><span class="special">:</span><span class="identifier">anonymous</span><span class="error">@</span><span class="identifier">cvs</span><span class="special">.</span><span class="identifier">cctbx</span><span class="special">.</span><span class="identifier">sourceforge</span><span class="special">.</span><span class="identifier">net</span><span class="special">:/</span><span class="identifier">cvsroot</span><span class="special">/</span><span class="identifier">cctbx</span> <span class="identifier">login</span>
|
|
||||||
<span class="identifier">cvs</span> <span class="special">-</span><span class="identifier">d</span><span class="special">:</span><span class="identifier">pserver</span><span class="special">:</span><span class="identifier">anonymous</span><span class="error">@</span><span class="identifier">cvs</span><span class="special">.</span><span class="identifier">cctbx</span><span class="special">.</span><span class="identifier">sourceforge</span><span class="special">.</span><span class="identifier">net</span><span class="special">:/</span><span class="identifier">cvsroot</span><span class="special">/</span><span class="identifier">cctbx</span> <span class="identifier">co</span> <span class="identifier">scitbx</span>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="is_return_internal_reference_eff.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="fatal_error_c1204_compiler_limit.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>How do I create sub-packages using Boost.Python?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="compilation_takes_too_much_time_.html" title="Compilation takes too much time and eats too much memory! What can I do to make it faster?">
|
|
||||||
<link rel="next" href="error_c2064_term_does_not_evalua.html" title="error C2064: term does not evaluate to a function taking 2 arguments">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="compilation_takes_too_much_time_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="error_c2064_term_does_not_evalua.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.how_do_i_create_sub_packages_usi"></a><a class="link" href="how_do_i_create_sub_packages_usi.html" title="How do I create sub-packages using Boost.Python?">How do I create
|
|
||||||
sub-packages using Boost.Python?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
Please refer to the <code class="computeroutput"><span class="identifier">Creating</span> <span class="identifier">Packages</span></code> section in the <a href="../tutorial/index.html" target="_top">Tutorial</a>.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="compilation_takes_too_much_time_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="error_c2064_term_does_not_evalua.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>How do I debug my Python extensions?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="fatal_error_c1204_compiler_limit.html" title="fatal error C1204:Compiler limit:internal structure overflow">
|
|
||||||
<link rel="next" href="why_doesn_t_my_operator_work.html" title="Why doesn't my *= operator work?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="fatal_error_c1204_compiler_limit.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="why_doesn_t_my_operator_work.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.how_do_i_debug_my_python_extensi"></a><a class="link" href="how_do_i_debug_my_python_extensi.html" title="How do I debug my Python extensions?">How do I debug
|
|
||||||
my Python extensions?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
Greg Burley gives the following answer for Unix GCC users:
|
|
||||||
</p>
|
|
||||||
<div class="blockquote"><blockquote class="blockquote">
|
|
||||||
<p>
|
|
||||||
Once you have created a boost python extension for your c++ library or
|
|
||||||
class, you may need to debug the code. Afterall this is one of the reasons
|
|
||||||
for wrapping the library in python. An expected side-effect or benefit
|
|
||||||
of using BPL is that debugging should be isolated to the c++ library that
|
|
||||||
is under test, given that python code is minimal and boost::python either
|
|
||||||
works or it doesn't. (ie. While errors can occur when the wrapping method
|
|
||||||
is invalid, most errors are caught by the compiler ;-).
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
The basic steps required to initiate a gdb session to debug a c++ library
|
|
||||||
via python are shown here. Note, however that you should start the gdb
|
|
||||||
session in the directory that contains your BPL my_ext.so module.
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">target</span> <span class="identifier">exec</span> <span class="identifier">python</span>
|
|
||||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">run</span>
|
|
||||||
<span class="special">>>></span> <span class="identifier">from</span> <span class="identifier">my_ext</span> <span class="identifier">import</span> <span class="special">*</span>
|
|
||||||
<span class="special">>>></span> <span class="special">[</span><span class="identifier">C</span><span class="special">-</span><span class="identifier">c</span><span class="special">]</span>
|
|
||||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="keyword">break</span> <span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">MyBuggyFunction</span>
|
|
||||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">cont</span>
|
|
||||||
<span class="special">>>></span> <span class="identifier">pyobj</span> <span class="special">=</span> <span class="identifier">MyClass</span><span class="special">()</span>
|
|
||||||
<span class="special">>>></span> <span class="identifier">pyobj</span><span class="special">.</span><span class="identifier">MyBuggyFunction</span><span class="special">()</span>
|
|
||||||
<span class="identifier">Breakpoint</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">MyBuggyFunction</span> <span class="special">...</span>
|
|
||||||
<span class="identifier">Current</span> <span class="identifier">language</span><span class="special">:</span> <span class="keyword">auto</span><span class="special">;</span> <span class="identifier">currently</span> <span class="identifier">c</span><span class="special">++</span>
|
|
||||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="keyword">do</span> <span class="identifier">debugging</span> <span class="identifier">stuff</span>
|
|
||||||
</pre>
|
|
||||||
</blockquote></div>
|
|
||||||
<p>
|
|
||||||
Greg's approach works even better using Emacs' "gdb" command, since
|
|
||||||
it will show you each line of source as you step through it.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
On <span class="bold"><strong>Windows</strong></span>, my favorite debugging solution
|
|
||||||
is the debugger that comes with Microsoft Visual C++ 7. This debugger seems
|
|
||||||
to work with code generated by all versions of Microsoft and Metrowerks toolsets;
|
|
||||||
it's rock solid and "just works" without requiring any special
|
|
||||||
tricks from the user.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Raoul Gough has provided the following for gdb on Windows:
|
|
||||||
</p>
|
|
||||||
<div class="blockquote"><blockquote class="blockquote">
|
|
||||||
<p>
|
|
||||||
gdb support for Windows DLLs has improved lately, so it is now possible
|
|
||||||
to debug Python extensions using a few tricks. Firstly, you will need an
|
|
||||||
up-to-date gdb with support for minimal symbol extraction from a DLL. Any
|
|
||||||
gdb from version 6 onwards, or Cygwin gdb-20030214-1 and onwards should
|
|
||||||
do. A suitable release will have a section in the gdb.info file under Configuration
|
|
||||||
- Native - Cygwin Native - Non-debug DLL symbols. Refer to that info section
|
|
||||||
for more details of the procedures outlined here.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Secondly, it seems necessary to set a breakpoint in the Python interpreter,
|
|
||||||
rather than using ^C to break execution. A good place to set this breakpoint
|
|
||||||
is PyOS_Readline, which will stop execution immediately before reading
|
|
||||||
each interactive Python command. You have to let Python start once under
|
|
||||||
the debugger, so that it loads its own DLL, before you can set the breakpoint:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="error">$</span> <span class="identifier">gdb</span> <span class="identifier">python</span>
|
|
||||||
<span class="identifier">GNU</span> <span class="identifier">gdb</span> <span class="number">2003</span><span class="special">-</span><span class="number">09</span><span class="special">-</span><span class="number">02</span><span class="special">-</span><span class="identifier">cvs</span> <span class="special">(</span><span class="identifier">cygwin</span><span class="special">-</span><span class="identifier">special</span><span class="special">)</span>
|
|
||||||
<span class="special">[...]</span>
|
|
||||||
|
|
||||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">run</span>
|
|
||||||
<span class="identifier">Starting</span> <span class="identifier">program</span><span class="special">:</span> <span class="special">/</span><span class="identifier">cygdrive</span><span class="special">/</span><span class="identifier">c</span><span class="special">/</span><span class="identifier">Python22</span><span class="special">/</span><span class="identifier">python</span><span class="special">.</span><span class="identifier">exe</span>
|
|
||||||
<span class="identifier">Python</span> <span class="number">2.2</span><span class="special">.</span><span class="number">2</span> <span class="special">(#</span><span class="number">37</span><span class="special">,</span> <span class="identifier">Oct</span> <span class="number">14</span> <span class="number">2002</span><span class="special">,</span> <span class="number">17</span><span class="special">:</span><span class="number">02</span><span class="special">:</span><span class="number">34</span><span class="special">)</span> <span class="special">[</span><span class="identifier">MSC</span> <span class="number">32</span> <span class="identifier">bit</span> <span class="special">(</span><span class="identifier">Intel</span><span class="special">)]</span> <span class="identifier">on</span> <span class="identifier">win32</span>
|
|
||||||
<span class="identifier">Type</span> <span class="string">"help"</span><span class="special">,</span> <span class="string">"copyright"</span><span class="special">,</span> <span class="string">"credits"</span> <span class="keyword">or</span> <span class="string">"license"</span> <span class="keyword">for</span> <span class="identifier">more</span> <span class="identifier">information</span><span class="special">.</span>
|
|
||||||
<span class="special">>>></span> <span class="special">^</span><span class="identifier">Z</span>
|
|
||||||
|
|
||||||
|
|
||||||
<span class="identifier">Program</span> <span class="identifier">exited</span> <span class="identifier">normally</span><span class="special">.</span>
|
|
||||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="keyword">break</span> <span class="special">*&</span><span class="identifier">PyOS_Readline</span>
|
|
||||||
<span class="identifier">Breakpoint</span> <span class="number">1</span> <span class="identifier">at</span> <span class="number">0x1e04eff0</span>
|
|
||||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">run</span>
|
|
||||||
<span class="identifier">Starting</span> <span class="identifier">program</span><span class="special">:</span> <span class="special">/</span><span class="identifier">cygdrive</span><span class="special">/</span><span class="identifier">c</span><span class="special">/</span><span class="identifier">Python22</span><span class="special">/</span><span class="identifier">python</span><span class="special">.</span><span class="identifier">exe</span>
|
|
||||||
<span class="identifier">Python</span> <span class="number">2.2</span><span class="special">.</span><span class="number">2</span> <span class="special">(#</span><span class="number">37</span><span class="special">,</span> <span class="identifier">Oct</span> <span class="number">14</span> <span class="number">2002</span><span class="special">,</span> <span class="number">17</span><span class="special">:</span><span class="number">02</span><span class="special">:</span><span class="number">34</span><span class="special">)</span> <span class="special">[</span><span class="identifier">MSC</span> <span class="number">32</span> <span class="identifier">bit</span> <span class="special">(</span><span class="identifier">Intel</span><span class="special">)]</span> <span class="identifier">on</span> <span class="identifier">win32</span>
|
|
||||||
<span class="identifier">Type</span> <span class="string">"help"</span><span class="special">,</span> <span class="string">"copyright"</span><span class="special">,</span> <span class="string">"credits"</span> <span class="keyword">or</span> <span class="string">"license"</span> <span class="keyword">for</span> <span class="identifier">more</span> <span class="identifier">information</span><span class="special">.</span>
|
|
||||||
|
|
||||||
<span class="identifier">Breakpoint</span> <span class="number">1</span><span class="special">,</span> <span class="number">0x1e04eff0</span> <span class="identifier">in</span> <span class="identifier">python22</span><span class="special">!</span><span class="identifier">PyOS_Readline</span> <span class="special">()</span>
|
|
||||||
<span class="identifier">from</span> <span class="special">/</span><span class="identifier">cygdrive</span><span class="special">/</span><span class="identifier">c</span><span class="special">/</span><span class="identifier">WINNT</span><span class="special">/</span><span class="identifier">system32</span><span class="special">/</span><span class="identifier">python22</span><span class="special">.</span><span class="identifier">dll</span>
|
|
||||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">cont</span>
|
|
||||||
<span class="identifier">Continuing</span><span class="special">.</span>
|
|
||||||
<span class="special">>>></span> <span class="identifier">from</span> <span class="identifier">my_ext</span> <span class="identifier">import</span> <span class="special">*</span>
|
|
||||||
|
|
||||||
<span class="identifier">Breakpoint</span> <span class="number">1</span><span class="special">,</span> <span class="number">0x1e04eff0</span> <span class="identifier">in</span> <span class="identifier">python22</span><span class="special">!</span><span class="identifier">PyOS_Readline</span> <span class="special">()</span>
|
|
||||||
<span class="identifier">from</span> <span class="special">/</span><span class="identifier">cygdrive</span><span class="special">/</span><span class="identifier">c</span><span class="special">/</span><span class="identifier">WINNT</span><span class="special">/</span><span class="identifier">system32</span><span class="special">/</span><span class="identifier">python22</span><span class="special">.</span><span class="identifier">dll</span>
|
|
||||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="special">#</span> <span class="identifier">my_ext</span> <span class="identifier">now</span> <span class="identifier">loaded</span> <span class="special">(</span><span class="identifier">with</span> <span class="identifier">any</span> <span class="identifier">debugging</span> <span class="identifier">symbols</span> <span class="identifier">it</span> <span class="identifier">contains</span><span class="special">)</span>
|
|
||||||
</pre>
|
|
||||||
</blockquote></div>
|
|
||||||
<h3>
|
|
||||||
<a name="faq.how_do_i_debug_my_python_extensi.h0"></a>
|
|
||||||
<span class="phrase"><a name="faq.how_do_i_debug_my_python_extensi.debugging_extensions_through_boo"></a></span><a class="link" href="how_do_i_debug_my_python_extensi.html#faq.how_do_i_debug_my_python_extensi.debugging_extensions_through_boo">Debugging
|
|
||||||
extensions through Boost.Build</a>
|
|
||||||
</h3>
|
|
||||||
<p>
|
|
||||||
If you are launching your extension module tests with <a href="http://www.boost.org/build" target="_top">Boost.Build</a>
|
|
||||||
using the <code class="computeroutput"><span class="identifier">boost</span><span class="special">-</span><span class="identifier">python</span><span class="special">-</span><span class="identifier">runtest</span></code> rule, you can ask it to launch
|
|
||||||
your debugger for you by adding "--debugger=<span class="emphasis"><em>debugger</em></span>"
|
|
||||||
to your bjam command-line:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="special">-</span><span class="identifier">sTOOLS</span><span class="special">=</span><span class="identifier">vc7</span><span class="special">.</span><span class="number">1</span> <span class="string">"--debugger=devenv /debugexe"</span> <span class="identifier">test</span>
|
|
||||||
<span class="identifier">bjam</span> <span class="special">-</span><span class="identifier">sTOOLS</span><span class="special">=</span><span class="identifier">gcc</span> <span class="special">-</span><span class="identifier">sPYTHON_LAUNCH</span><span class="special">=</span><span class="identifier">gdb</span> <span class="identifier">test</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
It can also be extremely useful to add the <code class="computeroutput"><span class="special">-</span><span class="identifier">d</span><span class="special">+</span><span class="number">2</span></code>
|
|
||||||
option when you run your test, because Boost.Build will then show you the
|
|
||||||
exact commands it uses to invoke it. This will invariably involve setting
|
|
||||||
up PYTHONPATH and other important environment variables such as LD_LIBRARY_PATH
|
|
||||||
which may be needed by your debugger in order to get things to work right.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="fatal_error_c1204_compiler_limit.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="why_doesn_t_my_operator_work.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>I'm getting the "attempt to return dangling reference" error. What am I doing wrong?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="next" href="is_return_internal_reference_eff.html" title="Is return_internal_reference efficient?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="../faq.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="is_return_internal_reference_eff.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.i_m_getting_the_attempt_to_retur"></a><a class="link" href="i_m_getting_the_attempt_to_retur.html" title="I'm getting the "attempt to return dangling reference" error. What am I doing wrong?">I'm getting the
|
|
||||||
"attempt to return dangling reference" error. What am I doing wrong?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
That exception is protecting you from causing a nasty crash. It usually happens
|
|
||||||
in response to some code like this:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">period</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">get_floating_frequency</span><span class="special">()</span> <span class="keyword">const</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">call_method</span><span class="special"><</span><span class="identifier">period</span> <span class="keyword">const</span> <span class="special">&>(</span>
|
|
||||||
<span class="identifier">m_self</span><span class="special">,</span><span class="string">"get_floating_frequency"</span><span class="special">);</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
And you get:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="identifier">ReferenceError</span><span class="special">:</span> <span class="identifier">Attempt</span> <span class="identifier">to</span> <span class="keyword">return</span> <span class="identifier">dangling</span> <span class="identifier">reference</span> <span class="identifier">to</span> <span class="identifier">object</span> <span class="identifier">of</span> <span class="identifier">type</span><span class="special">:</span>
|
|
||||||
<span class="keyword">class</span> <span class="identifier">period</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
In this case, the Python method invoked by <code class="computeroutput"><span class="identifier">call_method</span></code>
|
|
||||||
constructs a new Python object. You're trying to return a reference to a
|
|
||||||
C++ object (an instance of <code class="computeroutput"><span class="keyword">class</span> <span class="identifier">period</span></code>) contained within and owned by that
|
|
||||||
Python object. Because the called method handed back a brand new object,
|
|
||||||
the only reference to it is held for the duration of <code class="computeroutput"><span class="identifier">get_floating_frequency</span><span class="special">()</span></code> above. When the function returns, the Python
|
|
||||||
object will be destroyed, destroying the instance of <code class="computeroutput"><span class="keyword">class</span>
|
|
||||||
<span class="identifier">period</span></code>, and leaving the returned
|
|
||||||
reference dangling. That's already undefined behavior, and if you try to
|
|
||||||
do anything with that reference you're likely to cause a crash. Boost.Python
|
|
||||||
detects this situation at runtime and helpfully throws an exception instead
|
|
||||||
of letting you do that.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="../faq.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="is_return_internal_reference_eff.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Is Boost.Python thread-aware/compatible with multiple interpreters?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="why_is_my_automatic_to_python_co.html" title="Why is my automatic to-python conversion not being found?">
|
|
||||||
<link rel="next" href="../glossary.html" title="Chapter 6. Glossary">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="why_is_my_automatic_to_python_co.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../glossary.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.is_boost_python_thread_aware_com"></a><a class="link" href="is_boost_python_thread_aware_com.html" title="Is Boost.Python thread-aware/compatible with multiple interpreters?">Is Boost.Python
|
|
||||||
thread-aware/compatible with multiple interpreters?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>Niall Douglas provides these notes:</em></span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
The quick answer to this is: no.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
The longer answer is that it can be patched to be so, but it's complex. You
|
|
||||||
will need to add custom lock/unlock wrapping of every time your code enters
|
|
||||||
Boost.Python (particularly every virtual function override) plus heavily
|
|
||||||
modify <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">invoke</span><span class="special">.</span><span class="identifier">hpp</span></code> with custom unlock/lock wrapping of
|
|
||||||
every time Boost.Python enters your code. You must furthermore take care
|
|
||||||
to <span class="emphasis"><em>not</em></span> unlock/lock when Boost.Python is invoking iterator
|
|
||||||
changes via <code class="computeroutput"><span class="identifier">invoke</span><span class="special">.</span><span class="identifier">hpp</span></code>.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
There is a patched <code class="computeroutput"><span class="identifier">invoke</span><span class="special">.</span><span class="identifier">hpp</span></code> posted
|
|
||||||
on the C++-SIG mailing list archives and you can find a real implementation
|
|
||||||
of all the machinery necessary to fully implement this in the TnFOX project
|
|
||||||
at <a href="http://sourceforge.net/projects/tnfox/" target="_top">this</a> SourceForge
|
|
||||||
project location.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="why_is_my_automatic_to_python_co.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../glossary.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Is return_internal_reference efficient?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="i_m_getting_the_attempt_to_retur.html" title="I'm getting the "attempt to return dangling reference" error. What am I doing wrong?">
|
|
||||||
<link rel="next" href="how_can_i_wrap_functions_which_t.html" title="How can I wrap functions which take C++ containers as arguments?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="i_m_getting_the_attempt_to_retur.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_wrap_functions_which_t.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.is_return_internal_reference_eff"></a><a class="link" href="is_return_internal_reference_eff.html" title="Is return_internal_reference efficient?">Is <code class="computeroutput"><span class="identifier">return_internal_reference</span></code> efficient?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
<span class="bold"><strong>Q:</strong></span> /I have an object composed of 12 doubles.
|
|
||||||
A <code class="computeroutput"><span class="keyword">const</span><span class="special">&</span></code>
|
|
||||||
to this object is returned by a member function of another class. From the
|
|
||||||
viewpoint of using the returned object in Python I do not care if I get a
|
|
||||||
copy or a reference to the returned object. In Boost.Python I have the choice
|
|
||||||
of using <code class="computeroutput"><span class="identifier">copy_const_reference</span></code>
|
|
||||||
or <code class="computeroutput"><span class="identifier">return_internal_reference</span></code>.
|
|
||||||
Are there considerations that would lead me to prefer one over the other,
|
|
||||||
such as size of generated code or memory overhead?/
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<span class="bold"><strong>A:</strong></span> <code class="computeroutput"><span class="identifier">copy_const_reference</span></code>
|
|
||||||
will make an instance with storage for one of your objects, <code class="computeroutput"><span class="identifier">size</span> <span class="special">=</span> <span class="identifier">base_size</span> <span class="special">+</span> <span class="number">12</span> <span class="special">*</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">double</span><span class="special">)</span></code>.
|
|
||||||
<code class="computeroutput"><span class="identifier">return_internal_reference</span></code>
|
|
||||||
will make an instance with storage for a pointer to one of your objects,
|
|
||||||
<code class="computeroutput"><span class="identifier">size</span> <span class="special">=</span>
|
|
||||||
<span class="identifier">base_size</span> <span class="special">+</span>
|
|
||||||
<span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">void</span><span class="special">*)</span></code>. However,
|
|
||||||
it will also create a weak reference object which goes in the source object's
|
|
||||||
weakreflist and a special callback object to manage the lifetime of the internally-referenced
|
|
||||||
object. My guess? <code class="computeroutput"><span class="identifier">copy_const_reference</span></code>
|
|
||||||
is your friend here, resulting in less overall memory use and less fragmentation,
|
|
||||||
also probably fewer total cycles.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="i_m_getting_the_attempt_to_retur.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_wrap_functions_which_t.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Why doesn't my *= operator work?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="how_do_i_debug_my_python_extensi.html" title="How do I debug my Python extensions?">
|
|
||||||
<link rel="next" href="does_boost_python_work_with_mac_.html" title="Does Boost.Python work with Mac OS X?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_do_i_debug_my_python_extensi.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="does_boost_python_work_with_mac_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.why_doesn_t_my_operator_work"></a><a class="link" href="why_doesn_t_my_operator_work.html" title="Why doesn't my *= operator work?">Why doesn't my <code class="computeroutput"><span class="special">*=</span></code> operator work?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
<span class="bold"><strong>Q:</strong></span> <span class="emphasis"><em>I have exported my class to
|
|
||||||
python, with many overloaded operators. it works fine for me except the
|
|
||||||
<code class="computeroutput"><span class="special">*=</span></code> operator. It always tells
|
|
||||||
me "can't multiply sequence with non int type". If I use <code class="computeroutput"><span class="identifier">p1</span><span class="special">.</span><span class="identifier">__imul__</span><span class="special">(</span><span class="identifier">p2</span><span class="special">)</span></code>
|
|
||||||
instead of <code class="computeroutput"><span class="identifier">p1</span> <span class="special">*=</span>
|
|
||||||
<span class="identifier">p2</span></code>, it successfully executes my
|
|
||||||
code. What's wrong with me?</em></span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<span class="bold"><strong>A:</strong></span> There's nothing wrong with you. This
|
|
||||||
is a bug in Python 2.2. You can see the same effect in Pure Python (you can
|
|
||||||
learn a lot about what's happening in Boost.Python by playing with new-style
|
|
||||||
classes in Pure Python).
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">>>></span> <span class="keyword">class</span> <span class="identifier">X</span><span class="special">(</span><span class="identifier">object</span><span class="special">):</span>
|
|
||||||
<span class="special">...</span> <span class="identifier">def</span> <span class="identifier">__imul__</span><span class="special">(</span><span class="identifier">self</span><span class="special">,</span> <span class="identifier">x</span><span class="special">):</span>
|
|
||||||
<span class="special">...</span> <span class="identifier">print</span> <span class="char">'imul'</span>
|
|
||||||
<span class="special">...</span>
|
|
||||||
<span class="special">>>></span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">X</span><span class="special">()</span>
|
|
||||||
<span class="special">>>></span> <span class="identifier">x</span> <span class="special">*=</span> <span class="number">1</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
To cure this problem, all you need to do is upgrade your Python to version
|
|
||||||
2.2.1 or later.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_do_i_debug_my_python_extensi.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="does_boost_python_work_with_mac_.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Why is my automatic to-python conversion not being found?</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="../index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
|
||||||
<link rel="prev" href="how_can_i_automatically_convert_.html" title="How can I automatically convert my custom string type to and from a Python string?">
|
|
||||||
<link rel="next" href="is_boost_python_thread_aware_com.html" title="Is Boost.Python thread-aware/compatible with multiple interpreters?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_can_i_automatically_convert_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="is_boost_python_thread_aware_com.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="faq.why_is_my_automatic_to_python_co"></a><a class="link" href="why_is_my_automatic_to_python_co.html" title="Why is my automatic to-python conversion not being found?">Why is my automatic
|
|
||||||
to-python conversion not being found?</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
<span class="emphasis"><em>Niall Douglas provides these notes:</em></span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
If you define custom converters similar to the ones shown above the <code class="computeroutput"><span class="identifier">def_readonly</span><span class="special">()</span></code>
|
|
||||||
and <code class="computeroutput"><span class="identifier">def_readwrite</span><span class="special">()</span></code>
|
|
||||||
member functions provided by <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">class_</span></code>
|
|
||||||
for direct access to your member data will not work as expected. This is
|
|
||||||
because <code class="computeroutput"><span class="identifier">def_readonly</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">)</span></code> is equivalent to:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">.</span><span class="identifier">add_property</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,</span> <span class="identifier">make_getter</span><span class="special">(&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">,</span> <span class="identifier">return_internal_reference</span><span class="special">()))</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Similarly, <code class="computeroutput"><span class="identifier">def_readwrite</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">)</span></code>
|
|
||||||
is equivalent to:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">.</span><span class="identifier">add_property</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,</span> <span class="identifier">make_getter</span><span class="special">(&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">,</span> <span class="identifier">return_internal_reference</span><span class="special">()),</span>
|
|
||||||
<span class="identifier">make_setter</span><span class="special">(&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">,</span> <span class="identifier">return_internal_reference</span><span class="special">())</span>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
In order to define return value policies compatible with the custom conversions
|
|
||||||
replace <code class="computeroutput"><span class="identifier">def_readonly</span><span class="special">()</span></code>
|
|
||||||
and <code class="computeroutput"><span class="identifier">def_readwrite</span><span class="special">()</span></code>
|
|
||||||
by <code class="computeroutput"><span class="identifier">add_property</span><span class="special">()</span></code>.
|
|
||||||
E.g.:
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="special">.</span><span class="identifier">add_property</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,</span> <span class="identifier">make_getter</span><span class="special">(&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">,</span> <span class="identifier">return_value_policy</span><span class="special"><</span><span class="identifier">return_by_value</span><span class="special">>()),</span>
|
|
||||||
<span class="identifier">make_setter</span><span class="special">(&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">,</span> <span class="identifier">return_value_policy</span><span class="special"><</span><span class="identifier">return_by_value</span><span class="special">>()))</span>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="how_can_i_automatically_convert_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="is_boost_python_thread_aware_com.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Chapter 6. Glossary</title>
|
|
||||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="index.html" title="Boost.Python">
|
|
||||||
<link rel="up" href="index.html" title="Boost.Python">
|
|
||||||
<link rel="prev" href="faq/is_boost_python_thread_aware_com.html" title="Is Boost.Python thread-aware/compatible with multiple interpreters?">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="faq/is_boost_python_thread_aware_com.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a>
|
|
||||||
</div>
|
|
||||||
<div class="chapter">
|
|
||||||
<div class="titlepage"><div><div><h1 class="title">
|
|
||||||
<a name="glossary"></a>Chapter 6. Glossary</h1></div></div></div>
|
|
||||||
<div class="variablelist">
|
|
||||||
<p class="title"><b></b></p>
|
|
||||||
<dl class="variablelist">
|
|
||||||
<dt><span class="term">arity <a name="arity"></a></span></dt>
|
|
||||||
<dd><p>
|
|
||||||
The number of argumnts accepted by a function or member function. Unless
|
|
||||||
otherwise specified, the hidden <code class="computeroutput"><span class="keyword">this</span></code>
|
|
||||||
argument to member functions is not counted when specifying arity.
|
|
||||||
</p></dd>
|
|
||||||
<dt><span class="term">ntbs <a name="ntbs"></a></span></dt>
|
|
||||||
<dd><p>
|
|
||||||
Null-Terminated Byte String, or 'C'-string. C++ string literals are
|
|
||||||
<span class="bold"><strong>ntbs</strong></span>es. An <span class="bold"><strong>ntbs</strong></span>
|
|
||||||
must never be null.
|
|
||||||
</p></dd>
|
|
||||||
<dt><span class="term">raise <a name="raise"></a></span></dt>
|
|
||||||
<dd><p>
|
|
||||||
Exceptions in Python are "raised", not "thrown",
|
|
||||||
as they are in C++. When this documentation says that some Python exception
|
|
||||||
is "raised" in the context of C++ code, it means that the corresponding
|
|
||||||
Python exception is set via the <a href="http://www.python.org/doc/current/api/exceptionHandling.html" target="_top">Python/'C'
|
|
||||||
API</a>, and <code class="computeroutput"><span class="identifier">throw_error_already_set</span><span class="special">()</span></code> is called.
|
|
||||||
</p></dd>
|
|
||||||
<dt><span class="term">POD <a name="pod"></a></span></dt>
|
|
||||||
<dd><p>
|
|
||||||
A technical term from the C++ standard. Short for "Plain Ol'Data":
|
|
||||||
A POD-struct is an aggregate class that has no non-static data members
|
|
||||||
of type pointer to member, non-POD-struct, non-POD-union (or array of
|
|
||||||
such types) or reference, and has no user-defined copy assign- ment operator
|
|
||||||
and no user-defined destructor. Similarly, a POD-union is an aggregate
|
|
||||||
union that has no non-static data members of type pointer to member,
|
|
||||||
non-POD-struct, non-POD-union (or array of such types) or reference,
|
|
||||||
and has no user-defined copy assignment operator and no user-defined
|
|
||||||
destructor. A POD class is a class that is either a POD-struct or a POD-union.
|
|
||||||
An aggregate is an array or a class (clause 9) with no user-declared
|
|
||||||
constructors (12.1), no private or protected non-static data members
|
|
||||||
(clause 11), no base classes (clause 10), and no virtual functions (10.3).
|
|
||||||
</p></dd>
|
|
||||||
<dt><span class="term">ODR <a name="odr"></a></span></dt>
|
|
||||||
<dd><p>
|
|
||||||
The "One Definition Rule", which says that any entity in a
|
|
||||||
C++ program must have the same definition in all translation units (object
|
|
||||||
files) which make up a program.
|
|
||||||
</p></dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="faq/is_boost_python_thread_aware_com.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Boost.Python</title>
|
|
||||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="index.html" title="Boost.Python">
|
|
||||||
<link rel="next" href="rn.html" title="Chapter 1. Release Notes">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav"><a accesskey="n" href="rn.html"><img src="images/next.png" alt="Next"></a></div>
|
|
||||||
<div class="book">
|
|
||||||
<div class="titlepage">
|
|
||||||
<div>
|
|
||||||
<div><h1 class="title">
|
|
||||||
<a name="python"></a>Boost.Python</h1></div>
|
|
||||||
<div><div class="authorgroup">
|
|
||||||
<div class="author"><h3 class="author">
|
|
||||||
<span class="firstname">David</span> <span class="surname">Abrahams</span>
|
|
||||||
</h3></div>
|
|
||||||
<div class="author"><h3 class="author">
|
|
||||||
<span class="firstname">Stefan</span> <span class="surname">Seefeld</span>
|
|
||||||
</h3></div>
|
|
||||||
</div></div>
|
|
||||||
<div><p class="copyright">Copyright © 2002-2015 David
|
|
||||||
Abrahams, Stefan Seefeld</p></div>
|
|
||||||
<div><div class="legalnotice">
|
|
||||||
<a name="python.legal"></a><p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
||||||
</p>
|
|
||||||
</div></div>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
</div>
|
|
||||||
<h3>
|
|
||||||
<a name="python.h0"></a>
|
|
||||||
<span class="phrase"><a name="python.synopsis"></a></span><a class="link" href="index.html#python.synopsis">Synopsis</a>
|
|
||||||
</h3>
|
|
||||||
<p>
|
|
||||||
Welcome to Boost.Python, a C++ library which enables seamless interoperability
|
|
||||||
between C++ and the Python programming language. The library includes support
|
|
||||||
for:
|
|
||||||
</p>
|
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
|
||||||
<li class="listitem">
|
|
||||||
References and Pointers
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Globally Registered Type Coercions
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Automatic Cross-Module Type Conversions
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Efficient Function Overloading
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
C++ to Python Exception Translation
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Default Arguments
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Keyword Arguments
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Manipulating Python objects in C++
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Exporting C++ Iterators as Python Iterators
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
Documentation Strings
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
|
||||||
<p>
|
|
||||||
The development of these features was funded in part by grants to <code class="computeroutput"><span class="identifier">Boost</span> <span class="identifier">Consulting</span></code>
|
|
||||||
from the <a href="http://www.llnl.gov" target="_top">Lawrence Livermore National Laboratories</a>
|
|
||||||
and by the <a href="http://cci.lbl.gov" target="_top">Computational Crystallography Initiative</a>
|
|
||||||
at Lawrence Berkeley National Laboratories.
|
|
||||||
</p>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
|
||||||
<a name="python.contents"></a><a class="link" href="index.html#python.contents" title="Contents">Contents</a>
|
|
||||||
</h2></div></div></div>
|
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
|
||||||
<li class="listitem">
|
|
||||||
<a class="link" href="rn.html" title="Chapter 1. Release Notes">Release Notes</a>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<a href="tutorial/index.html" target="_top">Tutorial</a>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<a class="link" href="building.html" title="Chapter 2. Building and Testing">Building and Testing</a>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<a href="reference/index.html" target="_top">Reference Manual</a>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<a class="link" href="configuration.html" title="Chapter 3. Configuration">Configuration Information</a>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<a class="link" href="glossary.html" title="Chapter 6. Glossary">Glossary</a>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<a class="link" href="support.html" title="Chapter 4. Support Resources">Support Resources</a>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<a class="link" href="faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">Frequently Asked Questions (FAQs)</a>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<a href="numpy/index.html" target="_top">NumPy Extension Documentation</a>
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
|
||||||
</div>
|
|
||||||
<h3>
|
|
||||||
<a name="python.h1"></a>
|
|
||||||
<span class="phrase"><a name="python.articles"></a></span><a class="link" href="index.html#python.articles">Articles</a>
|
|
||||||
</h3>
|
|
||||||
<p>
|
|
||||||
<a href="article.html" target="_top">Building Hybrid Systems With Boost Python</a>,
|
|
||||||
by Dave Abrahams and Ralf W. Grosse-Kunstleve
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"><p><small>Last revised: June 01, 2019 at 23:25:23 GMT</small></p></td>
|
|
||||||
<td align="right"><div class="copyright-footer"></div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav"><a accesskey="n" href="rn.html"><img src="images/next.png" alt="Next"></a></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# Sphinx build info version 1
|
|
||||||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
|
|
||||||
config: c2f89bf9615bf36af14ecba75ba30ca4
|
|
||||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
How to use dtypes
|
|
||||||
=================
|
|
||||||
|
|
||||||
Here is a brief tutorial to show how to create ndarrays with built-in python data types, and extract the types and values of member variables
|
|
||||||
|
|
||||||
Like before, first get the necessary headers, setup the namespaces and initialize the Python runtime and numpy module::
|
|
||||||
|
|
||||||
#include <boost/python/numpy.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace p = boost::python;
|
|
||||||
namespace np = boost::python::numpy;
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Py_Initialize();
|
|
||||||
np::initialize();
|
|
||||||
|
|
||||||
Next, we create the shape and dtype. We use the get_builtin method to get the numpy dtype corresponding to the builtin C++ dtype
|
|
||||||
Here, we will create a 3x3 array passing a tuple with (3,3) for the size, and double as the data type ::
|
|
||||||
|
|
||||||
p::tuple shape = p::make_tuple(3, 3);
|
|
||||||
np::dtype dtype = np::dtype::get_builtin<double>();
|
|
||||||
np::ndarray a = np::zeros(shape, dtype);
|
|
||||||
|
|
||||||
Finally, we can print the array using the extract method in the python namespace.
|
|
||||||
Here, we first convert the variable into a string, and then extract it as a C++ character array from the python string using the <char const \* > template ::
|
|
||||||
|
|
||||||
std::cout << "Original array:\n" << p::extract<char const *>(p::str(a)) << std::endl;
|
|
||||||
|
|
||||||
We can also print the dtypes of the data members of the ndarray by using the get_dtype method for the ndarray ::
|
|
||||||
|
|
||||||
std::cout << "Datatype is:\n" << p::extract<char const *>(p::str(a.get_dtype())) << std::endl ;
|
|
||||||
|
|
||||||
We can also create custom dtypes and build ndarrays with the custom dtypes
|
|
||||||
|
|
||||||
We use the dtype constructor to create a custom dtype. This constructor takes a list as an argument.
|
|
||||||
|
|
||||||
The list should contain one or more tuples of the format (variable name, variable type)
|
|
||||||
|
|
||||||
So first create a tuple with a variable name and its dtype, double, to create a custom dtype ::
|
|
||||||
|
|
||||||
p::tuple for_custom_dtype = p::make_tuple("ha",dtype) ;
|
|
||||||
|
|
||||||
Next, create a list, and add this tuple to the list. Then use the list to create the custom dtype ::
|
|
||||||
|
|
||||||
p::list list_for_dtype ;
|
|
||||||
list_for_dtype.append(for_custom_dtype) ;
|
|
||||||
np::dtype custom_dtype = np::dtype(list_for_dtype) ;
|
|
||||||
|
|
||||||
We are now ready to create an ndarray with dimensions specified by \*shape\* and of custom dtpye ::
|
|
||||||
|
|
||||||
np::ndarray new_array = np::zeros(shape,custom_dtype);
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 673 B |
@@ -1,537 +0,0 @@
|
|||||||
/*
|
|
||||||
* basic.css
|
|
||||||
* ~~~~~~~~~
|
|
||||||
*
|
|
||||||
* Sphinx stylesheet -- basic theme.
|
|
||||||
*
|
|
||||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
|
||||||
* :license: BSD, see LICENSE for details.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* -- main layout ----------------------------------------------------------- */
|
|
||||||
|
|
||||||
div.clearer {
|
|
||||||
clear: both;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- relbar ---------------------------------------------------------------- */
|
|
||||||
|
|
||||||
div.related {
|
|
||||||
width: 100%;
|
|
||||||
font-size: 90%;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.related h3 {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.related ul {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0 0 0 10px;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.related li {
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.related li.right {
|
|
||||||
float: right;
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- sidebar --------------------------------------------------------------- */
|
|
||||||
|
|
||||||
div.sphinxsidebarwrapper {
|
|
||||||
padding: 10px 5px 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar {
|
|
||||||
float: left;
|
|
||||||
width: 230px;
|
|
||||||
margin-left: -100%;
|
|
||||||
font-size: 90%;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar ul {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar ul ul,
|
|
||||||
div.sphinxsidebar ul.want-points {
|
|
||||||
margin-left: 20px;
|
|
||||||
list-style: square;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar ul ul {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar form {
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar input {
|
|
||||||
border: 1px solid #98dbcc;
|
|
||||||
font-family: sans-serif;
|
|
||||||
font-size: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar #searchbox input[type="text"] {
|
|
||||||
width: 170px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar #searchbox input[type="submit"] {
|
|
||||||
width: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
img {
|
|
||||||
border: 0;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- search page ----------------------------------------------------------- */
|
|
||||||
|
|
||||||
ul.search {
|
|
||||||
margin: 10px 0 0 20px;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.search li {
|
|
||||||
padding: 5px 0 5px 20px;
|
|
||||||
background-image: url(file.png);
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: 0 7px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.search li a {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.search li div.context {
|
|
||||||
color: #888;
|
|
||||||
margin: 2px 0 0 30px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.keywordmatches li.goodmatch a {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- index page ------------------------------------------------------------ */
|
|
||||||
|
|
||||||
table.contentstable {
|
|
||||||
width: 90%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.contentstable p.biglink {
|
|
||||||
line-height: 150%;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.biglink {
|
|
||||||
font-size: 1.3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.linkdescr {
|
|
||||||
font-style: italic;
|
|
||||||
padding-top: 5px;
|
|
||||||
font-size: 90%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- general index --------------------------------------------------------- */
|
|
||||||
|
|
||||||
table.indextable {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.indextable td {
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.indextable dl, table.indextable dd {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.indextable tr.pcap {
|
|
||||||
height: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.indextable tr.cap {
|
|
||||||
margin-top: 10px;
|
|
||||||
background-color: #f2f2f2;
|
|
||||||
}
|
|
||||||
|
|
||||||
img.toggler {
|
|
||||||
margin-right: 3px;
|
|
||||||
margin-top: 3px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.modindex-jumpbox {
|
|
||||||
border-top: 1px solid #ddd;
|
|
||||||
border-bottom: 1px solid #ddd;
|
|
||||||
margin: 1em 0 1em 0;
|
|
||||||
padding: 0.4em;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.genindex-jumpbox {
|
|
||||||
border-top: 1px solid #ddd;
|
|
||||||
border-bottom: 1px solid #ddd;
|
|
||||||
margin: 1em 0 1em 0;
|
|
||||||
padding: 0.4em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- general body styles --------------------------------------------------- */
|
|
||||||
|
|
||||||
a.headerlink {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1:hover > a.headerlink,
|
|
||||||
h2:hover > a.headerlink,
|
|
||||||
h3:hover > a.headerlink,
|
|
||||||
h4:hover > a.headerlink,
|
|
||||||
h5:hover > a.headerlink,
|
|
||||||
h6:hover > a.headerlink,
|
|
||||||
dt:hover > a.headerlink {
|
|
||||||
visibility: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.body p.caption {
|
|
||||||
text-align: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.body td {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-list ul {
|
|
||||||
padding-left: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.first {
|
|
||||||
margin-top: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.rubric {
|
|
||||||
margin-top: 30px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
img.align-left, .figure.align-left, object.align-left {
|
|
||||||
clear: left;
|
|
||||||
float: left;
|
|
||||||
margin-right: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
img.align-right, .figure.align-right, object.align-right {
|
|
||||||
clear: right;
|
|
||||||
float: right;
|
|
||||||
margin-left: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
img.align-center, .figure.align-center, object.align-center {
|
|
||||||
display: block;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.align-left {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.align-center {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.align-right {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- sidebars -------------------------------------------------------------- */
|
|
||||||
|
|
||||||
div.sidebar {
|
|
||||||
margin: 0 0 0.5em 1em;
|
|
||||||
border: 1px solid #ddb;
|
|
||||||
padding: 7px 7px 0 7px;
|
|
||||||
background-color: #ffe;
|
|
||||||
width: 40%;
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.sidebar-title {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- topics ---------------------------------------------------------------- */
|
|
||||||
|
|
||||||
div.topic {
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
padding: 7px 7px 0 7px;
|
|
||||||
margin: 10px 0 10px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.topic-title {
|
|
||||||
font-size: 1.1em;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- admonitions ----------------------------------------------------------- */
|
|
||||||
|
|
||||||
div.admonition {
|
|
||||||
margin-top: 10px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
padding: 7px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.admonition dt {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.admonition dl {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.admonition-title {
|
|
||||||
margin: 0px 10px 5px 0px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.body p.centered {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 25px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- tables ---------------------------------------------------------------- */
|
|
||||||
|
|
||||||
table.docutils {
|
|
||||||
border: 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.docutils td, table.docutils th {
|
|
||||||
padding: 1px 8px 1px 5px;
|
|
||||||
border-top: 0;
|
|
||||||
border-left: 0;
|
|
||||||
border-right: 0;
|
|
||||||
border-bottom: 1px solid #aaa;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.field-list td, table.field-list th {
|
|
||||||
border: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.footnote td, table.footnote th {
|
|
||||||
border: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
text-align: left;
|
|
||||||
padding-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.citation {
|
|
||||||
border-left: solid 1px gray;
|
|
||||||
margin-left: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.citation td {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- other body styles ----------------------------------------------------- */
|
|
||||||
|
|
||||||
ol.arabic {
|
|
||||||
list-style: decimal;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol.loweralpha {
|
|
||||||
list-style: lower-alpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol.upperalpha {
|
|
||||||
list-style: upper-alpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol.lowerroman {
|
|
||||||
list-style: lower-roman;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol.upperroman {
|
|
||||||
list-style: upper-roman;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl {
|
|
||||||
margin-bottom: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
dd p {
|
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
dd ul, dd table {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
dd {
|
|
||||||
margin-top: 3px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
margin-left: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
dt:target, .highlighted {
|
|
||||||
background-color: #fbe54e;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.glossary dt {
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 1.1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-list ul {
|
|
||||||
margin: 0;
|
|
||||||
padding-left: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-list p {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.optional {
|
|
||||||
font-size: 1.3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.versionmodified {
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.system-message {
|
|
||||||
background-color: #fda;
|
|
||||||
padding: 5px;
|
|
||||||
border: 3px solid red;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footnote:target {
|
|
||||||
background-color: #ffa;
|
|
||||||
}
|
|
||||||
|
|
||||||
.line-block {
|
|
||||||
display: block;
|
|
||||||
margin-top: 1em;
|
|
||||||
margin-bottom: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.line-block .line-block {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 0;
|
|
||||||
margin-left: 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.guilabel, .menuselection {
|
|
||||||
font-family: sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.accelerator {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classifier {
|
|
||||||
font-style: oblique;
|
|
||||||
}
|
|
||||||
|
|
||||||
abbr, acronym {
|
|
||||||
border-bottom: dotted 1px;
|
|
||||||
cursor: help;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- code displays --------------------------------------------------------- */
|
|
||||||
|
|
||||||
pre {
|
|
||||||
overflow: auto;
|
|
||||||
overflow-y: hidden; /* fixes display issues on Chrome browsers */
|
|
||||||
}
|
|
||||||
|
|
||||||
td.linenos pre {
|
|
||||||
padding: 5px 0px;
|
|
||||||
border: 0;
|
|
||||||
background-color: transparent;
|
|
||||||
color: #aaa;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.highlighttable {
|
|
||||||
margin-left: 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.highlighttable td {
|
|
||||||
padding: 0 0.5em 0 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
tt.descname {
|
|
||||||
background-color: transparent;
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
tt.descclassname {
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
tt.xref, a tt {
|
|
||||||
background-color: transparent;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.viewcode-link {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.viewcode-back {
|
|
||||||
float: right;
|
|
||||||
font-family: sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.viewcode-block:target {
|
|
||||||
margin: -1px -10px;
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- math display ---------------------------------------------------------- */
|
|
||||||
|
|
||||||
img.math {
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.body div.math p {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.eqno {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- printout stylesheet --------------------------------------------------- */
|
|
||||||
|
|
||||||
@media print {
|
|
||||||
div.document,
|
|
||||||
div.documentwrapper,
|
|
||||||
div.bodywrapper {
|
|
||||||
margin: 0 !important;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar,
|
|
||||||
div.related,
|
|
||||||
div.footer,
|
|
||||||
#top-link {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,716 +0,0 @@
|
|||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Copyright (c) 2004 Joel de Guzman
|
|
||||||
http://spirit.sourceforge.net/
|
|
||||||
|
|
||||||
Copyright 2013 Niall Douglas additions for colors and alignment.
|
|
||||||
Copyright 2013 Paul A. Bristow additions for more colors and alignments.
|
|
||||||
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompany-
|
|
||||||
ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Body defaults
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
body
|
|
||||||
{
|
|
||||||
margin: 1em;
|
|
||||||
font-family: sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Paragraphs
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
p
|
|
||||||
{
|
|
||||||
text-align: left;
|
|
||||||
font-size: 10pt;
|
|
||||||
line-height: 1.15;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Program listings
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
/* Code on paragraphs */
|
|
||||||
p tt.computeroutput
|
|
||||||
{
|
|
||||||
font-size: 9pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre.synopsis
|
|
||||||
{
|
|
||||||
font-size: 9pt;
|
|
||||||
margin: 1pc 4% 0pc 4%;
|
|
||||||
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.programlisting,
|
|
||||||
.screen
|
|
||||||
{
|
|
||||||
font-size: 9pt;
|
|
||||||
display: block;
|
|
||||||
margin: 1pc 4% 0pc 4%;
|
|
||||||
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Program listings in tables don't get borders */
|
|
||||||
td .programlisting,
|
|
||||||
td .screen
|
|
||||||
{
|
|
||||||
margin: 0pc 0pc 0pc 0pc;
|
|
||||||
padding: 0pc 0pc 0pc 0pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Headings
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6
|
|
||||||
{
|
|
||||||
text-align: left;
|
|
||||||
margin: 1em 0em 0.5em 0em;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 { font-size: 140%; }
|
|
||||||
h2 { font-weight: bold; font-size: 140%; }
|
|
||||||
h3 { font-weight: bold; font-size: 130%; }
|
|
||||||
h4 { font-weight: bold; font-size: 120%; }
|
|
||||||
h5 { font-weight: normal; font-style: italic; font-size: 110%; }
|
|
||||||
h6 { font-weight: normal; font-style: italic; font-size: 100%; }
|
|
||||||
|
|
||||||
/* Top page titles */
|
|
||||||
title,
|
|
||||||
h1.title,
|
|
||||||
h2.title
|
|
||||||
h3.title,
|
|
||||||
h4.title,
|
|
||||||
h5.title,
|
|
||||||
h6.title,
|
|
||||||
.refentrytitle
|
|
||||||
{
|
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 1pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1.title { font-size: 140% }
|
|
||||||
h2.title { font-size: 140% }
|
|
||||||
h3.title { font-size: 130% }
|
|
||||||
h4.title { font-size: 120% }
|
|
||||||
h5.title { font-size: 110% }
|
|
||||||
h6.title { font-size: 100% }
|
|
||||||
|
|
||||||
.section h1
|
|
||||||
{
|
|
||||||
margin: 0em 0em 0.5em 0em;
|
|
||||||
font-size: 140%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section h2 { font-size: 140% }
|
|
||||||
.section h3 { font-size: 130% }
|
|
||||||
.section h4 { font-size: 120% }
|
|
||||||
.section h5 { font-size: 110% }
|
|
||||||
.section h6 { font-size: 100% }
|
|
||||||
|
|
||||||
/* Code on titles */
|
|
||||||
h1 tt.computeroutput { font-size: 140% }
|
|
||||||
h2 tt.computeroutput { font-size: 140% }
|
|
||||||
h3 tt.computeroutput { font-size: 130% }
|
|
||||||
h4 tt.computeroutput { font-size: 130% }
|
|
||||||
h5 tt.computeroutput { font-size: 130% }
|
|
||||||
h6 tt.computeroutput { font-size: 130% }
|
|
||||||
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Author
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
h3.author
|
|
||||||
{
|
|
||||||
font-size: 100%
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Lists
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
li
|
|
||||||
{
|
|
||||||
font-size: 10pt;
|
|
||||||
line-height: 1.3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unordered lists */
|
|
||||||
ul
|
|
||||||
{
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ordered lists */
|
|
||||||
ol
|
|
||||||
{
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Links
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
a
|
|
||||||
{
|
|
||||||
text-decoration: none; /* no underline */
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover
|
|
||||||
{
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Spirit style navigation
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
.spirit-nav
|
|
||||||
{
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spirit-nav a
|
|
||||||
{
|
|
||||||
color: white;
|
|
||||||
padding-left: 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spirit-nav img
|
|
||||||
{
|
|
||||||
border-width: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Copyright footer
|
|
||||||
=============================================================================*/
|
|
||||||
.copyright-footer
|
|
||||||
{
|
|
||||||
text-align: right;
|
|
||||||
font-size: 70%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.copyright-footer p
|
|
||||||
{
|
|
||||||
text-align: right;
|
|
||||||
font-size: 80%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Table of contents
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
div.toc
|
|
||||||
{
|
|
||||||
margin: 1pc 4% 0pc 4%;
|
|
||||||
padding: 0.1pc 1pc 0.1pc 1pc;
|
|
||||||
font-size: 80%;
|
|
||||||
line-height: 1.15;
|
|
||||||
}
|
|
||||||
|
|
||||||
.boost-toc
|
|
||||||
{
|
|
||||||
float: right;
|
|
||||||
padding: 0.5pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Code on toc */
|
|
||||||
.toc .computeroutput { font-size: 120% }
|
|
||||||
|
|
||||||
/* No margin on nested menus */
|
|
||||||
|
|
||||||
.toc dl dl { margin: 0; }
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Tables
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
.table-title,
|
|
||||||
div.table p.title
|
|
||||||
{
|
|
||||||
margin-left: 4%;
|
|
||||||
padding-right: 0.5em;
|
|
||||||
padding-left: 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.informaltable table,
|
|
||||||
.table table
|
|
||||||
{
|
|
||||||
width: 92%;
|
|
||||||
margin-left: 4%;
|
|
||||||
margin-right: 4%;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.informaltable table,
|
|
||||||
div.table table
|
|
||||||
{
|
|
||||||
padding: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Table Cells */
|
|
||||||
div.informaltable table tr td,
|
|
||||||
div.table table tr td
|
|
||||||
{
|
|
||||||
padding: 0.5em;
|
|
||||||
text-align: left;
|
|
||||||
font-size: 9pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.informaltable table tr th,
|
|
||||||
div.table table tr th
|
|
||||||
{
|
|
||||||
padding: 0.5em 0.5em 0.5em 0.5em;
|
|
||||||
border: 1pt solid white;
|
|
||||||
font-size: 80%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.simplelist
|
|
||||||
{
|
|
||||||
width: auto !important;
|
|
||||||
margin: 0em !important;
|
|
||||||
padding: 0em !important;
|
|
||||||
border: none !important;
|
|
||||||
}
|
|
||||||
table.simplelist td
|
|
||||||
{
|
|
||||||
margin: 0em !important;
|
|
||||||
padding: 0em !important;
|
|
||||||
text-align: left !important;
|
|
||||||
font-size: 9pt !important;
|
|
||||||
border: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Suppress margins in tables
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
table th > *:first-child,
|
|
||||||
table td > *:first-child
|
|
||||||
{
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
table th > *:last-child,
|
|
||||||
table td > *:last-child
|
|
||||||
{
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Blurbs
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
div.note,
|
|
||||||
div.tip,
|
|
||||||
div.important,
|
|
||||||
div.caution,
|
|
||||||
div.warning,
|
|
||||||
p.blurb
|
|
||||||
{
|
|
||||||
font-size: 9pt; /* A little bit smaller than the main text */
|
|
||||||
line-height: 1.2;
|
|
||||||
display: block;
|
|
||||||
margin: 1pc 4% 0pc 4%;
|
|
||||||
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.blurb img
|
|
||||||
{
|
|
||||||
padding: 1pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Variable Lists
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
div.variablelist
|
|
||||||
{
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make the terms in definition lists bold */
|
|
||||||
div.variablelist dl dt,
|
|
||||||
span.term
|
|
||||||
{
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 10pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.variablelist table tbody tr td
|
|
||||||
{
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: top;
|
|
||||||
padding: 0em 2em 0em 0em;
|
|
||||||
font-size: 10pt;
|
|
||||||
margin: 0em 0em 0.5em 0em;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.variablelist dl dt
|
|
||||||
{
|
|
||||||
margin-bottom: 0.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.variablelist dl dd
|
|
||||||
{
|
|
||||||
margin: 0em 0em 0.5em 2em;
|
|
||||||
font-size: 10pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.variablelist table tbody tr td p,
|
|
||||||
div.variablelist dl dd p
|
|
||||||
{
|
|
||||||
margin: 0em 0em 0.5em 0em;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Misc
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
/* Title of books and articles in bibliographies */
|
|
||||||
span.title
|
|
||||||
{
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.underline
|
|
||||||
{
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.strikethrough
|
|
||||||
{
|
|
||||||
text-decoration: line-through;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copyright, Legal Notice */
|
|
||||||
div div.legalnotice p
|
|
||||||
{
|
|
||||||
text-align: left
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Colors
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
@media screen
|
|
||||||
{
|
|
||||||
body {
|
|
||||||
background-color: #FFFFFF;
|
|
||||||
color: #000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Syntax Highlighting */
|
|
||||||
.keyword { color: #0000AA; }
|
|
||||||
.identifier { color: #000000; }
|
|
||||||
.special { color: #707070; }
|
|
||||||
.preprocessor { color: #402080; }
|
|
||||||
.char { color: teal; }
|
|
||||||
.comment { color: #800000; }
|
|
||||||
.string { color: teal; }
|
|
||||||
.number { color: teal; }
|
|
||||||
.white_bkd { background-color: #FFFFFF; }
|
|
||||||
.dk_grey_bkd { background-color: #999999; }
|
|
||||||
|
|
||||||
/* Links */
|
|
||||||
a, a .keyword, a .identifier, a .special, a .preprocessor
|
|
||||||
a .char, a .comment, a .string, a .number
|
|
||||||
{
|
|
||||||
color: #005a9c;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:visited, a:visited .keyword, a:visited .identifier,
|
|
||||||
a:visited .special, a:visited .preprocessor a:visited .char,
|
|
||||||
a:visited .comment, a:visited .string, a:visited .number
|
|
||||||
{
|
|
||||||
color: #9c5a9c;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
|
|
||||||
h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
|
|
||||||
h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
|
|
||||||
{
|
|
||||||
text-decoration: none; /* no underline */
|
|
||||||
color: #000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copyright, Legal Notice */
|
|
||||||
.copyright
|
|
||||||
{
|
|
||||||
color: #666666;
|
|
||||||
font-size: small;
|
|
||||||
}
|
|
||||||
|
|
||||||
div div.legalnotice p
|
|
||||||
{
|
|
||||||
color: #666666;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Program listing */
|
|
||||||
pre.synopsis
|
|
||||||
{
|
|
||||||
border: 1px solid #DCDCDC;
|
|
||||||
}
|
|
||||||
|
|
||||||
.programlisting,
|
|
||||||
.screen
|
|
||||||
{
|
|
||||||
border: 1px solid #DCDCDC;
|
|
||||||
}
|
|
||||||
|
|
||||||
td .programlisting,
|
|
||||||
td .screen
|
|
||||||
{
|
|
||||||
border: 0px solid #DCDCDC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Blurbs */
|
|
||||||
div.note,
|
|
||||||
div.tip,
|
|
||||||
div.important,
|
|
||||||
div.caution,
|
|
||||||
div.warning,
|
|
||||||
p.blurb
|
|
||||||
{
|
|
||||||
border: 1px solid #DCDCDC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Table of contents */
|
|
||||||
div.toc
|
|
||||||
{
|
|
||||||
border: 1px solid #DCDCDC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tables */
|
|
||||||
div.informaltable table tr td,
|
|
||||||
div.table table tr td
|
|
||||||
{
|
|
||||||
border: 1px solid #DCDCDC;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.informaltable table tr th,
|
|
||||||
div.table table tr th
|
|
||||||
{
|
|
||||||
background-color: #F0F0F0;
|
|
||||||
border: 1px solid #DCDCDC;
|
|
||||||
}
|
|
||||||
|
|
||||||
.copyright-footer
|
|
||||||
{
|
|
||||||
color: #8F8F8F;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Misc */
|
|
||||||
span.highlight
|
|
||||||
{
|
|
||||||
color: #00A000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media print
|
|
||||||
{
|
|
||||||
/* Links */
|
|
||||||
a
|
|
||||||
{
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:visited
|
|
||||||
{
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spirit-nav
|
|
||||||
{
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Program listing */
|
|
||||||
pre.synopsis
|
|
||||||
{
|
|
||||||
border: 1px solid gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
.programlisting,
|
|
||||||
.screen
|
|
||||||
{
|
|
||||||
border: 1px solid gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
td .programlisting,
|
|
||||||
td .screen
|
|
||||||
{
|
|
||||||
border: 0px solid #DCDCDC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Table of contents */
|
|
||||||
div.toc
|
|
||||||
{
|
|
||||||
border: 1px solid gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
.informaltable table,
|
|
||||||
.table table
|
|
||||||
{
|
|
||||||
border: 1px solid gray;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tables */
|
|
||||||
div.informaltable table tr td,
|
|
||||||
div.table table tr td
|
|
||||||
{
|
|
||||||
border: 1px solid gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.informaltable table tr th,
|
|
||||||
div.table table tr th
|
|
||||||
{
|
|
||||||
border: 1px solid gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.simplelist tr td
|
|
||||||
{
|
|
||||||
border: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Misc */
|
|
||||||
span.highlight
|
|
||||||
{
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================================================
|
|
||||||
Images
|
|
||||||
=============================================================================*/
|
|
||||||
|
|
||||||
span.inlinemediaobject img
|
|
||||||
{
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==============================================================================
|
|
||||||
Super and Subscript: style so that line spacing isn't effected, see
|
|
||||||
http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=1&postId=5341
|
|
||||||
==============================================================================*/
|
|
||||||
|
|
||||||
sup,
|
|
||||||
sub {
|
|
||||||
height: 0;
|
|
||||||
line-height: 1;
|
|
||||||
vertical-align: baseline;
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For internet explorer: */
|
|
||||||
|
|
||||||
* html sup,
|
|
||||||
* html sub {
|
|
||||||
vertical-align: bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
sup {
|
|
||||||
bottom: 1ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub {
|
|
||||||
top: .5ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==============================================================================
|
|
||||||
Indexes: pretty much the same as the TOC.
|
|
||||||
==============================================================================*/
|
|
||||||
|
|
||||||
.index
|
|
||||||
{
|
|
||||||
font-size: 80%;
|
|
||||||
padding-top: 0px;
|
|
||||||
padding-bottom: 0px;
|
|
||||||
margin-top: 0px;
|
|
||||||
margin-bottom: 0px;
|
|
||||||
margin-left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.index ul
|
|
||||||
{
|
|
||||||
padding-left: 3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.index p
|
|
||||||
{
|
|
||||||
padding: 2px;
|
|
||||||
margin: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.index-entry-level-0
|
|
||||||
{
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.index em
|
|
||||||
{
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*==============================================================================
|
|
||||||
Alignment and coloring use 'role' feature, available from Quickbook 1.6 up.
|
|
||||||
Added from Niall Douglas for role color and alignment.
|
|
||||||
http://article.gmane.org/gmane.comp.lib.boost.devel/243318
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Add text alignment (see http://www.w3schools.com/cssref/pr_text_text-align.asp) */
|
|
||||||
span.aligncenter
|
|
||||||
{
|
|
||||||
display: inline-block; width: 100%; text-align: center;
|
|
||||||
}
|
|
||||||
span.alignright
|
|
||||||
{
|
|
||||||
display: inline-block; width: 100%; text-align: right;
|
|
||||||
}
|
|
||||||
/* alignleft is the default. */
|
|
||||||
span.alignleft
|
|
||||||
{
|
|
||||||
display: inline-block; width: 100%; text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* alignjustify stretches the word spacing so that each line has equal width
|
|
||||||
within a chosen fraction of page width (here arbitrarily 20%).
|
|
||||||
*Not* useful inside table items as the column width remains the total string width.
|
|
||||||
Nor very useful, except to temporarily restrict the width.
|
|
||||||
*/
|
|
||||||
span.alignjustify
|
|
||||||
{
|
|
||||||
display: inline-block; width: 20%; text-align: justify;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Text colors.
|
|
||||||
Names at http://www.w3.org/TR/2002/WD-css3-color-20020219/ 4.3. X11 color keywords.
|
|
||||||
Quickbook Usage: [role red Some red text]
|
|
||||||
|
|
||||||
*/
|
|
||||||
span.red { inline-block; color: red; }
|
|
||||||
span.green { color: green; }
|
|
||||||
span.lime { color: #00FF00; }
|
|
||||||
span.blue { color: blue; }
|
|
||||||
span.navy { color: navy; }
|
|
||||||
span.yellow { color: yellow; }
|
|
||||||
span.magenta { color: magenta; }
|
|
||||||
span.indigo { color: #4B0082; }
|
|
||||||
span.cyan { color: cyan; }
|
|
||||||
span.purple { color: purple; }
|
|
||||||
span.gold { color: gold; }
|
|
||||||
span.silver { color: silver; } /* lighter gray */
|
|
||||||
span.gray { color: #808080; } /* light gray */
|
|
||||||
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
@@ -1,256 +0,0 @@
|
|||||||
/*
|
|
||||||
* default.css_t
|
|
||||||
* ~~~~~~~~~~~~~
|
|
||||||
*
|
|
||||||
* Sphinx stylesheet -- default theme.
|
|
||||||
*
|
|
||||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
|
||||||
* :license: BSD, see LICENSE for details.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
@import url("basic.css");
|
|
||||||
|
|
||||||
/* -- page layout ----------------------------------------------------------- */
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: sans-serif;
|
|
||||||
font-size: 100%;
|
|
||||||
background-color: #11303d;
|
|
||||||
color: #000;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.document {
|
|
||||||
background-color: #1c4e63;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.documentwrapper {
|
|
||||||
float: left;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.bodywrapper {
|
|
||||||
margin: 0 0 0 230px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.body {
|
|
||||||
background-color: #ffffff;
|
|
||||||
color: #000000;
|
|
||||||
padding: 0 20px 30px 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.footer {
|
|
||||||
color: #ffffff;
|
|
||||||
width: 100%;
|
|
||||||
padding: 9px 0 9px 0;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 75%;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.footer a {
|
|
||||||
color: #ffffff;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.related {
|
|
||||||
background-color: #133f52;
|
|
||||||
line-height: 30px;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.related a {
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar {
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar h3 {
|
|
||||||
font-family: 'Trebuchet MS', sans-serif;
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 1.4em;
|
|
||||||
font-weight: normal;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar h3 a {
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar h4 {
|
|
||||||
font-family: 'Trebuchet MS', sans-serif;
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 1.3em;
|
|
||||||
font-weight: normal;
|
|
||||||
margin: 5px 0 0 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar p {
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar p.topless {
|
|
||||||
margin: 5px 10px 10px 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar ul {
|
|
||||||
margin: 10px;
|
|
||||||
padding: 0;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar a {
|
|
||||||
color: #98dbcc;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.sphinxsidebar input {
|
|
||||||
border: 1px solid #98dbcc;
|
|
||||||
font-family: sans-serif;
|
|
||||||
font-size: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* -- hyperlink styles ------------------------------------------------------ */
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: #355f7c;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:visited {
|
|
||||||
color: #355f7c;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* -- body styles ----------------------------------------------------------- */
|
|
||||||
|
|
||||||
div.body h1,
|
|
||||||
div.body h2,
|
|
||||||
div.body h3,
|
|
||||||
div.body h4,
|
|
||||||
div.body h5,
|
|
||||||
div.body h6 {
|
|
||||||
font-family: 'Trebuchet MS', sans-serif;
|
|
||||||
background-color: #f2f2f2;
|
|
||||||
font-weight: normal;
|
|
||||||
color: #20435c;
|
|
||||||
border-bottom: 1px solid #ccc;
|
|
||||||
margin: 20px -20px 10px -20px;
|
|
||||||
padding: 3px 0 3px 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.body h1 { margin-top: 0; font-size: 200%; }
|
|
||||||
div.body h2 { font-size: 160%; }
|
|
||||||
div.body h3 { font-size: 140%; }
|
|
||||||
div.body h4 { font-size: 120%; }
|
|
||||||
div.body h5 { font-size: 110%; }
|
|
||||||
div.body h6 { font-size: 100%; }
|
|
||||||
|
|
||||||
a.headerlink {
|
|
||||||
color: #c60f0f;
|
|
||||||
font-size: 0.8em;
|
|
||||||
padding: 0 4px 0 4px;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.headerlink:hover {
|
|
||||||
background-color: #c60f0f;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.body p, div.body dd, div.body li {
|
|
||||||
text-align: justify;
|
|
||||||
line-height: 130%;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.admonition p.admonition-title + p {
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.admonition p {
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.admonition pre {
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.admonition ul, div.admonition ol {
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.note {
|
|
||||||
background-color: #eee;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.seealso {
|
|
||||||
background-color: #ffc;
|
|
||||||
border: 1px solid #ff6;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.topic {
|
|
||||||
background-color: #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.warning {
|
|
||||||
background-color: #ffe4e4;
|
|
||||||
border: 1px solid #f66;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.admonition-title {
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.admonition-title:after {
|
|
||||||
content: ":";
|
|
||||||
}
|
|
||||||
|
|
||||||
pre {
|
|
||||||
padding: 5px;
|
|
||||||
background-color: #eeffcc;
|
|
||||||
color: #333333;
|
|
||||||
line-height: 120%;
|
|
||||||
border: 1px solid #ac9;
|
|
||||||
border-left: none;
|
|
||||||
border-right: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
tt {
|
|
||||||
background-color: #ecf0f3;
|
|
||||||
padding: 0 1px 0 1px;
|
|
||||||
font-size: 0.95em;
|
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
background-color: #ede;
|
|
||||||
}
|
|
||||||
|
|
||||||
.warning tt {
|
|
||||||
background: #efc2c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.note tt {
|
|
||||||
background: #d6d6d6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.viewcode-back {
|
|
||||||
font-family: sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.viewcode-block:target {
|
|
||||||
background-color: #f4debf;
|
|
||||||
border-top: 1px solid #ac9;
|
|
||||||
border-bottom: 1px solid #ac9;
|
|
||||||
}
|
|
||||||
@@ -1,238 +0,0 @@
|
|||||||
/*
|
|
||||||
* doctools.js
|
|
||||||
* ~~~~~~~~~~~
|
|
||||||
*
|
|
||||||
* Sphinx JavaScript utilities for all documentation.
|
|
||||||
*
|
|
||||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
|
||||||
* :license: BSD, see LICENSE for details.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* select a different prefix for underscore
|
|
||||||
*/
|
|
||||||
$u = _.noConflict();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* make the code below compatible with browsers without
|
|
||||||
* an installed firebug like debugger
|
|
||||||
if (!window.console || !console.firebug) {
|
|
||||||
var names = ["log", "debug", "info", "warn", "error", "assert", "dir",
|
|
||||||
"dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",
|
|
||||||
"profile", "profileEnd"];
|
|
||||||
window.console = {};
|
|
||||||
for (var i = 0; i < names.length; ++i)
|
|
||||||
window.console[names[i]] = function() {};
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* small helper function to urldecode strings
|
|
||||||
*/
|
|
||||||
jQuery.urldecode = function(x) {
|
|
||||||
return decodeURIComponent(x).replace(/\+/g, ' ');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* small helper function to urlencode strings
|
|
||||||
*/
|
|
||||||
jQuery.urlencode = encodeURIComponent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function returns the parsed url parameters of the
|
|
||||||
* current request. Multiple values per key are supported,
|
|
||||||
* it will always return arrays of strings for the value parts.
|
|
||||||
*/
|
|
||||||
jQuery.getQueryParameters = function(s) {
|
|
||||||
if (typeof s == 'undefined')
|
|
||||||
s = document.location.search;
|
|
||||||
var parts = s.substr(s.indexOf('?') + 1).split('&');
|
|
||||||
var result = {};
|
|
||||||
for (var i = 0; i < parts.length; i++) {
|
|
||||||
var tmp = parts[i].split('=', 2);
|
|
||||||
var key = jQuery.urldecode(tmp[0]);
|
|
||||||
var value = jQuery.urldecode(tmp[1]);
|
|
||||||
if (key in result)
|
|
||||||
result[key].push(value);
|
|
||||||
else
|
|
||||||
result[key] = [value];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* highlight a given string on a jquery object by wrapping it in
|
|
||||||
* span elements with the given class name.
|
|
||||||
*/
|
|
||||||
jQuery.fn.highlightText = function(text, className) {
|
|
||||||
function highlight(node) {
|
|
||||||
if (node.nodeType == 3) {
|
|
||||||
var val = node.nodeValue;
|
|
||||||
var pos = val.toLowerCase().indexOf(text);
|
|
||||||
if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) {
|
|
||||||
var span = document.createElement("span");
|
|
||||||
span.className = className;
|
|
||||||
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
|
|
||||||
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
|
|
||||||
document.createTextNode(val.substr(pos + text.length)),
|
|
||||||
node.nextSibling));
|
|
||||||
node.nodeValue = val.substr(0, pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!jQuery(node).is("button, select, textarea")) {
|
|
||||||
jQuery.each(node.childNodes, function() {
|
|
||||||
highlight(this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.each(function() {
|
|
||||||
highlight(this);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Small JavaScript module for the documentation.
|
|
||||||
*/
|
|
||||||
var Documentation = {
|
|
||||||
|
|
||||||
init : function() {
|
|
||||||
this.fixFirefoxAnchorBug();
|
|
||||||
this.highlightSearchWords();
|
|
||||||
this.initIndexTable();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* i18n support
|
|
||||||
*/
|
|
||||||
TRANSLATIONS : {},
|
|
||||||
PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },
|
|
||||||
LOCALE : 'unknown',
|
|
||||||
|
|
||||||
// gettext and ngettext don't access this so that the functions
|
|
||||||
// can safely bound to a different name (_ = Documentation.gettext)
|
|
||||||
gettext : function(string) {
|
|
||||||
var translated = Documentation.TRANSLATIONS[string];
|
|
||||||
if (typeof translated == 'undefined')
|
|
||||||
return string;
|
|
||||||
return (typeof translated == 'string') ? translated : translated[0];
|
|
||||||
},
|
|
||||||
|
|
||||||
ngettext : function(singular, plural, n) {
|
|
||||||
var translated = Documentation.TRANSLATIONS[singular];
|
|
||||||
if (typeof translated == 'undefined')
|
|
||||||
return (n == 1) ? singular : plural;
|
|
||||||
return translated[Documentation.PLURALEXPR(n)];
|
|
||||||
},
|
|
||||||
|
|
||||||
addTranslations : function(catalog) {
|
|
||||||
for (var key in catalog.messages)
|
|
||||||
this.TRANSLATIONS[key] = catalog.messages[key];
|
|
||||||
this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
|
|
||||||
this.LOCALE = catalog.locale;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add context elements like header anchor links
|
|
||||||
*/
|
|
||||||
addContextElements : function() {
|
|
||||||
$('div[id] > :header:first').each(function() {
|
|
||||||
$('<a class="headerlink">\u00B6</a>').
|
|
||||||
attr('href', '#' + this.id).
|
|
||||||
attr('title', _('Permalink to this headline')).
|
|
||||||
appendTo(this);
|
|
||||||
});
|
|
||||||
$('dt[id]').each(function() {
|
|
||||||
$('<a class="headerlink">\u00B6</a>').
|
|
||||||
attr('href', '#' + this.id).
|
|
||||||
attr('title', _('Permalink to this definition')).
|
|
||||||
appendTo(this);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* workaround a firefox stupidity
|
|
||||||
*/
|
|
||||||
fixFirefoxAnchorBug : function() {
|
|
||||||
if (document.location.hash && $.browser.mozilla)
|
|
||||||
window.setTimeout(function() {
|
|
||||||
document.location.href += '';
|
|
||||||
}, 10);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* highlight the search words provided in the url in the text
|
|
||||||
*/
|
|
||||||
highlightSearchWords : function() {
|
|
||||||
var params = $.getQueryParameters();
|
|
||||||
var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
|
|
||||||
if (terms.length) {
|
|
||||||
var body = $('div.body');
|
|
||||||
if (!body.length) {
|
|
||||||
body = $('body');
|
|
||||||
}
|
|
||||||
window.setTimeout(function() {
|
|
||||||
$.each(terms, function() {
|
|
||||||
body.highlightText(this.toLowerCase(), 'highlighted');
|
|
||||||
});
|
|
||||||
}, 10);
|
|
||||||
$('<p class="highlight-link"><a href="javascript:Documentation.' +
|
|
||||||
'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
|
|
||||||
.appendTo($('#searchbox'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* init the domain index toggle buttons
|
|
||||||
*/
|
|
||||||
initIndexTable : function() {
|
|
||||||
var togglers = $('img.toggler').click(function() {
|
|
||||||
var src = $(this).attr('src');
|
|
||||||
var idnum = $(this).attr('id').substr(7);
|
|
||||||
$('tr.cg-' + idnum).toggle();
|
|
||||||
if (src.substr(-9) == 'minus.png')
|
|
||||||
$(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
|
|
||||||
else
|
|
||||||
$(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
|
|
||||||
}).css('display', '');
|
|
||||||
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
|
|
||||||
togglers.click();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* helper function to hide the search marks again
|
|
||||||
*/
|
|
||||||
hideSearchWords : function() {
|
|
||||||
$('#searchbox .highlight-link').fadeOut(300);
|
|
||||||
$('span.highlighted').removeClass('highlighted');
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* make the url absolute
|
|
||||||
*/
|
|
||||||
makeURL : function(relativeURL) {
|
|
||||||
return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get the current relative url
|
|
||||||
*/
|
|
||||||
getCurrentURL : function() {
|
|
||||||
var path = document.location.pathname;
|
|
||||||
var parts = path.split(/\//);
|
|
||||||
$.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
|
|
||||||
if (this == '..')
|
|
||||||
parts.pop();
|
|
||||||
});
|
|
||||||
var url = parts.join('/');
|
|
||||||
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// quick alias for translations
|
|
||||||
_ = Documentation.gettext;
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
Documentation.init();
|
|
||||||
});
|
|
||||||
|
Before Width: | Height: | Size: 368 B |
|
Before Width: | Height: | Size: 363 B |
|
Before Width: | Height: | Size: 392 B |
9404
develop/doc/html/numpy/_static/jquery.js
vendored
|
Before Width: | Height: | Size: 199 B |
|
Before Width: | Height: | Size: 199 B |
@@ -1,62 +0,0 @@
|
|||||||
.highlight .hll { background-color: #ffffcc }
|
|
||||||
.highlight { background: #f8f8f8; }
|
|
||||||
.highlight .c { color: #408080; font-style: italic } /* Comment */
|
|
||||||
.highlight .err { border: 1px solid #FF0000 } /* Error */
|
|
||||||
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
|
|
||||||
.highlight .o { color: #666666 } /* Operator */
|
|
||||||
.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
|
||||||
.highlight .cp { color: #BC7A00 } /* Comment.Preproc */
|
|
||||||
.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
|
||||||
.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
|
|
||||||
.highlight .gd { color: #A00000 } /* Generic.Deleted */
|
|
||||||
.highlight .ge { font-style: italic } /* Generic.Emph */
|
|
||||||
.highlight .gr { color: #FF0000 } /* Generic.Error */
|
|
||||||
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
|
||||||
.highlight .gi { color: #00A000 } /* Generic.Inserted */
|
|
||||||
.highlight .go { color: #888888 } /* Generic.Output */
|
|
||||||
.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
|
||||||
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
|
||||||
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
|
||||||
.highlight .gt { color: #0044DD } /* Generic.Traceback */
|
|
||||||
.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
|
|
||||||
.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
|
|
||||||
.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
|
|
||||||
.highlight .kp { color: #008000 } /* Keyword.Pseudo */
|
|
||||||
.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
|
|
||||||
.highlight .kt { color: #B00040 } /* Keyword.Type */
|
|
||||||
.highlight .m { color: #666666 } /* Literal.Number */
|
|
||||||
.highlight .s { color: #BA2121 } /* Literal.String */
|
|
||||||
.highlight .na { color: #7D9029 } /* Name.Attribute */
|
|
||||||
.highlight .nb { color: #008000 } /* Name.Builtin */
|
|
||||||
.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
|
||||||
.highlight .no { color: #880000 } /* Name.Constant */
|
|
||||||
.highlight .nd { color: #AA22FF } /* Name.Decorator */
|
|
||||||
.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
|
||||||
.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
|
||||||
.highlight .nf { color: #0000FF } /* Name.Function */
|
|
||||||
.highlight .nl { color: #A0A000 } /* Name.Label */
|
|
||||||
.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
|
||||||
.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
|
|
||||||
.highlight .nv { color: #19177C } /* Name.Variable */
|
|
||||||
.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
|
||||||
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
|
||||||
.highlight .mf { color: #666666 } /* Literal.Number.Float */
|
|
||||||
.highlight .mh { color: #666666 } /* Literal.Number.Hex */
|
|
||||||
.highlight .mi { color: #666666 } /* Literal.Number.Integer */
|
|
||||||
.highlight .mo { color: #666666 } /* Literal.Number.Oct */
|
|
||||||
.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
|
|
||||||
.highlight .sc { color: #BA2121 } /* Literal.String.Char */
|
|
||||||
.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
|
|
||||||
.highlight .s2 { color: #BA2121 } /* Literal.String.Double */
|
|
||||||
.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
|
||||||
.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
|
|
||||||
.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
|
||||||
.highlight .sx { color: #008000 } /* Literal.String.Other */
|
|
||||||
.highlight .sr { color: #BB6688 } /* Literal.String.Regex */
|
|
||||||
.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
|
|
||||||
.highlight .ss { color: #19177C } /* Literal.String.Symbol */
|
|
||||||
.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
|
|
||||||
.highlight .vc { color: #19177C } /* Name.Variable.Class */
|
|
||||||
.highlight .vg { color: #19177C } /* Name.Variable.Global */
|
|
||||||
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
|
|
||||||
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
|
|
||||||
@@ -1,622 +0,0 @@
|
|||||||
/*
|
|
||||||
* searchtools.js_t
|
|
||||||
* ~~~~~~~~~~~~~~~~
|
|
||||||
*
|
|
||||||
* Sphinx JavaScript utilties for the full-text search.
|
|
||||||
*
|
|
||||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
|
||||||
* :license: BSD, see LICENSE for details.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Porter Stemmer
|
|
||||||
*/
|
|
||||||
var Stemmer = function() {
|
|
||||||
|
|
||||||
var step2list = {
|
|
||||||
ational: 'ate',
|
|
||||||
tional: 'tion',
|
|
||||||
enci: 'ence',
|
|
||||||
anci: 'ance',
|
|
||||||
izer: 'ize',
|
|
||||||
bli: 'ble',
|
|
||||||
alli: 'al',
|
|
||||||
entli: 'ent',
|
|
||||||
eli: 'e',
|
|
||||||
ousli: 'ous',
|
|
||||||
ization: 'ize',
|
|
||||||
ation: 'ate',
|
|
||||||
ator: 'ate',
|
|
||||||
alism: 'al',
|
|
||||||
iveness: 'ive',
|
|
||||||
fulness: 'ful',
|
|
||||||
ousness: 'ous',
|
|
||||||
aliti: 'al',
|
|
||||||
iviti: 'ive',
|
|
||||||
biliti: 'ble',
|
|
||||||
logi: 'log'
|
|
||||||
};
|
|
||||||
|
|
||||||
var step3list = {
|
|
||||||
icate: 'ic',
|
|
||||||
ative: '',
|
|
||||||
alize: 'al',
|
|
||||||
iciti: 'ic',
|
|
||||||
ical: 'ic',
|
|
||||||
ful: '',
|
|
||||||
ness: ''
|
|
||||||
};
|
|
||||||
|
|
||||||
var c = "[^aeiou]"; // consonant
|
|
||||||
var v = "[aeiouy]"; // vowel
|
|
||||||
var C = c + "[^aeiouy]*"; // consonant sequence
|
|
||||||
var V = v + "[aeiou]*"; // vowel sequence
|
|
||||||
|
|
||||||
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
|
|
||||||
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
|
|
||||||
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
|
|
||||||
var s_v = "^(" + C + ")?" + v; // vowel in stem
|
|
||||||
|
|
||||||
this.stemWord = function (w) {
|
|
||||||
var stem;
|
|
||||||
var suffix;
|
|
||||||
var firstch;
|
|
||||||
var origword = w;
|
|
||||||
|
|
||||||
if (w.length < 3)
|
|
||||||
return w;
|
|
||||||
|
|
||||||
var re;
|
|
||||||
var re2;
|
|
||||||
var re3;
|
|
||||||
var re4;
|
|
||||||
|
|
||||||
firstch = w.substr(0,1);
|
|
||||||
if (firstch == "y")
|
|
||||||
w = firstch.toUpperCase() + w.substr(1);
|
|
||||||
|
|
||||||
// Step 1a
|
|
||||||
re = /^(.+?)(ss|i)es$/;
|
|
||||||
re2 = /^(.+?)([^s])s$/;
|
|
||||||
|
|
||||||
if (re.test(w))
|
|
||||||
w = w.replace(re,"$1$2");
|
|
||||||
else if (re2.test(w))
|
|
||||||
w = w.replace(re2,"$1$2");
|
|
||||||
|
|
||||||
// Step 1b
|
|
||||||
re = /^(.+?)eed$/;
|
|
||||||
re2 = /^(.+?)(ed|ing)$/;
|
|
||||||
if (re.test(w)) {
|
|
||||||
var fp = re.exec(w);
|
|
||||||
re = new RegExp(mgr0);
|
|
||||||
if (re.test(fp[1])) {
|
|
||||||
re = /.$/;
|
|
||||||
w = w.replace(re,"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (re2.test(w)) {
|
|
||||||
var fp = re2.exec(w);
|
|
||||||
stem = fp[1];
|
|
||||||
re2 = new RegExp(s_v);
|
|
||||||
if (re2.test(stem)) {
|
|
||||||
w = stem;
|
|
||||||
re2 = /(at|bl|iz)$/;
|
|
||||||
re3 = new RegExp("([^aeiouylsz])\\1$");
|
|
||||||
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
|
||||||
if (re2.test(w))
|
|
||||||
w = w + "e";
|
|
||||||
else if (re3.test(w)) {
|
|
||||||
re = /.$/;
|
|
||||||
w = w.replace(re,"");
|
|
||||||
}
|
|
||||||
else if (re4.test(w))
|
|
||||||
w = w + "e";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 1c
|
|
||||||
re = /^(.+?)y$/;
|
|
||||||
if (re.test(w)) {
|
|
||||||
var fp = re.exec(w);
|
|
||||||
stem = fp[1];
|
|
||||||
re = new RegExp(s_v);
|
|
||||||
if (re.test(stem))
|
|
||||||
w = stem + "i";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 2
|
|
||||||
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
|
|
||||||
if (re.test(w)) {
|
|
||||||
var fp = re.exec(w);
|
|
||||||
stem = fp[1];
|
|
||||||
suffix = fp[2];
|
|
||||||
re = new RegExp(mgr0);
|
|
||||||
if (re.test(stem))
|
|
||||||
w = stem + step2list[suffix];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 3
|
|
||||||
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
|
|
||||||
if (re.test(w)) {
|
|
||||||
var fp = re.exec(w);
|
|
||||||
stem = fp[1];
|
|
||||||
suffix = fp[2];
|
|
||||||
re = new RegExp(mgr0);
|
|
||||||
if (re.test(stem))
|
|
||||||
w = stem + step3list[suffix];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 4
|
|
||||||
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
|
|
||||||
re2 = /^(.+?)(s|t)(ion)$/;
|
|
||||||
if (re.test(w)) {
|
|
||||||
var fp = re.exec(w);
|
|
||||||
stem = fp[1];
|
|
||||||
re = new RegExp(mgr1);
|
|
||||||
if (re.test(stem))
|
|
||||||
w = stem;
|
|
||||||
}
|
|
||||||
else if (re2.test(w)) {
|
|
||||||
var fp = re2.exec(w);
|
|
||||||
stem = fp[1] + fp[2];
|
|
||||||
re2 = new RegExp(mgr1);
|
|
||||||
if (re2.test(stem))
|
|
||||||
w = stem;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 5
|
|
||||||
re = /^(.+?)e$/;
|
|
||||||
if (re.test(w)) {
|
|
||||||
var fp = re.exec(w);
|
|
||||||
stem = fp[1];
|
|
||||||
re = new RegExp(mgr1);
|
|
||||||
re2 = new RegExp(meq1);
|
|
||||||
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
|
||||||
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
|
|
||||||
w = stem;
|
|
||||||
}
|
|
||||||
re = /ll$/;
|
|
||||||
re2 = new RegExp(mgr1);
|
|
||||||
if (re.test(w) && re2.test(w)) {
|
|
||||||
re = /.$/;
|
|
||||||
w = w.replace(re,"");
|
|
||||||
}
|
|
||||||
|
|
||||||
// and turn initial Y back to y
|
|
||||||
if (firstch == "y")
|
|
||||||
w = firstch.toLowerCase() + w.substr(1);
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple result scoring code.
|
|
||||||
*/
|
|
||||||
var Scorer = {
|
|
||||||
// Implement the following function to further tweak the score for each result
|
|
||||||
// The function takes a result array [filename, title, anchor, descr, score]
|
|
||||||
// and returns the new score.
|
|
||||||
/*
|
|
||||||
score: function(result) {
|
|
||||||
return result[4];
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
|
|
||||||
// query matches the full name of an object
|
|
||||||
objNameMatch: 11,
|
|
||||||
// or matches in the last dotted part of the object name
|
|
||||||
objPartialMatch: 6,
|
|
||||||
// Additive scores depending on the priority of the object
|
|
||||||
objPrio: {0: 15, // used to be importantResults
|
|
||||||
1: 5, // used to be objectResults
|
|
||||||
2: -5}, // used to be unimportantResults
|
|
||||||
// Used when the priority is not in the mapping.
|
|
||||||
objPrioDefault: 0,
|
|
||||||
|
|
||||||
// query found in title
|
|
||||||
title: 15,
|
|
||||||
// query found in terms
|
|
||||||
term: 5
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Search Module
|
|
||||||
*/
|
|
||||||
var Search = {
|
|
||||||
|
|
||||||
_index : null,
|
|
||||||
_queued_query : null,
|
|
||||||
_pulse_status : -1,
|
|
||||||
|
|
||||||
init : function() {
|
|
||||||
var params = $.getQueryParameters();
|
|
||||||
if (params.q) {
|
|
||||||
var query = params.q[0];
|
|
||||||
$('input[name="q"]')[0].value = query;
|
|
||||||
this.performSearch(query);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
loadIndex : function(url) {
|
|
||||||
$.ajax({type: "GET", url: url, data: null,
|
|
||||||
dataType: "script", cache: true,
|
|
||||||
complete: function(jqxhr, textstatus) {
|
|
||||||
if (textstatus != "success") {
|
|
||||||
document.getElementById("searchindexloader").src = url;
|
|
||||||
}
|
|
||||||
}});
|
|
||||||
},
|
|
||||||
|
|
||||||
setIndex : function(index) {
|
|
||||||
var q;
|
|
||||||
this._index = index;
|
|
||||||
if ((q = this._queued_query) !== null) {
|
|
||||||
this._queued_query = null;
|
|
||||||
Search.query(q);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
hasIndex : function() {
|
|
||||||
return this._index !== null;
|
|
||||||
},
|
|
||||||
|
|
||||||
deferQuery : function(query) {
|
|
||||||
this._queued_query = query;
|
|
||||||
},
|
|
||||||
|
|
||||||
stopPulse : function() {
|
|
||||||
this._pulse_status = 0;
|
|
||||||
},
|
|
||||||
|
|
||||||
startPulse : function() {
|
|
||||||
if (this._pulse_status >= 0)
|
|
||||||
return;
|
|
||||||
function pulse() {
|
|
||||||
var i;
|
|
||||||
Search._pulse_status = (Search._pulse_status + 1) % 4;
|
|
||||||
var dotString = '';
|
|
||||||
for (i = 0; i < Search._pulse_status; i++)
|
|
||||||
dotString += '.';
|
|
||||||
Search.dots.text(dotString);
|
|
||||||
if (Search._pulse_status > -1)
|
|
||||||
window.setTimeout(pulse, 500);
|
|
||||||
}
|
|
||||||
pulse();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* perform a search for something (or wait until index is loaded)
|
|
||||||
*/
|
|
||||||
performSearch : function(query) {
|
|
||||||
// create the required interface elements
|
|
||||||
this.out = $('#search-results');
|
|
||||||
this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out);
|
|
||||||
this.dots = $('<span></span>').appendTo(this.title);
|
|
||||||
this.status = $('<p style="display: none"></p>').appendTo(this.out);
|
|
||||||
this.output = $('<ul class="search"/>').appendTo(this.out);
|
|
||||||
|
|
||||||
$('#search-progress').text(_('Preparing search...'));
|
|
||||||
this.startPulse();
|
|
||||||
|
|
||||||
// index already loaded, the browser was quick!
|
|
||||||
if (this.hasIndex())
|
|
||||||
this.query(query);
|
|
||||||
else
|
|
||||||
this.deferQuery(query);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* execute search (requires search index to be loaded)
|
|
||||||
*/
|
|
||||||
query : function(query) {
|
|
||||||
var i;
|
|
||||||
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
|
|
||||||
|
|
||||||
// stem the searchterms and add them to the correct list
|
|
||||||
var stemmer = new Stemmer();
|
|
||||||
var searchterms = [];
|
|
||||||
var excluded = [];
|
|
||||||
var hlterms = [];
|
|
||||||
var tmp = query.split(/\s+/);
|
|
||||||
var objectterms = [];
|
|
||||||
for (i = 0; i < tmp.length; i++) {
|
|
||||||
if (tmp[i] !== "") {
|
|
||||||
objectterms.push(tmp[i].toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i].match(/^\d+$/) ||
|
|
||||||
tmp[i] === "") {
|
|
||||||
// skip this "word"
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// stem the word
|
|
||||||
var word = stemmer.stemWord(tmp[i].toLowerCase());
|
|
||||||
var toAppend;
|
|
||||||
// select the correct list
|
|
||||||
if (word[0] == '-') {
|
|
||||||
toAppend = excluded;
|
|
||||||
word = word.substr(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
toAppend = searchterms;
|
|
||||||
hlterms.push(tmp[i].toLowerCase());
|
|
||||||
}
|
|
||||||
// only add if not already in the list
|
|
||||||
if (!$u.contains(toAppend, word))
|
|
||||||
toAppend.push(word);
|
|
||||||
}
|
|
||||||
var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" "));
|
|
||||||
|
|
||||||
// console.debug('SEARCH: searching for:');
|
|
||||||
// console.info('required: ', searchterms);
|
|
||||||
// console.info('excluded: ', excluded);
|
|
||||||
|
|
||||||
// prepare search
|
|
||||||
var terms = this._index.terms;
|
|
||||||
var titleterms = this._index.titleterms;
|
|
||||||
|
|
||||||
// array of [filename, title, anchor, descr, score]
|
|
||||||
var results = [];
|
|
||||||
$('#search-progress').empty();
|
|
||||||
|
|
||||||
// lookup as object
|
|
||||||
for (i = 0; i < objectterms.length; i++) {
|
|
||||||
var others = [].concat(objectterms.slice(0, i),
|
|
||||||
objectterms.slice(i+1, objectterms.length));
|
|
||||||
results = results.concat(this.performObjectSearch(objectterms[i], others));
|
|
||||||
}
|
|
||||||
|
|
||||||
// lookup as search terms in fulltext
|
|
||||||
results = results.concat(this.performTermsSearch(searchterms, excluded, terms, Scorer.term))
|
|
||||||
.concat(this.performTermsSearch(searchterms, excluded, titleterms, Scorer.title));
|
|
||||||
|
|
||||||
// let the scorer override scores with a custom scoring function
|
|
||||||
if (Scorer.score) {
|
|
||||||
for (i = 0; i < results.length; i++)
|
|
||||||
results[i][4] = Scorer.score(results[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// now sort the results by score (in opposite order of appearance, since the
|
|
||||||
// display function below uses pop() to retrieve items) and then
|
|
||||||
// alphabetically
|
|
||||||
results.sort(function(a, b) {
|
|
||||||
var left = a[4];
|
|
||||||
var right = b[4];
|
|
||||||
if (left > right) {
|
|
||||||
return 1;
|
|
||||||
} else if (left < right) {
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
// same score: sort alphabetically
|
|
||||||
left = a[1].toLowerCase();
|
|
||||||
right = b[1].toLowerCase();
|
|
||||||
return (left > right) ? -1 : ((left < right) ? 1 : 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// for debugging
|
|
||||||
//Search.lastresults = results.slice(); // a copy
|
|
||||||
//console.info('search results:', Search.lastresults);
|
|
||||||
|
|
||||||
// print the results
|
|
||||||
var resultCount = results.length;
|
|
||||||
function displayNextItem() {
|
|
||||||
// results left, load the summary and display it
|
|
||||||
if (results.length) {
|
|
||||||
var item = results.pop();
|
|
||||||
var listItem = $('<li style="display:none"></li>');
|
|
||||||
if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') {
|
|
||||||
// dirhtml builder
|
|
||||||
var dirname = item[0] + '/';
|
|
||||||
if (dirname.match(/\/index\/$/)) {
|
|
||||||
dirname = dirname.substring(0, dirname.length-6);
|
|
||||||
} else if (dirname == 'index/') {
|
|
||||||
dirname = '';
|
|
||||||
}
|
|
||||||
listItem.append($('<a/>').attr('href',
|
|
||||||
DOCUMENTATION_OPTIONS.URL_ROOT + dirname +
|
|
||||||
highlightstring + item[2]).html(item[1]));
|
|
||||||
} else {
|
|
||||||
// normal html builders
|
|
||||||
listItem.append($('<a/>').attr('href',
|
|
||||||
item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX +
|
|
||||||
highlightstring + item[2]).html(item[1]));
|
|
||||||
}
|
|
||||||
if (item[3]) {
|
|
||||||
listItem.append($('<span> (' + item[3] + ')</span>'));
|
|
||||||
Search.output.append(listItem);
|
|
||||||
listItem.slideDown(5, function() {
|
|
||||||
displayNextItem();
|
|
||||||
});
|
|
||||||
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
|
|
||||||
$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[0] + '.txt',
|
|
||||||
dataType: "text",
|
|
||||||
complete: function(jqxhr, textstatus) {
|
|
||||||
var data = jqxhr.responseText;
|
|
||||||
if (data !== '') {
|
|
||||||
listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
|
|
||||||
}
|
|
||||||
Search.output.append(listItem);
|
|
||||||
listItem.slideDown(5, function() {
|
|
||||||
displayNextItem();
|
|
||||||
});
|
|
||||||
}});
|
|
||||||
} else {
|
|
||||||
// no source available, just display title
|
|
||||||
Search.output.append(listItem);
|
|
||||||
listItem.slideDown(5, function() {
|
|
||||||
displayNextItem();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// search finished, update title and status message
|
|
||||||
else {
|
|
||||||
Search.stopPulse();
|
|
||||||
Search.title.text(_('Search Results'));
|
|
||||||
if (!resultCount)
|
|
||||||
Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
|
|
||||||
else
|
|
||||||
Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));
|
|
||||||
Search.status.fadeIn(500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
displayNextItem();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* search for object names
|
|
||||||
*/
|
|
||||||
performObjectSearch : function(object, otherterms) {
|
|
||||||
var filenames = this._index.filenames;
|
|
||||||
var objects = this._index.objects;
|
|
||||||
var objnames = this._index.objnames;
|
|
||||||
var titles = this._index.titles;
|
|
||||||
|
|
||||||
var i;
|
|
||||||
var results = [];
|
|
||||||
|
|
||||||
for (var prefix in objects) {
|
|
||||||
for (var name in objects[prefix]) {
|
|
||||||
var fullname = (prefix ? prefix + '.' : '') + name;
|
|
||||||
if (fullname.toLowerCase().indexOf(object) > -1) {
|
|
||||||
var score = 0;
|
|
||||||
var parts = fullname.split('.');
|
|
||||||
// check for different match types: exact matches of full name or
|
|
||||||
// "last name" (i.e. last dotted part)
|
|
||||||
if (fullname == object || parts[parts.length - 1] == object) {
|
|
||||||
score += Scorer.objNameMatch;
|
|
||||||
// matches in last name
|
|
||||||
} else if (parts[parts.length - 1].indexOf(object) > -1) {
|
|
||||||
score += Scorer.objPartialMatch;
|
|
||||||
}
|
|
||||||
var match = objects[prefix][name];
|
|
||||||
var objname = objnames[match[1]][2];
|
|
||||||
var title = titles[match[0]];
|
|
||||||
// If more than one term searched for, we require other words to be
|
|
||||||
// found in the name/title/description
|
|
||||||
if (otherterms.length > 0) {
|
|
||||||
var haystack = (prefix + ' ' + name + ' ' +
|
|
||||||
objname + ' ' + title).toLowerCase();
|
|
||||||
var allfound = true;
|
|
||||||
for (i = 0; i < otherterms.length; i++) {
|
|
||||||
if (haystack.indexOf(otherterms[i]) == -1) {
|
|
||||||
allfound = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!allfound) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var descr = objname + _(', in ') + title;
|
|
||||||
|
|
||||||
var anchor = match[3];
|
|
||||||
if (anchor === '')
|
|
||||||
anchor = fullname;
|
|
||||||
else if (anchor == '-')
|
|
||||||
anchor = objnames[match[1]][1] + '-' + fullname;
|
|
||||||
// add custom score for some objects according to scorer
|
|
||||||
if (Scorer.objPrio.hasOwnProperty(match[2])) {
|
|
||||||
score += Scorer.objPrio[match[2]];
|
|
||||||
} else {
|
|
||||||
score += Scorer.objPrioDefault;
|
|
||||||
}
|
|
||||||
results.push([filenames[match[0]], fullname, '#'+anchor, descr, score]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* search for full-text terms in the index
|
|
||||||
*/
|
|
||||||
performTermsSearch : function(searchterms, excluded, terms, score) {
|
|
||||||
var filenames = this._index.filenames;
|
|
||||||
var titles = this._index.titles;
|
|
||||||
|
|
||||||
var i, j, file, files;
|
|
||||||
var fileMap = {};
|
|
||||||
var results = [];
|
|
||||||
|
|
||||||
// perform the search on the required terms
|
|
||||||
for (i = 0; i < searchterms.length; i++) {
|
|
||||||
var word = searchterms[i];
|
|
||||||
// no match but word was a required one
|
|
||||||
if ((files = terms[word]) === undefined)
|
|
||||||
break;
|
|
||||||
if (files.length === undefined) {
|
|
||||||
files = [files];
|
|
||||||
}
|
|
||||||
// create the mapping
|
|
||||||
for (j = 0; j < files.length; j++) {
|
|
||||||
file = files[j];
|
|
||||||
if (file in fileMap)
|
|
||||||
fileMap[file].push(word);
|
|
||||||
else
|
|
||||||
fileMap[file] = [word];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// now check if the files don't contain excluded terms
|
|
||||||
for (file in fileMap) {
|
|
||||||
var valid = true;
|
|
||||||
|
|
||||||
// check if all requirements are matched
|
|
||||||
if (fileMap[file].length != searchterms.length)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// ensure that none of the excluded terms is in the search result
|
|
||||||
for (i = 0; i < excluded.length; i++) {
|
|
||||||
if (terms[excluded[i]] == file ||
|
|
||||||
$u.contains(terms[excluded[i]] || [], file)) {
|
|
||||||
valid = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we have still a valid result we can add it to the result list
|
|
||||||
if (valid) {
|
|
||||||
results.push([filenames[file], titles[file], '', null, score]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* helper function to return a node containing the
|
|
||||||
* search summary for a given text. keywords is a list
|
|
||||||
* of stemmed words, hlwords is the list of normal, unstemmed
|
|
||||||
* words. the first one is used to find the occurance, the
|
|
||||||
* latter for highlighting it.
|
|
||||||
*/
|
|
||||||
makeSearchSummary : function(text, keywords, hlwords) {
|
|
||||||
var textLower = text.toLowerCase();
|
|
||||||
var start = 0;
|
|
||||||
$.each(keywords, function() {
|
|
||||||
var i = textLower.indexOf(this.toLowerCase());
|
|
||||||
if (i > -1)
|
|
||||||
start = i;
|
|
||||||
});
|
|
||||||
start = Math.max(start - 120, 0);
|
|
||||||
var excerpt = ((start > 0) ? '...' : '') +
|
|
||||||
$.trim(text.substr(start, 240)) +
|
|
||||||
((start + 240 - text.length) ? '...' : '');
|
|
||||||
var rv = $('<div class="context"></div>').text(excerpt);
|
|
||||||
$.each(hlwords, function() {
|
|
||||||
rv = rv.highlightText(this, 'highlighted');
|
|
||||||
});
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
Search.init();
|
|
||||||
});
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
/*
|
|
||||||
* sidebar.js
|
|
||||||
* ~~~~~~~~~~
|
|
||||||
*
|
|
||||||
* This script makes the Sphinx sidebar collapsible.
|
|
||||||
*
|
|
||||||
* .sphinxsidebar contains .sphinxsidebarwrapper. This script adds
|
|
||||||
* in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton
|
|
||||||
* used to collapse and expand the sidebar.
|
|
||||||
*
|
|
||||||
* When the sidebar is collapsed the .sphinxsidebarwrapper is hidden
|
|
||||||
* and the width of the sidebar and the margin-left of the document
|
|
||||||
* are decreased. When the sidebar is expanded the opposite happens.
|
|
||||||
* This script saves a per-browser/per-session cookie used to
|
|
||||||
* remember the position of the sidebar among the pages.
|
|
||||||
* Once the browser is closed the cookie is deleted and the position
|
|
||||||
* reset to the default (expanded).
|
|
||||||
*
|
|
||||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
|
||||||
* :license: BSD, see LICENSE for details.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
$(function() {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// global elements used by the functions.
|
|
||||||
// the 'sidebarbutton' element is defined as global after its
|
|
||||||
// creation, in the add_sidebar_button function
|
|
||||||
var bodywrapper = $('.bodywrapper');
|
|
||||||
var sidebar = $('.sphinxsidebar');
|
|
||||||
var sidebarwrapper = $('.sphinxsidebarwrapper');
|
|
||||||
|
|
||||||
// for some reason, the document has no sidebar; do not run into errors
|
|
||||||
if (!sidebar.length) return;
|
|
||||||
|
|
||||||
// original margin-left of the bodywrapper and width of the sidebar
|
|
||||||
// with the sidebar expanded
|
|
||||||
var bw_margin_expanded = bodywrapper.css('margin-left');
|
|
||||||
var ssb_width_expanded = sidebar.width();
|
|
||||||
|
|
||||||
// margin-left of the bodywrapper and width of the sidebar
|
|
||||||
// with the sidebar collapsed
|
|
||||||
var bw_margin_collapsed = '.8em';
|
|
||||||
var ssb_width_collapsed = '.8em';
|
|
||||||
|
|
||||||
// colors used by the current theme
|
|
||||||
var dark_color = $('.related').css('background-color');
|
|
||||||
var light_color = $('.document').css('background-color');
|
|
||||||
|
|
||||||
function sidebar_is_collapsed() {
|
|
||||||
return sidebarwrapper.is(':not(:visible)');
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggle_sidebar() {
|
|
||||||
if (sidebar_is_collapsed())
|
|
||||||
expand_sidebar();
|
|
||||||
else
|
|
||||||
collapse_sidebar();
|
|
||||||
}
|
|
||||||
|
|
||||||
function collapse_sidebar() {
|
|
||||||
sidebarwrapper.hide();
|
|
||||||
sidebar.css('width', ssb_width_collapsed);
|
|
||||||
bodywrapper.css('margin-left', bw_margin_collapsed);
|
|
||||||
sidebarbutton.css({
|
|
||||||
'margin-left': '0',
|
|
||||||
'height': bodywrapper.height()
|
|
||||||
});
|
|
||||||
sidebarbutton.find('span').text('»');
|
|
||||||
sidebarbutton.attr('title', _('Expand sidebar'));
|
|
||||||
document.cookie = 'sidebar=collapsed';
|
|
||||||
}
|
|
||||||
|
|
||||||
function expand_sidebar() {
|
|
||||||
bodywrapper.css('margin-left', bw_margin_expanded);
|
|
||||||
sidebar.css('width', ssb_width_expanded);
|
|
||||||
sidebarwrapper.show();
|
|
||||||
sidebarbutton.css({
|
|
||||||
'margin-left': ssb_width_expanded-12,
|
|
||||||
'height': bodywrapper.height()
|
|
||||||
});
|
|
||||||
sidebarbutton.find('span').text('«');
|
|
||||||
sidebarbutton.attr('title', _('Collapse sidebar'));
|
|
||||||
document.cookie = 'sidebar=expanded';
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_sidebar_button() {
|
|
||||||
sidebarwrapper.css({
|
|
||||||
'float': 'left',
|
|
||||||
'margin-right': '0',
|
|
||||||
'width': ssb_width_expanded - 28
|
|
||||||
});
|
|
||||||
// create the button
|
|
||||||
sidebar.append(
|
|
||||||
'<div id="sidebarbutton"><span>«</span></div>'
|
|
||||||
);
|
|
||||||
var sidebarbutton = $('#sidebarbutton');
|
|
||||||
light_color = sidebarbutton.css('background-color');
|
|
||||||
// find the height of the viewport to center the '<<' in the page
|
|
||||||
var viewport_height;
|
|
||||||
if (window.innerHeight)
|
|
||||||
viewport_height = window.innerHeight;
|
|
||||||
else
|
|
||||||
viewport_height = $(window).height();
|
|
||||||
sidebarbutton.find('span').css({
|
|
||||||
'display': 'block',
|
|
||||||
'margin-top': (viewport_height - sidebar.position().top - 20) / 2
|
|
||||||
});
|
|
||||||
|
|
||||||
sidebarbutton.click(toggle_sidebar);
|
|
||||||
sidebarbutton.attr('title', _('Collapse sidebar'));
|
|
||||||
sidebarbutton.css({
|
|
||||||
'color': '#FFFFFF',
|
|
||||||
'border-left': '1px solid ' + dark_color,
|
|
||||||
'font-size': '1.2em',
|
|
||||||
'cursor': 'pointer',
|
|
||||||
'height': bodywrapper.height(),
|
|
||||||
'padding-top': '1px',
|
|
||||||
'margin-left': ssb_width_expanded - 12
|
|
||||||
});
|
|
||||||
|
|
||||||
sidebarbutton.hover(
|
|
||||||
function () {
|
|
||||||
$(this).css('background-color', dark_color);
|
|
||||||
},
|
|
||||||
function () {
|
|
||||||
$(this).css('background-color', light_color);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_position_from_cookie() {
|
|
||||||
if (!document.cookie)
|
|
||||||
return;
|
|
||||||
var items = document.cookie.split(';');
|
|
||||||
for(var k=0; k<items.length; k++) {
|
|
||||||
var key_val = items[k].split('=');
|
|
||||||
var key = key_val[0].replace(/ /, ""); // strip leading spaces
|
|
||||||
if (key == 'sidebar') {
|
|
||||||
var value = key_val[1];
|
|
||||||
if ((value == 'collapsed') && (!sidebar_is_collapsed()))
|
|
||||||
collapse_sidebar();
|
|
||||||
else if ((value == 'expanded') && (sidebar_is_collapsed()))
|
|
||||||
expand_sidebar();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
add_sidebar_button();
|
|
||||||
var sidebarbutton = $('#sidebarbutton');
|
|
||||||
set_position_from_cookie();
|
|
||||||
});
|
|
||||||
|
Before Width: | Height: | Size: 372 B |
@@ -1,808 +0,0 @@
|
|||||||
/*
|
|
||||||
* websupport.js
|
|
||||||
* ~~~~~~~~~~~~~
|
|
||||||
*
|
|
||||||
* sphinx.websupport utilties for all documentation.
|
|
||||||
*
|
|
||||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
|
||||||
* :license: BSD, see LICENSE for details.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function($) {
|
|
||||||
$.fn.autogrow = function() {
|
|
||||||
return this.each(function() {
|
|
||||||
var textarea = this;
|
|
||||||
|
|
||||||
$.fn.autogrow.resize(textarea);
|
|
||||||
|
|
||||||
$(textarea)
|
|
||||||
.focus(function() {
|
|
||||||
textarea.interval = setInterval(function() {
|
|
||||||
$.fn.autogrow.resize(textarea);
|
|
||||||
}, 500);
|
|
||||||
})
|
|
||||||
.blur(function() {
|
|
||||||
clearInterval(textarea.interval);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.autogrow.resize = function(textarea) {
|
|
||||||
var lineHeight = parseInt($(textarea).css('line-height'), 10);
|
|
||||||
var lines = textarea.value.split('\n');
|
|
||||||
var columns = textarea.cols;
|
|
||||||
var lineCount = 0;
|
|
||||||
$.each(lines, function() {
|
|
||||||
lineCount += Math.ceil(this.length / columns) || 1;
|
|
||||||
});
|
|
||||||
var height = lineHeight * (lineCount + 1);
|
|
||||||
$(textarea).css('height', height);
|
|
||||||
};
|
|
||||||
})(jQuery);
|
|
||||||
|
|
||||||
(function($) {
|
|
||||||
var comp, by;
|
|
||||||
|
|
||||||
function init() {
|
|
||||||
initEvents();
|
|
||||||
initComparator();
|
|
||||||
}
|
|
||||||
|
|
||||||
function initEvents() {
|
|
||||||
$('a.comment-close').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
hide($(this).attr('id').substring(2));
|
|
||||||
});
|
|
||||||
$('a.vote').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
handleVote($(this));
|
|
||||||
});
|
|
||||||
$('a.reply').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
openReply($(this).attr('id').substring(2));
|
|
||||||
});
|
|
||||||
$('a.close-reply').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
closeReply($(this).attr('id').substring(2));
|
|
||||||
});
|
|
||||||
$('a.sort-option').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
handleReSort($(this));
|
|
||||||
});
|
|
||||||
$('a.show-proposal').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
showProposal($(this).attr('id').substring(2));
|
|
||||||
});
|
|
||||||
$('a.hide-proposal').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
hideProposal($(this).attr('id').substring(2));
|
|
||||||
});
|
|
||||||
$('a.show-propose-change').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
showProposeChange($(this).attr('id').substring(2));
|
|
||||||
});
|
|
||||||
$('a.hide-propose-change').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
hideProposeChange($(this).attr('id').substring(2));
|
|
||||||
});
|
|
||||||
$('a.accept-comment').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
acceptComment($(this).attr('id').substring(2));
|
|
||||||
});
|
|
||||||
$('a.delete-comment').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
deleteComment($(this).attr('id').substring(2));
|
|
||||||
});
|
|
||||||
$('a.comment-markup').live("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
toggleCommentMarkupBox($(this).attr('id').substring(2));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set comp, which is a comparator function used for sorting and
|
|
||||||
* inserting comments into the list.
|
|
||||||
*/
|
|
||||||
function setComparator() {
|
|
||||||
// If the first three letters are "asc", sort in ascending order
|
|
||||||
// and remove the prefix.
|
|
||||||
if (by.substring(0,3) == 'asc') {
|
|
||||||
var i = by.substring(3);
|
|
||||||
comp = function(a, b) { return a[i] - b[i]; };
|
|
||||||
} else {
|
|
||||||
// Otherwise sort in descending order.
|
|
||||||
comp = function(a, b) { return b[by] - a[by]; };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset link styles and format the selected sort option.
|
|
||||||
$('a.sel').attr('href', '#').removeClass('sel');
|
|
||||||
$('a.by' + by).removeAttr('href').addClass('sel');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a comp function. If the user has preferences stored in
|
|
||||||
* the sortBy cookie, use those, otherwise use the default.
|
|
||||||
*/
|
|
||||||
function initComparator() {
|
|
||||||
by = 'rating'; // Default to sort by rating.
|
|
||||||
// If the sortBy cookie is set, use that instead.
|
|
||||||
if (document.cookie.length > 0) {
|
|
||||||
var start = document.cookie.indexOf('sortBy=');
|
|
||||||
if (start != -1) {
|
|
||||||
start = start + 7;
|
|
||||||
var end = document.cookie.indexOf(";", start);
|
|
||||||
if (end == -1) {
|
|
||||||
end = document.cookie.length;
|
|
||||||
by = unescape(document.cookie.substring(start, end));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setComparator();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a comment div.
|
|
||||||
*/
|
|
||||||
function show(id) {
|
|
||||||
$('#ao' + id).hide();
|
|
||||||
$('#ah' + id).show();
|
|
||||||
var context = $.extend({id: id}, opts);
|
|
||||||
var popup = $(renderTemplate(popupTemplate, context)).hide();
|
|
||||||
popup.find('textarea[name="proposal"]').hide();
|
|
||||||
popup.find('a.by' + by).addClass('sel');
|
|
||||||
var form = popup.find('#cf' + id);
|
|
||||||
form.submit(function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
addComment(form);
|
|
||||||
});
|
|
||||||
$('#s' + id).after(popup);
|
|
||||||
popup.slideDown('fast', function() {
|
|
||||||
getComments(id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hide a comment div.
|
|
||||||
*/
|
|
||||||
function hide(id) {
|
|
||||||
$('#ah' + id).hide();
|
|
||||||
$('#ao' + id).show();
|
|
||||||
var div = $('#sc' + id);
|
|
||||||
div.slideUp('fast', function() {
|
|
||||||
div.remove();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform an ajax request to get comments for a node
|
|
||||||
* and insert the comments into the comments tree.
|
|
||||||
*/
|
|
||||||
function getComments(id) {
|
|
||||||
$.ajax({
|
|
||||||
type: 'GET',
|
|
||||||
url: opts.getCommentsURL,
|
|
||||||
data: {node: id},
|
|
||||||
success: function(data, textStatus, request) {
|
|
||||||
var ul = $('#cl' + id);
|
|
||||||
var speed = 100;
|
|
||||||
$('#cf' + id)
|
|
||||||
.find('textarea[name="proposal"]')
|
|
||||||
.data('source', data.source);
|
|
||||||
|
|
||||||
if (data.comments.length === 0) {
|
|
||||||
ul.html('<li>No comments yet.</li>');
|
|
||||||
ul.data('empty', true);
|
|
||||||
} else {
|
|
||||||
// If there are comments, sort them and put them in the list.
|
|
||||||
var comments = sortComments(data.comments);
|
|
||||||
speed = data.comments.length * 100;
|
|
||||||
appendComments(comments, ul);
|
|
||||||
ul.data('empty', false);
|
|
||||||
}
|
|
||||||
$('#cn' + id).slideUp(speed + 200);
|
|
||||||
ul.slideDown(speed);
|
|
||||||
},
|
|
||||||
error: function(request, textStatus, error) {
|
|
||||||
showError('Oops, there was a problem retrieving the comments.');
|
|
||||||
},
|
|
||||||
dataType: 'json'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a comment via ajax and insert the comment into the comment tree.
|
|
||||||
*/
|
|
||||||
function addComment(form) {
|
|
||||||
var node_id = form.find('input[name="node"]').val();
|
|
||||||
var parent_id = form.find('input[name="parent"]').val();
|
|
||||||
var text = form.find('textarea[name="comment"]').val();
|
|
||||||
var proposal = form.find('textarea[name="proposal"]').val();
|
|
||||||
|
|
||||||
if (text == '') {
|
|
||||||
showError('Please enter a comment.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable the form that is being submitted.
|
|
||||||
form.find('textarea,input').attr('disabled', 'disabled');
|
|
||||||
|
|
||||||
// Send the comment to the server.
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: opts.addCommentURL,
|
|
||||||
dataType: 'json',
|
|
||||||
data: {
|
|
||||||
node: node_id,
|
|
||||||
parent: parent_id,
|
|
||||||
text: text,
|
|
||||||
proposal: proposal
|
|
||||||
},
|
|
||||||
success: function(data, textStatus, error) {
|
|
||||||
// Reset the form.
|
|
||||||
if (node_id) {
|
|
||||||
hideProposeChange(node_id);
|
|
||||||
}
|
|
||||||
form.find('textarea')
|
|
||||||
.val('')
|
|
||||||
.add(form.find('input'))
|
|
||||||
.removeAttr('disabled');
|
|
||||||
var ul = $('#cl' + (node_id || parent_id));
|
|
||||||
if (ul.data('empty')) {
|
|
||||||
$(ul).empty();
|
|
||||||
ul.data('empty', false);
|
|
||||||
}
|
|
||||||
insertComment(data.comment);
|
|
||||||
var ao = $('#ao' + node_id);
|
|
||||||
ao.find('img').attr({'src': opts.commentBrightImage});
|
|
||||||
if (node_id) {
|
|
||||||
// if this was a "root" comment, remove the commenting box
|
|
||||||
// (the user can get it back by reopening the comment popup)
|
|
||||||
$('#ca' + node_id).slideUp();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(request, textStatus, error) {
|
|
||||||
form.find('textarea,input').removeAttr('disabled');
|
|
||||||
showError('Oops, there was a problem adding the comment.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively append comments to the main comment list and children
|
|
||||||
* lists, creating the comment tree.
|
|
||||||
*/
|
|
||||||
function appendComments(comments, ul) {
|
|
||||||
$.each(comments, function() {
|
|
||||||
var div = createCommentDiv(this);
|
|
||||||
ul.append($(document.createElement('li')).html(div));
|
|
||||||
appendComments(this.children, div.find('ul.comment-children'));
|
|
||||||
// To avoid stagnating data, don't store the comments children in data.
|
|
||||||
this.children = null;
|
|
||||||
div.data('comment', this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* After adding a new comment, it must be inserted in the correct
|
|
||||||
* location in the comment tree.
|
|
||||||
*/
|
|
||||||
function insertComment(comment) {
|
|
||||||
var div = createCommentDiv(comment);
|
|
||||||
|
|
||||||
// To avoid stagnating data, don't store the comments children in data.
|
|
||||||
comment.children = null;
|
|
||||||
div.data('comment', comment);
|
|
||||||
|
|
||||||
var ul = $('#cl' + (comment.node || comment.parent));
|
|
||||||
var siblings = getChildren(ul);
|
|
||||||
|
|
||||||
var li = $(document.createElement('li'));
|
|
||||||
li.hide();
|
|
||||||
|
|
||||||
// Determine where in the parents children list to insert this comment.
|
|
||||||
for(i=0; i < siblings.length; i++) {
|
|
||||||
if (comp(comment, siblings[i]) <= 0) {
|
|
||||||
$('#cd' + siblings[i].id)
|
|
||||||
.parent()
|
|
||||||
.before(li.html(div));
|
|
||||||
li.slideDown('fast');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we get here, this comment rates lower than all the others,
|
|
||||||
// or it is the only comment in the list.
|
|
||||||
ul.append(li.html(div));
|
|
||||||
li.slideDown('fast');
|
|
||||||
}
|
|
||||||
|
|
||||||
function acceptComment(id) {
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: opts.acceptCommentURL,
|
|
||||||
data: {id: id},
|
|
||||||
success: function(data, textStatus, request) {
|
|
||||||
$('#cm' + id).fadeOut('fast');
|
|
||||||
$('#cd' + id).removeClass('moderate');
|
|
||||||
},
|
|
||||||
error: function(request, textStatus, error) {
|
|
||||||
showError('Oops, there was a problem accepting the comment.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteComment(id) {
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: opts.deleteCommentURL,
|
|
||||||
data: {id: id},
|
|
||||||
success: function(data, textStatus, request) {
|
|
||||||
var div = $('#cd' + id);
|
|
||||||
if (data == 'delete') {
|
|
||||||
// Moderator mode: remove the comment and all children immediately
|
|
||||||
div.slideUp('fast', function() {
|
|
||||||
div.remove();
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// User mode: only mark the comment as deleted
|
|
||||||
div
|
|
||||||
.find('span.user-id:first')
|
|
||||||
.text('[deleted]').end()
|
|
||||||
.find('div.comment-text:first')
|
|
||||||
.text('[deleted]').end()
|
|
||||||
.find('#cm' + id + ', #dc' + id + ', #ac' + id + ', #rc' + id +
|
|
||||||
', #sp' + id + ', #hp' + id + ', #cr' + id + ', #rl' + id)
|
|
||||||
.remove();
|
|
||||||
var comment = div.data('comment');
|
|
||||||
comment.username = '[deleted]';
|
|
||||||
comment.text = '[deleted]';
|
|
||||||
div.data('comment', comment);
|
|
||||||
},
|
|
||||||
error: function(request, textStatus, error) {
|
|
||||||
showError('Oops, there was a problem deleting the comment.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function showProposal(id) {
|
|
||||||
$('#sp' + id).hide();
|
|
||||||
$('#hp' + id).show();
|
|
||||||
$('#pr' + id).slideDown('fast');
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideProposal(id) {
|
|
||||||
$('#hp' + id).hide();
|
|
||||||
$('#sp' + id).show();
|
|
||||||
$('#pr' + id).slideUp('fast');
|
|
||||||
}
|
|
||||||
|
|
||||||
function showProposeChange(id) {
|
|
||||||
$('#pc' + id).hide();
|
|
||||||
$('#hc' + id).show();
|
|
||||||
var textarea = $('#pt' + id);
|
|
||||||
textarea.val(textarea.data('source'));
|
|
||||||
$.fn.autogrow.resize(textarea[0]);
|
|
||||||
textarea.slideDown('fast');
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideProposeChange(id) {
|
|
||||||
$('#hc' + id).hide();
|
|
||||||
$('#pc' + id).show();
|
|
||||||
var textarea = $('#pt' + id);
|
|
||||||
textarea.val('').removeAttr('disabled');
|
|
||||||
textarea.slideUp('fast');
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleCommentMarkupBox(id) {
|
|
||||||
$('#mb' + id).toggle();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Handle when the user clicks on a sort by link. */
|
|
||||||
function handleReSort(link) {
|
|
||||||
var classes = link.attr('class').split(/\s+/);
|
|
||||||
for (var i=0; i<classes.length; i++) {
|
|
||||||
if (classes[i] != 'sort-option') {
|
|
||||||
by = classes[i].substring(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setComparator();
|
|
||||||
// Save/update the sortBy cookie.
|
|
||||||
var expiration = new Date();
|
|
||||||
expiration.setDate(expiration.getDate() + 365);
|
|
||||||
document.cookie= 'sortBy=' + escape(by) +
|
|
||||||
';expires=' + expiration.toUTCString();
|
|
||||||
$('ul.comment-ul').each(function(index, ul) {
|
|
||||||
var comments = getChildren($(ul), true);
|
|
||||||
comments = sortComments(comments);
|
|
||||||
appendComments(comments, $(ul).empty());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to process a vote when a user clicks an arrow.
|
|
||||||
*/
|
|
||||||
function handleVote(link) {
|
|
||||||
if (!opts.voting) {
|
|
||||||
showError("You'll need to login to vote.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var id = link.attr('id');
|
|
||||||
if (!id) {
|
|
||||||
// Didn't click on one of the voting arrows.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// If it is an unvote, the new vote value is 0,
|
|
||||||
// Otherwise it's 1 for an upvote, or -1 for a downvote.
|
|
||||||
var value = 0;
|
|
||||||
if (id.charAt(1) != 'u') {
|
|
||||||
value = id.charAt(0) == 'u' ? 1 : -1;
|
|
||||||
}
|
|
||||||
// The data to be sent to the server.
|
|
||||||
var d = {
|
|
||||||
comment_id: id.substring(2),
|
|
||||||
value: value
|
|
||||||
};
|
|
||||||
|
|
||||||
// Swap the vote and unvote links.
|
|
||||||
link.hide();
|
|
||||||
$('#' + id.charAt(0) + (id.charAt(1) == 'u' ? 'v' : 'u') + d.comment_id)
|
|
||||||
.show();
|
|
||||||
|
|
||||||
// The div the comment is displayed in.
|
|
||||||
var div = $('div#cd' + d.comment_id);
|
|
||||||
var data = div.data('comment');
|
|
||||||
|
|
||||||
// If this is not an unvote, and the other vote arrow has
|
|
||||||
// already been pressed, unpress it.
|
|
||||||
if ((d.value !== 0) && (data.vote === d.value * -1)) {
|
|
||||||
$('#' + (d.value == 1 ? 'd' : 'u') + 'u' + d.comment_id).hide();
|
|
||||||
$('#' + (d.value == 1 ? 'd' : 'u') + 'v' + d.comment_id).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the comments rating in the local data.
|
|
||||||
data.rating += (data.vote === 0) ? d.value : (d.value - data.vote);
|
|
||||||
data.vote = d.value;
|
|
||||||
div.data('comment', data);
|
|
||||||
|
|
||||||
// Change the rating text.
|
|
||||||
div.find('.rating:first')
|
|
||||||
.text(data.rating + ' point' + (data.rating == 1 ? '' : 's'));
|
|
||||||
|
|
||||||
// Send the vote information to the server.
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: opts.processVoteURL,
|
|
||||||
data: d,
|
|
||||||
error: function(request, textStatus, error) {
|
|
||||||
showError('Oops, there was a problem casting that vote.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Open a reply form used to reply to an existing comment.
|
|
||||||
*/
|
|
||||||
function openReply(id) {
|
|
||||||
// Swap out the reply link for the hide link
|
|
||||||
$('#rl' + id).hide();
|
|
||||||
$('#cr' + id).show();
|
|
||||||
|
|
||||||
// Add the reply li to the children ul.
|
|
||||||
var div = $(renderTemplate(replyTemplate, {id: id})).hide();
|
|
||||||
$('#cl' + id)
|
|
||||||
.prepend(div)
|
|
||||||
// Setup the submit handler for the reply form.
|
|
||||||
.find('#rf' + id)
|
|
||||||
.submit(function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
addComment($('#rf' + id));
|
|
||||||
closeReply(id);
|
|
||||||
})
|
|
||||||
.find('input[type=button]')
|
|
||||||
.click(function() {
|
|
||||||
closeReply(id);
|
|
||||||
});
|
|
||||||
div.slideDown('fast', function() {
|
|
||||||
$('#rf' + id).find('textarea').focus();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close the reply form opened with openReply.
|
|
||||||
*/
|
|
||||||
function closeReply(id) {
|
|
||||||
// Remove the reply div from the DOM.
|
|
||||||
$('#rd' + id).slideUp('fast', function() {
|
|
||||||
$(this).remove();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Swap out the hide link for the reply link
|
|
||||||
$('#cr' + id).hide();
|
|
||||||
$('#rl' + id).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively sort a tree of comments using the comp comparator.
|
|
||||||
*/
|
|
||||||
function sortComments(comments) {
|
|
||||||
comments.sort(comp);
|
|
||||||
$.each(comments, function() {
|
|
||||||
this.children = sortComments(this.children);
|
|
||||||
});
|
|
||||||
return comments;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the children comments from a ul. If recursive is true,
|
|
||||||
* recursively include childrens' children.
|
|
||||||
*/
|
|
||||||
function getChildren(ul, recursive) {
|
|
||||||
var children = [];
|
|
||||||
ul.children().children("[id^='cd']")
|
|
||||||
.each(function() {
|
|
||||||
var comment = $(this).data('comment');
|
|
||||||
if (recursive)
|
|
||||||
comment.children = getChildren($(this).find('#cl' + comment.id), true);
|
|
||||||
children.push(comment);
|
|
||||||
});
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create a div to display a comment in. */
|
|
||||||
function createCommentDiv(comment) {
|
|
||||||
if (!comment.displayed && !opts.moderator) {
|
|
||||||
return $('<div class="moderate">Thank you! Your comment will show up '
|
|
||||||
+ 'once it is has been approved by a moderator.</div>');
|
|
||||||
}
|
|
||||||
// Prettify the comment rating.
|
|
||||||
comment.pretty_rating = comment.rating + ' point' +
|
|
||||||
(comment.rating == 1 ? '' : 's');
|
|
||||||
// Make a class (for displaying not yet moderated comments differently)
|
|
||||||
comment.css_class = comment.displayed ? '' : ' moderate';
|
|
||||||
// Create a div for this comment.
|
|
||||||
var context = $.extend({}, opts, comment);
|
|
||||||
var div = $(renderTemplate(commentTemplate, context));
|
|
||||||
|
|
||||||
// If the user has voted on this comment, highlight the correct arrow.
|
|
||||||
if (comment.vote) {
|
|
||||||
var direction = (comment.vote == 1) ? 'u' : 'd';
|
|
||||||
div.find('#' + direction + 'v' + comment.id).hide();
|
|
||||||
div.find('#' + direction + 'u' + comment.id).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.moderator || comment.text != '[deleted]') {
|
|
||||||
div.find('a.reply').show();
|
|
||||||
if (comment.proposal_diff)
|
|
||||||
div.find('#sp' + comment.id).show();
|
|
||||||
if (opts.moderator && !comment.displayed)
|
|
||||||
div.find('#cm' + comment.id).show();
|
|
||||||
if (opts.moderator || (opts.username == comment.username))
|
|
||||||
div.find('#dc' + comment.id).show();
|
|
||||||
}
|
|
||||||
return div;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple template renderer. Placeholders such as <%id%> are replaced
|
|
||||||
* by context['id'] with items being escaped. Placeholders such as <#id#>
|
|
||||||
* are not escaped.
|
|
||||||
*/
|
|
||||||
function renderTemplate(template, context) {
|
|
||||||
var esc = $(document.createElement('div'));
|
|
||||||
|
|
||||||
function handle(ph, escape) {
|
|
||||||
var cur = context;
|
|
||||||
$.each(ph.split('.'), function() {
|
|
||||||
cur = cur[this];
|
|
||||||
});
|
|
||||||
return escape ? esc.text(cur || "").html() : cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
return template.replace(/<([%#])([\w\.]*)\1>/g, function() {
|
|
||||||
return handle(arguments[2], arguments[1] == '%' ? true : false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Flash an error message briefly. */
|
|
||||||
function showError(message) {
|
|
||||||
$(document.createElement('div')).attr({'class': 'popup-error'})
|
|
||||||
.append($(document.createElement('div'))
|
|
||||||
.attr({'class': 'error-message'}).text(message))
|
|
||||||
.appendTo('body')
|
|
||||||
.fadeIn("slow")
|
|
||||||
.delay(2000)
|
|
||||||
.fadeOut("slow");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Add a link the user uses to open the comments popup. */
|
|
||||||
$.fn.comment = function() {
|
|
||||||
return this.each(function() {
|
|
||||||
var id = $(this).attr('id').substring(1);
|
|
||||||
var count = COMMENT_METADATA[id];
|
|
||||||
var title = count + ' comment' + (count == 1 ? '' : 's');
|
|
||||||
var image = count > 0 ? opts.commentBrightImage : opts.commentImage;
|
|
||||||
var addcls = count == 0 ? ' nocomment' : '';
|
|
||||||
$(this)
|
|
||||||
.append(
|
|
||||||
$(document.createElement('a')).attr({
|
|
||||||
href: '#',
|
|
||||||
'class': 'sphinx-comment-open' + addcls,
|
|
||||||
id: 'ao' + id
|
|
||||||
})
|
|
||||||
.append($(document.createElement('img')).attr({
|
|
||||||
src: image,
|
|
||||||
alt: 'comment',
|
|
||||||
title: title
|
|
||||||
}))
|
|
||||||
.click(function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
show($(this).attr('id').substring(2));
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.append(
|
|
||||||
$(document.createElement('a')).attr({
|
|
||||||
href: '#',
|
|
||||||
'class': 'sphinx-comment-close hidden',
|
|
||||||
id: 'ah' + id
|
|
||||||
})
|
|
||||||
.append($(document.createElement('img')).attr({
|
|
||||||
src: opts.closeCommentImage,
|
|
||||||
alt: 'close',
|
|
||||||
title: 'close'
|
|
||||||
}))
|
|
||||||
.click(function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
hide($(this).attr('id').substring(2));
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var opts = {
|
|
||||||
processVoteURL: '/_process_vote',
|
|
||||||
addCommentURL: '/_add_comment',
|
|
||||||
getCommentsURL: '/_get_comments',
|
|
||||||
acceptCommentURL: '/_accept_comment',
|
|
||||||
deleteCommentURL: '/_delete_comment',
|
|
||||||
commentImage: '/static/_static/comment.png',
|
|
||||||
closeCommentImage: '/static/_static/comment-close.png',
|
|
||||||
loadingImage: '/static/_static/ajax-loader.gif',
|
|
||||||
commentBrightImage: '/static/_static/comment-bright.png',
|
|
||||||
upArrow: '/static/_static/up.png',
|
|
||||||
downArrow: '/static/_static/down.png',
|
|
||||||
upArrowPressed: '/static/_static/up-pressed.png',
|
|
||||||
downArrowPressed: '/static/_static/down-pressed.png',
|
|
||||||
voting: false,
|
|
||||||
moderator: false
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof COMMENT_OPTIONS != "undefined") {
|
|
||||||
opts = jQuery.extend(opts, COMMENT_OPTIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
var popupTemplate = '\
|
|
||||||
<div class="sphinx-comments" id="sc<%id%>">\
|
|
||||||
<p class="sort-options">\
|
|
||||||
Sort by:\
|
|
||||||
<a href="#" class="sort-option byrating">best rated</a>\
|
|
||||||
<a href="#" class="sort-option byascage">newest</a>\
|
|
||||||
<a href="#" class="sort-option byage">oldest</a>\
|
|
||||||
</p>\
|
|
||||||
<div class="comment-header">Comments</div>\
|
|
||||||
<div class="comment-loading" id="cn<%id%>">\
|
|
||||||
loading comments... <img src="<%loadingImage%>" alt="" /></div>\
|
|
||||||
<ul id="cl<%id%>" class="comment-ul"></ul>\
|
|
||||||
<div id="ca<%id%>">\
|
|
||||||
<p class="add-a-comment">Add a comment\
|
|
||||||
(<a href="#" class="comment-markup" id="ab<%id%>">markup</a>):</p>\
|
|
||||||
<div class="comment-markup-box" id="mb<%id%>">\
|
|
||||||
reStructured text markup: <i>*emph*</i>, <b>**strong**</b>, \
|
|
||||||
<tt>``code``</tt>, \
|
|
||||||
code blocks: <tt>::</tt> and an indented block after blank line</div>\
|
|
||||||
<form method="post" id="cf<%id%>" class="comment-form" action="">\
|
|
||||||
<textarea name="comment" cols="80"></textarea>\
|
|
||||||
<p class="propose-button">\
|
|
||||||
<a href="#" id="pc<%id%>" class="show-propose-change">\
|
|
||||||
Propose a change ▹\
|
|
||||||
</a>\
|
|
||||||
<a href="#" id="hc<%id%>" class="hide-propose-change">\
|
|
||||||
Propose a change ▿\
|
|
||||||
</a>\
|
|
||||||
</p>\
|
|
||||||
<textarea name="proposal" id="pt<%id%>" cols="80"\
|
|
||||||
spellcheck="false"></textarea>\
|
|
||||||
<input type="submit" value="Add comment" />\
|
|
||||||
<input type="hidden" name="node" value="<%id%>" />\
|
|
||||||
<input type="hidden" name="parent" value="" />\
|
|
||||||
</form>\
|
|
||||||
</div>\
|
|
||||||
</div>';
|
|
||||||
|
|
||||||
var commentTemplate = '\
|
|
||||||
<div id="cd<%id%>" class="sphinx-comment<%css_class%>">\
|
|
||||||
<div class="vote">\
|
|
||||||
<div class="arrow">\
|
|
||||||
<a href="#" id="uv<%id%>" class="vote" title="vote up">\
|
|
||||||
<img src="<%upArrow%>" />\
|
|
||||||
</a>\
|
|
||||||
<a href="#" id="uu<%id%>" class="un vote" title="vote up">\
|
|
||||||
<img src="<%upArrowPressed%>" />\
|
|
||||||
</a>\
|
|
||||||
</div>\
|
|
||||||
<div class="arrow">\
|
|
||||||
<a href="#" id="dv<%id%>" class="vote" title="vote down">\
|
|
||||||
<img src="<%downArrow%>" id="da<%id%>" />\
|
|
||||||
</a>\
|
|
||||||
<a href="#" id="du<%id%>" class="un vote" title="vote down">\
|
|
||||||
<img src="<%downArrowPressed%>" />\
|
|
||||||
</a>\
|
|
||||||
</div>\
|
|
||||||
</div>\
|
|
||||||
<div class="comment-content">\
|
|
||||||
<p class="tagline comment">\
|
|
||||||
<span class="user-id"><%username%></span>\
|
|
||||||
<span class="rating"><%pretty_rating%></span>\
|
|
||||||
<span class="delta"><%time.delta%></span>\
|
|
||||||
</p>\
|
|
||||||
<div class="comment-text comment"><#text#></div>\
|
|
||||||
<p class="comment-opts comment">\
|
|
||||||
<a href="#" class="reply hidden" id="rl<%id%>">reply ▹</a>\
|
|
||||||
<a href="#" class="close-reply" id="cr<%id%>">reply ▿</a>\
|
|
||||||
<a href="#" id="sp<%id%>" class="show-proposal">proposal ▹</a>\
|
|
||||||
<a href="#" id="hp<%id%>" class="hide-proposal">proposal ▿</a>\
|
|
||||||
<a href="#" id="dc<%id%>" class="delete-comment hidden">delete</a>\
|
|
||||||
<span id="cm<%id%>" class="moderation hidden">\
|
|
||||||
<a href="#" id="ac<%id%>" class="accept-comment">accept</a>\
|
|
||||||
</span>\
|
|
||||||
</p>\
|
|
||||||
<pre class="proposal" id="pr<%id%>">\
|
|
||||||
<#proposal_diff#>\
|
|
||||||
</pre>\
|
|
||||||
<ul class="comment-children" id="cl<%id%>"></ul>\
|
|
||||||
</div>\
|
|
||||||
<div class="clearleft"></div>\
|
|
||||||
</div>\
|
|
||||||
</div>';
|
|
||||||
|
|
||||||
var replyTemplate = '\
|
|
||||||
<li>\
|
|
||||||
<div class="reply-div" id="rd<%id%>">\
|
|
||||||
<form id="rf<%id%>">\
|
|
||||||
<textarea name="comment" cols="80"></textarea>\
|
|
||||||
<input type="submit" value="Add reply" />\
|
|
||||||
<input type="button" value="Cancel" />\
|
|
||||||
<input type="hidden" name="parent" value="<%id%>" />\
|
|
||||||
<input type="hidden" name="node" value="" />\
|
|
||||||
</form>\
|
|
||||||
</div>\
|
|
||||||
</li>';
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
init();
|
|
||||||
});
|
|
||||||
})(jQuery);
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
// add comment anchors for all paragraphs that are commentable
|
|
||||||
$('.sphinx-has-comment').comment();
|
|
||||||
|
|
||||||
// highlight search words in search results
|
|
||||||
$("div.context").each(function() {
|
|
||||||
var params = $.getQueryParameters();
|
|
||||||
var terms = (params.q) ? params.q[0].split(/\s+/) : [];
|
|
||||||
var result = $(this);
|
|
||||||
$.each(terms, function() {
|
|
||||||
result.highlightText(this.toLowerCase(), 'highlighted');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// directly open comment window if requested
|
|
||||||
var anchor = document.location.hash;
|
|
||||||
if (anchor.substring(0, 9) == '#comment-') {
|
|
||||||
$('#ao' + anchor.substring(9)).click();
|
|
||||||
document.location.hash = '#s' + anchor.substring(9);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>Index - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: './',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="#" />
|
|
||||||
<link rel="search" title="Search" href="search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="index.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="index.html"><img
|
|
||||||
alt="C++ Boost" src="_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<h1 id="index">Index</h1>
|
|
||||||
|
|
||||||
<div class="genindex-jumpbox">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>Welcome to the documentation of the Boost.Python NumPy extension! - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: './',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="#" />
|
|
||||||
<link rel="next" title="Boost.Python NumPy extension Tutorial" href="tutorial/index.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="#"><img
|
|
||||||
alt="C++ Boost" src="_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="#">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="next" title="Boost.Python NumPy extension Tutorial" href="tutorial/index.html"><img src="_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="welcome-to-the-documentation-of-the-boost-python-numpy-extension">
|
|
||||||
<h1>Welcome to the documentation of the Boost.Python NumPy extension!</h1>
|
|
||||||
<div class="toctree-wrapper compound">
|
|
||||||
<ul>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="tutorial/index.html">Tutorial</a><ul>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="tutorial/simple.html">A simple tutorial on Arrays</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="tutorial/dtype.html">How to use dtypes</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="tutorial/ndarray.html">Creating ndarrays</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="tutorial/ufunc.html">Ufuncs</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="tutorial/fromdata.html">How to access data using raw pointers</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a><ul>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="reference/dtype.html">dtype</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="reference/ndarray.html">ndarray</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="reference/unary_ufunc.html">unary_ufunc</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="reference/binary_ufunc.html">binary_ufunc</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="reference/multi_iter.html">multi_iter</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="next" title="Boost.Python NumPy extension Tutorial" href="tutorial/index.html"><img src="_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,211 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>binary_ufunc - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="up" title="Boost.Python NumPy extension Reference" href="index.html" />
|
|
||||||
<link rel="next" title="multi_iter" href="multi_iter.html" />
|
|
||||||
<link rel="prev" title="unary_ufunc" href="unary_ufunc.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="unary_ufunc" href="unary_ufunc.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="multi_iter" href="multi_iter.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="binary-ufunc">
|
|
||||||
<h1><a class="toc-backref" href="#id1">binary_ufunc</a></h1>
|
|
||||||
<div class="contents topic" id="table-of-contents">
|
|
||||||
<p class="topic-title first">Table of Contents</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li><a class="reference internal" href="#binary-ufunc" id="id1">binary_ufunc</a><ul>
|
|
||||||
<li><a class="reference internal" href="#synopsis" id="id2">synopsis</a></li>
|
|
||||||
<li><a class="reference internal" href="#constructors" id="id3">constructors</a></li>
|
|
||||||
<li><a class="reference internal" href="#accessors" id="id4">accessors</a></li>
|
|
||||||
<li><a class="reference internal" href="#example-s" id="id5">Example(s)</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<p>A <tt class="docutils literal"><span class="pre">binary_ufunc</span></tt> is a struct used as an intermediate step to broadcast two arguments so that a C++ function can be converted to a ufunc like function</p>
|
|
||||||
<blockquote>
|
|
||||||
<div><tt class="docutils literal"><span class="pre"><boost/python/numpy/ufunc.hpp></span></tt> contains the <tt class="docutils literal"><span class="pre">binary_ufunc</span></tt> structure definitions</div></blockquote>
|
|
||||||
<div class="section" id="synopsis">
|
|
||||||
<h2><a class="toc-backref" href="#id2">synopsis</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">boost</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">python</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">numpy</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
|
|
||||||
<span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TArgument1</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">first_argument_type</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TArgument2</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">second_argument_type</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TResult</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">result_type</span><span class="o">></span>
|
|
||||||
|
|
||||||
<span class="k">struct</span> <span class="n">binary_ufunc</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
|
|
||||||
<span class="k">static</span> <span class="n">object</span> <span class="n">call</span><span class="p">(</span><span class="n">TBinaryFunctor</span> <span class="o">&</span> <span class="n">self</span><span class="p">,</span>
|
|
||||||
<span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">input1</span><span class="p">,</span>
|
|
||||||
<span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">input2</span><span class="p">,</span>
|
|
||||||
<span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">output</span><span class="p">);</span>
|
|
||||||
|
|
||||||
<span class="k">static</span> <span class="n">object</span> <span class="nf">make</span><span class="p">();</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="constructors">
|
|
||||||
<h2><a class="toc-backref" href="#id3">constructors</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">struct</span> <span class="n">example_binary_ufunc</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">typedef</span> <span class="n">any_valid</span> <span class="n">first_argument_type</span><span class="p">;</span>
|
|
||||||
<span class="k">typedef</span> <span class="n">any_valid</span> <span class="n">second_argument_type</span><span class="p">;</span>
|
|
||||||
<span class="k">typedef</span> <span class="n">any_valid</span> <span class="n">result_type</span><span class="p">;</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The <tt class="docutils literal"><span class="pre">any_valid</span></tt> type must be defined using typedef as a valid C++ type in order to use the struct methods correctly</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Note:</th><td class="field-body">The struct must be exposed as a Python class, and an instance of the class must be created to use the <tt class="docutils literal"><span class="pre">call</span></tt> method corresponding to the <tt class="docutils literal"><span class="pre">__call__</span></tt> attribute of the Python object</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="accessors">
|
|
||||||
<h2><a class="toc-backref" href="#id4">accessors</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TArgument1</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">first_argument_type</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TArgument2</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">second_argument_type</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TResult</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">result_type</span><span class="o">></span>
|
|
||||||
<span class="k">static</span> <span class="n">object</span> <span class="n">call</span><span class="p">(</span><span class="n">TBinaryFunctor</span> <span class="o">&</span> <span class="n">self</span><span class="p">,</span>
|
|
||||||
<span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">input</span><span class="p">,</span>
|
|
||||||
<span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">output</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <tt class="docutils literal"><span class="pre">TBinaryFunctor</span></tt> and optionally <tt class="docutils literal"><span class="pre">TArgument1</span></tt> and <tt class="docutils literal"><span class="pre">TArgument2</span></tt> for argument type and <tt class="docutils literal"><span class="pre">TResult</span></tt> for result type</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Effects:</th><td class="field-body">Passes a Python object to the underlying C++ functor after broadcasting its arguments</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TArgument1</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">first_argument_type</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TArgument2</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">second_argument_type</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TResult</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">result_type</span><span class="o">></span>
|
|
||||||
<span class="k">static</span> <span class="n">object</span> <span class="n">make</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <tt class="docutils literal"><span class="pre">TBinaryFunctor</span></tt> and optionally <tt class="docutils literal"><span class="pre">TArgument1</span></tt> and <tt class="docutils literal"><span class="pre">TArgument2</span></tt> for argument type and <tt class="docutils literal"><span class="pre">TResult</span></tt> for result type</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A Python function object to call the overloaded () operator in the struct (in typical usage)</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="example-s">
|
|
||||||
<h2><a class="toc-backref" href="#id5">Example(s)</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="k">struct</span> <span class="n">BinarySquare</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">first_argument_type</span><span class="p">;</span>
|
|
||||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">second_argument_type</span><span class="p">;</span>
|
|
||||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">result_type</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="kt">double</span> <span class="nf">operator</span><span class="p">()(</span><span class="kt">double</span> <span class="n">a</span><span class="p">,</span><span class="kt">double</span> <span class="n">b</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="n">b</span><span class="o">*</span><span class="n">b</span><span class="p">)</span> <span class="p">;</span> <span class="p">}</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">ud</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">class_</span><span class="o"><</span><span class="n">BinarySquare</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">shared_ptr</span><span class="o"><</span><span class="n">BinarySquare</span><span class="o">></span> <span class="o">></span><span class="p">(</span><span class="s">"BinarySquare"</span><span class="p">).</span><span class="n">def</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">binary_ufunc</span><span class="o"><</span><span class="n">BinarySquare</span><span class="o">>::</span><span class="n">make</span><span class="p">());</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">inst</span> <span class="o">=</span> <span class="n">ud</span><span class="p">();</span>
|
|
||||||
<span class="n">result_array</span> <span class="o">=</span> <span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="n">demo_array</span><span class="p">,</span><span class="n">demo_array</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of list with binary ufunc is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span> <span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*</span> <span class="o">></span> <span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">result_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span> <span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="unary_ufunc" href="unary_ufunc.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="multi_iter" href="multi_iter.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>dtype - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="up" title="Boost.Python NumPy extension Reference" href="index.html" />
|
|
||||||
<link rel="next" title="ndarray" href="ndarray.html" />
|
|
||||||
<link rel="prev" title="Boost.Python NumPy extension Reference" href="index.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="ndarray" href="ndarray.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="dtype">
|
|
||||||
<h1><a class="toc-backref" href="#id2">dtype</a></h1>
|
|
||||||
<div class="contents topic" id="table-of-contents">
|
|
||||||
<p class="topic-title first">Table of Contents</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li><a class="reference internal" href="#dtype" id="id2">dtype</a><ul>
|
|
||||||
<li><a class="reference internal" href="#synopsis" id="id3">synopsis</a></li>
|
|
||||||
<li><a class="reference internal" href="#constructors" id="id4">constructors</a></li>
|
|
||||||
<li><a class="reference internal" href="#accessors" id="id5">accessors</a></li>
|
|
||||||
<li><a class="reference internal" href="#example-s" id="id6">Example(s)</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<p>A <a class="reference external" href="http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#data-type-objects-dtype">dtype</a> is an object describing the type of the elements of an ndarray</p>
|
|
||||||
<blockquote>
|
|
||||||
<div><tt class="docutils literal"><span class="pre"><boost/python/numpy/dtype.hpp></span></tt> contains the method calls necessary to generate a python object equivalent to a numpy.dtype from builtin C++ objects, as well as to create custom dtypes from user defined types</div></blockquote>
|
|
||||||
<div class="section" id="synopsis">
|
|
||||||
<h2><a class="toc-backref" href="#id3">synopsis</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">boost</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">python</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">numpy</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
|
|
||||||
<span class="k">class</span> <span class="nc">dtype</span> <span class="o">:</span> <span class="k">public</span> <span class="n">object</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">static</span> <span class="n">python</span><span class="o">::</span><span class="n">detail</span><span class="o">::</span><span class="n">new_reference</span> <span class="n">convert</span><span class="p">(</span><span class="n">object</span><span class="o">::</span><span class="n">object_cref</span> <span class="n">arg</span><span class="p">,</span> <span class="kt">bool</span> <span class="n">align</span><span class="p">);</span>
|
|
||||||
<span class="nl">public:</span>
|
|
||||||
|
|
||||||
<span class="c1">// Convert an arbitrary Python object to a data-type descriptor object.</span>
|
|
||||||
<span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span>
|
|
||||||
<span class="k">explicit</span> <span class="n">dtype</span><span class="p">(</span><span class="n">T</span> <span class="n">arg</span><span class="p">,</span> <span class="kt">bool</span> <span class="n">align</span><span class="o">=</span><span class="nb">false</span><span class="p">);</span>
|
|
||||||
|
|
||||||
<span class="c1">// Get the built-in numpy dtype associated with the given scalar template type.</span>
|
|
||||||
<span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span> <span class="k">static</span> <span class="n">dtype</span> <span class="n">get_builtin</span><span class="p">();</span>
|
|
||||||
|
|
||||||
<span class="c1">// Return the size of the data type in bytes.</span>
|
|
||||||
<span class="kt">int</span> <span class="n">get_itemsize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="constructors">
|
|
||||||
<h2><a class="toc-backref" href="#id4">constructors</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span>
|
|
||||||
<span class="k">explicit</span> <span class="n">dtype</span><span class="p">(</span><span class="n">T</span> <span class="n">arg</span><span class="p">,</span> <span class="kt">bool</span> <span class="n">align</span><span class="o">=</span><span class="nb">false</span><span class="p">)</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first"><tt class="docutils literal"><span class="pre">T</span></tt> must be either :</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>a built-in C++ typename convertible to object</li>
|
|
||||||
<li>a valid python object or convertible to object</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Effects:</th><td class="field-body"><p class="first">Constructs an object from the supplied python object / convertible
|
|
||||||
to object / builtin C++ data type</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-odd field"><th class="field-name">Throws:</th><td class="field-body"><p class="first last">Nothing</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span> <span class="k">static</span> <span class="n">dtype</span> <span class="n">get_builtin</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The typename supplied, <tt class="docutils literal"><span class="pre">T</span></tt> must be a builtin C++ type also supported by numpy</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Numpy dtype corresponding to builtin C++ type</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="accessors">
|
|
||||||
<h2><a class="toc-backref" href="#id5">accessors</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="n">get_itemsize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the size of the data type in bytes.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="example-s">
|
|
||||||
<h2><a class="toc-backref" href="#id6">Example(s)</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">double</span><span class="o">></span><span class="p">();</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">for_custom_dtype</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="s">"ha"</span><span class="p">,</span><span class="n">dtype</span><span class="p">);</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">custom_dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="p">(</span><span class="n">list_for_dtype</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="ndarray" href="ndarray.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>Boost.Python NumPy extension Reference - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="next" title="dtype" href="dtype.html" />
|
|
||||||
<link rel="prev" title="How to access data using raw pointers" href="../tutorial/fromdata.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="How to access data using raw pointers" href="../tutorial/fromdata.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="next" title="dtype" href="dtype.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="boost-python-numpy-extension-reference">
|
|
||||||
<h1>Boost.Python NumPy extension Reference</h1>
|
|
||||||
<div class="toctree-wrapper compound">
|
|
||||||
<ul>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="dtype.html">dtype</a><ul>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="dtype.html#synopsis">synopsis</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="dtype.html#constructors">constructors</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="dtype.html#accessors">accessors</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="dtype.html#example-s">Example(s)</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="ndarray.html">ndarray</a><ul>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="ndarray.html#synopsis">synopsis</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="ndarray.html#constructors">constructors</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="ndarray.html#accessors">accessors</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="ndarray.html#example-s">Example(s)</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="unary_ufunc.html">unary_ufunc</a><ul>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="unary_ufunc.html#synopsis">synopsis</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="unary_ufunc.html#constructors">constructors</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="unary_ufunc.html#accessors">accessors</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="unary_ufunc.html#example-s">Example(s)</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="binary_ufunc.html">binary_ufunc</a><ul>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="binary_ufunc.html#synopsis">synopsis</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="binary_ufunc.html#constructors">constructors</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="binary_ufunc.html#accessors">accessors</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="binary_ufunc.html#example-s">Example(s)</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="multi_iter.html">multi_iter</a><ul>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="multi_iter.html#synopsis">synopsis</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="multi_iter.html#constructors">constructors</a></li>
|
|
||||||
<li class="toctree-l2"><a class="reference internal" href="multi_iter.html#accessors">accessors</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="How to access data using raw pointers" href="../tutorial/fromdata.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="next" title="dtype" href="dtype.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,211 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>multi_iter - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="up" title="Boost.Python NumPy extension Reference" href="index.html" />
|
|
||||||
<link rel="prev" title="binary_ufunc" href="binary_ufunc.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="binary_ufunc" href="binary_ufunc.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="multi-iter">
|
|
||||||
<h1><a class="toc-backref" href="#id1">multi_iter</a></h1>
|
|
||||||
<div class="contents topic" id="table-of-contents">
|
|
||||||
<p class="topic-title first">Table of Contents</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li><a class="reference internal" href="#multi-iter" id="id1">multi_iter</a><ul>
|
|
||||||
<li><a class="reference internal" href="#synopsis" id="id2">synopsis</a></li>
|
|
||||||
<li><a class="reference internal" href="#constructors" id="id3">constructors</a></li>
|
|
||||||
<li><a class="reference internal" href="#accessors" id="id4">accessors</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<p>A <tt class="docutils literal"><span class="pre">multi_iter</span></tt> is a Python object, intended to be used as an iterator It should generally only be used in loops.</p>
|
|
||||||
<blockquote>
|
|
||||||
<div><tt class="docutils literal"><span class="pre"><boost/python/numpy/ufunc.hpp></span></tt> contains the class definitions for <tt class="docutils literal"><span class="pre">multi_iter</span></tt></div></blockquote>
|
|
||||||
<div class="section" id="synopsis">
|
|
||||||
<h2><a class="toc-backref" href="#id2">synopsis</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">boost</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">python</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">numpy</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
|
|
||||||
<span class="k">class</span> <span class="nc">multi_iter</span> <span class="o">:</span> <span class="k">public</span> <span class="n">object</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="nl">public:</span>
|
|
||||||
<span class="kt">void</span> <span class="n">next</span><span class="p">();</span>
|
|
||||||
<span class="kt">bool</span> <span class="n">not_done</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="kt">char</span> <span class="o">*</span> <span class="n">get_data</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="kt">int</span> <span class="k">const</span> <span class="n">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="n">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
|
|
||||||
|
|
||||||
<span class="n">multi_iter</span> <span class="nf">make_multi_iter</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a1</span><span class="p">);</span>
|
|
||||||
<span class="n">multi_iter</span> <span class="nf">make_multi_iter</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a1</span><span class="p">,</span> <span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a2</span><span class="p">);</span>
|
|
||||||
<span class="n">multi_iter</span> <span class="nf">make_multi_iter</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a1</span><span class="p">,</span> <span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a2</span><span class="p">,</span> <span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a3</span><span class="p">);</span>
|
|
||||||
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="constructors">
|
|
||||||
<h2><a class="toc-backref" href="#id3">constructors</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">multi_iter</span> <span class="nf">make_multi_iter</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a1</span><span class="p">);</span>
|
|
||||||
<span class="n">multi_iter</span> <span class="nf">make_multi_iter</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a1</span><span class="p">,</span> <span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a2</span><span class="p">);</span>
|
|
||||||
<span class="n">multi_iter</span> <span class="nf">make_multi_iter</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a1</span><span class="p">,</span> <span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a2</span><span class="p">,</span> <span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a3</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">A Python iterator object broadcasting over one, two or three sequences as supplied</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="accessors">
|
|
||||||
<h2><a class="toc-backref" href="#id4">accessors</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">next</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Effects:</th><td class="field-body">Increments the iterator</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">bool</span> <span class="n">not_done</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">boolean value indicating whether the iterator is at its end</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">char</span> <span class="o">*</span> <span class="n">get_data</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">a pointer to the element of the nth broadcasted array.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="k">const</span> <span class="n">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the number of dimensions of the broadcasted array expression</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the shape of the broadcasted array expression as an array of integers.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="n">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the shape of the broadcasted array expression in the nth dimension.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="binary_ufunc" href="binary_ufunc.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,628 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>ndarray - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="up" title="Boost.Python NumPy extension Reference" href="index.html" />
|
|
||||||
<link rel="next" title="unary_ufunc" href="unary_ufunc.html" />
|
|
||||||
<link rel="prev" title="dtype" href="dtype.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="dtype" href="dtype.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="unary_ufunc" href="unary_ufunc.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="ndarray">
|
|
||||||
<h1><a class="toc-backref" href="#id2">ndarray</a></h1>
|
|
||||||
<div class="contents topic" id="table-of-contents">
|
|
||||||
<p class="topic-title first">Table of Contents</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li><a class="reference internal" href="#ndarray" id="id2">ndarray</a><ul>
|
|
||||||
<li><a class="reference internal" href="#synopsis" id="id3">synopsis</a></li>
|
|
||||||
<li><a class="reference internal" href="#constructors" id="id4">constructors</a></li>
|
|
||||||
<li><a class="reference internal" href="#accessors" id="id5">accessors</a></li>
|
|
||||||
<li><a class="reference internal" href="#example-s" id="id6">Example(s)</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<p>A <a class="reference external" href="http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html">ndarray</a> is an N-dimensional array which contains items of the same type and size, where N is the number of dimensions and is specified in the form of a <tt class="docutils literal"><span class="pre">shape</span></tt> tuple. Optionally, the numpy <tt class="docutils literal"><span class="pre">dtype</span></tt> for the objects contained may also be specified.</p>
|
|
||||||
<blockquote>
|
|
||||||
<div><tt class="docutils literal"><span class="pre"><boost/python/numpy/ndarray.hpp></span></tt> contains the structures and methods necessary to move raw data between C++ and Python and create ndarrays from the data</div></blockquote>
|
|
||||||
<div class="section" id="synopsis">
|
|
||||||
<h2><a class="toc-backref" href="#id3">synopsis</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">boost</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">python</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">numpy</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
|
|
||||||
<span class="k">class</span> <span class="nc">ndarray</span> <span class="o">:</span> <span class="k">public</span> <span class="n">object</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
|
|
||||||
<span class="nl">public:</span>
|
|
||||||
|
|
||||||
<span class="k">enum</span> <span class="n">bitflag</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="n">NONE</span><span class="o">=</span><span class="mh">0x0</span><span class="p">,</span> <span class="n">C_CONTIGUOUS</span><span class="o">=</span><span class="mh">0x1</span><span class="p">,</span> <span class="n">F_CONTIGUOUS</span><span class="o">=</span><span class="mh">0x2</span><span class="p">,</span> <span class="n">V_CONTIGUOUS</span><span class="o">=</span><span class="mh">0x1</span><span class="o">|</span><span class="mh">0x2</span><span class="p">,</span>
|
|
||||||
<span class="n">ALIGNED</span><span class="o">=</span><span class="mh">0x4</span><span class="p">,</span> <span class="n">WRITEABLE</span><span class="o">=</span><span class="mh">0x8</span><span class="p">,</span> <span class="n">BEHAVED</span><span class="o">=</span><span class="mh">0x4</span><span class="o">|</span><span class="mh">0x8</span><span class="p">,</span>
|
|
||||||
<span class="n">CARRAY_RO</span><span class="o">=</span><span class="mh">0x1</span><span class="o">|</span><span class="mh">0x4</span><span class="p">,</span> <span class="n">CARRAY</span><span class="o">=</span><span class="mh">0x1</span><span class="o">|</span><span class="mh">0x4</span><span class="o">|</span><span class="mh">0x8</span><span class="p">,</span> <span class="n">CARRAY_MIS</span><span class="o">=</span><span class="mh">0x1</span><span class="o">|</span><span class="mh">0x8</span><span class="p">,</span>
|
|
||||||
<span class="n">FARRAY_RO</span><span class="o">=</span><span class="mh">0x2</span><span class="o">|</span><span class="mh">0x4</span><span class="p">,</span> <span class="n">FARRAY</span><span class="o">=</span><span class="mh">0x2</span><span class="o">|</span><span class="mh">0x4</span><span class="o">|</span><span class="mh">0x8</span><span class="p">,</span> <span class="n">FARRAY_MIS</span><span class="o">=</span><span class="mh">0x2</span><span class="o">|</span><span class="mh">0x8</span><span class="p">,</span>
|
|
||||||
<span class="n">UPDATE_ALL</span><span class="o">=</span><span class="mh">0x1</span><span class="o">|</span><span class="mh">0x2</span><span class="o">|</span><span class="mh">0x4</span><span class="p">,</span> <span class="n">VARRAY</span><span class="o">=</span><span class="mh">0x1</span><span class="o">|</span><span class="mh">0x2</span><span class="o">|</span><span class="mh">0x8</span><span class="p">,</span> <span class="n">ALL</span><span class="o">=</span><span class="mh">0x1</span><span class="o">|</span><span class="mh">0x2</span><span class="o">|</span><span class="mh">0x4</span><span class="o">|</span><span class="mh">0x8</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
|
|
||||||
<span class="n">ndarray</span> <span class="n">view</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="n">ndarray</span> <span class="n">astype</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="n">ndarray</span> <span class="n">copy</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="kt">int</span> <span class="k">const</span> <span class="n">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="kt">int</span> <span class="k">const</span> <span class="n">strides</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="kt">char</span> <span class="o">*</span> <span class="n">get_data</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="n">dtype</span> <span class="n">get_dtype</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="n">python</span><span class="o">::</span><span class="n">object</span> <span class="n">get_base</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="kt">void</span> <span class="nf">set_base</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">base</span><span class="p">);</span>
|
|
||||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_strides</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="kt">int</span> <span class="k">const</span> <span class="n">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="n">bitflag</span> <span class="k">const</span> <span class="n">get_flags</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="n">ndarray</span> <span class="n">transpose</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="n">ndarray</span> <span class="n">squeeze</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="n">ndarray</span> <span class="n">reshape</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="n">object</span> <span class="n">scalarize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
|
|
||||||
<span class="n">ndarray</span> <span class="nf">zeros</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">zeros</span><span class="p">(</span><span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
|
||||||
|
|
||||||
<span class="n">ndarray</span> <span class="nf">empty</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">empty</span><span class="p">(</span><span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
|
||||||
|
|
||||||
<span class="n">ndarray</span> <span class="nf">array</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">array</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
|
||||||
|
|
||||||
<span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">Container</span><span class="o">></span>
|
|
||||||
<span class="n">ndarray</span> <span class="n">from_data</span><span class="p">(</span><span class="kt">void</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span><span class="n">Container</span> <span class="n">shape</span><span class="p">,</span><span class="n">Container</span> <span class="n">strides</span><span class="p">,</span><span class="n">python</span><span class="o">::</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">owner</span><span class="p">);</span>
|
|
||||||
<span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">Container</span><span class="o">></span>
|
|
||||||
<span class="n">ndarray</span> <span class="n">from_data</span><span class="p">(</span><span class="kt">void</span> <span class="k">const</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span> <span class="n">Container</span> <span class="n">shape</span><span class="p">,</span> <span class="n">Container</span> <span class="n">strides</span><span class="p">,</span> <span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">owner</span><span class="p">);</span>
|
|
||||||
|
|
||||||
<span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span><span class="kt">int</span> <span class="n">nd_min</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_max</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span><span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_min</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_max</span><span class="p">,</span><span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">)</span>
|
|
||||||
|
|
||||||
<span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="k">operator</span><span class="o">|</span><span class="p">(</span><span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">a</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">b</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
<span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="k">operator</span><span class="o">&</span><span class="p">(</span><span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">a</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">b</span><span class="p">);</span>
|
|
||||||
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="constructors">
|
|
||||||
<h2><a class="toc-backref" href="#id4">constructors</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">view</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">new ndarray with old ndarray data cast as supplied dtype</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">astype</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">new ndarray with old ndarray data converted to supplied dtype</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">copy</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Copy of calling ndarray object</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">transpose</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An ndarray with the rows and columns interchanged</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">squeeze</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An ndarray with all unit-shaped dimensions removed</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">reshape</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The new <tt class="docutils literal"><span class="pre">shape</span></tt> of the ndarray must be supplied as a tuple</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">An ndarray with the same data but reshaped to the <tt class="docutils literal"><span class="pre">shape</span></tt> supplied</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">object</span> <span class="n">scalarize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">A scalar if the ndarray has only one element, otherwise it returns the entire array</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="nf">zeros</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">zeros</span><span class="p">(</span><span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied as required :</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">shape</span></tt> or the size of all dimensions, as a tuple</li>
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">dtype</span></tt> of the data</li>
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">nd</span></tt> size for a square shaped ndarray</li>
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">shape</span></tt> Py_intptr_t</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A new ndarray with the given shape and data type, with data initialized to zero.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="nf">empty</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">empty</span><span class="p">(</span><span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">shape</span></tt> or the size of all dimensions, as a tuple</li>
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">dtype</span></tt> of the data</li>
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">shape</span></tt> Py_intptr_t</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A new ndarray with the given shape and data type, with data left uninitialized.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="nf">array</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">);</span>
|
|
||||||
<span class="n">ndarray</span> <span class="nf">array</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">A new ndarray from an arbitrary Python sequence, with dtype of each element specified optionally</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">Container</span><span class="o">></span>
|
|
||||||
<span class="kr">inline</span> <span class="n">ndarray</span> <span class="n">from_data</span><span class="p">(</span><span class="kt">void</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span><span class="n">Container</span> <span class="n">shape</span><span class="p">,</span><span class="n">Container</span> <span class="n">strides</span><span class="p">,</span><span class="n">python</span><span class="o">::</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">owner</span><span class="p">)</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">data</span></tt> which is a generic C++ data container</li>
|
|
||||||
<li>the dtype <tt class="docutils literal"><span class="pre">dt</span></tt> of the data</li>
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">shape</span></tt> of the ndarray as Python object</li>
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">strides</span></tt> of each dimension of the array as a Python object</li>
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">owner</span></tt> of the data, in case it is not the ndarray itself</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">ndarray with attributes and data supplied</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-odd field"><th class="field-name">Note:</th><td class="field-body"><p class="first last">The <tt class="docutils literal"><span class="pre">Container</span></tt> typename must be one that is convertible to a std::vector or python object type</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span><span class="kt">int</span> <span class="n">nd_min</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_max</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
|
||||||
<li>the dtype <tt class="docutils literal"><span class="pre">dt</span></tt> of the data</li>
|
|
||||||
<li>minimum number of dimensions <tt class="docutils literal"><span class="pre">nd_min</span></tt> of the ndarray as Python object</li>
|
|
||||||
<li>maximum number of dimensions <tt class="docutils literal"><span class="pre">nd_max</span></tt> of the ndarray as Python object</li>
|
|
||||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">ndarray constructed with dimensions and data supplied as parameters</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
|
||||||
<li>the dtype <tt class="docutils literal"><span class="pre">dt</span></tt> of the data</li>
|
|
||||||
<li>number of dimensions <tt class="docutils literal"><span class="pre">nd</span></tt> of the ndarray as Python object</li>
|
|
||||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">ndarray with dimensions <tt class="docutils literal"><span class="pre">nd</span></tt> x <tt class="docutils literal"><span class="pre">nd</span></tt> and suplied parameters</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span> <span class="n">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">)</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
|
||||||
<li>the dtype <tt class="docutils literal"><span class="pre">dt</span></tt> of the data</li>
|
|
||||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Supplied Python object as ndarray</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_min</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_max</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
|
||||||
<li>minimum number of dimensions <tt class="docutils literal"><span class="pre">nd_min</span></tt> of the ndarray as Python object</li>
|
|
||||||
<li>maximum number of dimensions <tt class="docutils literal"><span class="pre">nd_max</span></tt> of the ndarray as Python object</li>
|
|
||||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">ndarray with supplied dimension limits and parameters</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-odd field"><th class="field-name">Note:</th><td class="field-body"><p class="first last">dtype need not be supplied here</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
|
||||||
<li>the dtype <tt class="docutils literal"><span class="pre">dt</span></tt> of the data</li>
|
|
||||||
<li>number of dimensions <tt class="docutils literal"><span class="pre">nd</span></tt> of the ndarray as Python object</li>
|
|
||||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">ndarray of <tt class="docutils literal"><span class="pre">nd</span></tt> x <tt class="docutils literal"><span class="pre">nd</span></tt> dimensions constructed from the supplied object</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span> <span class="n">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">)</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
|
||||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">ndarray of same dimensions and dtype as supplied Python object</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="accessors">
|
|
||||||
<h2><a class="toc-backref" href="#id5">accessors</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="k">const</span> <span class="n">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The size of the n-th dimension of the ndarray</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="k">const</span> <span class="n">strides</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The stride of the nth dimension.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">char</span> <span class="o">*</span> <span class="n">get_data</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array’s raw data pointer as a char</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Note:</th><td class="field-body">This returns char so stride math works properly on it.User will have to reinterpret_cast it.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">dtype</span> <span class="n">get_dtype</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array’s data-type descriptor object (dtype)</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">object</span> <span class="n">get_base</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Object that owns the array’s data, or None if the array owns its own data.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">set_base</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">base</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Set the object that owns the array’s data. Exercise caution while using this</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Shape of the array as an array of integers</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_strides</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Stride of the array as an array of integers</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="k">const</span> <span class="n">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Number of array dimensions</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">bitflag</span> <span class="k">const</span> <span class="n">get_flags</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array flags</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="k">operator</span><span class="o">|</span><span class="p">(</span><span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">a</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">b</span><span class="p">)</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">bitflag logically OR-ed as (a | b)</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="k">operator</span><span class="o">&</span><span class="p">(</span><span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">a</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">b</span><span class="p">)</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">bitflag logically AND-ed as (a & b)</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="example-s">
|
|
||||||
<h2><a class="toc-backref" href="#id6">Example(s)</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">tu</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="sc">'a'</span><span class="p">,</span><span class="sc">'b'</span><span class="p">,</span><span class="sc">'c'</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">example_tuple</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">array</span> <span class="p">(</span><span class="n">tu</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">list</span> <span class="n">l</span> <span class="p">;</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">example_list</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">array</span> <span class="p">(</span><span class="n">l</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dt</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">int</span><span class="o">></span><span class="p">();</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">example_list1</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">array</span> <span class="p">(</span><span class="n">l</span><span class="p">,</span><span class="n">dt</span><span class="p">);</span>
|
|
||||||
|
|
||||||
<span class="kt">int</span> <span class="n">data</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">}</span> <span class="p">;</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">stride</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">own</span> <span class="p">;</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">data_ex</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="n">dt</span><span class="p">,</span><span class="n">shape</span><span class="p">,</span><span class="n">stride</span><span class="p">,</span><span class="n">own</span><span class="p">);</span>
|
|
||||||
|
|
||||||
<span class="kt">uint8_t</span> <span class="n">mul_data</span><span class="p">[][</span><span class="mi">4</span><span class="p">]</span> <span class="o">=</span> <span class="p">{{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">},{</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">7</span><span class="p">,</span><span class="mi">8</span><span class="p">},{</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">7</span><span class="p">}};</span>
|
|
||||||
<span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
<span class="n">stride</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dt1</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">uint8_t</span><span class="o">></span><span class="p">();</span>
|
|
||||||
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">mul_data_ex</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">mul_data</span><span class="p">,</span><span class="n">dt1</span><span class="p">,</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">),</span><span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span><span class="n">p</span><span class="o">::</span><span class="n">object</span><span class="p">());</span>
|
|
||||||
<span class="n">mul_data_ex</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">mul_data</span><span class="p">,</span><span class="n">dt1</span><span class="p">,</span> <span class="n">shape</span><span class="p">,</span><span class="n">stride</span><span class="p">,</span><span class="n">p</span><span class="o">::</span><span class="n">object</span><span class="p">());</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="dtype" href="dtype.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="unary_ufunc" href="unary_ufunc.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>unary_ufunc - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="up" title="Boost.Python NumPy extension Reference" href="index.html" />
|
|
||||||
<link rel="next" title="binary_ufunc" href="binary_ufunc.html" />
|
|
||||||
<link rel="prev" title="ndarray" href="ndarray.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="ndarray" href="ndarray.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="binary_ufunc" href="binary_ufunc.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="unary-ufunc">
|
|
||||||
<h1><a class="toc-backref" href="#id1">unary_ufunc</a></h1>
|
|
||||||
<div class="contents topic" id="table-of-contents">
|
|
||||||
<p class="topic-title first">Table of Contents</p>
|
|
||||||
<ul class="simple">
|
|
||||||
<li><a class="reference internal" href="#unary-ufunc" id="id1">unary_ufunc</a><ul>
|
|
||||||
<li><a class="reference internal" href="#synopsis" id="id2">synopsis</a></li>
|
|
||||||
<li><a class="reference internal" href="#constructors" id="id3">constructors</a></li>
|
|
||||||
<li><a class="reference internal" href="#accessors" id="id4">accessors</a></li>
|
|
||||||
<li><a class="reference internal" href="#example-s" id="id5">Example(s)</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<p>A <tt class="docutils literal"><span class="pre">unary_ufunc</span></tt> is a struct used as an intermediate step to broadcast a single argument so that a C++ function can be converted to a ufunc like function</p>
|
|
||||||
<blockquote>
|
|
||||||
<div><tt class="docutils literal"><span class="pre"><boost/python/numpy/ufunc.hpp></span></tt> contains the <tt class="docutils literal"><span class="pre">unary_ufunc</span></tt> structure definitions</div></blockquote>
|
|
||||||
<div class="section" id="synopsis">
|
|
||||||
<h2><a class="toc-backref" href="#id2">synopsis</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">boost</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">python</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">numpy</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
|
|
||||||
<span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TArgument</span><span class="o">=</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="o">::</span><span class="n">argument_type</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TResult</span><span class="o">=</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="o">::</span><span class="n">result_type</span><span class="o">></span>
|
|
||||||
<span class="k">struct</span> <span class="n">unary_ufunc</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
|
|
||||||
<span class="k">static</span> <span class="n">object</span> <span class="n">call</span><span class="p">(</span><span class="n">TUnaryFunctor</span> <span class="o">&</span> <span class="n">self</span><span class="p">,</span>
|
|
||||||
<span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">input</span><span class="p">,</span>
|
|
||||||
<span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">output</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="k">static</span> <span class="n">object</span> <span class="nf">make</span><span class="p">();</span>
|
|
||||||
|
|
||||||
<span class="p">};</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="constructors">
|
|
||||||
<h2><a class="toc-backref" href="#id3">constructors</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">struct</span> <span class="n">example_unary_ufunc</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">typedef</span> <span class="n">any_valid_type</span> <span class="n">argument_type</span><span class="p">;</span>
|
|
||||||
<span class="k">typedef</span> <span class="n">any_valid_type</span> <span class="n">result_type</span><span class="p">;</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The <tt class="docutils literal"><span class="pre">any_valid</span></tt> type must be defined using typedef as a valid C++ type in order to use the struct methods correctly</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Note:</th><td class="field-body">The struct must be exposed as a Python class, and an instance of the class must be created to use the <tt class="docutils literal"><span class="pre">call</span></tt> method corresponding to the <tt class="docutils literal"><span class="pre">__call__</span></tt> attribute of the Python object</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="accessors">
|
|
||||||
<h2><a class="toc-backref" href="#id4">accessors</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TArgument</span><span class="o">=</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="o">::</span><span class="n">argument_type</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TResult</span><span class="o">=</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="o">::</span><span class="n">result_type</span><span class="o">></span>
|
|
||||||
<span class="k">static</span> <span class="n">object</span> <span class="n">call</span><span class="p">(</span><span class="n">TUnaryFunctor</span> <span class="o">&</span> <span class="n">self</span><span class="p">,</span>
|
|
||||||
<span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">input</span><span class="p">,</span>
|
|
||||||
<span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">output</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <tt class="docutils literal"><span class="pre">TUnaryFunctor</span></tt> and optionally <tt class="docutils literal"><span class="pre">TArgument</span></tt> for argument type and <tt class="docutils literal"><span class="pre">TResult</span></tt> for result type</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Effects:</th><td class="field-body">Passes a Python object to the underlying C++ functor after broadcasting its arguments</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TArgument</span><span class="o">=</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="o">::</span><span class="n">argument_type</span><span class="p">,</span>
|
|
||||||
<span class="k">typename</span> <span class="n">TResult</span><span class="o">=</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="o">::</span><span class="n">result_type</span><span class="o">></span>
|
|
||||||
<span class="k">static</span> <span class="n">object</span> <span class="n">make</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<table class="docutils field-list" frame="void" rules="none">
|
|
||||||
<col class="field-name" />
|
|
||||||
<col class="field-body" />
|
|
||||||
<tbody valign="top">
|
|
||||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <tt class="docutils literal"><span class="pre">TUnaryFunctor</span></tt> and optionally <tt class="docutils literal"><span class="pre">TArgument</span></tt> for argument type and <tt class="docutils literal"><span class="pre">TResult</span></tt> for result type</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A Python function object to call the overloaded () operator in the struct (in typical usage)</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="example-s">
|
|
||||||
<h2><a class="toc-backref" href="#id5">Example(s)</a></h2>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="k">struct</span> <span class="n">UnarySquare</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">argument_type</span><span class="p">;</span>
|
|
||||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">result_type</span><span class="p">;</span>
|
|
||||||
<span class="kt">double</span> <span class="k">operator</span><span class="p">()(</span><span class="kt">double</span> <span class="n">r</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">r</span> <span class="o">*</span> <span class="n">r</span><span class="p">;}</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">ud</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">class_</span><span class="o"><</span><span class="n">UnarySquare</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">shared_ptr</span><span class="o"><</span><span class="n">UnarySquare</span><span class="o">></span> <span class="o">></span><span class="p">(</span><span class="s">"UnarySquare"</span><span class="p">).</span><span class="n">def</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">unary_ufunc</span><span class="o"><</span><span class="n">UnarySquare</span><span class="o">>::</span><span class="n">make</span><span class="p">());</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">inst</span> <span class="o">=</span> <span class="n">ud</span><span class="p">();</span>
|
|
||||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of unary scalar 1.0 is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span> <span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*</span> <span class="o">></span> <span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="mf">1.0</span><span class="p">)))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span> <span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="ndarray" href="ndarray.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Reference" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="binary_ufunc" href="binary_ufunc.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>Search - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: './',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
||||||
<script type="text/javascript" src="_static/searchtools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="#" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="index.html" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
jQuery(function() { Search.loadIndex("searchindex.js"); });
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/javascript" id="searchindexloader"></script>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="index.html"><img
|
|
||||||
alt="C++ Boost" src="_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h1 id="search-documentation">Search</h1>
|
|
||||||
<div id="fallback" class="admonition warning">
|
|
||||||
<script type="text/javascript">$('#fallback').hide();</script>
|
|
||||||
<p>
|
|
||||||
Please activate JavaScript to enable the search
|
|
||||||
functionality.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<p>
|
|
||||||
From here you can search these documents. Enter your search
|
|
||||||
words into the box below and click "search". Note that the search
|
|
||||||
function will automatically search for all of the words. Pages
|
|
||||||
containing fewer words won't appear in the result list.
|
|
||||||
</p>
|
|
||||||
<form action="" method="get">
|
|
||||||
<input type="text" name="q" value="" />
|
|
||||||
<input type="submit" value="search" />
|
|
||||||
<span id="search-progress" style="padding-left: 10px"></span>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<div id="search-results">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>How to use dtypes - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="up" title="Boost.Python NumPy extension Tutorial" href="index.html" />
|
|
||||||
<link rel="next" title="Creating ndarrays" href="ndarray.html" />
|
|
||||||
<link rel="prev" title="A simple tutorial on Arrays" href="simple.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="A simple tutorial on Arrays" href="simple.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="Creating ndarrays" href="ndarray.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="how-to-use-dtypes">
|
|
||||||
<h1>How to use dtypes</h1>
|
|
||||||
<p>Here is a brief tutorial to show how to create ndarrays with built-in python data types, and extract the types and values of member variables</p>
|
|
||||||
<p>Like before, first get the necessary headers, setup the namespaces and initialize the Python runtime and numpy module:</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <boost/python/numpy.hpp></span>
|
|
||||||
<span class="cp">#include <iostream></span>
|
|
||||||
|
|
||||||
<span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="n">Py_Initialize</span><span class="p">();</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">initialize</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Next, we create the shape and dtype. We use the get_builtin method to get the numpy dtype corresponding to the builtin C++ dtype
|
|
||||||
Here, we will create a 3x3 array passing a tuple with (3,3) for the size, and double as the data type</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">double</span><span class="o">></span><span class="p">();</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Finally, we can print the array using the extract method in the python namespace.
|
|
||||||
Here, we first convert the variable into a string, and then extract it as a C++ character array from the python string using the <char const * > template</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Original array:</span><span class="se">\n</span><span class="s">"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">a</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>We can also print the dtypes of the data members of the ndarray by using the get_dtype method for the ndarray</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Datatype is:</span><span class="se">\n</span><span class="s">"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">get_dtype</span><span class="p">()))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span> <span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>We can also create custom dtypes and build ndarrays with the custom dtypes</p>
|
|
||||||
<p>We use the dtype constructor to create a custom dtype. This constructor takes a list as an argument.</p>
|
|
||||||
<p>The list should contain one or more tuples of the format (variable name, variable type)</p>
|
|
||||||
<p>So first create a tuple with a variable name and its dtype, double, to create a custom dtype</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">for_custom_dtype</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="s">"ha"</span><span class="p">,</span><span class="n">dtype</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Next, create a list, and add this tuple to the list. Then use the list to create the custom dtype</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">list</span> <span class="n">list_for_dtype</span> <span class="p">;</span>
|
|
||||||
<span class="n">list_for_dtype</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">for_custom_dtype</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">custom_dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="p">(</span><span class="n">list_for_dtype</span><span class="p">)</span> <span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>We are now ready to create an ndarray with dimensions specified by *shape* and of custom dtpye</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre> <span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">new_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span><span class="n">custom_dtype</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="A simple tutorial on Arrays" href="simple.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="Creating ndarrays" href="ndarray.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>How to access data using raw pointers - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="up" title="Boost.Python NumPy extension Tutorial" href="index.html" />
|
|
||||||
<link rel="next" title="Boost.Python NumPy extension Reference" href="../reference/index.html" />
|
|
||||||
<link rel="prev" title="Ufuncs" href="ufunc.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="Ufuncs" href="ufunc.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="Boost.Python NumPy extension Reference" href="../reference/index.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="how-to-access-data-using-raw-pointers">
|
|
||||||
<h1>How to access data using raw pointers</h1>
|
|
||||||
<p>One of the advantages of the ndarray wrapper is that the same data can be used in both Python and C++ and changes can be made to reflect at both ends.
|
|
||||||
The from_data method makes this possible.</p>
|
|
||||||
<p>Like before, first get the necessary headers, setup the namespaces and initialize the Python runtime and numpy module:</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <boost/python/numpy.hpp></span>
|
|
||||||
<span class="cp">#include <iostream></span>
|
|
||||||
|
|
||||||
<span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="n">Py_Initialize</span><span class="p">();</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">initialize</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Create an array in C++ , and pass the pointer to it to the from_data method to create an ndarray:</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="n">arr</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">};</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">py_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">int</span><span class="o">></span><span class="p">(),</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="k">sizeof</span><span class="p">(</span><span class="kt">int</span><span class="p">)),</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span><span class="p">());</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Print the source C++ array, as well as the ndarray, to check if they are the same:</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"C++ array :"</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">j</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="n">j</span><span class="o"><</span><span class="mi">4</span><span class="p">;</span><span class="n">j</span><span class="o">++</span><span class="p">)</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="n">arr</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o"><<</span> <span class="sc">' '</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
|
||||||
<span class="o"><<</span> <span class="s">"Python ndarray :"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">py_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Now, change an element in the Python ndarray, and check if the value changed correspondingly in the source C++ array:</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">py_array</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mi">5</span> <span class="p">;</span>
|
|
||||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Is the change reflected in the C++ array used to create the ndarray ? "</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">j</span> <span class="o"><</span> <span class="mi">5</span><span class="p">;</span> <span class="n">j</span><span class="o">++</span><span class="p">)</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="n">arr</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o"><<</span> <span class="sc">' '</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Next, change an element of the source C++ array and see if it is reflected in the Python ndarray:</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre> <span class="n">arr</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="mi">8</span><span class="p">;</span>
|
|
||||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
|
||||||
<span class="o"><<</span> <span class="s">"Is the change reflected in the Python ndarray ?"</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
|
||||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">py_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>As we can see, the changes are reflected across the ends. This happens because the from_data method passes the C++ array by reference to create the ndarray, and thus uses the same locations for storing data.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="Ufuncs" href="ufunc.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="Boost.Python NumPy extension Reference" href="../reference/index.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>Boost.Python NumPy extension Tutorial - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="next" title="A simple tutorial on Arrays" href="simple.html" />
|
|
||||||
<link rel="prev" title="Welcome to the documentation of the Boost.Python NumPy extension!" href="../index.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="Welcome to the documentation of the Boost.Python NumPy extension!" href="../index.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="next" title="A simple tutorial on Arrays" href="simple.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="boost-python-numpy-extension-tutorial">
|
|
||||||
<h1>Boost.Python NumPy extension Tutorial</h1>
|
|
||||||
<div class="toctree-wrapper compound">
|
|
||||||
<ul>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="simple.html">A simple tutorial on Arrays</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="dtype.html">How to use dtypes</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="ndarray.html">Creating ndarrays</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="ufunc.html">Ufuncs</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="fromdata.html">How to access data using raw pointers</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="Welcome to the documentation of the Boost.Python NumPy extension!" href="../index.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="next" title="A simple tutorial on Arrays" href="simple.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>Creating ndarrays - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="up" title="Boost.Python NumPy extension Tutorial" href="index.html" />
|
|
||||||
<link rel="next" title="Ufuncs" href="ufunc.html" />
|
|
||||||
<link rel="prev" title="How to use dtypes" href="dtype.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="How to use dtypes" href="dtype.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="Ufuncs" href="ufunc.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="creating-ndarrays">
|
|
||||||
<h1>Creating ndarrays</h1>
|
|
||||||
<p>The Boost.Numpy library exposes quite a few methods to create ndarrays. ndarrays can be created in a variety of ways, include empty arrays and zero filled arrays.
|
|
||||||
ndarrays can also be created from arbitrary python sequences as well as from data and dtypes.</p>
|
|
||||||
<p>This tutorial will introduce you to some of the ways in which you can create ndarrays. The methods covered here include creating ndarrays from arbitrary Python sequences, as well as from C++ containers, using both unit and non-unit strides</p>
|
|
||||||
<p>First, as before, initialise the necessary namepaces and runtimes</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <boost/python/numpy.hpp></span>
|
|
||||||
<span class="cp">#include <iostream></span>
|
|
||||||
|
|
||||||
<span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="n">Py_Initialize</span><span class="p">();</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">initialize</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Let’s now create an ndarray from a simple tuple. We first create a tuple object, and then pass it to the array method, to generate the necessary tuple</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">tu</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="sc">'a'</span><span class="p">,</span><span class="sc">'b'</span><span class="p">,</span><span class="sc">'c'</span><span class="p">);</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">example_tuple</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">array</span><span class="p">(</span><span class="n">tu</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Let’s now try the same with a list. We create an empty list, add an element using the append method, and as before, call the array method</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">list</span> <span class="n">l</span><span class="p">;</span>
|
|
||||||
<span class="n">l</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="sc">'a'</span><span class="p">);</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">example_list</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">array</span> <span class="p">(</span><span class="n">l</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Optionally, we can also specify a dtype for the array</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dt</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">int</span><span class="o">></span><span class="p">();</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">example_list1</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">array</span> <span class="p">(</span><span class="n">l</span><span class="p">,</span><span class="n">dt</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>We can also create an array by supplying data arrays and a few other parameters.</p>
|
|
||||||
<p>First,create an integer array</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="n">data</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">};</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Create a shape, and strides, needed by the function</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">stride</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="k">sizeof</span><span class="p">(</span><span class="kt">int</span><span class="p">));</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Here, shape is (4,) , and the stride is <cite>sizeof(int)`</cite>.
|
|
||||||
A stride is the number of bytes that must be traveled to get to the next desired element while constructing the ndarray.</p>
|
|
||||||
<p>The function also needs an owner, to keep track of the data array passed. Passing none is dangerous</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">own</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>The from_data function takes the data array, datatype,shape,stride and owner as arguments and returns an ndarray</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">data_ex1</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="n">dt</span><span class="p">,</span> <span class="n">shape</span><span class="p">,</span><span class="n">stride</span><span class="p">,</span><span class="n">own</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Now let’s print the ndarray we created</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Single dimensional array ::"</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
|
||||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">data_ex</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Let’s make it a little more interesting. Lets make an 3x2 ndarray from a multi-dimensional array using non-unit strides</p>
|
|
||||||
<p>First lets create a 3x4 array of 8-bit integers</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">uint8_t</span> <span class="n">mul_data</span><span class="p">[][</span><span class="mi">4</span><span class="p">]</span> <span class="o">=</span> <span class="p">{{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">},{</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">7</span><span class="p">,</span><span class="mi">8</span><span class="p">},{</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">7</span><span class="p">}};</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Now let’s create an array of 3x2 elements, picking the first and third elements from each row . For that, the shape will be 3x2.
|
|
||||||
The strides will be 4x2 i.e. 4 bytes to go to the next desired row, and 2 bytes to go to the next desired column</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">2</span><span class="p">);</span>
|
|
||||||
<span class="n">stride</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="k">sizeof</span><span class="p">(</span><span class="kt">uint8_t</span><span class="p">)</span><span class="o">*</span><span class="mi">2</span><span class="p">,</span><span class="k">sizeof</span><span class="p">(</span><span class="kt">uint8_t</span><span class="p">));</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Get the numpy dtype for the built-in 8-bit integer data type</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dt1</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">uint8_t</span><span class="o">></span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Now lets first create and print out the ndarray as is.
|
|
||||||
Notice how we can pass the shape and strides in the function directly, as well as the owner. The last part can be done because we don’t have any use to
|
|
||||||
manipulate the “owner” object</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">mul_data_ex</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">mul_data</span><span class="p">,</span> <span class="n">dt1</span><span class="p">,</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">),</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span><span class="p">());</span>
|
|
||||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Original multi dimensional array :: "</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
|
||||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">mul_data_ex</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Now create the new ndarray using the shape and strides and print out the array we created using non-unit strides</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre> <span class="n">mul_data_ex</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">mul_data</span><span class="p">,</span> <span class="n">dt1</span><span class="p">,</span> <span class="n">shape</span><span class="p">,</span> <span class="n">stride</span><span class="p">,</span> <span class="n">p</span><span class="o">::</span><span class="n">object</span><span class="p">());</span>
|
|
||||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Selective multidimensional array :: "</span><span class="o"><<</span><span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
|
||||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">mul_data_ex</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span> <span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<div class="admonition note">
|
|
||||||
<p class="first admonition-title">Note</p>
|
|
||||||
<p class="last">The from_data method will throw <tt class="docutils literal"><span class="pre">error_already_set</span></tt> if the number of elements dictated by the shape and the corresponding strides don’t match.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="How to use dtypes" href="dtype.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="Ufuncs" href="ufunc.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>A simple tutorial on Arrays - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="up" title="Boost.Python NumPy extension Tutorial" href="index.html" />
|
|
||||||
<link rel="next" title="How to use dtypes" href="dtype.html" />
|
|
||||||
<link rel="prev" title="Boost.Python NumPy extension Tutorial" href="index.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="How to use dtypes" href="dtype.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="a-simple-tutorial-on-arrays">
|
|
||||||
<h1>A simple tutorial on Arrays</h1>
|
|
||||||
<p>Let’s start with a simple tutorial to create and modify arrays.</p>
|
|
||||||
<p>Get the necessary headers for numpy components and set up necessary namespaces:</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <boost/python/numpy.hpp></span>
|
|
||||||
<span class="cp">#include <iostream></span>
|
|
||||||
|
|
||||||
<span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Initialise the Python runtime, and the numpy module. Failure to call these results in segmentation errors:</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="n">Py_Initialize</span><span class="p">();</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">initialize</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Zero filled n-dimensional arrays can be created using the shape and data-type of the array as a parameter. Here, the shape is 3x3 and the datatype is the built-in float type:</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">float</span><span class="o">></span><span class="p">();</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>You can also create an empty array like this</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">b</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">empty</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span><span class="n">dtype</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Print the original and reshaped array. The array a which is a list is first converted to a string, and each value in the list is extracted using extract< >:</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Original array:</span><span class="se">\n</span><span class="s">"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">a</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="c1">// Reshape the array into a 1D array</span>
|
|
||||||
<span class="n">a</span> <span class="o">=</span> <span class="n">a</span><span class="p">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">9</span><span class="p">));</span>
|
|
||||||
<span class="c1">// Print it again.</span>
|
|
||||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Reshaped array:</span><span class="se">\n</span><span class="s">"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">a</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="How to use dtypes" href="dtype.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
|
|
||||||
<title>Ufuncs - Boost.Python NumPy extension 1.0 documentation</title>
|
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
||||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
|
||||||
<script type="text/javascript">
|
|
||||||
var DOCUMENTATION_OPTIONS = {
|
|
||||||
URL_ROOT: '../',
|
|
||||||
VERSION: '1.0',
|
|
||||||
COLLAPSE_MODINDEX: false,
|
|
||||||
FILE_SUFFIX: '.html'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
|
||||||
<link rel="up" title="Boost.Python NumPy extension Tutorial" href="index.html" />
|
|
||||||
<link rel="next" title="How to access data using raw pointers" href="fromdata.html" />
|
|
||||||
<link rel="prev" title="Creating ndarrays" href="ndarray.html" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../index.html"><img
|
|
||||||
alt="C++ Boost" src="../_static/bpl.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td >
|
|
||||||
<h1 align="center"><a href="../index.html">(NumPy)</a></h1>
|
|
||||||
<!-- <h2 align="center">CallPolicies Concept</h2>-->
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="searchbox" style="display: none">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" size="18" />
|
|
||||||
<input type="submit" value="Search" />
|
|
||||||
<input type="hidden" name="check_keywords" value="yes" />
|
|
||||||
<input type="hidden" name="area" value="default" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="content">
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="Creating ndarrays" href="ndarray.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="How to access data using raw pointers" href="fromdata.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section" id="ufuncs">
|
|
||||||
<h1>Ufuncs</h1>
|
|
||||||
<p>Ufuncs or universal functions operate on ndarrays element by element, and support array broadcasting, type casting, and other features.</p>
|
|
||||||
<p>Lets try and see how we can use the binary and unary ufunc methods</p>
|
|
||||||
<p>After the neccessary includes</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <boost/python/numpy.hpp></span>
|
|
||||||
<span class="cp">#include <iostream></span>
|
|
||||||
|
|
||||||
<span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
|
||||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Now we create the structs necessary to implement the ufuncs. The typedefs <em>must</em> be made as the ufunc generators take these typedefs as inputs and return an error otherwise</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">struct</span> <span class="n">UnarySquare</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">argument_type</span><span class="p">;</span>
|
|
||||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">result_type</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="kt">double</span> <span class="k">operator</span><span class="p">()(</span><span class="kt">double</span> <span class="n">r</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">r</span> <span class="o">*</span> <span class="n">r</span><span class="p">;}</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
|
|
||||||
<span class="k">struct</span> <span class="n">BinarySquare</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">first_argument_type</span><span class="p">;</span>
|
|
||||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">second_argument_type</span><span class="p">;</span>
|
|
||||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">result_type</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="kt">double</span> <span class="nf">operator</span><span class="p">()(</span><span class="kt">double</span> <span class="n">a</span><span class="p">,</span><span class="kt">double</span> <span class="n">b</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="n">b</span><span class="o">*</span><span class="n">b</span><span class="p">)</span> <span class="p">;</span> <span class="p">}</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Initialise the Python runtime and the numpy module</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
|
|
||||||
<span class="p">{</span>
|
|
||||||
<span class="n">Py_Initialize</span><span class="p">();</span>
|
|
||||||
<span class="n">np</span><span class="o">::</span><span class="n">initialize</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Now expose the struct UnarySquare to Python as a class, and let ud be the class object.</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">ud</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">class_</span><span class="o"><</span><span class="n">UnarySquare</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">shared_ptr</span><span class="o"><</span><span class="n">UnarySquare</span><span class="o">></span> <span class="o">></span><span class="p">(</span><span class="s">"UnarySquare"</span><span class="p">);</span>
|
|
||||||
<span class="n">ud</span><span class="p">.</span><span class="n">def</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">unary_ufunc</span><span class="o"><</span><span class="n">UnarySquare</span><span class="o">>::</span><span class="n">make</span><span class="p">());</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Let inst be an instance of the class ud</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">inst</span> <span class="o">=</span> <span class="n">ud</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Use the “__call__” method to call the overloaded () operator and print the value</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of unary scalar 1.0 is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="mf">1.0</span><span class="p">)))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Create an array in C++</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="n">arr</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">}</span> <span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>..and use it to create the ndarray in Python</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">demo_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">int</span><span class="o">></span><span class="p">(),</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span>
|
|
||||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span><span class="p">());</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Print out the demo array</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Demo array is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">demo_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Call the “__call__” method to perform the operation and assign the value to result_array</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">result_array</span> <span class="o">=</span> <span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="n">demo_array</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Print the resultant array</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of demo array is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">result_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Lets try the same with a list</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">list</span> <span class="n">li</span><span class="p">;</span>
|
|
||||||
<span class="n">li</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="mi">3</span><span class="p">);</span>
|
|
||||||
<span class="n">li</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="mi">7</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Print out the demo list</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Demo list is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">li</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Call the ufunc for the list</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">result_array</span> <span class="o">=</span> <span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="n">li</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>And print the list out</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of demo list is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">result_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Now lets try Binary ufuncs. Again, expose the struct BinarySquare to Python as a class, and let ud be the class object</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ud</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">class_</span><span class="o"><</span><span class="n">BinarySquare</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">shared_ptr</span><span class="o"><</span><span class="n">BinarySquare</span><span class="o">></span> <span class="o">></span><span class="p">(</span><span class="s">"BinarySquare"</span><span class="p">);</span>
|
|
||||||
<span class="n">ud</span><span class="p">.</span><span class="n">def</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">binary_ufunc</span><span class="o"><</span><span class="n">BinarySquare</span><span class="o">>::</span><span class="n">make</span><span class="p">());</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>And initialise ud</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">inst</span> <span class="o">=</span> <span class="n">ud</span><span class="p">();</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Print the two input lists</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"The two input list for binary ufunc are "</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
|
||||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">demo_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
|
||||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">demo_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>Call the binary ufunc taking demo_array as both inputs</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">result_array</span> <span class="o">=</span> <span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="n">demo_array</span><span class="p">,</span><span class="n">demo_array</span><span class="p">);</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
<p>And print the output</p>
|
|
||||||
<div class="highlight-c++"><div class="highlight"><pre> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of list with binary ufunc is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">result_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="navbar" style="text-align:right;">
|
|
||||||
|
|
||||||
|
|
||||||
<a class="prev" title="Creating ndarrays" href="ndarray.html"><img src="../_static/prev.png" alt="prev"/></a>
|
|
||||||
<a class="up" title="Boost.Python NumPy extension Tutorial" href="index.html"><img src="../_static/up.png" alt="up"/></a>
|
|
||||||
<a class="next" title="How to access data using raw pointers" href="fromdata.html"><img src="../_static/next.png" alt="next"/></a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
index.html
|
|
||||||
concepts.html
|
|
||||||
concepts/dereferenceable.html
|
|
||||||
concepts/extractor.html
|
|
||||||
concepts/holdergenerator.html
|
|
||||||
concepts/resultconverter.html
|
|
||||||
concepts/objectwrapper.html
|
|
||||||
high_level_components.html
|
|
||||||
high_level_components/boost_python_def_hpp.html
|
|
||||||
high_level_components/boost_python_def_visitor_hpp.html
|
|
||||||
high_level_components/boost_python_docstring_options_h.html
|
|
||||||
high_level_components/boost_python_enum_hpp.html
|
|
||||||
high_level_components/boost_python_errors_hpp.html
|
|
||||||
high_level_components/boost_python_exception_translato.html
|
|
||||||
high_level_components/boost_python_init_hpp.html
|
|
||||||
high_level_components/boost_python_iterator_hpp.html
|
|
||||||
high_level_components/boost_python_module_hpp.html
|
|
||||||
high_level_components/boost_python_operators_hpp.html
|
|
||||||
high_level_components/boost_python_scope_hpp.html
|
|
||||||
high_level_components/boost_python_stl_iterator_hpp.html
|
|
||||||
high_level_components/boost_python_wrapper_hpp.html
|
|
||||||
object_wrappers.html
|
|
||||||
object_wrappers/boost_python_list_hpp.html
|
|
||||||
object_wrappers/boost_python_long_hpp.html
|
|
||||||
object_wrappers/boost_python_object_hpp.html
|
|
||||||
object_wrappers/boost_python_str_hpp.html
|
|
||||||
object_wrappers/boost_python_slice_hpp.html
|
|
||||||
object_wrappers/boost_python_tuple_hpp.html
|
|
||||||
function_invocation_and_creation.html
|
|
||||||
function_invocation_and_creation/boost_python_call_hpp.html
|
|
||||||
function_invocation_and_creation/boost_python_call_method_hpp.html
|
|
||||||
function_invocation_and_creation/boost_python_data_members_hpp.html
|
|
||||||
function_invocation_and_creation/boost_python_make_function_hpp.html
|
|
||||||
function_invocation_and_creation/boost_python_overloads_hpp.html
|
|
||||||
function_invocation_and_creation/boost_python_ptr_hpp.html
|
|
||||||
function_invocation_and_creation/boost_python_raw_function_hpp.html
|
|
||||||
function_invocation_and_creation/function_documentation.html
|
|
||||||
function_invocation_and_creation/models_of_callpolicies.html
|
|
||||||
function_invocation_and_creation/models_of_resultconverter.html
|
|
||||||
function_invocation_and_creation/models_of_resultconvertergenerat.html
|
|
||||||
to_from_python_type_conversion.html
|
|
||||||
to_from_python_type_conversion/boost_python_implicit_hpp.html
|
|
||||||
to_from_python_type_conversion/boost_python_lvalue_from_pytype_.html
|
|
||||||
to_from_python_type_conversion/boost_python_opaque_pointer_conv.html
|
|
||||||
to_from_python_type_conversion/boost_python_to_python_converter.html
|
|
||||||
to_from_python_type_conversion/boost_python_register_ptr_to_pyt.html
|
|
||||||
embedding.html
|
|
||||||
embedding/boost_python_import_hpp.html
|
|
||||||
utility_and_infrastructure.html
|
|
||||||
utility_and_infrastructure/boost_python_instance_holder_hpp.html
|
|
||||||
utility_and_infrastructure/boost_python_pointee_hpp.html
|
|
||||||
utility_and_infrastructure/boost_python_handle_hpp.html
|
|
||||||
utility_and_infrastructure/boost_python_type_id_hpp.html
|
|
||||||
utility_and_infrastructure/boost_python_ssize_t_hpp.html
|
|
||||||
topics.html
|
|
||||||
topics/pickle_support.html
|
|
||||||
topics/indexing_support.html
|
|
||||||
glossary.html
|
|
||||||
@@ -1,261 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
||||||
<title>Chapter 1. Concepts</title>
|
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
||||||
<link rel="home" href="index.html" title="Boost.Python Reference Manual">
|
|
||||||
<link rel="up" href="index.html" title="Boost.Python Reference Manual">
|
|
||||||
<link rel="prev" href="index.html" title="Boost.Python Reference Manual">
|
|
||||||
<link rel="next" href="concepts/dereferenceable.html" title="Dereferenceable">
|
|
||||||
</head>
|
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
||||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="index.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="concepts/dereferenceable.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
<div class="chapter">
|
|
||||||
<div class="titlepage"><div><div><h1 class="title">
|
|
||||||
<a name="concepts"></a>Chapter 1. Concepts</h1></div></div></div>
|
|
||||||
<div class="toc">
|
|
||||||
<p><b>Table of Contents</b></p>
|
|
||||||
<dl class="toc">
|
|
||||||
<dt><span class="section"><a href="concepts.html#concepts.callpolicies">CallPolicies</a></span></dt>
|
|
||||||
<dd><dl>
|
|
||||||
<dt><span class="section"><a href="concepts.html#concepts.callpolicies.introduction">Introduction</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts.html#concepts.callpolicies.callpolicies_composition">CallPolicies
|
|
||||||
Composition</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts.html#concepts.callpolicies.concept_requirements">Concept
|
|
||||||
Requirements</a></span></dt>
|
|
||||||
</dl></dd>
|
|
||||||
<dt><span class="section"><a href="concepts/dereferenceable.html">Dereferenceable</a></span></dt>
|
|
||||||
<dd><dl>
|
|
||||||
<dt><span class="section"><a href="concepts/dereferenceable.html#concepts.dereferenceable.introduction">Introduction</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts/dereferenceable.html#concepts.dereferenceable.concept_requirements">Concept
|
|
||||||
Requirements</a></span></dt>
|
|
||||||
</dl></dd>
|
|
||||||
<dt><span class="section"><a href="concepts/extractor.html">Extractor</a></span></dt>
|
|
||||||
<dd><dl>
|
|
||||||
<dt><span class="section"><a href="concepts/extractor.html#concepts.extractor.introduction">Introduction</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts/extractor.html#concepts.extractor.concept_requirements">Concept Requirements</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts/extractor.html#concepts.extractor.notes">Notes</a></span></dt>
|
|
||||||
</dl></dd>
|
|
||||||
<dt><span class="section"><a href="concepts/holdergenerator.html">HolderGenerator</a></span></dt>
|
|
||||||
<dd><dl>
|
|
||||||
<dt><span class="section"><a href="concepts/holdergenerator.html#concepts.holdergenerator.introduction">Introduction</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts/holdergenerator.html#concepts.holdergenerator.concept_requirements">Concept
|
|
||||||
Requirements</a></span></dt>
|
|
||||||
</dl></dd>
|
|
||||||
<dt><span class="section"><a href="concepts/resultconverter.html">ResultConverter</a></span></dt>
|
|
||||||
<dd><dl>
|
|
||||||
<dt><span class="section"><a href="concepts/resultconverter.html#concepts.resultconverter.introduction">Introduction</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts/resultconverter.html#concepts.resultconverter.resultconverter_concept_requirem">ResultConverter
|
|
||||||
Concept Requirements</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts/resultconverter.html#concepts.resultconverter.resultconvertergenerator_concept">ResultConverterGenerator
|
|
||||||
Concept Requirements</a></span></dt>
|
|
||||||
</dl></dd>
|
|
||||||
<dt><span class="section"><a href="concepts/objectwrapper.html">ObjectWrapper</a></span></dt>
|
|
||||||
<dd><dl>
|
|
||||||
<dt><span class="section"><a href="concepts/objectwrapper.html#concepts.objectwrapper.introduction">Introduction</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts/objectwrapper.html#concepts.objectwrapper.objectwrapper_concept_requiremen">ObjectWrapper
|
|
||||||
Concept Requirements</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts/objectwrapper.html#concepts.objectwrapper.typewrapper_concept_requirements">TypeWrapper
|
|
||||||
Concept Requirements</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts/objectwrapper.html#concepts.objectwrapper.caveat">Caveat</a></span></dt>
|
|
||||||
</dl></dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
|
||||||
<a name="concepts.callpolicies"></a><a class="link" href="concepts.html#concepts.callpolicies" title="CallPolicies">CallPolicies</a>
|
|
||||||
</h2></div></div></div>
|
|
||||||
<div class="toc"><dl class="toc">
|
|
||||||
<dt><span class="section"><a href="concepts.html#concepts.callpolicies.introduction">Introduction</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts.html#concepts.callpolicies.callpolicies_composition">CallPolicies
|
|
||||||
Composition</a></span></dt>
|
|
||||||
<dt><span class="section"><a href="concepts.html#concepts.callpolicies.concept_requirements">Concept
|
|
||||||
Requirements</a></span></dt>
|
|
||||||
</dl></div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="concepts.callpolicies.introduction"></a><a class="link" href="concepts.html#concepts.callpolicies.introduction" title="Introduction">Introduction</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
Models of the CallPolicies concept are used to specialize the behavior
|
|
||||||
of Python callable objects generated by Boost.Python to wrapped C++ objects
|
|
||||||
like function and member function pointers, providing three behaviors:
|
|
||||||
</p>
|
|
||||||
<div class="orderedlist"><ol class="orderedlist" type="1">
|
|
||||||
<li class="listitem">
|
|
||||||
<code class="computeroutput"><span class="identifier">precall</span></code> - Python argument
|
|
||||||
tuple management before the wrapped object is invoked
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<code class="computeroutput"><span class="identifier">result_converter</span></code> -
|
|
||||||
C++ return value handling
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<code class="computeroutput"><span class="identifier">postcall</span></code> - Python argument
|
|
||||||
tuple and result management after the wrapped object is invoked
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<code class="computeroutput"><span class="identifier">extract_return_type</span></code>
|
|
||||||
- metafunction for extracting the return type from a given signature
|
|
||||||
type sequence
|
|
||||||
</li>
|
|
||||||
</ol></div>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="concepts.callpolicies.callpolicies_composition"></a><a class="link" href="concepts.html#concepts.callpolicies.callpolicies_composition" title="CallPolicies Composition">CallPolicies
|
|
||||||
Composition</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<p>
|
|
||||||
In order to allow the use of multiple models of CallPolicies in the same
|
|
||||||
callable object, Boost.Python's CallPolicies class templates provide a
|
|
||||||
chaining interface which allows them to be recursively composed. This interface
|
|
||||||
takes the form of an optional template parameter, <code class="computeroutput"><span class="identifier">Base</span></code>,
|
|
||||||
which defaults to <code class="computeroutput"><span class="identifier">default_call_policies</span></code>.
|
|
||||||
By convention, the <code class="computeroutput"><span class="identifier">precall</span></code>
|
|
||||||
function of the <code class="computeroutput"><span class="identifier">Base</span></code> is
|
|
||||||
invoked after the <code class="computeroutput"><span class="identifier">precall</span></code>
|
|
||||||
function supplied by the <code class="computeroutput"><span class="identifier">outer</span></code>
|
|
||||||
template, and the <code class="computeroutput"><span class="identifier">postcall</span></code>
|
|
||||||
function of the <code class="computeroutput"><span class="identifier">Base</span></code> is
|
|
||||||
invoked before the <code class="computeroutput"><span class="identifier">postcall</span></code>
|
|
||||||
function of the <code class="computeroutput"><span class="identifier">outer</span></code> template.
|
|
||||||
If a <code class="computeroutput"><span class="identifier">result_converter</span></code> is
|
|
||||||
supplied by the <code class="computeroutput"><span class="identifier">outer</span></code> template,
|
|
||||||
it replaces any <code class="computeroutput"><span class="identifier">result_converter</span></code>
|
|
||||||
supplied by the <code class="computeroutput"><span class="identifier">Base</span></code>. For
|
|
||||||
an example, see <code class="computeroutput"><span class="identifier">return_internal_reference</span></code>.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
|
||||||
<a name="concepts.callpolicies.concept_requirements"></a><a class="link" href="concepts.html#concepts.callpolicies.concept_requirements" title="Concept Requirements">Concept
|
|
||||||
Requirements</a>
|
|
||||||
</h3></div></div></div>
|
|
||||||
<div class="informaltable"><table class="table">
|
|
||||||
<colgroup>
|
|
||||||
<col>
|
|
||||||
<col>
|
|
||||||
<col>
|
|
||||||
</colgroup>
|
|
||||||
<thead><tr>
|
|
||||||
<th>
|
|
||||||
<p>
|
|
||||||
Expression
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<p>
|
|
||||||
Type
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<p>
|
|
||||||
Result/Semantics
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
</tr></thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">precall</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
convertible to <code class="computeroutput"><span class="keyword">bool</span></code>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
returns <code class="computeroutput"><span class="keyword">false</span></code> and
|
|
||||||
<code class="computeroutput"><span class="identifier">PyErr_Occurred</span><span class="special">()</span> <span class="special">!=</span>
|
|
||||||
<span class="number">0</span></code> upon failure, <code class="computeroutput"><span class="keyword">true</span></code> otherwise.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<code class="computeroutput"><span class="identifier">P</span><span class="special">::</span><span class="identifier">result_converter</span></code>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
A model of <code class="computeroutput"><span class="identifier">ResultConverterGenerator</span></code>.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
An MPL unary Metafunction Class used produce the "preliminary"
|
|
||||||
result object.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">postcall</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span>
|
|
||||||
<span class="identifier">r</span><span class="special">)</span></code>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
convertible to <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<code class="computeroutput"><span class="number">0</span></code> and <code class="computeroutput"><span class="identifier">PyErr_Occurred</span><span class="special">()</span>
|
|
||||||
<span class="special">!=</span> <span class="number">0</span></code>
|
|
||||||
upon failure. Must "conserve references" even in the
|
|
||||||
event of an exception. In other words, if <code class="computeroutput"><span class="identifier">r</span></code>
|
|
||||||
is not returned, its reference count must be decremented; if
|
|
||||||
another existing object is returned, its reference count must
|
|
||||||
be incremented.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
<code class="computeroutput"><span class="identifier">P</span><span class="special">::</span><span class="identifier">extract_return_type</span></code>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
A model of Metafunction.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
An MPL unary Metafunction used extract the return type from a
|
|
||||||
given signature. By default it is derived from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">front</span></code>.
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
||||||
<td align="left"></td>
|
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2005, 2015 David Abrahams, Stefan Seefeld<p>
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>
|
|
||||||
</p>
|
|
||||||
</div></td>
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
<div class="spirit-nav">
|
|
||||||
<a accesskey="p" href="index.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="concepts/dereferenceable.html"><img src="../images/next.png" alt="Next"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||