RatInABox-Lab / RatInABox

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

Package structuring #55

Closed TomGeorge1234 closed 9 months ago

TomGeorge1234 commented 1 year ago

Long run we will probably look to changing the package structure of ratinabox so that Environments Agents and Neurons are modules. Each module should contain its one contribs folder (tidier this way rather than one global contribs containing loads of stuff). The package structure will eventually look something like this:

├── demos
├── dist
├── figures
└── ratinabox
    ├── README.md
    ├── __init__.py
    ├── Environments
    │   ├── __init__.py
    │   ├── Environment.py
    │   ├── SubEnvironment.py
    │   └── contribs
    ├── Agents
    │   ├── __init__.py
    │   ├── Agent.py
    │   ├── SubAgent.py
    │   └── contribs
    ├── Neurons
    │   ├── __init__.py
    │   ├── Neurons.py
    │   ├── PlaceCells.py
    │   ├── GridCells.py
    │   ├── ...
    │   └── contribs
    ├── data
    └── utils.py
mehulrastogi commented 1 year ago

I guess there are many ways to structure the python packages as there is not strict rule that python does follow. But I do particularly like the following article and a stack over flow answer:-

According to which we can structure the project in the following way :-

├── README.md
├── LICENSE.md
├── demos
├── dist
├── figures
└── ratinabox  
    ├── __init__.py
    ├── Environments
    │   ├── __init__.py
    │   ├── Environment.py
    │   ├── SubEnvironment.py
    │   └── contribs
    ├── Agents
    │   ├── __init__.py
    │   ├── Agent.py
    │   ├── SubAgent.py
    │   └── contribs
    ├── Neurons
    │   ├── __init__.py
    │   ├── Neurons.py
    │   ├── PlaceCells.py
    │   ├── GridCells.py
    │   ├── ...
    │   └── contribs
    ├── data
    └── utils.py
└── .gitignore

What do you think?

mehulrastogi commented 1 year ago

I guess there are many ways to structure the python packages as there is not strict rule that python does follow. But I do particularly like the following article and a stack over flow answer:-

* https://stackoverflow.com/a/19871661

* https://dev.to/codemouse92/dead-simple-python-project-structure-and-imports-38c6

According to which we can structure the project in the following way :-

├── README.md
├── LICENSE.md
├── demos
├── dist
├── figures
└── ratinabox  
    ├── __init__.py
    ├── Environments
    │   ├── __init__.py
    │   ├── Environment.py
    │   ├── SubEnvironment.py
    │   └── contribs
    ├── Agents
    │   ├── __init__.py
    │   ├── Agent.py
    │   ├── SubAgent.py
    │   └── contribs
    ├── Neurons
    │   ├── __init__.py
    │   ├── Neurons.py
    │   ├── PlaceCells.py
    │   ├── GridCells.py
    │   ├── ...
    │   └── contribs
    ├── data
    └── utils.py
└── .gitignore

What do you think?

The top level can also have the requirements.py , setup.py, ...

TomGeorge1234 commented 1 year ago

I can't quite tell the difference between this and what I put in the first one. But looks good to me, I agree

TomGeorge1234 commented 1 year ago

Closing and continuing discussion on PR #58

TomGeorge1234 commented 1 year ago

Just linking this to #64 re changing module names to lower-case to avoid import problems.

TomGeorge1234 commented 1 year ago

This could be backwards compatible if in each __init__ we import cells and list them in __all__ = PlaceCells, GridCells,...

TomGeorge1234 commented 11 months ago

Updated design:

├── README.md
├── LICENSE.md
├── .gitignore
├── demos
├── dist
├── figures
└── ratinabox  
    ├── __init__.py
    ├── ends
    │   ├── __init__.py
    │   ├── Environment.py
    │   ├── SubEnvironment.py
    │   └── contribs
    ├── agents
    │   ├── __init__.py
    │   ├── Agent.py
    │   ├── SubAgent.py
    │   └── contribs
    ├── neurons
    │   ├── __init__.py
    │   ├── Neurons.py
    │   ├── PlaceCells.py
    │   ├── GridCells.py
    │   ├── ...
    │   └── contribs
    ├── data
    └── utils.py
TomGeorge1234 commented 9 months ago

closing this for now