image renamed to _image
This commit is contained in:
parent
39f54825f8
commit
ddecf5f697
|
@ -2,21 +2,9 @@
|
|||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "NameError",
|
||||
"evalue": "name 'String' is not defined",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[1;32m/home/lillian/Coding/jupyter/assignment.ipynb Cell 1\u001b[0m line \u001b[0;36m7\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=68'>69</a>\u001b[0m \u001b[39mfor\u001b[39;00m cat \u001b[39min\u001b[39;00m cat_json:\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=69'>70</a>\u001b[0m \u001b[39myield\u001b[39;00m Cat(\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=70'>71</a>\u001b[0m cat\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39mid\u001b[39m\u001b[39m\"\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=71'>72</a>\u001b[0m cat\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39murl\u001b[39m\u001b[39m\"\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=72'>73</a>\u001b[0m cat\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39mwidth\u001b[39m\u001b[39m\"\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=73'>74</a>\u001b[0m cat\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39mheight\u001b[39m\u001b[39m\"\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=74'>75</a>\u001b[0m )\n\u001b[0;32m---> <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=77'>78</a>\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mget_cat_image\u001b[39m(url: String) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m Image:\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=78'>79</a>\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"Fetch an image url of the cat provided, returns an image file.\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=79'>80</a>\u001b[0m \n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=80'>81</a>\u001b[0m \u001b[39m Args:\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=84'>85</a>\u001b[0m \u001b[39m Image: An image file parsed with the PIL library, read from a bytestream from the cats API.\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=85'>86</a>\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/lillian/Coding/jupyter/assignment.ipynb#W0sZmlsZQ%3D%3D?line=86'>87</a>\u001b[0m cr \u001b[39m=\u001b[39m requests\u001b[39m.\u001b[39mget(url)\n",
|
||||
"\u001b[0;31mNameError\u001b[0m: name 'String' is not defined"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from collections.abc import Generator\n",
|
||||
"from io import BytesIO\n",
|
||||
|
@ -41,9 +29,9 @@
|
|||
" Returns:\n",
|
||||
" Image: Image object that has been edited by the crop function.\n",
|
||||
" \"\"\"\n",
|
||||
" if (self.width, self.height) != self.image.size:\n",
|
||||
" return self.image.resize((self.width, self.height))\n",
|
||||
" return self.image\n",
|
||||
" if (self.width, self.height) != self._image.size:\n",
|
||||
" return self._image.resize((self.width, self.height))\n",
|
||||
" return self._image\n",
|
||||
"\n",
|
||||
" def save_image(self, path: str) -> bool:\n",
|
||||
" \"\"\"Save image in cat to disk\n",
|
||||
|
|
Loading…
Reference in a new issue