RatInABox-Lab / RatInABox

A python package for modelling locomotion in complex environments and spatially/velocity selective cell activity.
MIT License
172 stars 31 forks source link

Small fixes and new warning for Neurons classes. #101

Closed colleenjg closed 5 months ago

colleenjg commented 5 months ago

Small fixes and new warning for Neurons classes.

Fixes:

New warning added:

New warning examples:

  1. In the simple case that applies to HeadDirectionCells in 1D environments and to SpeedCell, if you run something like:
    
    from ratinabox import Agent, Environment, SpeedCell

Env = Environment(params={"objects": [[0.5, 0.5]]}) Ag = Agent(Env) SpeedCell(Ag, params={"n": 3})

you get: 

```UserWarning: Ignoring 'n' parameter value (3) that was passed for SpeedCell. Only 1 speed cell is needed.```

2. In the slightly more complex case that applies to `VectorCells` and its child classes, if you run something like

from ratinabox import Agent, Environment, FieldOfViewOVCs

Env = Environment(params={"objects": [[0.5, 0.5]]}) Ag = Agent(Env)

FieldOfViewOVCs(Ag, params={"object_tuning_type": "random", "cell_arrangement": "diverging_manifold"}) FieldOfViewOVCs(Ag, params={"object_tuning_type": "random", "cell_arrangement": "random", "n":10})

then there's no warning. In the first case, because you didn't specify an `n` value [1] and in the second case, because the `n` value is not changed. 

However, if you run 

from ratinabox import Agent, Environment, FieldOfViewOVCs

Env = Environment(params={"objects": [[0.5, 0.5]]}) Ag = Agent(Env) FieldOfViewOVCs(Ag, params={"object_tuning_type": "random", "cell_arrangement": "diverging_manifold", "n": 10})


you get: 

```UserWarning: Ignoring 'n' parameter value (10) that was passed, and setting number of ObjectVectorCell neurons to 58, inferred from the cell arrangement parameter.```

[1] To ensure that no superfluous warning is produced in this case, I had to create an extra attribute `_warn_n_change` that can be set in a child class. This allows the init of `VectorCells` to know whether `n` was actively passed by the user or was added to `params` at some point during the initialization chain (e.g., from a child class' default parameters). 
TomGeorge1234 commented 5 months ago

Enormous thanks, as per, for your work on this!