Skip to content

Instantly share code, notes, and snippets.

@mhlr
Created September 10, 2021 02:30
Show Gist options
  • Save mhlr/6990be27d0e36699d672353e16bfcaef to your computer and use it in GitHub Desktop.
Save mhlr/6990be27d0e36699d672353e16bfcaef to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "182a16c4-4777-4ec3-99b1-476914c2ec1b",
"metadata": {},
"source": [
"# Current"
]
},
{
"cell_type": "markdown",
"id": "11b1cb71-4f1b-441f-a6bf-93d430ac5356",
"metadata": {
"tags": []
},
"source": [
"## Create test example"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "61901771-5a93-4cc9-a180-0cc2cc580a53",
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "b0d92f0d-3549-4619-a272-a324ef475104",
"metadata": {},
"outputs": [],
"source": [
"import string, random, toolz, pandas, importlib, sys, os"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "d2c51a56-7617-427e-8ec5-12e4a0fc0a08",
"metadata": {},
"outputs": [],
"source": [
"terms = [(term, 1) for term in str(random.choices(string.ascii_letters, k=10**7)).split('Z')]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "1f8a40cc-df42-4f45-9220-afd1f212239f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"count 191557.000000\n",
"mean 260.018919\n",
"std 258.235286\n",
"min 4.000000\n",
"25% 74.000000\n",
"50% 179.000000\n",
"75% 359.000000\n",
"max 3084.000000\n",
"dtype: float64"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pandas.Series(len(term) for term, _ in terms).describe()"
]
},
{
"cell_type": "markdown",
"id": "ed7030e6-6d63-4f54-a8af-13e938191812",
"metadata": {},
"source": [
"## Run current version"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "bc701097-6aa9-44a1-8673-b2777e84e929",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Switched to branch 'main'\n",
"Your branch and 'upstream/main' have diverged,\n",
"and have 1 and 2 different commits each, respectively.\n",
" (use \"git pull\" to merge the remote branch into yours)\n"
]
}
],
"source": [
"!git checkout main\n",
"#importlib.reload(dimod)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "0dff8f12-ff29-4991-ad7c-8bb9d6367f5e",
"metadata": {},
"outputs": [],
"source": [
"from dimod import BinaryPolynomial as BPold"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "ec77f944-27b1-47ce-b141-2b8d6fc3f116",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[0;31mSignature:\u001b[0m \u001b[0mBPold\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpoly\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvartype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mDocstring:\u001b[0m Initialize self. See help(type(self)) for accurate signature.\n",
"\u001b[0;31mSource:\u001b[0m \n",
" \u001b[0;34m@\u001b[0m\u001b[0mvartype_argument\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'vartype'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpoly\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvartype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpoly\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mabc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mMapping\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mpoly\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpoly\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;31m# we need to aggregate the repeated terms\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_terms\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mterms\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mterm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbias\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mpoly\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mfsterm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0masfrozenset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mterm\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;31m# when SPIN-valued, s^2 == 1, so we need to handle that case\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;31m# in BINARY, x^2 == x\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfsterm\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mterm\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mvartype\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mVartype\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSPIN\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mnew\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mterm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtuple\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mterm\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# make sure it has .count\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mfsterm\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mterm\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcount\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mnew\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mfsterm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfrozenset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnew\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mfsterm\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mterms\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mterms\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfsterm\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0mbias\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mterms\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfsterm\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbias\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvartype\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvartype\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mFile:\u001b[0m ~/dimod/dimod/higherorder/polynomial.py\n",
"\u001b[0;31mType:\u001b[0m function\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"BPold.__init__??"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "e4cfa0c6-b7d4-4642-82fb-9eba71ab340b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" "
]
},
{
"data": {
"text/plain": [
" 9687489 function calls (9687409 primitive calls) in 28.809 seconds\n",
"\n",
" Ordered by: cumulative time\n",
" List reduced from 47 to 20 due to restriction <20>\n",
"\n",
" ncalls tottime percall cumtime percall filename:lineno(function)\n",
" 1 0.000 0.000 28.809 28.809 {built-in method builtins.exec}\n",
" 1 0.065 0.065 28.809 28.809 <string>:1(<module>)\n",
" 1 0.000 0.000 28.743 28.743 decorators.py:289(new_f)\n",
" 1 2.587 2.587 28.743 28.743 polynomial.py:89(__init__)\n",
" 5468426 25.143 0.000 25.143 0.000 {method 'count' of 'tuple' objects}\n",
" 191557 0.649 0.000 0.677 0.000 polynomial.py:32(asfrozenset)\n",
" 3452632 0.297 0.000 0.297 0.000 {method 'add' of 'set' objects}\n",
" 383116 0.039 0.000 0.039 0.000 {built-in method builtins.len}\n",
" 191567 0.028 0.000 0.028 0.000 {built-in method builtins.isinstance}\n",
" 1 0.000 0.000 0.000 0.000 abc.py:96(__instancecheck__)\n",
" 1 0.000 0.000 0.000 0.000 {built-in method _abc._abc_instancecheck}\n",
" 41/1 0.000 0.000 0.000 0.000 abc.py:100(__subclasscheck__)\n",
" 41/1 0.000 0.000 0.000 0.000 {built-in method _abc._abc_subclasscheck}\n",
" 1 0.000 0.000 0.000 0.000 inspect.py:1340(getcallargs)\n",
" 1 0.000 0.000 0.000 0.000 inspect.py:1102(getfullargspec)\n",
" 1 0.000 0.000 0.000 0.000 inspect.py:2218(_signature_from_callable)\n",
" 1 0.000 0.000 0.000 0.000 inspect.py:2124(_signature_from_function)\n",
" 3 0.000 0.000 0.000 0.000 inspect.py:2489(__init__)\n",
" 1 0.000 0.000 0.000 0.000 inspect.py:2772(__init__)\n",
" 1 0.000 0.000 0.000 0.000 <string>:1(__new__)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%prun -s cumtime -l 20 BPold(terms, 'SPIN')"
]
},
{
"cell_type": "markdown",
"id": "81473689-9ece-45a7-85a0-389d0418be3e",
"metadata": {},
"source": [
"# Exit interpreter\n",
"I just can'get module reloading to work properly here ..."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "673fe5b0-5934-4b40-a418-62122e867aa9",
"metadata": {},
"outputs": [],
"source": [
"## \n",
"exit()\n",
"#del BPold"
]
},
{
"cell_type": "markdown",
"id": "8d68e1c7-8d3c-40ae-acdd-360edccad297",
"metadata": {},
"source": [
"# Proposed"
]
},
{
"cell_type": "markdown",
"id": "c2041ccc-e502-4135-b067-159d85043378",
"metadata": {
"tags": []
},
"source": [
"## Create test example"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "370178a2-f029-4e9b-b4f7-f4c051df686c",
"metadata": {},
"outputs": [],
"source": [
"import string, random, toolz, pandas, importlib, sys, os"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "a2199fbe-fa29-4286-b93a-eadba3b739e3",
"metadata": {},
"outputs": [],
"source": [
"terms = [(term, 1) for term in str(random.choices(string.ascii_letters, k=10**7)).split('Z')]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "5707eff9-710b-4799-87bc-99bed0eed866",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"count 192902.000000\n",
"mean 258.198977\n",
"std 257.967508\n",
"min 4.000000\n",
"25% 74.000000\n",
"50% 179.000000\n",
"75% 359.000000\n",
"max 3254.000000\n",
"dtype: float64"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pandas.Series(len(term) for term, _ in terms).describe()"
]
},
{
"cell_type": "markdown",
"id": "75dbfea5-3022-4652-89f2-e41f0b822abd",
"metadata": {},
"source": [
"## Run proposed version"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6f8b616f-1835-4723-83c3-dc189b891a94",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Already on 'binary-polynomial'\n",
"Your branch is up to date with 'origin/binary-polynomial'.\n"
]
}
],
"source": [
"!git checkout binary-polynomial\n",
"!touch -c ./dimod/higherorder/polynomial.py\n",
"#importlib.reload(dimod)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "6e5ac6a3-5a9a-4147-8909-0b09208d66c2",
"metadata": {},
"outputs": [],
"source": [
"from dimod import BinaryPolynomial as BPnew"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b8472b21-b3e6-4c19-b860-d2631dd78065",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[0;31mSignature:\u001b[0m \u001b[0mBPnew\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpoly\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvartype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mDocstring:\u001b[0m Initialize self. See help(type(self)) for accurate signature.\n",
"\u001b[0;31mSource:\u001b[0m \n",
" \u001b[0;34m@\u001b[0m\u001b[0mvartype_argument\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'vartype'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpoly\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvartype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpoly\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mabc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mMapping\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mpoly\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpoly\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;31m# we need to aggregate the repeated terms\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_terms\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mterms\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdefaultdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mterm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbias\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mpoly\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mterms\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfreeze_term\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mterm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvartype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0mbias\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvartype\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvartype\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mFile:\u001b[0m ~/dimod/dimod/higherorder/polynomial.py\n",
"\u001b[0;31mType:\u001b[0m function\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"BPnew.__init__??"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "9065a62a-4c71-4f58-843b-65f611bc4848",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" "
]
},
{
"data": {
"text/plain": [
" 578909 function calls (578829 primitive calls) in 4.456 seconds\n",
"\n",
" Ordered by: cumulative time\n",
" List reduced from 45 to 20 due to restriction <20>\n",
"\n",
" ncalls tottime percall cumtime percall filename:lineno(function)\n",
" 1 0.000 0.000 4.456 4.456 {built-in method builtins.exec}\n",
" 1 0.073 0.073 4.456 4.456 <string>:1(<module>)\n",
" 1 0.000 0.000 4.383 4.383 decorators.py:289(new_f)\n",
" 1 0.188 0.188 4.383 4.383 polynomial.py:111(__init__)\n",
" 192902 4.167 0.000 4.195 0.000 polynomial.py:43(freeze_term)\n",
" 192912 0.015 0.000 0.015 0.000 {built-in method builtins.isinstance}\n",
" 192903 0.013 0.000 0.013 0.000 {method 'items' of 'dict' objects}\n",
" 1 0.000 0.000 0.000 0.000 abc.py:96(__instancecheck__)\n",
" 1 0.000 0.000 0.000 0.000 {built-in method _abc._abc_instancecheck}\n",
" 41/1 0.000 0.000 0.000 0.000 abc.py:100(__subclasscheck__)\n",
" 41/1 0.000 0.000 0.000 0.000 {built-in method _abc._abc_subclasscheck}\n",
" 1 0.000 0.000 0.000 0.000 inspect.py:1340(getcallargs)\n",
" 1 0.000 0.000 0.000 0.000 inspect.py:1102(getfullargspec)\n",
" 1 0.000 0.000 0.000 0.000 inspect.py:2218(_signature_from_callable)\n",
" 1 0.000 0.000 0.000 0.000 inspect.py:2124(_signature_from_function)\n",
" 3 0.000 0.000 0.000 0.000 inspect.py:2489(__init__)\n",
" 1 0.000 0.000 0.000 0.000 <string>:1(__new__)\n",
" 1 0.000 0.000 0.000 0.000 inspect.py:2772(__init__)\n",
" 38 0.000 0.000 0.000 0.000 _collections_abc.py:392(__subclasshook__)\n",
" 1 0.000 0.000 0.000 0.000 decorators.py:281(_enforce_single_arg)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%prun -s cumtime -l 20 BPnew(terms, 'SPIN')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "909a0aa9-bf75-4026-9fc3-48879ee20269",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment