Comments (8)
Interesting. I see the problem. i could rename the module but I'd rather not. Seems worth fixing but I don't know the most standard way to fix this. Anyone?
from ratinabox.
Workaround:
>>> import importlib
>>> importlib.import_module("ratinabox.Neurons")
<module 'ratinabox.Neurons' from '/Users/pierreglaser/.local/miniforge/envs/ratinabox/lib/python3.9/site-packages/ratinabox/Neurons.py'>
To avoid having to use importlib
, consider removing star-imports from __init__.py
.
from ratinabox.
thanks @pierreglaser.
It's coming back to me now, I added star-imports because I briefly wanted things like
from ratinabox import *
Env = Environment()
but I never adopted this import style and don't think anyone else has either. I just removed them in latest push.
from ratinabox.
Thanks @pierreglaser for the workaround. I'll test it out.
Quick note: @TomGeorge1234, removing the * imports is likely to cause a big impact on everyone's repos, as it should break all imports of any Agent, Env or Neuron classes. Just want to check that that is the intention.
Clarification: I omitted to clarify that although the * imports cause the problem described above in the dev
branch, in the v2_beta
branch, from ratinabox.env.Environment import Environment
in ratinabox/env/__init__.py
, for example, has the same effect. It overwrites the module with the class, in the attributes of ratinabox.env
.
I see a lot of packages that use this type of import in the inits to make imports less deep - I do think that's fine. Where it fails is where the class and file names also match exactly. The most standard fix is probably to rename the modules to lowercase, as mentioned above. This would also align the package with PEP 8 guidelines, where modules have short, all-lowercase names, with underscores if needed, and classes are named in CapWords, as you've done.
Is there a particular reason you don't want to rename the modules? Unless I've overlooked something, changing their names shouldn't break the code for most users, given that the current import convention has been overwriting the modules in the namespace anyway.
from ratinabox.
Clarification: The removal of the star imports will break current users' imports if they were using import ratinabox
, but not if they were using, like you were, from ratinabox.Environment import Environment
.
from ratinabox.
So, to be fair, the change of the module names would break imports for people who have been using from ratinabox.Environment import Environment
. Which is why, if this name convention change were adopted, I do think it would be best as part of the overall refactor.
from ratinabox.
Re quick note
Yeah, it shouldn't break if people do
import ratinabox
from ratinabox.Environment import Environment
from ratinabox.Agent import Agent
from ratinabox.Neurons import PlaceCells, GridCells #...
which I assume is essentially everyone. But if you're okay with the workaround I'll put back the star import (just to be safe) and add it to the refactor down the line.
Re clarification
Yeh so I definitely can't change the module names in RiaB1.x. For 2.0 I agree and will rename Environment.py
---> environment.py
, PlaceCells.py
---> placecells.py
etc. which should fix this issues and align with PEP8. Thanks for the heads up!
from ratinabox.
That's right - removing the star import would only break imports if they were doing from ratinabox import Environment, Agent, Neurons
. I think since no one else appears to have encountered the issue I reported here, I agree - I think it's fine to keep the star import for now, and address this in the refactor!
from ratinabox.
Related Issues (20)
- Small bug relating to PR #101 HOT 1
- history not loaded when importing trajectory HOT 3
- New python version bug HOT 2
- Modules of grid cells with uniform offsets HOT 1
- add error checking to parameter settings HOT 2
- Firingrate norm for BVCs should be unscaled HOT 2
- BVC firingrates go over max_fr HOT 9
- Confused about setting multiple spatial goals in the A2C demo HOT 4
- straight trajectory with fixed speed mean, but Ag.history['vel'] is not constant HOT 5
- Spikes are sliced twice consecutively when plotting timeseries. HOT 2
- Please tag the 1.9.1 release HOT 2
- Minimum required python version currently 3.10 HOT 2
- Agent vector cells HOT 1
- New Actions HOT 3
- AgentVectorCells and FieldOfViewAVCs HOT 3
- Version mismatch in 1.11.0 metadata HOT 1
- Open discussion: Object disappear after Agent passes by HOT 3
- Name swap...
- Speed and place cells HOT 13
- "I" not updated in FeedForward Neurons HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ratinabox.