Skip to content

Commit

Permalink
solvoing jupyter conflicts, it seems like the ruff routine is doing w…
Browse files Browse the repository at this point in the history
…eird things to the jupyter
  • Loading branch information
rodrigcd committed Oct 15, 2024
2 parents d3540a4 + 24be1d0 commit cdbbd98
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ repos:
- id: trailing-whitespace
exclude: 'README.md'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
rev: v0.6.3
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.8.0
hooks:
- id: black
21 changes: 8 additions & 13 deletions examples/agent_examples/stachenfeld_2018_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@
"outputs": [],
"source": [
"import sys\n",
"import numpy as np\n",
"import random\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from scipy.stats import multivariate_normal\n",
"from tqdm.notebook import tqdm\n",
"from neuralplayground.arenas import Simple2D, MergingRoom, Sargolini2006, Hafting2008, BasicSargolini2006,Wernle2018\n",
"from neuralplayground.utils import create_circular_wall\n",
"from neuralplayground.agents import Stachenfeld2018\n"
"\n",
"from neuralplayground.agents import Stachenfeld2018\n",
"from neuralplayground.arenas import Hafting2008, MergingRoom, Sargolini2006, Simple2D, Wernle2018\n",
"from neuralplayground.utils import create_circular_wall\n"
]
},
{
Expand Down Expand Up @@ -2311,17 +2310,13 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.append(\"../\")\n",
"import numpy as np\n",
"import random\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from scipy.stats import multivariate_normal\n",
"from tqdm import tqdm\n",
"from neuralplayground.arenas import Simple2D, MergingRoom, Sargolini2006, Hafting2008, BasicSargolini2006,Wernle2018\n",
"from neuralplayground.utils import create_circular_wall\n",
"from neuralplayground.agents import Stachenfeld2018"
"\n",
"from neuralplayground.agents import Stachenfeld2018\n",
"from neuralplayground.arenas import Hafting2008, MergingRoom, Sargolini2006, Simple2D"
]
},
{
Expand Down
17 changes: 9 additions & 8 deletions examples/agent_examples/weber_2018_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@
}
],
"source": [
"from IPython.display import display, HTML\n",
"from IPython.display import HTML, display\n",
"\n",
"display(HTML(\"<style>.container { width:80% !important; }</style>\"))\n",
"import sys\n",
"from tqdm.notebook import tqdm\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from neuralplayground.arenas import Simple2D, MergingRoom, Sargolini2006, Hafting2008, BasicSargolini2006,Wernle2018\n",
"from neuralplayground.agents import Weber2018, RandomAgent, LevyFlightAgent\n",
"from neuralplayground.experiments import Wernle2018Data\n",
"from neuralplayground.arenas import Simple2D,Wernle2018, MergingRoom"
"import numpy as np\n",
"from tqdm.notebook import tqdm\n",
"\n",
"from neuralplayground.agents import Weber2018\n",
"from neuralplayground.arenas import MergingRoom, Sargolini2006, Simple2D\n",
"from neuralplayground.experiments import Wernle2018Data"
]
},
{
Expand Down Expand Up @@ -1309,6 +1309,7 @@
],
"source": [
"from neuralplayground.comparison import GridScorer\n",
"\n",
"r_out_im=agent.get_rate_map_matrix()\n",
"GridScorer_Stachenfeld2018 = GridScorer(agent.resolution_width)\n",
"GridScorer_Stachenfeld2018.plot_grid_score(r_out_im=r_out_im, plot= True)\n",
Expand Down
10 changes: 5 additions & 5 deletions examples/agent_examples/whittington_2020_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
"import importlib\n",
"import os\n",
"import pickle\n",
"\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import neuralplayground.agents.whittington_2020_extras.whittington_2020_analyse as analyse\n",
"from neuralplayground.plotting import PlotSim\n",
"from neuralplayground.comparison import GridScorer"
"from neuralplayground.comparison import GridScorer\n",
"from neuralplayground.plotting import PlotSim"
]
},
{
Expand All @@ -56,6 +55,7 @@
"source": [
"simulation_id = \"TEM_custom_plot_sim\"\n",
"from neuralplayground.saved_models import fetch_model_path\n",
"\n",
"save_path = fetch_model_path(\"whittington_2020_in_discritized_objects\")\n",
"print('save_path')\n",
"plotting_loop_params = {\"n_episode\": 5000}"
Expand Down Expand Up @@ -475,7 +475,7 @@
}
],
"source": [
"agent.plot_rate_map(rate_map_type='g');\n",
"agent.plot_rate_map(rate_map_type='g')\n",
"agent.plot_rate_map(rate_map_type='p');"
]
},
Expand Down
18 changes: 9 additions & 9 deletions examples/arena_examples/arena_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
}
],
"source": [
"from IPython.display import display, HTML\n",
"from IPython.display import HTML, display\n",
"\n",
"display(HTML(\"<style>.container { width:80% !important; }</style>\"))\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
"import matplotlib.pyplot as plt\n",
"import numpy as np"
]
},
{
Expand All @@ -61,7 +62,7 @@
"metadata": {},
"outputs": [],
"source": [
"from neuralplayground.arenas import Simple2D, ConnectedRooms"
"from neuralplayground.arenas import ConnectedRooms, Simple2D"
]
},
{
Expand Down Expand Up @@ -97,7 +98,8 @@
"metadata": {},
"outputs": [],
"source": [
"from neuralplayground.agents import RandomAgent, LevyFlightAgent, RatMovementAgent\n",
"from neuralplayground.agents import RatMovementAgent\n",
"\n",
"# Random agent generates a brownian motion. Levy flight is still experimental.\n",
"# agent = LevyFlightAgent(step_size=0.8, scale=2.0, loc=0.0, beta=1.0, alpha=0.5, max_action_size=100)\n",
"agent = RatMovementAgent(step_size=1.0, room_width=room_width, room_depth=room_depth)"
Expand Down Expand Up @@ -444,7 +446,7 @@
"metadata": {},
"outputs": [],
"source": [
"from neuralplayground.arenas import BatchEnvironment, Simple2D, DiscreteObjectEnvironment\n",
"from neuralplayground.arenas import BatchEnvironment, Simple2D\n",
"from neuralplayground.experiments import Sargolini2006Data"
]
},
Expand Down Expand Up @@ -538,9 +540,7 @@
"metadata": {},
"outputs": [],
"source": [
"from neuralplayground.arenas import Sargolini2006\n",
"from neuralplayground.arenas import Hafting2008\n",
"from neuralplayground.arenas import Wernle2018"
"from neuralplayground.arenas import Hafting2008, Sargolini2006, Wernle2018"
]
},
{
Expand Down
11 changes: 6 additions & 5 deletions examples/colab_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"metadata": {},
"outputs": [],
"source": [
"import neuralplayground\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from tqdm import tqdm"
Expand Down Expand Up @@ -302,7 +301,7 @@
"metadata": {},
"outputs": [],
"source": [
"from neuralplayground.arenas import Simple2D, ConnectedRooms"
"from neuralplayground.arenas import Simple2D"
]
},
{
Expand All @@ -311,7 +310,8 @@
"metadata": {},
"outputs": [],
"source": [
"from neuralplayground.agents import RandomAgent, LevyFlightAgent\n",
"from neuralplayground.agents import LevyFlightAgent\n",
"\n",
"# Random agent generates a brownian motion. Levy flight is still experimental.\n",
"agent = LevyFlightAgent(step_size=0.8, scale=2.0, loc=0.0, beta=1.0, alpha=0.5, max_action_size=100)"
]
Expand Down Expand Up @@ -541,10 +541,11 @@
"metadata": {},
"outputs": [],
"source": [
"from neuralplayground.saved_models import fetch_model_path\n",
"import pandas as pd\n",
"\n",
"from neuralplayground.comparison import GridScorer\n",
"from neuralplayground.plotting.plot_utils import make_plot_trajectories , make_plot_rate_map, make_agent_comparison"
"from neuralplayground.plotting.plot_utils import make_agent_comparison\n",
"from neuralplayground.saved_models import fetch_model_path"
]
},
{
Expand Down
26 changes: 12 additions & 14 deletions examples/comparisons_examples/comparison_board.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@
}
],
"source": [
"from IPython.display import display, HTML\n",
"from IPython.display import HTML, display\n",
"\n",
"display(HTML(\"<style>.container { width:80% !important; }</style>\"))\n",
"import numpy as np\n",
"from tqdm.notebook import tqdm\n",
"import pandas as pd\n",
"import os\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from tqdm.notebook import tqdm\n",
"\n",
"from neuralplayground.experiments import Wernle2018Data, Hafting2008Data, Sargolini2006Data\n",
"from neuralplayground.agents import Stachenfeld2018, Weber2018\n",
"from neuralplayground.arenas import MergingRoom, Simple2D\n",
"from neuralplayground.comparison import GridScorer\n",
"from neuralplayground.arenas import Simple2D, ConnectedRooms,Wernle2018, MergingRoom, Sargolini2006\n",
"from neuralplayground.agents import Weber2018, Stachenfeld2018\n",
"from neuralplayground.experiments import Wernle2018Data, Hafting2008Data\n",
"from neuralplayground.saved_models import fetch_model_path\n",
"from neuralplayground.plotting.plot_utils import make_plot_trajectories , make_plot_rate_map, make_agent_comparison"
"from neuralplayground.experiments import Sargolini2006Data, Wernle2018Data\n",
"from neuralplayground.plotting.plot_utils import make_agent_comparison\n",
"from neuralplayground.saved_models import fetch_model_path"
]
},
{
Expand Down Expand Up @@ -295,10 +296,7 @@
}
],
"source": [
"from neuralplayground.agents import Stachenfeld2018, Weber2018\n",
"from neuralplayground.arenas import Simple2D, MergingRoom, Sargolini2006, Hafting2008, BasicSargolini2006,Wernle2018\n",
"from neuralplayground.backend import default_training_loop, episode_based_training_loop\n",
"\n",
"from neuralplayground.backend import episode_based_training_loop\n",
"\n",
"stachenfeld_in_2d_params = {\n",
" \"simulation_id\": \"stachenfeld_2018_in_simple2D\",\n",
Expand Down
26 changes: 13 additions & 13 deletions examples/comparisons_examples/comparison_examples_score.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from tqdm.notebook import tqdm\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from neuralplayground.arenas import Wernle2018, MergingRoom, Sargolini2006, Simple2D, BasicSargolini2006,Hafting2008\n",
"from neuralplayground.agents import Weber2018, Stachenfeld2018, RandomAgent, LevyFlightAgent\n",
"from neuralplayground.experiments import Wernle2018Data, Hafting2008Data, Sargolini2006Data\n",
"from neuralplayground.comparison import GridScorer\n"
"from tqdm.notebook import tqdm\n",
"\n",
"from neuralplayground.agents import Stachenfeld2018, Weber2018\n",
"from neuralplayground.arenas import Hafting2008, Sargolini2006, Simple2D, Wernle2018\n",
"from neuralplayground.comparison import GridScorer\n",
"from neuralplayground.experiments import Hafting2008Data, Sargolini2006Data, Wernle2018Data\n"
]
},
{
Expand All @@ -62,7 +61,8 @@
}
],
"source": [
"from IPython.display import display, HTML\n",
"from IPython.display import HTML, display\n",
"\n",
"display(HTML(\"<style>.container { width:80% !important; }</style>\"))"
]
},
Expand Down Expand Up @@ -1259,10 +1259,9 @@
"import importlib\n",
"import os\n",
"import pickle\n",
"\n",
"import pandas as pd\n",
"import torch\n",
"import matplotlib.pyplot as plt\n",
"import neuralplayground.agents.whittington_2020_extras.whittington_2020_analyse as analyse\n",
"\n",
"from neuralplayground.plotting import PlotSim"
]
},
Expand All @@ -1274,6 +1273,7 @@
"source": [
"simulation_id = \"TEM_custom_plot_sim\"\n",
"from neuralplayground.saved_models import fetch_model_path\n",
"\n",
"save_path = fetch_model_path(\"whittington_2020_in_discritized_objects\")\n",
"plotting_loop_params = {\"n_episode\": 5000}"
]
Expand Down Expand Up @@ -1636,8 +1636,8 @@
"del training_dict[\"agent_params\"]\n",
"agent = training_dict[\"agent_class\"](**training_dict[\"params\"])\n",
"agent.plot_run(tem, model_input, environments)\n",
"agent.plot_rate_map(rate_map_type='g');\n",
"agent.plot_rate_map(rate_map_type='p');\n",
"agent.plot_rate_map(rate_map_type='g')\n",
"agent.plot_rate_map(rate_map_type='p')\n",
"rate_map_mat = agent.get_rate_map_matrix(agent.g_rates,1,2)\n",
"GridScorer = GridScorer(rate_map_mat.shape[0])\n",
"GridScorer.plot_grid_score(r_out_im = rate_map_mat, plot= True)\n",
Expand Down
22 changes: 9 additions & 13 deletions examples/comparisons_examples/comparison_from_manager.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@
}
],
"source": [
"from IPython.display import display, HTML\n",
"from IPython.display import HTML, display\n",
"\n",
"display(HTML(\"<style>.container { width:80% !important; }</style>\"))\n",
"import numpy as np\n",
"from tqdm.notebook import tqdm\n",
"import pandas as pd\n",
"from neuralplayground.experiments import Wernle2018Data, Hafting2008Data, Sargolini2006Data\n",
"\n",
"from neuralplayground.agents import Stachenfeld2018\n",
"from neuralplayground.arenas import Simple2D\n",
"from neuralplayground.comparison import GridScorer\n",
"from neuralplayground.arenas import Simple2D, ConnectedRooms,Wernle2018, MergingRoom, Sargolini2006\n",
"from neuralplayground.agents import Weber2018, Stachenfeld2018\n",
"from neuralplayground.experiments import Wernle2018Data, Hafting2008Data\n",
"from neuralplayground.saved_models import fetch_model_path\n",
"from neuralplayground.plotting.plot_utils import make_plot_trajectories, make_plot_rate_map, make_agent_comparison"
"from neuralplayground.experiments import Sargolini2006Data\n",
"from neuralplayground.plotting.plot_utils import make_agent_comparison\n",
"from neuralplayground.saved_models import fetch_model_path"
]
},
{
Expand Down Expand Up @@ -770,10 +769,7 @@
}
],
"source": [
"from neuralplayground.agents import Stachenfeld2018\n",
"from neuralplayground.arenas import Simple2D, MergingRoom, Sargolini2006, Hafting2008, BasicSargolini2006,Wernle2018\n",
"from neuralplayground.backend import default_training_loop, episode_based_training_loop\n",
"\n",
"from neuralplayground.backend import episode_based_training_loop\n",
"\n",
"stachenfeld_in_2d_params = {\n",
" \"simulation_id\": \"stachenfeld_2018_in_simple2D\",\n",
Expand Down
7 changes: 3 additions & 4 deletions examples/comparisons_examples/simulation_manager.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"\n",
"from neuralplayground.agents import Stachenfeld2018\n",
"from neuralplayground.arenas import Simple2D\n",
"from neuralplayground.backend import episode_based_training_loop\n",
"from neuralplayground.backend import SingleSim"
"from neuralplayground.backend import SingleSim, episode_based_training_loop"
]
},
{
Expand Down Expand Up @@ -449,8 +448,8 @@
"metadata": {},
"outputs": [],
"source": [
"from neuralplayground.backend.default_simulation import stachenfeld_in_2d\n",
"from neuralplayground.backend import SimulationManager"
"from neuralplayground.backend import SimulationManager\n",
"from neuralplayground.backend.default_simulation import stachenfeld_in_2d"
]
},
{
Expand Down
Loading

0 comments on commit cdbbd98

Please sign in to comment.