diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..700ba0e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,49 @@ +language: python +git: + depth: 3 +cache: pip +matrix: + # mark build as complete as soon as the versions that may not fail is finished + fast_finish: true + include: + - python: 3.6 + dist: trusty + addons: + postgresql: '9.5' + - python: 3.7 + dist: xenial + #env: NO_RMQ='t' + addons: + postgresql: '9.5' + apt: + packages: + - rabbitmq-server + - python: 3.8 + dist: xenial + addons: + postgresql: '9.5' + apt: + packages: + - rabbitmq-server +services: + - postgresql + - rabbitmq +before_install: + # Now we install the needed dependencies + - sudo apt-get install locate + - sudo service postgresql stop + - sudo apt-get remove postgresql + - sudo apt-get install postgresql-9.5 + - sudo updatedb +install: # python installations + - pip install -U pip wheel setuptools + # install package and requirements for tests + - pip install -e .[testing] +script: + # refresh entry points + - reentry scan + # run tests + - cd tests; pytest --cov-report=term-missing --cov=aiida_jutools -sv . +after_success: + - pip install codecov + - codecov diff --git a/aiida_jutools/structure_analyzer.py b/aiida_jutools/structure_analyzer.py index 78d8fa2..36e2217 100644 --- a/aiida_jutools/structure_analyzer.py +++ b/aiida_jutools/structure_analyzer.py @@ -37,7 +37,7 @@ import spglib # local imports -from terminal_colors import * +from .terminal_colors import * # CSQ color for sequence # CDB color for structure database # CRC color for recipe @@ -48,7 +48,7 @@ # CER color for error messages # COK color for OK messages # CIN color for info messages -from ptable import ptable +from .ptable import ptable __copyright__ = (u"Copyright (c), 2019-2020, Forschungszentrum Jülich GmbH, " "IAS-1/PGI-1, Germany. All rights reserved.") diff --git a/docs/requirements_for_rtd.txt b/docs/requirements_for_rtd.txt index e273837..d15c933 100644 --- a/docs/requirements_for_rtd.txt +++ b/docs/requirements_for_rtd.txt @@ -1 +1,10 @@ -aiida-core>0.9.0 +aiida-core +masci-tools +aiida-kkr +numpy +scipy +pycifrw +pymatgen +spglib +pandas +humanfriendly diff --git a/docs/source/conf.py b/docs/source/conf.py old mode 100755 new mode 100644 index 1f9463f..9ee4488 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -232,7 +232,7 @@ #html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. -htmlhelp_basename = 'aiida-jutoolsdoc' +htmlhelp_basename = 'aiida-jutools-doc' # -- Options for LaTeX output -------------------------------------------------- @@ -301,49 +301,6 @@ configuration.BACKEND = "django" configuration.AIIDADB_PROFILE = "default" -''' -def run_apidoc(_): - """Runs sphinx-apidoc when building the documentation. - - Needs to be done in conf.py in order to include the APIdoc in the - build on readthedocs. - - See also https://github.com/rtfd/readthedocs.org/issues/1139 - """ - source_dir = os.path.abspath(os.path.dirname(__file__)) - apidoc_dir = os.path.join(source_dir, 'apidoc') - package_dir = os.path.join(source_dir, os.pardir, os.pardir) - - # In #1139, they suggest the route below, but for me this ended up - # calling sphinx-build, not sphinx-apidoc - #from sphinx.apidoc import main - #main([None, '-e', '-o', apidoc_dir, package_dir, '--force']) - - import subprocess - cmd_path = 'sphinx-apidoc' - if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv - # If we are, assemble the path manually - cmd_path = os.path.abspath(os.path.join(sys.prefix, 'bin', 'sphinx-apidoc')) - - options = [ - '-o', apidoc_dir, package_dir, - '--private', - '--force', - '--no-headings', - '--module-first', - '--no-toc', - '--maxdepth', '4', - ] - - # See https://stackoverflow.com/a/30144019 - env = os.environ.copy() - env["SPHINX_APIDOC_OPTIONS"] = 'members,special-members,private-members,undoc-members,show-inheritance' - subprocess.check_call([cmd_path] + options, env=env) -''' - -#def setup(app): -# app.connect('builder-inited', run_apidoc) - # -- Options for manual page output -------------------------------------------- diff --git a/docs/source/index.rst b/docs/source/index.rst old mode 100755 new mode 100644 index 38667cc..e49f636 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,6 +1,6 @@ -######################################### +###################################################################### `AiiDA`_ helper tools used by the aiida-plugins for the `juDFT`_ codes -######################################### +###################################################################### .. image:: images/AiiDA_transparent_logo.png :width: 40% diff --git a/docs/source/module_guide/index.rst b/docs/source/module_guide/index.rst index 55e53ed..736759f 100644 --- a/docs/source/module_guide/index.rst +++ b/docs/source/module_guide/index.rst @@ -4,5 +4,53 @@ Modules provided with aiida-jutools (API reference) .. toctree:: :maxdepth: 3 - utilities +.. automodule:: aiida_jutools.ptable + :members: + :private-members: + :special-members: + +.. automodule:: aiida_jutools.terminal_colors + :members: + :private-members: + :special-members: + +.. automodule:: aiida_jutools.util_computer + :members: + :private-members: + :special-members: + +.. automodule:: aiida_jutools.util_group + :members: + :private-members: + :special-members: + +.. automodule:: aiida_jutools.util_node + :members: + :private-members: + :special-members: + +.. automodule:: aiida_jutools.structure_analyzer + :members: + :private-members: + :special-members: + +.. automodule:: aiida_jutools.util_code + :members: + :private-members: + :special-members: + +.. automodule:: aiida_jutools.util_data + :members: + :private-members: + :special-members: + +.. automodule:: aiida_jutools.util_kkr + :members: + :private-members: + :special-members: + +.. automodule:: aiida_jutools.util_process + :members: + :private-members: + :special-members: diff --git a/docs/source/user_guide/index.rst b/docs/source/user_guide/index.rst index 34e1287..5d065a7 100644 --- a/docs/source/user_guide/index.rst +++ b/docs/source/user_guide/index.rst @@ -5,6 +5,3 @@ User's guide .. toctree:: :maxdepth: 3 - tools - - diff --git a/docs/source/user_guide/tools.rst b/docs/source/user_guide/tools.rst deleted file mode 100644 index 3980ff6..0000000 --- a/docs/source/user_guide/tools.rst +++ /dev/null @@ -1,4 +0,0 @@ -===== -Tools -===== - diff --git a/setup.json b/setup.json index 7836609..72b5b42 100644 --- a/setup.json +++ b/setup.json @@ -1,6 +1,6 @@ { "name": "aiida-jutools", - "author": "JuDFTteam, Philipp Rüßmann", + "author": "JuDFTteam", "author_email": "p.ruessmann@fz-juelich.de", "description": "AiiDA helper for Jülich AiiDA plugins", "url": "https://github.com/JuDFTteam/aiida-jutools", @@ -8,12 +8,11 @@ "license": "MIT", "classifiers": [ "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Development Status :: 4 - Beta", "Environment :: Plugins", "Intended Audience :: Science/Research", @@ -30,12 +29,19 @@ "numpy", "scipy", "pycifrw", + "pymatgen", "spglib", "pandas", "humanfriendly" ], "extras_require": { - "pre-commit": [ + "testing": [ + "pytest-cov", + "pgtest" + ], + "docs": [ + "Sphinx", + "sphinx-rtd-theme" ] }, "entry_points": { diff --git a/tests/files/Cu_mp-30_computed.cif b/tests/files/Cu_mp-30_computed.cif new file mode 100644 index 0000000..622465c --- /dev/null +++ b/tests/files/Cu_mp-30_computed.cif @@ -0,0 +1,27 @@ +# generated using pymatgen +data_Cu +_symmetry_space_group_name_H-M 'P 1' +_cell_length_a 2.56061937 +_cell_length_b 2.56061937 +_cell_length_c 2.56061937 +_cell_angle_alpha 60.00000000 +_cell_angle_beta 60.00000000 +_cell_angle_gamma 60.00000000 +_symmetry_Int_Tables_number 1 +_chemical_formula_structural Cu +_chemical_formula_sum Cu1 +_cell_volume 11.87189593 +_cell_formula_units_Z 1 +loop_ + _symmetry_equiv_pos_site_id + _symmetry_equiv_pos_as_xyz + 1 'x, y, z' +loop_ + _atom_site_type_symbol + _atom_site_label + _atom_site_symmetry_multiplicity + _atom_site_fract_x + _atom_site_fract_y + _atom_site_fract_z + _atom_site_occupancy + Cu Cu0 1 0.000000 -0.000000 0.000000 1 diff --git a/aiida_jutools/str2aiida.py b/tests/test_structure_analyzer.py old mode 100644 new mode 100755 similarity index 83% rename from aiida_jutools/str2aiida.py rename to tests/test_structure_analyzer.py index 9f16597..b7ac425 --- a/aiida_jutools/str2aiida.py +++ b/tests/test_structure_analyzer.py @@ -16,15 +16,11 @@ - apart from aiida, pymatgen and PyCifRW packages are needed to use > analyze_symmetry < """ -import sys - -# aiida imports -from aiida import load_profile -load_profile() - -from structure_analyzer import analyze_symmetry -from terminal_colors import * +from aiida.manage.tests.pytest_fixtures import aiida_profile +from aiida_jutools.structure_analyzer import analyze_symmetry +from aiida_jutools.terminal_colors import * from pprint import pprint +import pathlib __copyright__ = (u"Copyright (c), 2019-2020, Forschungszentrum Jülich GmbH, " "IAS-1/PGI-1, Germany. All rights reserved.") @@ -56,4 +52,15 @@ def cif2astr(cifpath): print('\n'+'extras:'+'\n') pprint(structure['aiida_structure_conventional'].extras, width=256) -cif2astr('/path/to/cif/file.cif') + +def test_cif2astr(aiida_profile): + cifpath = pathlib.Path('files/Cu_mp-30_computed.cif') + cif_abspath = str(cifpath.absolute()) + print(cif_abspath) + cif2astr(cif_abspath) + + +if __name__=='__main__': + from aiida import load_profile + load_profile() + test_cif2astr(None)