diff --git a/.circleci/config.yml b/.circleci/config.yml index 488672680..3dac54714 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ default_job: &default_job - checkout - run: name: Install Python dependencies - command: python3.8 -m pip install -r requirements.txt + command: python3.8 -m pip install -r requirements/dev.txt - run: name: Configure command: | @@ -89,7 +89,7 @@ jobs: - checkout - run: name: Install Python dependencies - command: python3.8 -m pip install -r requirements.txt + command: python3.8 -m pip install -r requirements/doc.txt - run: name: Configure command: | @@ -119,7 +119,7 @@ jobs: - checkout - run: name: Install Python dependencies - command: python3.8 -m pip install -r requirements.txt + command: python3.8 -m pip install -r requirements/dev.txt - run: name: Configure command: | @@ -138,7 +138,7 @@ jobs: - checkout - run: name: Install Python dependencies - command: python3.8 -m pip install -r requirements.txt + command: python3.8 -m pip install -r requirements/dev.txt - run: name: Configure command: | @@ -160,7 +160,7 @@ jobs: - run: name: Install Python dependencies command: | - python3.8 -m pip install -r requirements.txt + python3.8 -m pip install -r requirements/dev.txt python3.8 -m pip install codecov coverage - run: name: Configure @@ -199,7 +199,7 @@ jobs: - checkout - run: name: Install Python dependencies - command: python3.8 -m pip install -r requirements.txt + command: python3.8 -m pip install -r requirements/tests.txt - run: name: Configure command: | diff --git a/AUTHORS.txt b/AUTHORS.txt new file mode 100644 index 000000000..834f852af --- /dev/null +++ b/AUTHORS.txt @@ -0,0 +1,18 @@ +Michele Ceriotti +Rose K. Cersonsky +Guillaume Fraux +Federico Giberti +Lorenzo Gigli +Klim Goldshtein +Alexander Goscinski +Andrea Grisafi +Ben A. Helfrecht +Kevin K. Huguenin-Dumittan +Giulio Imbalzano +Till Junge +Chiheb B. Mahmoud +Félix Musil +Jigyasa Nigam +Markus Stricker +Max Veit +Michael J. Willatt diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index c6f7495ae..7ac1d09ae 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,52 +1,58 @@ -Contributing to libRascal -------------------------- +Contributing to librascal +******************************************************************************** -Thank you for contributing to libRascal! To make sure your pull request gets +Thank you for contributing to libRascal! To make sure your pull request gets accepted with a minimum of hassle for everyone involved, please make sure first -and foremost that you've read the ``README`` [*]_, especially the section -entitled "Helpers for Developers", which contains details on the formatting -functions that you should run on your code before sending a pull request for -review. (Note that the use of auto-formatters isn't mandatory, but your code -*must* pass the various linters that are run with ``make lint``; this is part of -the automated CI build. Any code that has been auto-formatted should pass the -linters; please open an issue if this is not the case for your code). If the -linter fails on your code, the pull request will be sent back for revision -without any further comments. +and foremost that you've read the ``README`` (You'd think this would be obvious, +but far too many people ignore ``README``\ s in practice). It is also a good +idea to browse the `developer's guide +`_, especially +the `coding conventions +`_ for +C++ code (Python code generally follows PEP 8). + -It is also a good idea to browse the -`developer's guide `_, -especially the -`coding conventions `_ -for C++ code (Python code generally follows PEP 8). +Development dependencies +================================================================================ -We now have a pull request template; please use it (especially for new -features)! In particular, make sure you've checked off all the items listed -under "Tasks before review". If you haven't been able to complete all these -tasks, then your code isn't ready for review; consider submitting a "Draft pull -request" instead (or waiting to request reviewers). +All python packages required for development (including all python dependencies +of the librascal project) can be installed with + +.. code:: shell + + pip install -r requirements/dev.txt -.. [*] You'd think this would be obvious, but far too many people ignore - ``README``\ s in practice Summary of the review process -=============================== +================================================================================ + +We have a pull request template; please use it (especially for new features)! In +particular, make sure you've checked off all the items listed under "Tasks +before review". If you haven't been able to complete all these tasks, then your +code isn't ready for review; consider submitting a "Draft pull request" instead +(or waiting to request reviewers). -A detailed description can be found in a separate document about the `review -process `_ +A detailed description of the review process can be found in a separate document +about the `review process +`_. Here +is a short summary of the important points: For developers + * We want a clean and tested master branch, which is why we review code and use continuous integration tools. * Contact us if you have any questions. * Start the discussion about your contribution early by using the Draft-Pull-Request feature of Github. * Use our Pull-Request template in preparing your PR. - * Provide tests for the new/changed functionalities in the test suite of the library. + * Provide tests for the new/changed functionalities in the test suite of the + library. * Make sure your proposed changes pass the all existing tests, change (not deactivate) them if necessary. * Document your contribution. For reviewers + * The first person to make a full review is responsible for seeing it through. * Single line comments are ok, but consider a proper review. * If you started a review, you are responsible for seeing it through. @@ -55,30 +61,128 @@ For reviewers review you code. Jupyter Notebooks -================= +================================================================================ + -Please read the `README section `_ on this topic. -In general, avoid contributing -code in notebooks wherever possible. If you do have to commit notebooks to -version control, make sure you've installed the ``nbstripout`` extension and -that it works properly (i.e. you're not committing the output of notebook -cells). Any pull requests that include diffs of notebook outputs will be -sent back without further comments. The two exceptions to this rule are: +If you do have to commit notebooks to version control, make sure you've +installed the ``nbstripout`` extension (available on `github +`_ and `PyPI +`_) and that it works properly (i.e. +you're not committing the output of notebook cells). Any pull requests that +include diffs of notebook outputs will be sent back without further comments. +The two exceptions to this rule are: 1. Deleting existing, committed outputs (a rebase may be requested to prevent those outputs from making it into the history in the first place) 2. Stable outputs for example notebooks meant to be processed to HTML for the - `tutorials page `_. - "Stable" here means these are the final outputs meant to be shown to the - public and won't be changed unless errors or omissions are discovered, or the - tutorial is later updated or expanded. Note that tutorials that rely on - volatile code features should *not* have their outputs included, since in - that case the tutorials themselves aren't stable; instead, you should use the - auto-execution feature of ``nbsphinx`` (see - `here `_ - for details). + `tutorials page + `_. "Stable" + here means these are the final outputs meant to be shown to the public and + won't be changed unless errors or omissions are discovered, or the tutorial + is later updated or expanded. Note that tutorials that rely on volatile code + features should *not* have their outputs included, since in that case the + tutorials themselves aren't stable; instead, you should use the + auto-execution feature of ``nbsphinx`` (see `here + `_ for + details). + +Nonetheless, it is highly discouraged to contribute code in the form of +notebooks; even with filters like ``nbstripout`` they're a hassle to use in +version control. Use them only for comprehensive tutorials or *stable* examples +that are either meant to be run *interactively* or are meant to be processed by +`sphinx` (`nbsphinx `_) for +inclusion in the `introductive examples +`_. + +After installing ``nbstripout``, activate it for this project by running: + +.. code:: shell + + nbstripout --install --attributes .gitattributes + +from the top-level repository directory. Please note that that ``nbstripout`` +will not strip output from cells with the metadata fields ``keep_output`` or +``init_cell`` set to ``True``, so use these fields judiciously. You can ignore +these settings with the following command: + +.. code:: shell + + git config filter.nbstripout.extrakeys '\ + cell.metadata.keep_output cell.metadata.init_cell' + +(The keys ``metadata.kernel_spec.name`` and +``metadata.kernel_spec.display_name`` may also be useful to reduce diff noise.) Note also that ``nbstripout`` will not strip output from cells with the metadata -fields ``keep_output`` or ``init_cell`` set to ``True``. Please use these -fields judiciously. +fields ``keep_output`` or ``init_cell`` set to ``True``. Please use these fields +judiciously. + + +Developer tools +================================================================================ + +Tools to make life simpler for developers + +Deepclean +-------------------------------------------------------------------------------- + +To remove all the cmake files/folders except for the external libraries: + +.. code:: shell + + make deepclean + +Automatic code formatting +-------------------------------------------------------------------------------- + +To help developers conform their contribution to the coding convention, the +formatting of new functionalities can be automated using clang-format (for the +c++ files) and black (for the python files). The .clang-format and .pycodestyle +files define common settings to be used. + +To enable these functionalities (optional) you can install these tools with: + +.. code:: shell + + sudo apt-get install clang-format-8 + pip install black + +The automatic formatting of the c++ and python files can be triggered by: + +.. code:: shell + + cd build + cmake .. + make pretty-cpp + make pretty-python + + +Note that the use of auto-formatters isn't mandatory, but your code *must* pass +the various linters that are run with ``make lint``; this is part of the +automated CI build. Any code that has been auto-formatted should pass the +linters; please open an issue if this is not the case for your code. If the +linter fails on your code, the pull request will be sent back for revision +without any further comments. + +Please use these tools with caution as they can potentially introduce unwanted +changes to the code. If code needs to be specifically excluded from auto +formatting, e.g. a matrix which should be human-readable, code comments tells +the formatters to ignore lines: + +- C++ + + .. code:: C++ + + // clang-format off + SOME CODE TO IGNORE + // clang-format on + +- python + + .. code:: python + + SOME LINE TO IGNORE # noqa + + where ``noqa`` stands for ``no`` ``q``\ uality ``a``\ ssurance. + diff --git a/MANIFEST.in b/MANIFEST.in index 33260b680..30a8cf18f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include README.rst requirements_pip.txt CMakeLists.txt pyproject.toml +include README.rst AUTHORS.txt requirements/minimal.txt CMakeLists.txt pyproject.toml recursive-include src * recursive-include bindings * recursive-include cmake * diff --git a/README.rst b/README.rst index 4f0e8a458..96e8d1440 100644 --- a/README.rst +++ b/README.rst @@ -1,141 +1,106 @@ librascal -========= +******************************************************************************** .. start-intro -librascal is a versatile and scalable fingerprint and machine learning -code. It focuses on the efficient construction of representations of -atomic structures, that can then be fed to any supervised or -unsupervised learning algorithm. Simple regression code will be included -for testing purposes, but the long-term goal is to develop a separate -collection of tools to this end. - -librascal is currently considered a standalone code. However, we aim to -provide enough flexibility to interface it with other codes such as -LAMMPS and PLUMED-2.0. It can be used as a C++ library as well as a -python module. To be able to call it from python, we have used the -pybind11 library. - -Although at the moment is a serial-only code, we aim to write it in MPI -so that it will be possible to take advantage of parallelization to -speed up the calculations significantly. Parallelization is possible especially -over atoms in a structure (for large structures), over structures in a -collection (for large collections of small structures), or over components of a -representation (for representations with a large number of independent functions -or components). - -It comes with a GNU Lesser General Public License of version 3, which -means that it can be modified and freely distributed, although we take -no responsibility for its misuse. +librascal is a versatile and scalable fingerprint and machine learning code. It +focuses on the efficient construction of representations of atomic structures, +that can then be fed to any supervised or unsupervised learning algorithm. +Simple regression code will be included for testing purposes, but the long-term +goal is to develop a separate collection of tools to this end. + +The code is currently in the beta development phase, therefore we cannot +guarantee that the interface and data formats will not change, but it has been +in use for at least a year. Feedback and bug reports are welcome, as long as you +keep the above in mind. + +librascal is currently considered a standalone code. However, we aim to provide +enough flexibility to interface it with other codes such as LAMMPS and +PLUMED-2.0. It can be used as a C++ library as well as a python module. To be +able to call it from python, we have used the pybind11 library. + +Although at the moment is a serial-only code, we aim to write it in MPI so that +it will be possible to take advantage of parallelization to speed up the +calculations significantly. Parallelization is possible especially over atoms in +a structure (for large structures), over structures in a collection (for large +collections of small structures), or over components of a representation (for +representations with a large number of independent functions or components). + +It comes with a GNU Lesser General Public License of version 3, which means that +it can be modified and freely distributed, although we take no responsibility +for its misuse. For more information, have a look at the documentation_! .. _documentation: https://cosmo-epfl.github.io/librascal/ -Development ------------ - -The code is currently in the alpha development phase; it is not yet -suitable for public use. Nevertheless, there is a significant amount of -functionality (including two tutorials) currently working and available -to test if you’re feeling adventurous. Feedback and bug reports are -welcome, as long as you keep the above in mind. - .. end-intro -See `Helpers for Developers`_ below for some essential tools if you want to help -develop libRascal. Be sure to also read `CONTRIBUTING.rst `_ -if you plan on making a contribution. - -Installation ------------- - -.. start-install - -The installation of the library for python use can be done simply with: - -.. code:: bash - - pip install . - -assuming that `python` 3.5 (or higher) and `gcc` or `clang` are available. - Dependencies -~~~~~~~~~~~~ +================================================================================ -Before installing librascal, please make sure you have at least the -following packages installed: +Before installing librascal, please make sure you have at least the following +packages installed: +-------------+--------------------+ | Package | Required version | +=============+====================+ -| gcc (g++) | 4.9 or higher | -+-------------+--------------------+ -| clang | 4.0 or higher | -+-------------+--------------------+ -| cmake | 2.8 or higher | +| cmake | 3.1 or higher | +-------------+--------------------+ | python | 3.6 or higher | +-------------+--------------------+ -| numpy | 1.13 or higher | + +To compile the code it is necessary to have a C++ compiler supporting C++14. For +gcc and clang this corresponds to versions + +-------------+--------------------+ -| scipy | 1.4.0 or higher | +| Compiler | Required version | ++=============+====================+ +| gcc (g++) | 4.9 or higher | +-------------+--------------------+ -| ASE | 3.18 or higher | +| clang | 4.0 or higher | +-------------+--------------------+ -Other necessary packages (such as Eigen and PyBind11) are downloaded -automatically when compiling Rascal. +Other necessary packages Eigen, PyBind11 and wigxjpf are downloaded +automatically when compiling librascal. + + +Installation +================================================================================ + +.. start-install + +When the dependencies are met, the python package can be installed with: -The following packages are required for some optional features: +.. code:: bash + + pip install librascal + +For optional features we have python packages required for the optional +librascal features: +--------------------------+-------------+--------------------+ -| Feature | Package | Required version | +| Librascal feature | Package | Required version | +==========================+=============+====================+ | Feature compression | skcosmo | 0.1.0 or later | +--------------------------+-------------+--------------------+ | Rotational algebra | sympy | 1.4 or later | | (Clebsch-Gordan coeffs.) | | | +--------------------------+-------------+--------------------+ -| Building documentation | pandoc | (latest) | -+--------------------------+-------------+--------------------+ -| | sphinx | 2.1.2 or later | -+--------------------------+-------------+--------------------+ -| | breathe | 4.14.1 or later | -+--------------------------+-------------+--------------------+ -| | nbsphinx | 0.8.1 or later | -+--------------------------+-------------+--------------------+ - -Compiling -~~~~~~~~~ - -To compile the code it is necessary to have CMake 3.0 and a C++ compiler -supporting C++14. During the configuration, it will automatically try to -download the external libraries on which it depends: -- Eigen -- Pybind11 -- Boost (only the unit test framework library) -- Python3 - -And the following libraries to build the documentation: - -- Doxygen -- Sphinx -- Breathe - -Beware, Python3 is mandatory. The code won’t work with a Python version -older than 3. - -You can then use pip to install all python packages required for the usage -and development of rascal: +The dependencies for the optional features and the `introductive examples +`_ can be +installed with .. code:: bash - pip install -r requirements.txt + pip install -r requirements/common.txt + +Compiling +================================================================================ -To configure and compile the code with the default options, on \*nix -systems (Windows is not supported): +To configure and compile the code with the default options, on \*nix systems +(Windows is not supported): .. code:: shell @@ -145,19 +110,18 @@ systems (Windows is not supported): make Customizing the build -~~~~~~~~~~~~~~~~~~~~~ +-------------------------------------------------------------------------------- The library supports several alternative builds that have additional -dependencies. Note that the ``ncurses`` GUI for cmake (ccmake) is quite -helpful to customize the build options. +dependencies. Note that the ``ncurses`` GUI for cmake (ccmake) is quite helpful +to customize the build options. Tests -^^^^^ -Librascal source code is extensively tested (both c++ and python). -The BOOST unit_test_framework is required to build the tests (see -BOOST.md for further details on how to install the boost library). To -build and run the tests: + +Librascal source code is extensively tested (both c++ and python). The BOOST +unit_test_framework is required to build the tests (see BOOST.md for further +details on how to install the boost library). To build and run the tests: .. code:: shell @@ -169,20 +133,20 @@ build and run the tests: You can also run the tests with Valgrind (a memory-error checker) by passing ``-DRASCAL_TESTS_USE_VALGRIND=ON`` to ``cmake``. -In addition to testing the behaviour of the code, the test suite also check -for formatting compliance with clang-format 8.0 or higher and black packages -(these dependencies are optional). To install these dependencies on Ubuntu: +In addition to testing the behaviour of the code, the test suite also check for +formatting compliance with clang-format 8.0 or higher and black packages (these +dependencies are optional). To install these dependencies on Ubuntu: .. code:: shell sudo apt-get install clang-format-8 - pip3 install black + pip install -r requirements/testing.txt Build Type -^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Several build types are available Release (default), Debug and -RelWithDebInfo. To build an alternative mode +Several build types are available Release (default), Debug and RelWithDebInfo. +To build an alternative mode .. code:: shell @@ -201,15 +165,14 @@ Or make Documentation -^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The documentation relies on the sphinx (with nbsphinx and breathe -extensions), doxygen, pandoc, and graphviz -packages. To install them on ubuntu: +The documentation relies on the sphinx (with nbsphinx and breathe extensions), +doxygen, pandoc, and graphviz packages. To install them on ubuntu: .. code:: shell - pip3 install sphinx sphinx_rtd_theme breathe nbsphinx + pip install -r requirements/doc.txt sudo apt-get install pandoc doxygen graphviz Then to build the documentation run: @@ -220,14 +183,14 @@ Then to build the documentation run: cmake -DBUILD_DOC=ON .. make doc -and open :file:`build/docs/html/index.html` in a browser. +and open `build/docs/html/index.html` in a browser. Bindings -^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Librascal relies on the pybind11 library to automate the generation -of the python bindings which are built by default. Nevertheless, to -build only the c++ library: +Librascal relies on the pybind11 library to automate the generation of the +python bindings which are built by default. Nevertheless, to build only the c++ +library: .. code:: shell @@ -235,142 +198,9 @@ build only the c++ library: cmake -DBUILD_BINDINGS=OFF .. make -Installing rascal -^^^^^^^^^^^^^^^^^ -To install the python library with c++ bindings: - -.. code:: shell - - pip install . - - -Helpers for Developers -~~~~~~~~~~~~~~~~~~~~~~ - -Deepclean -^^^^^^^^^ - -To remove all the cmake files/folders except for the external -library (enable glob and remove): - -.. code:: shell - - shopt -s extglob - rm -fr -- !(external|third-party) - -Automatic code formatting -^^^^^^^^^^^^^^^^^^^^^^^^^ - -To help developers conform their contribution to the coding -convention, the formatting of new functionalities can be automated -using clang-format (for the c++ files) and black (for the -python files). The .clang-format and .pycodestyle files define -common settings to be used. - -To enable these functionalities (optional) you can install these -tools with: - -.. code:: shell - - sudo apt-get install clang-format - pip install black - -The automatic formatting of the c++ and python files can be -triggered by: - -.. code:: shell - - cd build - cmake .. - make pretty-cpp - make pretty-python - -Please use these tools with caution as they can potentially -introduce unwanted changes to the code. If code needs to be -specifically excluded from auto formatting, e.g. a matrix which -should be human-readable, code comments tells the formatters to -ignore lines: - -- C++ - - .. code:: C++ - - // clang-format off - SOME CODE TO IGNORE - // clang-format on - -- python - - .. code:: python - - SOME LINE TO IGNORE # noqa - - where ``noqa`` stands for ``no`` ``q``\ uality ``a``\ ssurance. - -Jupyter notebooks -^^^^^^^^^^^^^^^^^ - -If you are contributing any code in IPython/Jupyter notebooks, *please* -install the `nbstripout` extension (available e.g. on -`github `_ and -`PyPI `_). After installing, -activate it for this project by running: - -.. code:: shell - - nbstripout --install --attributes .gitattributes - -from the top-level repository directory. Please note that that -``nbstripout`` will not strip output from cells with the metadata fields -``keep_output`` or ``init_cell`` set to ``True``, so use these fields -judiciously. You can ignore these settings with the following command: - -.. code:: shell - - git config filter.nbstripout.extrakeys '\ - cell.metadata.keep_output cell.metadata.init_cell' - -(The keys ``metadata.kernel_spec.name`` and -``metadata.kernel_spec.display_name`` may also be useful to reduce diff -noise.) - -Nonetheless, it is highly discouraged to contribute code in the form of -notebooks; even with filters like ``nbstripout`` they're a hassle to use -in version control. Use them only for tutorials or *stable* examples that -are either meant to be run *interactively* or are meant to be processed by -`sphinx` (`nbsphinx `_) for -inclusion in the -`tutorials page `_. - -Miscellaneous Information -------------------------- - -- Common cmake flags: - - - -DCMAKE_CXX_COMPILER - - -DCMAKE_C_COMPILER - - -DCMAKE_BUILD_TYPE - - -DBUILD_BINDINGS - - -DINSTALL_PATH - - -DBUILD_DOC - - -DBUILD_TESTS - -- Special flags: - - - -DBUILD_BINDINGS: - - - ON (default) -> build python binding - - OFF -> does not build python binding - - - -DINSTALL_PATH: - - - empty (default) -> does not install in a custom folder - - custom string -> root path for the installation - - -To build librascal as a docker environment: - -.. code:: shell +Development +================================================================================ - sudo docker build -t test -f ./docker/install_env.dockerfile . - sudo docker run -it -v /path/to/repo/:/home/user/ test +Read the `CONTRIBUTING.rst +`_ if you +plan on making a contribution. diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index 64d9b94ba..07d74f52b 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -80,22 +80,22 @@ set_target_properties(_rascal PROPERTIES INSTALL_RPATH "${BINDNIGS_INSTALL_RPATH # Normal installation procedure # copy rascal folder in the python distribution -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/rascal" DESTINATION "${CMAKE_INSTALL_PREFIX}/bindings" +install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/librascal" DESTINATION "${CMAKE_INSTALL_PREFIX}/bindings" PATTERN "*__pycache__" EXCLUDE PATTERN "*.pyc" EXCLUDE PATTERN "*.so" EXCLUDE PATTERN "*.dylib" EXCLUDE ) -install(TARGETS _rascal DESTINATION "${CMAKE_INSTALL_PREFIX}/bindings/rascal/lib") +install(TARGETS _rascal DESTINATION "${CMAKE_INSTALL_PREFIX}/bindings/librascal/lib") # Copy the python wrappers in the build folder # Copy the resulting bindings lib in the python wrapper lib folder add_custom_target(copy_python_bindings ALL - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/rascal + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/librascal COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/rascal ${CMAKE_BINARY_DIR}/rascal + ${CMAKE_CURRENT_SOURCE_DIR}/librascal ${CMAKE_BINARY_DIR}/librascal COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_BINARY_DIR}/_rascal.* ${CMAKE_BINARY_DIR}/rascal/lib/ + ${CMAKE_CURRENT_BINARY_DIR}/_rascal.* ${CMAKE_BINARY_DIR}/librascal/lib/ DEPENDS _rascal COMMENT "Copying python bindings and libraries" ) diff --git a/bindings/rascal/__init__.py b/bindings/librascal/__init__.py similarity index 74% rename from bindings/rascal/__init__.py rename to bindings/librascal/__init__.py index 9627b0cc0..017475757 100644 --- a/bindings/rascal/__init__.py +++ b/bindings/librascal/__init__.py @@ -1,3 +1,3 @@ __all__ = ["lib", "representations", "utils", "neighbourlist"] -__version__ = "0.0.0" +__version__ = "0.1.0" diff --git a/bindings/rascal/lib/__init__.py b/bindings/librascal/lib/__init__.py similarity index 100% rename from bindings/rascal/lib/__init__.py rename to bindings/librascal/lib/__init__.py diff --git a/bindings/rascal/models/__init__.py b/bindings/librascal/models/__init__.py similarity index 100% rename from bindings/rascal/models/__init__.py rename to bindings/librascal/models/__init__.py diff --git a/bindings/rascal/models/asemd.py b/bindings/librascal/models/asemd.py similarity index 100% rename from bindings/rascal/models/asemd.py rename to bindings/librascal/models/asemd.py diff --git a/bindings/rascal/models/genericmd.py b/bindings/librascal/models/genericmd.py similarity index 100% rename from bindings/rascal/models/genericmd.py rename to bindings/librascal/models/genericmd.py diff --git a/bindings/rascal/models/kernels.py b/bindings/librascal/models/kernels.py similarity index 99% rename from bindings/rascal/models/kernels.py rename to bindings/librascal/models/kernels.py index 96801794d..ceeee1d27 100644 --- a/bindings/rascal/models/kernels.py +++ b/bindings/librascal/models/kernels.py @@ -45,7 +45,7 @@ class Kernel(BaseIO): sparse kernels [1]_, we refer to the pseudo points with 'M'. So a kernel between the training samples and the pseudo points is 'KNM'. For more information on sparse kernels see - :meth:`rascal.models.krr.train_gap_model`. + :meth:`librascal.models.krr.train_gap_model`. .. [1] Joaquin Quiñonero-Candela, Carl Edward Rasmussen; A Unifying View of Sparse Approximate Gaussian Process Regression, diff --git a/bindings/rascal/models/krr.py b/bindings/librascal/models/krr.py similarity index 100% rename from bindings/rascal/models/krr.py rename to bindings/librascal/models/krr.py diff --git a/bindings/rascal/models/sparse_points.py b/bindings/librascal/models/sparse_points.py similarity index 100% rename from bindings/rascal/models/sparse_points.py rename to bindings/librascal/models/sparse_points.py diff --git a/bindings/rascal/neighbourlist/__init__.py b/bindings/librascal/neighbourlist/__init__.py similarity index 100% rename from bindings/rascal/neighbourlist/__init__.py rename to bindings/librascal/neighbourlist/__init__.py diff --git a/bindings/rascal/neighbourlist/base.py b/bindings/librascal/neighbourlist/base.py similarity index 100% rename from bindings/rascal/neighbourlist/base.py rename to bindings/librascal/neighbourlist/base.py diff --git a/bindings/rascal/neighbourlist/structure_manager.py b/bindings/librascal/neighbourlist/structure_manager.py similarity index 100% rename from bindings/rascal/neighbourlist/structure_manager.py rename to bindings/librascal/neighbourlist/structure_manager.py diff --git a/bindings/rascal/representations/__init__.py b/bindings/librascal/representations/__init__.py similarity index 100% rename from bindings/rascal/representations/__init__.py rename to bindings/librascal/representations/__init__.py diff --git a/bindings/rascal/representations/base.py b/bindings/librascal/representations/base.py similarity index 100% rename from bindings/rascal/representations/base.py rename to bindings/librascal/representations/base.py diff --git a/bindings/rascal/representations/coulomb_matrix.py b/bindings/librascal/representations/coulomb_matrix.py similarity index 100% rename from bindings/rascal/representations/coulomb_matrix.py rename to bindings/librascal/representations/coulomb_matrix.py diff --git a/bindings/rascal/representations/spherical_covariants.py b/bindings/librascal/representations/spherical_covariants.py similarity index 100% rename from bindings/rascal/representations/spherical_covariants.py rename to bindings/librascal/representations/spherical_covariants.py diff --git a/bindings/rascal/representations/spherical_expansion.py b/bindings/librascal/representations/spherical_expansion.py similarity index 100% rename from bindings/rascal/representations/spherical_expansion.py rename to bindings/librascal/representations/spherical_expansion.py diff --git a/bindings/rascal/representations/spherical_invariants.py b/bindings/librascal/representations/spherical_invariants.py similarity index 100% rename from bindings/rascal/representations/spherical_invariants.py rename to bindings/librascal/representations/spherical_invariants.py diff --git a/bindings/rascal/utils/__init__.py b/bindings/librascal/utils/__init__.py similarity index 100% rename from bindings/rascal/utils/__init__.py rename to bindings/librascal/utils/__init__.py diff --git a/bindings/rascal/utils/cg_utils.py b/bindings/librascal/utils/cg_utils.py similarity index 100% rename from bindings/rascal/utils/cg_utils.py rename to bindings/librascal/utils/cg_utils.py diff --git a/bindings/rascal/utils/filter.py b/bindings/librascal/utils/filter.py similarity index 100% rename from bindings/rascal/utils/filter.py rename to bindings/librascal/utils/filter.py diff --git a/bindings/rascal/utils/io.py b/bindings/librascal/utils/io.py similarity index 100% rename from bindings/rascal/utils/io.py rename to bindings/librascal/utils/io.py diff --git a/bindings/rascal/utils/pool_worker.py b/bindings/librascal/utils/pool_worker.py similarity index 100% rename from bindings/rascal/utils/pool_worker.py rename to bindings/librascal/utils/pool_worker.py diff --git a/bindings/rascal/utils/radial_basis.py b/bindings/librascal/utils/radial_basis.py similarity index 100% rename from bindings/rascal/utils/radial_basis.py rename to bindings/librascal/utils/radial_basis.py diff --git a/bindings/rascal/utils/scorer.py b/bindings/librascal/utils/scorer.py similarity index 100% rename from bindings/rascal/utils/scorer.py rename to bindings/librascal/utils/scorer.py diff --git a/docs/source/conf.py.in b/docs/source/conf.py.in index 4bb94dcdf..1bb26242c 100644 --- a/docs/source/conf.py.in +++ b/docs/source/conf.py.in @@ -19,11 +19,14 @@ import os import sys import subprocess +import datetime +import re # import sys # sys.path.insert(0, os.path.abspath('.')) if sys.version_info < (3, 6): raise Exception("Python >= 3.6 is required") +ROOT = os.path.abspath(os.path.join("..", "..")) # -- General configuration ------------------------------------------------ @@ -79,20 +82,22 @@ master_doc = 'index' # General information about the project. project = 'Rascal' -copyright = '''2019, Chiheb Ben Mahmoud, Michele Ceriotti, Federico Giberti, -Klim Goldshtein, Till Junge, Markus Stricker, Félix Musil, Max Veit''' -author = '''Michele Ceriotti, Federico Giberti, Alexander Gocsinski, -Till Junge, Félix Musil, Markus Stricker, Max Veit, and Michael Willatt''' +author = ", ".join(open(os.path.join(ROOT, "AUTHORS.txt"))).replace("\n", "") + +copyright = datetime.date.today().strftime("%Y") + ", " + author # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. -# -# The short X.Y version. -version = '0.0.1' + # The full version, including alpha/beta/rc tags. -release = '0.0.1' +release = re.search( + r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', open(os.path.join(ROOT, "bindings/librascal/__init__.py")).read() +).group(1) + +# The short X.Y version. +version = re.search(r'(\d+\.\d+\.\d+)', release).group(1) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -185,5 +190,5 @@ latex_elements = { # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'Rascal.tex', 'Rascal Documentation', - 'Felix Musil, Federico Giberti, Till Junge, Michele Ceriotti', 'manual'), + author, 'manual'), ] diff --git a/examples/Feature_selection_example.ipynb b/examples/Feature_selection_example.ipynb index b5b9ac154..c475bb96b 100644 --- a/examples/Feature_selection_example.ipynb +++ b/examples/Feature_selection_example.ipynb @@ -2,7 +2,6 @@ "cells": [ { "cell_type": "markdown", - "id": "47d10a9a", "metadata": {}, "source": [ "# Using feature selection to build an efficient potential" @@ -10,7 +9,6 @@ }, { "cell_type": "markdown", - "id": "85a81755", "metadata": {}, "source": [ "In the previous examples (`MLIP_example` and `zundel_i-PI`) we have seen how to use the tools provided by `librascal` in order to build a working potential. We have already used a \"sparsification\" technique to select a basis set of environments for the fit, as well as to keep the computational cost of both fitting and evaluating the potential manageable.\n", @@ -26,7 +24,6 @@ }, { "cell_type": "markdown", - "id": "cd8d9cdd", "metadata": {}, "source": [ "Let us begin with the Zundel cation example introduced in the previous notebook:" @@ -34,7 +31,6 @@ }, { "cell_type": "markdown", - "id": "a298ec8b", "metadata": {}, "source": [ "## Initialization" @@ -43,7 +39,6 @@ { "cell_type": "code", "execution_count": 1, - "id": "ee33dff6", "metadata": { "init_cell": true }, @@ -68,15 +63,14 @@ "import logging\n", "logging.basicConfig(level=logging.INFO)\n", "\n", - "from rascal.models import Kernel, train_gap_model, compute_KNM\n", - "from rascal.representations import SphericalInvariants\n", - "from rascal.utils import from_dict, to_dict, CURFilter, FPSFilter, dump_obj, load_obj" + "from librascal.models import Kernel, train_gap_model, compute_KNM\n", + "from librascal.representations import SphericalInvariants\n", + "from librascal.utils import from_dict, to_dict, CURFilter, FPSFilter, dump_obj, load_obj" ] }, { "cell_type": "code", "execution_count": 2, - "id": "c0320d69", "metadata": {}, "outputs": [ { @@ -94,7 +88,6 @@ { "cell_type": "code", "execution_count": 3, - "id": "1a8da102", "metadata": {}, "outputs": [], "source": [ @@ -108,7 +101,6 @@ { "cell_type": "code", "execution_count": 4, - "id": "2d198335", "metadata": {}, "outputs": [ { @@ -129,7 +121,6 @@ { "cell_type": "code", "execution_count": 5, - "id": "0fea5828", "metadata": { "code_folding": [] }, @@ -158,7 +149,6 @@ }, { "cell_type": "markdown", - "id": "bc1b367a", "metadata": {}, "source": [ "## Set hyperparameters" @@ -167,7 +157,6 @@ { "cell_type": "code", "execution_count": 6, - "id": "ee7dcb0b", "metadata": {}, "outputs": [], "source": [ @@ -179,7 +168,6 @@ { "cell_type": "code", "execution_count": 7, - "id": "f41ac68a", "metadata": {}, "outputs": [], "source": [ @@ -215,7 +203,6 @@ }, { "cell_type": "markdown", - "id": "ee0b243f", "metadata": {}, "source": [ "## Compute descriptors" @@ -224,7 +211,6 @@ { "cell_type": "code", "execution_count": 8, - "id": "3dd2d30d", "metadata": {}, "outputs": [ { @@ -247,7 +233,6 @@ }, { "cell_type": "markdown", - "id": "4a2732fd", "metadata": {}, "source": [ "## Sample selection" @@ -255,7 +240,6 @@ }, { "cell_type": "markdown", - "id": "30c2c3d5", "metadata": {}, "source": [ "Now we select the set of sparse _samples_ (environments). In effect, we are selecting an optimally diverse set of _rows_ of the feature matrix $X$." @@ -264,7 +248,6 @@ { "cell_type": "code", "execution_count": 9, - "id": "60d5982b", "metadata": { "code_folding": [], "scrolled": true @@ -289,7 +272,6 @@ }, { "cell_type": "markdown", - "id": "8e254859", "metadata": {}, "source": [ "## Model assessment: Sparse samples only" @@ -297,7 +279,6 @@ }, { "cell_type": "markdown", - "id": "51e67152", "metadata": {}, "source": [ "Let's build our potential and get some benchmarks." @@ -306,7 +287,6 @@ { "cell_type": "code", "execution_count": 10, - "id": "55bc94ab", "metadata": {}, "outputs": [ { @@ -339,7 +319,6 @@ { "cell_type": "code", "execution_count": 11, - "id": "4046787a", "metadata": { "scrolled": true }, @@ -362,7 +341,6 @@ { "cell_type": "code", "execution_count": 12, - "id": "065ae1f5", "metadata": {}, "outputs": [ { @@ -376,7 +354,7 @@ } ], "source": [ - "from rascal.utils import get_score\n", + "from librascal.utils import get_score\n", "\n", "score = get_score(e_pred, e_test)\n", "RMSE = score['RMSE']\n", @@ -388,7 +366,6 @@ }, { "cell_type": "markdown", - "id": "fdaa07ef", "metadata": {}, "source": [ "## Now introduce feature selection" @@ -396,7 +373,6 @@ }, { "cell_type": "markdown", - "id": "fecb1e3d", "metadata": {}, "source": [ "This potential uses quite a large number of features to make its predictions:" @@ -405,7 +381,6 @@ { "cell_type": "code", "execution_count": 13, - "id": "b10c08f5", "metadata": {}, "outputs": [ { @@ -425,7 +400,6 @@ }, { "cell_type": "markdown", - "id": "e761f4b0", "metadata": {}, "source": [ "Since the cost to compute the kernel (and hence evaluate the model) scales asymptotically linearly with the number of features [2], it would be nice if we could get away with using fewer components of the feature vector.\n", @@ -435,7 +409,6 @@ }, { "cell_type": "markdown", - "id": "f2381cf3", "metadata": {}, "source": [ "To select features (columns) instead of samples (rows), we use the same selector class as above with a few changes. Let's start with a conservative estimate of half the total number of features:" @@ -444,7 +417,6 @@ { "cell_type": "code", "execution_count": 14, - "id": "2fc20224", "metadata": { "code_folding": [], "scrolled": true @@ -459,7 +431,6 @@ }, { "cell_type": "markdown", - "id": "13c54d51", "metadata": {}, "source": [ "Note that here we use the full feature matrix again, but in real scientific applications this might not be possible or practical due to the size of the full matrix. In this case we might sub-select samples, either randomly or using our existing sparse sample selection*, to obtain a smaller matrix to work with.\n", @@ -470,7 +441,6 @@ { "cell_type": "code", "execution_count": 15, - "id": "55140518", "metadata": {}, "outputs": [ { @@ -490,7 +460,6 @@ }, { "cell_type": "markdown", - "id": "1d74eb07", "metadata": {}, "source": [ "The result is a dictionary that tells the `SphericalInvariants` class which coefficents to compute. In order to use it, we must update the `hypers` and create a new, sparsified version of the `soap` feature calculator." @@ -499,7 +468,6 @@ { "cell_type": "code", "execution_count": 16, - "id": "a19e712a", "metadata": {}, "outputs": [], "source": [ @@ -510,7 +478,6 @@ { "cell_type": "code", "execution_count": 17, - "id": "07d21b97", "metadata": {}, "outputs": [ { @@ -530,7 +497,6 @@ { "cell_type": "code", "execution_count": 18, - "id": "2d2119cc", "metadata": {}, "outputs": [], "source": [ @@ -542,7 +508,6 @@ }, { "cell_type": "markdown", - "id": "6dff3c7e", "metadata": {}, "source": [ "### How do we know how many features to select?" @@ -550,7 +515,6 @@ }, { "cell_type": "markdown", - "id": "7f13fe5d", "metadata": {}, "source": [ "With FPS, one metric we can look at to get a rough estimate of the required number of features is the Hausdorff distance of each selected point (basically, the distance of the selected point to the closest point in the \"blob\" of already-selected points). This tells us how far (in feature space) each selected point is from the selected set, and _very_ roughly, the amount of diversity it adds to the set. So when the decrease in this distance starts to slow down, it indicates that we are getting less of an information return for each point added to the set." @@ -559,7 +523,6 @@ { "cell_type": "code", "execution_count": 19, - "id": "2bef5be2", "metadata": {}, "outputs": [ { @@ -595,7 +558,6 @@ }, { "cell_type": "markdown", - "id": "da9b6430", "metadata": {}, "source": [ "From this plot, it seems that we might even be able to get away with 200 or 300 features, but we should test this more rigorously. What we really care about is how well these sparsified features reproduce the _kernel_ -- so let's look at the difference in the kernel between the sparse _environments_, with and without _feature_ sparsification." @@ -604,7 +566,6 @@ { "cell_type": "code", "execution_count": 20, - "id": "caef3793", "metadata": {}, "outputs": [], "source": [ @@ -616,7 +577,6 @@ { "cell_type": "code", "execution_count": 21, - "id": "00de1098", "metadata": {}, "outputs": [ { @@ -637,7 +597,6 @@ { "cell_type": "code", "execution_count": 22, - "id": "5f5b489a", "metadata": {}, "outputs": [ { @@ -657,7 +616,6 @@ }, { "cell_type": "markdown", - "id": "5ca20ac8", "metadata": {}, "source": [ "So the difference in the norms is less than 1% of the norm of the kernel matrix. Let's see if we can use an even smaller number of features:" @@ -666,7 +624,6 @@ { "cell_type": "code", "execution_count": 23, - "id": "aa01d850", "metadata": {}, "outputs": [], "source": [ @@ -686,7 +643,6 @@ { "cell_type": "code", "execution_count": 24, - "id": "ab26edf1", "metadata": {}, "outputs": [], "source": [ @@ -698,7 +654,6 @@ { "cell_type": "code", "execution_count": 25, - "id": "b859802b", "metadata": {}, "outputs": [], "source": [ @@ -709,7 +664,6 @@ { "cell_type": "code", "execution_count": 26, - "id": "d2bf5422", "metadata": {}, "outputs": [ { @@ -729,7 +683,6 @@ }, { "cell_type": "markdown", - "id": "4397853b", "metadata": {}, "source": [ "Barely a difference. So let's proceed with 200 features and see how accurate our model is:" @@ -737,7 +690,6 @@ }, { "cell_type": "markdown", - "id": "5ca42c50", "metadata": {}, "source": [ "## Model assessment: Sparse samples and sparse features" @@ -746,7 +698,6 @@ { "cell_type": "code", "execution_count": 27, - "id": "0be4e95b", "metadata": {}, "outputs": [ { @@ -789,7 +740,6 @@ { "cell_type": "code", "execution_count": 28, - "id": "22d31fb0", "metadata": { "scrolled": true }, @@ -811,7 +761,6 @@ }, { "cell_type": "markdown", - "id": "b320a45b", "metadata": {}, "source": [ "Notice how it is already much faster to train and evaluate a model. Now, how accurate is it?" @@ -820,7 +769,6 @@ { "cell_type": "code", "execution_count": 29, - "id": "dff52672", "metadata": {}, "outputs": [ { @@ -834,7 +782,7 @@ } ], "source": [ - "from rascal.utils import get_score\n", + "from librascal.utils import get_score\n", "\n", "score = get_score(e_pred.flat, e_test)\n", "RMSE = score['RMSE']\n", @@ -846,7 +794,6 @@ }, { "cell_type": "markdown", - "id": "3396f60c", "metadata": {}, "source": [ "In fact, it's slightly _more_ accurate than the model built with the full feature set. This might be because the model built with the full features overfits slightly, since it has more than enough features to describe the dataset. If we were to optimize the regularizers for both these fits, it is likely that the feature-sparsified model would have approximately equal or lower accuracy than the full model." @@ -854,7 +801,6 @@ }, { "cell_type": "markdown", - "id": "b03fdbc8", "metadata": {}, "source": [ "## Timings" @@ -862,7 +808,6 @@ }, { "cell_type": "markdown", - "id": "8c6c9c77", "metadata": {}, "source": [ "Now, back to our main motivation for doing feature sparsification. If we use these models to run molecular dynamics (MD), how much of a speedup do we get with the feature-sparsified model?" @@ -871,7 +816,6 @@ { "cell_type": "code", "execution_count": 30, - "id": "f3c8abcf", "metadata": {}, "outputs": [], "source": [ @@ -885,16 +829,14 @@ { "cell_type": "code", "execution_count": 31, - "id": "7f4c3bb8", "metadata": {}, "outputs": [], "source": [ - "from rascal.models.asemd import ASEMLCalculator" + "from librascal.models.asemd import ASEMLCalculator" ] }, { "cell_type": "markdown", - "id": "b9b3ee9d", "metadata": {}, "source": [ "Let's use the ASE calculator (as in `MLIP_example.ipynb`), which we can run directly in the notebook." @@ -902,7 +844,6 @@ }, { "cell_type": "markdown", - "id": "40d996ef", "metadata": {}, "source": [ "Full model:" @@ -911,7 +852,6 @@ { "cell_type": "code", "execution_count": 32, - "id": "c29218ba", "metadata": {}, "outputs": [ { @@ -940,7 +880,6 @@ }, { "cell_type": "markdown", - "id": "26e48a5b", "metadata": {}, "source": [ "Feature-sparsified model:" @@ -949,7 +888,6 @@ { "cell_type": "code", "execution_count": 33, - "id": "43afd338", "metadata": {}, "outputs": [ { @@ -978,7 +916,6 @@ }, { "cell_type": "markdown", - "id": "1b80dfa8", "metadata": {}, "source": [ "So our feature-sparsified model is about twice as fast as the full model, and with the same accuracy!\n", @@ -1003,7 +940,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.13" + "version": "3.7.6" } }, "nbformat": 4, diff --git a/examples/MLIP_example.ipynb b/examples/MLIP_example.ipynb index 8b4f700f3..9ee721097 100644 --- a/examples/MLIP_example.ipynb +++ b/examples/MLIP_example.ipynb @@ -25,7 +25,7 @@ "from matplotlib import pylab as plt\n", "\n", "import time\n", - "import rascal\n", + "import librascal\n", "import json\n", "\n", "import ase\n", @@ -34,10 +34,10 @@ "from ase.visualize import view\n", "import numpy as np\n", "\n", - "from rascal.representations import SphericalInvariants\n", - "from rascal.models import Kernel, train_gap_model\n", - "from rascal.models.asemd import ASEMLCalculator\n", - "from rascal.utils import from_dict, to_dict, CURFilter, dump_obj, load_obj, get_score, print_score" + "from librascal.representations import SphericalInvariants\n", + "from librascal.models import Kernel, train_gap_model\n", + "from librascal.models.asemd import ASEMLCalculator\n", + "from librascal.utils import from_dict, to_dict, CURFilter, dump_obj, load_obj, get_score, print_score" ] }, { @@ -376,7 +376,7 @@ "metadata": {}, "outputs": [], "source": [ - "from rascal.models.asemd import ASEMLCalculator" + "from librascal.models.asemd import ASEMLCalculator" ] }, { diff --git a/examples/equivariant_demo.ipynb b/examples/equivariant_demo.ipynb index 116b48c37..367cc012d 100644 --- a/examples/equivariant_demo.ipynb +++ b/examples/equivariant_demo.ipynb @@ -12,11 +12,11 @@ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", - "from rascal.representations import SphericalExpansion, SphericalInvariants\n", - "from rascal.utils import (get_radial_basis_covariance, get_radial_basis_pca, \n", + "from librascal.representations import SphericalExpansion, SphericalInvariants\n", + "from librascal.utils import (get_radial_basis_covariance, get_radial_basis_pca, \n", " get_radial_basis_projections, get_optimal_radial_basis_hypers )\n", - "from rascal.utils import radial_basis\n", - "from rascal.utils import (WignerDReal, ClebschGordanReal, \n", + "from librascal.utils import radial_basis\n", + "from librascal.utils import (WignerDReal, ClebschGordanReal, \n", " spherical_expansion_reshape, spherical_expansion_conjugate,\n", " lm_slice, real2complex_matrix, xyz_to_spherical, spherical_to_xyz)" ] @@ -64,11 +64,11 @@ "outputs": [], "source": [ "# imports also some internals to demonstrate manually some CG manipulations\n", - "from rascal.utils.cg_utils import _r2c as r2c\n", - "from rascal.utils.cg_utils import _c2r as c2r\n", - "from rascal.utils.cg_utils import _cg as clebsch_gordan\n", - "from rascal.utils.cg_utils import _rotation as rotation\n", - "from rascal.utils.cg_utils import _wigner_d as wigner_d" + "from librascal.utils.cg_utils import _r2c as r2c\n", + "from librascal.utils.cg_utils import _c2r as c2r\n", + "from librascal.utils.cg_utils import _cg as clebsch_gordan\n", + "from librascal.utils.cg_utils import _rotation as rotation\n", + "from librascal.utils.cg_utils import _wigner_d as wigner_d" ] }, { diff --git a/examples/needs_updating/Prediction_example.ipynb b/examples/needs_updating/Prediction_example.ipynb index b760399ab..8bc0318d0 100644 --- a/examples/needs_updating/Prediction_example.ipynb +++ b/examples/needs_updating/Prediction_example.ipynb @@ -25,9 +25,9 @@ "%autoreload 2\n", "from tutorial_utils import *\n", "try:\n", - " from rascal.representations import SphericalInvariants as SOAP\n", + " from librascal.representations import SphericalInvariants as SOAP\n", "except:\n", - " from rascal.representations import SOAP\n", + " from librascal.representations import SOAP\n", "readme_button()" ] }, @@ -128,9 +128,9 @@ "from ase.io import read\n", "import numpy as np\n", "try:\n", - " from rascal.representations import SphericalInvariants as SOAP\n", + " from librascal.representations import SphericalInvariants as SOAP\n", "except:\n", - " from rascal.representations import SOAP\n", + " from librascal.representations import SOAP\n", "\n", "def split_dataset(N, training_percentage, seed=20):\n", " np.random.seed(seed)\n", diff --git a/examples/needs_updating/SOAP_example.ipynb b/examples/needs_updating/SOAP_example.ipynb index b7859a4e4..a75059653 100644 --- a/examples/needs_updating/SOAP_example.ipynb +++ b/examples/needs_updating/SOAP_example.ipynb @@ -27,9 +27,9 @@ "sys.path.insert(0, '../build')\n", "from tutorial_utils import *\n", "try:\n", - " from rascal.representations import SphericalInvariants as SOAP\n", + " from librascal.representations import SphericalInvariants as SOAP\n", "except:\n", - " from rascal.representations import SOAP\n", + " from librascal.representations import SOAP\n", "readme_button()" ] }, @@ -121,9 +121,9 @@ "from ase.io import read\n", "import numpy as np\n", "try:\n", - " from rascal.representations import SphericalInvariants as SOAP\n", + " from librascal.representations import SphericalInvariants as SOAP\n", "except:\n", - " from rascal.representations import SOAP\n", + " from librascal.representations import SOAP\n", "\n", "def split_dataset(N, training_percentage, seed=20):\n", " np.random.seed(seed)\n", diff --git a/examples/needs_updating/Spherical_invariants_and_database_exploration.ipynb b/examples/needs_updating/Spherical_invariants_and_database_exploration.ipynb index a89f6b2b9..3f0d9e683 100644 --- a/examples/needs_updating/Spherical_invariants_and_database_exploration.ipynb +++ b/examples/needs_updating/Spherical_invariants_and_database_exploration.ipynb @@ -30,7 +30,7 @@ "\n", "import sys\n", "import time\n", - "import rascal\n", + "import librascal\n", "import json\n", "\n", "import ase\n", @@ -44,10 +44,10 @@ "\n", "from tqdm.notebook import tqdm\n", "\n", - "from rascal.representations import SphericalInvariants\n", - "from rascal.models import Kernel, KRR, train_gap_model\n", - "from rascal.models.sparse_points import SparsePoints\n", - "from rascal.utils import from_dict, to_dict, CURFilter, FPSFilter, get_score, print_score" + "from librascal.representations import SphericalInvariants\n", + "from librascal.models import Kernel, KRR, train_gap_model\n", + "from librascal.models.sparse_points import SparsePoints\n", + "from librascal.utils import from_dict, to_dict, CURFilter, FPSFilter, get_score, print_score" ] }, { diff --git a/examples/needs_updating/coulomb_example.ipynb b/examples/needs_updating/coulomb_example.ipynb index 993483d0f..0e2f3894e 100644 --- a/examples/needs_updating/coulomb_example.ipynb +++ b/examples/needs_updating/coulomb_example.ipynb @@ -69,8 +69,8 @@ "source": [ "import sys, os\n", "sys.path.insert(0,'../build/')\n", - "import rascal as rc\n", - "from rascal.representations import SortedCoulombMatrix" + "import librascal as rc\n", + "from librascal.representations import SortedCoulombMatrix" ] }, { @@ -177,7 +177,7 @@ "metadata": {}, "outputs": [], "source": [ - "from rascal.utils import fps" + "from librascal.utils import fps" ] }, { diff --git a/examples/nice_demo.ipynb b/examples/nice_demo.ipynb index e9ba02936..49d9da7ed 100644 --- a/examples/nice_demo.ipynb +++ b/examples/nice_demo.ipynb @@ -12,11 +12,11 @@ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", - "from rascal.representations import SphericalExpansion, SphericalInvariants\n", - "from rascal.utils import (get_radial_basis_covariance, get_radial_basis_pca, \n", + "from librascal.representations import SphericalExpansion, SphericalInvariants\n", + "from librascal.utils import (get_radial_basis_covariance, get_radial_basis_pca, \n", " get_radial_basis_projections, get_optimal_radial_basis_hypers )\n", - "from rascal.utils import radial_basis\n", - "from rascal.utils import (WignerDReal, ClebschGordanReal, \n", + "from librascal.utils import radial_basis\n", + "from librascal.utils import (WignerDReal, ClebschGordanReal, \n", " spherical_expansion_reshape, spherical_expansion_conjugate,\n", " lm_slice, real2complex_matrix, compute_lambda_soap)" ] diff --git a/examples/optimized_radial_basis_functions.ipynb b/examples/optimized_radial_basis_functions.ipynb index 7fd7a217c..ff1d540be 100644 --- a/examples/optimized_radial_basis_functions.ipynb +++ b/examples/optimized_radial_basis_functions.ipynb @@ -26,10 +26,10 @@ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", - "from rascal.representations import SphericalExpansion, SphericalInvariants\n", - "from rascal.utils import (get_radial_basis_covariance, get_radial_basis_pca, \n", + "from librascal.representations import SphericalExpansion, SphericalInvariants\n", + "from librascal.utils import (get_radial_basis_covariance, get_radial_basis_pca, \n", " get_radial_basis_projections, get_optimal_radial_basis_hypers )\n", - "from rascal.utils import radial_basis" + "from librascal.utils import radial_basis" ] }, { diff --git a/examples/python/center_select_example.py b/examples/python/center_select_example.py index 2917fcbc4..b56ed3e79 100644 --- a/examples/python/center_select_example.py +++ b/examples/python/center_select_example.py @@ -9,8 +9,8 @@ import ase.io import numpy as np -from rascal.representations import SphericalInvariants -from rascal.neighbourlist.structure_manager import ( +from librascal.representations import SphericalInvariants +from librascal.neighbourlist.structure_manager import ( mask_center_atoms_by_species, mask_center_atoms_by_id, ) diff --git a/examples/zundel_i-PI.ipynb b/examples/zundel_i-PI.ipynb index 863b940eb..f19644319 100644 --- a/examples/zundel_i-PI.ipynb +++ b/examples/zundel_i-PI.ipynb @@ -105,9 +105,9 @@ "\n", "from time import time\n", "\n", - "from rascal.models import Kernel, train_gap_model, compute_KNM\n", - "from rascal.representations import SphericalInvariants\n", - "from rascal.utils import from_dict, to_dict, CURFilter, dump_obj, load_obj" + "from librascal.models import Kernel, train_gap_model, compute_KNM\n", + "from librascal.representations import SphericalInvariants\n", + "from librascal.utils import from_dict, to_dict, CURFilter, dump_obj, load_obj" ] }, { @@ -565,7 +565,7 @@ } ], "source": [ - "from rascal.utils import get_score\n", + "from librascal.utils import get_score\n", "\n", "score = get_score(y_pred, y_test)\n", "RMSE = score['RMSE']\n", diff --git a/performance/benchmarks/benchmark_spherical_representations.py b/performance/benchmarks/benchmark_spherical_representations.py index 994496806..51f84fb48 100644 --- a/performance/benchmarks/benchmark_spherical_representations.py +++ b/performance/benchmarks/benchmark_spherical_representations.py @@ -31,8 +31,8 @@ import benchmarks try: - from rascal.representations import SphericalInvariants - from rascal.representations import SphericalExpansion + from librascal.representations import SphericalInvariants + from librascal.representations import SphericalExpansion except ImportError: sys.exit("Could not import rascal.") diff --git a/reference_data/tests_only/simple_gap_model.json b/reference_data/tests_only/simple_gap_model.json index 2dcb57db9..a08764b97 100644 --- a/reference_data/tests_only/simple_gap_model.json +++ b/reference_data/tests_only/simple_gap_model.json @@ -5142,11 +5142,11 @@ "radial_basis": "GTO", "soap_type": "PowerSpectrum" }, - "module_name": "rascal.representations.spherical_invariants", + "module_name": "librascal.representations.spherical_invariants", "version": "0.1" } }, - "module_name": "rascal.models.sparse_points", + "module_name": "librascal.models.sparse_points", "version": "0.1" }, "description": "Simple fit of methane dimer energies, just for testing. Generated by fit_gap.py on 2021-03-25 at 13:17:33 CET", @@ -5181,13 +5181,13 @@ "radial_basis": "GTO", "soap_type": "PowerSpectrum" }, - "module_name": "rascal.representations.spherical_invariants", + "module_name": "librascal.representations.spherical_invariants", "version": "0.1" }, "target_type": "Structure", "zeta": 2 }, - "module_name": "rascal.models.kernels", + "module_name": "librascal.models.kernels", "version": "0.1" }, "self_contributions": { @@ -5234,6 +5234,6 @@ ] ] }, - "module_name": "rascal.models.krr", + "module_name": "librascal.models.krr", "version": "0.1" } diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 567c78789..000000000 --- a/requirements.txt +++ /dev/null @@ -1,27 +0,0 @@ -# python library -numpy -scipy -jupyter -sympy>=1.4 -skcosmo -# notebook tutorials -matplotlib -# Developers tools for compiling documentation -sphinx>=2.1.2,<=4.0.2 -breathe>=4.14.1 -# Jinja2 v3 breaks nbsphinx -jinja2==2.11.3 -sphinx_rtd_theme -# notebook tutorials -nbsphinx>=0.8.1 -pygments>=2.4.1 -# Developers tools for linting and formatting -cpplint==1.5.5 -black==20.8b1 -# Developers tools - data generation scripts -ase -mpmath -py-ubjson -# Developers tools - testing -pytest -nbval diff --git a/requirements/README.md b/requirements/README.md new file mode 100644 index 000000000..f7d052947 --- /dev/null +++ b/requirements/README.md @@ -0,0 +1,9 @@ +Dependcy graph + +dev.txt +├── common.txt +| ├── minimal.txt +| └── dependencies for optional features +| └── dependencies for running example notebooks +├── doc.txt +└── tests.txt diff --git a/requirements/common.txt b/requirements/common.txt new file mode 100644 index 000000000..0d1e55dc2 --- /dev/null +++ b/requirements/common.txt @@ -0,0 +1,12 @@ +# required packages to use all features from librascal and to run notebook examples +-r minimal.txt + +## running example jupyter notebooks +jupyter +matplotlib>=2.0.0 + +## feature compression +skcosmo>=0.1.0 + +## rotational algebra +sympy>=1.4 diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 000000000..5701b071b --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,11 @@ +# all requirements for development +-r common.txt +-r doc.txt +-r tests.txt + +## data generation scripts +mpmath +py-ubjson + +## building python package +scikit-build diff --git a/requirements/doc.txt b/requirements/doc.txt new file mode 100644 index 000000000..a2780f995 --- /dev/null +++ b/requirements/doc.txt @@ -0,0 +1,8 @@ +# building documentation +-r minimal.txt + +sphinx_rtd_theme +sphinx>=2.1.2,<=4.0.2 +breathe>=4.14.1 +nbsphinx>=0.8.1 +pygments>=2.4.1 diff --git a/requirements/minimal.txt b/requirements/minimal.txt new file mode 100644 index 000000000..72587591a --- /dev/null +++ b/requirements/minimal.txt @@ -0,0 +1,4 @@ +# minimal requirements for pip installation +numpy>=1.16.0 +scipy>=1.4.0 +ase>=3.19.0 diff --git a/requirements/tests.txt b/requirements/tests.txt new file mode 100644 index 000000000..a76fccc78 --- /dev/null +++ b/requirements/tests.txt @@ -0,0 +1,10 @@ +# requirements to run tests +-r common.txt + +## python tests +pytest +nbval + +## linting and formatting +cpplint==1.5.5 +black==20.8b1 diff --git a/requirements_pip.txt b/requirements_pip.txt deleted file mode 100644 index 7f469e4fb..000000000 --- a/requirements_pip.txt +++ /dev/null @@ -1,5 +0,0 @@ -# python library that contain numpy and scipy already -numpy>=1.16.0 -scipy>=1.4.0 -matplotlib>=2.0.0 -ase>=3.19.0 diff --git a/setup.py b/setup.py index 788dc484a..175abf4ee 100644 --- a/setup.py +++ b/setup.py @@ -1,41 +1,58 @@ import sys import os +import re from os.path import join from distutils.sysconfig import get_python_lib - from setuptools import find_packages +from pkg_resources import parse_requirements from skbuild import setup from skbuild.constants import CMAKE_INSTALL_DIR -import re -# read the version number from the library -pattern = r"[0-9]\.[0-9]\.[0-9]" -version = None -with open("./bindings/rascal/__init__.py", "r") as fp: - for line in fp.readlines(): - if "__version__" in line: - version = re.findall(pattern, line)[0] -if version is None: - raise ValueError("Version number not found.") +version = re.search( + r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', + open("bindings/librascal/__init__.py").read(), +).group(1) -with open("./requirements_pip.txt", "r") as fp: - requirements = list(filter(lambda x: "#" not in x, (line.strip() for line in fp))) +with open("README.rst") as f: + long_description = f.read() + +with open("AUTHORS.txt") as fp: + author = ", ".join(fp.readlines()).replace("\n", "").replace("\n", "") + +with open("./requirements/minimal.txt", "r") as fp: + install_requires = [ + str(requirement) for requirement in parse_requirements(fp.read()) + ] setup( - name="rascal", + name="librascal", version=version, + long_description_content_type="text/x-rst", + long_description=long_description, description="""A versatile and scalable computation of representations of \ atomic structures for machine learning.""", - author="librascal developers", - license="LGPL-3.0-or-later", + author=author, + author_email="michele.ceriotti@epfl.ch", cmake_args=[ "-DINSTALL_PATH:STRING=" + join(os.getcwd(), CMAKE_INSTALL_DIR()), "-DBUILD_EXAMPLES:BOOL=OFF", ], + url="https://github.com/cosmo-epfl/librascal/", package_dir={"": "bindings"}, packages=find_packages(where="bindings"), - install_requires=requirements, - # include_package_data=True, + install_requires=install_requires, package_data={"": ["lib/librascal.*"]}, zip_safe=False, + license="LGPLv3+", + classifiers=[ + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: C++", + "Topic :: Scientific/Engineering", + "Operating System :: Unix", + ], ) diff --git a/tests/python/md_calculator_test.py b/tests/python/md_calculator_test.py index a80846930..77d0f34c1 100644 --- a/tests/python/md_calculator_test.py +++ b/tests/python/md_calculator_test.py @@ -5,7 +5,7 @@ import ase.io import numpy as np -from rascal.models.genericmd import GenericMDCalculator +from librascal.models.genericmd import GenericMDCalculator class TestGenericMD(unittest.TestCase): diff --git a/tests/python/python_cg_test.py b/tests/python/python_cg_test.py index d89e83b70..8bbd2aaaa 100644 --- a/tests/python/python_cg_test.py +++ b/tests/python/python_cg_test.py @@ -1,8 +1,8 @@ -from rascal.representations import ( +from librascal.representations import ( SphericalExpansion, SphericalInvariants, ) -from rascal.utils import ( +from librascal.utils import ( ClebschGordanReal, WignerDReal, spherical_expansion_reshape, diff --git a/tests/python/python_math_test.py b/tests/python/python_math_test.py index d6b6eabf7..01ba2801c 100644 --- a/tests/python/python_math_test.py +++ b/tests/python/python_math_test.py @@ -1,4 +1,4 @@ -import rascal.lib._rascal as rc +import librascal.lib._rascal as rc import unittest import numpy as np import scipy.special as sps diff --git a/tests/python/python_models_test.py b/tests/python/python_models_test.py index 05d852ce2..5a5581894 100644 --- a/tests/python/python_models_test.py +++ b/tests/python/python_models_test.py @@ -1,8 +1,8 @@ -from rascal.representations import SphericalInvariants -from rascal.models import Kernel -from rascal.models.sparse_points import SparsePoints -from rascal.models.kernels import compute_numerical_kernel_gradients -from rascal.utils import from_dict, to_dict +from librascal.representations import SphericalInvariants +from librascal.models import Kernel +from librascal.models.sparse_points import SparsePoints +from librascal.models.kernels import compute_numerical_kernel_gradients +from librascal.utils import from_dict, to_dict from test_utils import load_json_frame, BoxList, Box, compute_relative_error from ase.calculators.lj import LennardJones import ase.io diff --git a/tests/python/python_representation_calculator_test.py b/tests/python/python_representation_calculator_test.py index 9688c16c0..1e61da94c 100644 --- a/tests/python/python_representation_calculator_test.py +++ b/tests/python/python_representation_calculator_test.py @@ -1,11 +1,11 @@ -from rascal.representations import ( +from librascal.representations import ( SortedCoulombMatrix, SphericalExpansion, SphericalInvariants, ) -from rascal.utils import from_dict, to_dict, FPSFilter -from rascal.models import Kernel -from rascal.models.sparse_points import SparsePoints +from librascal.utils import from_dict, to_dict, FPSFilter +from librascal.models import Kernel +from librascal.models.sparse_points import SparsePoints from test_utils import load_json_frame, BoxList, Box, dot import unittest import numpy as np diff --git a/tests/python/python_structure_manager_test.py b/tests/python/python_structure_manager_test.py index 0e3d788af..4e894f6d5 100644 --- a/tests/python/python_structure_manager_test.py +++ b/tests/python/python_structure_manager_test.py @@ -1,7 +1,7 @@ import ase.io from ase.build import molecule -from rascal.neighbourlist import get_neighbourlist, AtomsList -from rascal.neighbourlist.structure_manager import ( +from librascal.neighbourlist import get_neighbourlist, AtomsList +from librascal.neighbourlist.structure_manager import ( mask_center_atoms_by_species, mask_center_atoms_by_id, ) diff --git a/tests/python/python_utils_test.py b/tests/python/python_utils_test.py index 41e8c81d2..8f327f692 100644 --- a/tests/python/python_utils_test.py +++ b/tests/python/python_utils_test.py @@ -1,8 +1,8 @@ -from rascal.representations import ( +from librascal.representations import ( SphericalExpansion, SphericalInvariants, ) -from rascal.utils import ( +from librascal.utils import ( get_radial_basis_covariance, get_radial_basis_pca, get_radial_basis_projections, diff --git a/tests/python/test_filter.py b/tests/python/test_filter.py index ad04d3d68..832f45ae0 100644 --- a/tests/python/test_filter.py +++ b/tests/python/test_filter.py @@ -2,8 +2,8 @@ import numpy as np import ase.io -from rascal.utils import filter, FPSFilter, CURFilter -from rascal.representations import SphericalInvariants as SOAP +from librascal.utils import filter, FPSFilter, CURFilter +from librascal.representations import SphericalInvariants as SOAP class IndexConversionTest(unittest.TestCase):