babbush / HistoricalFermiLib

This is repo where we developed FermiLib, which then became OpenFermion
Apache License 2.0
1 stars 0 forks source link

Move code into fermilib package dir and fix imports #64

Closed maffoo closed 7 years ago

maffoo commented 7 years ago

This moves the code into the src/fermilib directory. To use the package from src, you'll need to add the src/ directory to your python path (or virtualenv). I also fixed up the imports to work now that all the modules are part of the fermilib package from python's perspective. I added a

from __future__ import absolute_import

directive to ensure that import behavior is consistent between python 2 and python 3. Also, I rearranged imports by grouping imports from the standard library, then 3rd party libraries, and finally fermilib. I also had to move a few imports to break some circular dependencies, in particular in places where different operator types can interconvert (e.g. fermion_operators <-> qubit_operators). In these cases, I moved the relevant imports into the conversion functions themselves.

Fixes #26

babbush commented 7 years ago

@maffoo Where do you suggest we have the default directory for the user's chemistry data? Basically, when FermiLib runs electronic structure calculations it stores them in a default location that is the first place the code looks when trying to load them. Right now the directory is data, which is in the FermiLib root directory. Should we keep that folder in this location? When I run the precommit tests right now it breaks because the file structure changes broke the code that points to the data directory.

maffoo commented 7 years ago

I would suggest having the code create a folder in the user's home directory to store data like this, for example it could go in ~/.fermilib/data (os.path.join(os.path.expanduser('~'), '.fermilib', 'data')). We should avoid putting this in the same location as the source code itself because often when installed the code will be in a site packages directory that is only writeable by root. This location could be configurable to allow people to store such data somewhere else if they want to (though note that the existing config system will probably need to change for the same reason: it won't generally be possible, or at least not easy, to edit a config.py file in the fermilib package after it has been installed).