Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NiuZhixiao committed Oct 11, 2023
2 parents 8f07fd5 + 14436c2 commit bfc4ee9
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 153 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/binder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build Notebook Container
on: [push] # You may want to trigger this Action on other things than a push.
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: update jupyter dependencies with repo2docker
uses: jupyterhub/repo2docker-action@master
with:
NO_PUSH: true
MYBINDERORG_TAG: ${{ github.event.pull_request.head.ref }}
IMAGE_NAME: xiaoganghe/python-climate-visuals # fixed var because Docker not allow uppercases
# BINDER_CACHE: true
# PUBLIC_REGISTRY_CHECK: true
43 changes: 0 additions & 43 deletions .github/workflows/static.yml

This file was deleted.

43 changes: 23 additions & 20 deletions chapters/data-analytics/numpy-basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source": [
"# NumPy tutorial\n",
"\n",
"[NumPy](http://www.numpy.org/) is the core library for scientific computing in Python. It vastly simplifies manipulating and crunching vectors and matrices. Many of python-based leading packages rely on NumPy as a infrastructure piece."
"[NumPy](http://www.numpy.org/) is the **core** package for scientific computing in Python. It vastly simplifies manipulating and crunching vectors and matrices. Many of other leading packages rely on NumPy as a infrastructure piece."
]
},
{
Expand Down Expand Up @@ -167,9 +167,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[[0.69381927]\n",
" [0.62248209]\n",
" [0.41387215]]\n"
"[[0.67742525]\n",
" [0.0784592 ]\n",
" [0.6098676 ]]\n"
]
}
],
Expand All @@ -178,7 +178,7 @@
"d = np.zeros((2, 2)) # Create an array of all zeros with shape (2, 2)\n",
"d = np.ones((1, 2)) # Create an array of all ones with shape (1, 2)\n",
"d = np.random.random((3, 1)) # Create an array of random values with shape (3, 1)\n",
"# try printing them\n",
"# Try printing them\n",
"print(d)"
]
},
Expand All @@ -191,7 +191,7 @@
"source": [
"## Array Indexing\n",
"\n",
"There are several ways to pull out a section of arrays. The most common ways include **slicing**, **integer array indexing** and **Boolean array indexing**. We may choose the appropriate indexing methods for different purposes."
"The most common ways to pull out a section of arrays include **slicing**, **integer array indexing** and **Boolean array indexing**. We may choose the appropriate indexing methods for different purposes."
]
},
{
Expand Down Expand Up @@ -398,17 +398,17 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[4 5 6] (3,)\n",
"[[4 5 6]] (1, 3)\n"
"[1 2 3] (3,)\n",
"[[1 2 3]] (1, 3)\n"
]
}
],
"source": [
"a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])\n",
"row_r1 = a[1, :] # Mix integer indexing with slice indexing\n",
"row_r2 = a[1:2, :] # Slice indexing\n",
"print(row_r1, row_r1.shape) # Lower rank\n",
"print(row_r2, row_r2.shape)"
"a_1row = a[0, :] # Mix integer indexing with slice indexing\n",
"a_2rows = a[0:1, :] # Slice indexing\n",
"print(a_1row, a_1row.shape) # Lower rank\n",
"print(a_2rows, a_2rows.shape) "
]
},
{
Expand Down Expand Up @@ -481,15 +481,18 @@
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 9 10 11 12]\n"
]
"data": {
"text/plain": [
"array([ 9, 10, 11, 12])"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print(a[a > 8])"
"a[a > 8]"
]
},
{
Expand Down Expand Up @@ -689,7 +692,7 @@
}
],
"source": [
"x = np.array([[1, 2], [3, 4]], dtype=np.float64)\n",
"x = np.array([[1, 2], [3, 4]], dtype=np.float64) # Set data types of elements by dtype\n",
"y = np.array([[5, 6], [7, 8]], dtype=np.float64)\n",
"\n",
"# Elementwise sum; both produce an array\n",
Expand Down Expand Up @@ -989,7 +992,7 @@
"id": "89e2FXxFL9jQ"
},
"source": [
"Broadcasting typically makes your code more ***concise***, ***readable***, and more importantly, ***faster***, so you should strive to use it where possible."
"Broadcasting typically makes your code more ***concise***, ***readable***, and more importantly, ***faster***."
]
},
{
Expand Down
Loading

0 comments on commit bfc4ee9

Please sign in to comment.