Skip to content

Commit

Permalink
change order of cells
Browse files Browse the repository at this point in the history
  • Loading branch information
glibesyck committed Aug 21, 2024
1 parent a5c3afa commit c41d00c
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions tutorials/W1D5_Microcircuits/W1D5_Tutorial1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,47 @@
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form"
},
"outputs": [],
"source": [
"# @title Data retrieval\n",
"\n",
"import os\n",
"import requests\n",
"import hashlib\n",
"\n",
"# Variables for file and download URL\n",
"fnames = [\"frame1.npy\", \"sig.npy\", \"reweight_digits.npy\", \"model.npy\", \"video_array.npy\"] # The names of the files to be downloaded\n",
"urls = [\"https://osf.io/n652y/download\", \"https://osf.io/c9qxk/download\", \"https://osf.io/ry5am/download\", \"https://osf.io/uebw5/download\", \"https://osf.io/t9g2m/download\"] # URLs from where the files will be downloaded\n",
"expected_md5s = [\"6ce619172367742dd148cc5830df908c\", \"f3618e05e39f6df5997f78ea668f2568\", \"1f2f3a5d08e13ed2ec3222dca1e85b60\", \"ae20e6321836783777c132149493ec70\", \"bbd1d73eeb7f5c81768771ceb85c849e\"] # MD5 hashes for verifying files integrity\n",
"\n",
"for fname, url, expected_md5 in zip(fnames, urls, expected_md5s):\n",
" if not os.path.isfile(fname):\n",
" try:\n",
" # Attempt to download the file\n",
" r = requests.get(url) # Make a GET request to the specified URL\n",
" except requests.ConnectionError:\n",
" # Handle connection errors during the download\n",
" print(\"!!! Failed to download data !!!\")\n",
" else:\n",
" # No connection errors, proceed to check the response\n",
" if r.status_code != requests.codes.ok:\n",
" # Check if the HTTP response status code indicates a successful download\n",
" print(\"!!! Failed to download data !!!\")\n",
" elif hashlib.md5(r.content).hexdigest() != expected_md5:\n",
" # Verify the integrity of the downloaded file using MD5 checksum\n",
" print(\"!!! Data download appears corrupted !!!\")\n",
" else:\n",
" # If download is successful and data is not corrupted, save the file\n",
" with open(fname, \"wb\") as fid:\n",
" fid.write(r.content) # Write the downloaded content to a file"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -722,47 +763,6 @@
"reg = OrthogonalMatchingPursuit(fit_intercept = True, n_nonzero_coefs = 10).fit(np.vstack(set_sigs).T, sig)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form"
},
"outputs": [],
"source": [
"# @title Data retrieval\n",
"\n",
"import os\n",
"import requests\n",
"import hashlib\n",
"\n",
"# Variables for file and download URL\n",
"fnames = [\"frame1.npy\", \"sig.npy\", \"reweight_digits.npy\", \"model.npy\", \"video_array.npy\"] # The names of the files to be downloaded\n",
"urls = [\"https://osf.io/n652y/download\", \"https://osf.io/c9qxk/download\", \"https://osf.io/ry5am/download\", \"https://osf.io/uebw5/download\", \"https://osf.io/t9g2m/download\"] # URLs from where the files will be downloaded\n",
"expected_md5s = [\"6ce619172367742dd148cc5830df908c\", \"f3618e05e39f6df5997f78ea668f2568\", \"1f2f3a5d08e13ed2ec3222dca1e85b60\", \"ae20e6321836783777c132149493ec70\", \"bbd1d73eeb7f5c81768771ceb85c849e\"] # MD5 hashes for verifying files integrity\n",
"\n",
"for fname, url, expected_md5 in zip(fnames, urls, expected_md5s):\n",
" if not os.path.isfile(fname):\n",
" try:\n",
" # Attempt to download the file\n",
" r = requests.get(url) # Make a GET request to the specified URL\n",
" except requests.ConnectionError:\n",
" # Handle connection errors during the download\n",
" print(\"!!! Failed to download data !!!\")\n",
" else:\n",
" # No connection errors, proceed to check the response\n",
" if r.status_code != requests.codes.ok:\n",
" # Check if the HTTP response status code indicates a successful download\n",
" print(\"!!! Failed to download data !!!\")\n",
" elif hashlib.md5(r.content).hexdigest() != expected_md5:\n",
" # Verify the integrity of the downloaded file using MD5 checksum\n",
" print(\"!!! Data download appears corrupted !!!\")\n",
" else:\n",
" # If download is successful and data is not corrupted, save the file\n",
" with open(fname, \"wb\") as fid:\n",
" fid.write(r.content) # Write the downloaded content to a file"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down

0 comments on commit c41d00c

Please sign in to comment.