Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions appa.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,22 @@
"demeaned.mean(2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def demean_axis(arr, axis=0):\n",
" means = arr.mean(axis)\n",
"\n",
" # This generalizes things like [:, :, np.newaxis] to N dimensions\n",
" indexer = [slice(None)] * arr.ndim\n",
" indexer[axis] = np.newaxis\n",
" #Tuple is added in the next line to avoid non-tuple sequence for multidimensional indexing error\n",
" return arr - means[tuple(indexer)]"
]
},
{
"cell_type": "code",
"execution_count": 36,
Expand Down Expand Up @@ -939,9 +955,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.10.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
}