Skip to content

Commit

Permalink
restructure pkg & drop support for python 2.7, 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrmnn committed Feb 19, 2020
1 parent 0cba143 commit 800db3e
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 124 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
*.pyc
*.egg-info/
/.coverage
/*.egg-info/
/dist/
/docs/build/
/.pytest_cache/
/.cache/
/.tox/
/dist/
/docs/build/
/htmlcov/
/poetry.lock
/setup.py
11 changes: 2 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,17 @@ language: python
dist: xenial
matrix:
include:
- python: 2.7
env: TOXENV=py27-coverage-codecov
- python: 3.4
env: TOXENV=py34
- python: 3.5
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- python: 3.7
env: TOXENV=py37-coverage-codecov
env: TOXENV=py37-codecov
- python: 3.6
stage: deploy
env: TOXENV=docs
before_install:
- pip install tox tox-venv
- pip install poetry tox tox-venv
- |
if [[ $TOXENV != docs ]]; then
pip install poetry
source .travis/install-mopac.sh
fi
install: true
Expand Down
27 changes: 0 additions & 27 deletions berny/_py2.py

This file was deleted.

1 change: 1 addition & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.katex { font-size: 1em; }
53 changes: 24 additions & 29 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,33 @@
import datetime
import os
import sys
from unittest.mock import MagicMock

import toml
from importlib_metadata import metadata

sys.path.insert(0, os.path.abspath('..'))


class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return MagicMock()


MOCK_MODULES = ['numpy', 'numpy.linalg']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

metadata = toml.load(open('../pyproject.toml'))['tool']['poetry']
md = metadata('pyberny')

project = 'berny'
version = metadata['version']
author = ' '.join(metadata['authors'][0].split()[:-1])
description = metadata['description']
author = md['Author']
release = version = md['Version']
description = md['Summary']
year_range = (2016, datetime.date.today().year)
year_str = (
str(year_range[0])
if year_range[0] == year_range[1]
else f'{year_range[0]}-{year_range[1]}'
)
copyright = f'{year_str}, {author}'

master_doc = 'index'
extensions = [
'sphinx.ext.githubpages',
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinxcontrib.katex',
]
source_suffix = '.rst'
master_doc = 'index'
copyright = f'2017-{datetime.date.today().year}, {author}'
release = version
language = None
exclude_patterns = ['build', '.DS_Store']
pygments_style = 'sphinx'
todo_include_todos = True

html_theme = 'alabaster'
html_theme_options = {
'description': description,
Expand All @@ -47,12 +37,17 @@ def __getattr__(cls, name):
'badge_branch': 'master',
'codecov_button': True,
'travis_button': True,
'fixed_sidebar': True,
'page_width': '60em',
}
html_sidebars = {
'**': ['about.html', 'navigation.html', 'relations.html', 'searchbox.html']
}
htmlhelp_basename = f'{project}doc'
html_static_path = ['_static']

autodoc_default_options = {'special-members': '__call__'}
todo_include_todos = True
pygments_style = 'sphinx'


def skip_namedtuples(app, what, name, obj, skip, options):
Expand Down
39 changes: 20 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[tool.black]
target-version = "py27"
skip-string-normalization = true
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

[tool.poetry]
name = "pyberny"
version = "0.5.0"
version = "0.6.0"
description = "Molecular/crystal structure optimizer"
readme = "README.md"
authors = ["Jan Hermann <[email protected]>"]
repository = "https://github.com/jhrmnn/pyberny"
documentation = "https://jhrmnn.github.io/pyberny"
license = "MPL-2.0"
packages = [
{ include = "berny" },
{ include = "berny", from = "src" },
]
classifiers = [
"Environment :: Console",
Expand All @@ -23,30 +23,31 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "~2.7 || ^3.4"
python = "^3.5"
numpy = "^1.15"
pytest = { version = "^3.6", optional = true }
sphinx = { version = "^1.7", optional = true }
coverage = { version = "^4.5", optional = true }
toml = { version = "^0.10.0", optional = true }
sphinx = { version = "^2.2", optional = true }
sphinxcontrib-katex = { version = "^0.5.1", optional = true }
importlib-metadata = { version = "^1.5.0", optional = true }

[tool.poetry.extras]
test = ["pytest"]
cov = ["coverage"]
doc = ["sphinx", "toml"]
test = ["pytest", "coverage"]
doc = ["sphinx", "sphinxcontrib-katex", "importlib-metadata"]

[tool.poetry.dev-dependencies]
flake8 = "^3.5"
flake8-bugbear = { version = "^18.8", python = "^3.5" }
flake8-comprehensions = "^1.4"
flake8-quotes = "^1.0"
flake8-bugbear = ">=18.8"
flake8-comprehensions = ">=1.4"
flake8-quotes = "^2"
black = { version = ">=19-beta.0", python = "^3.6" }
pep8-naming = ">=0.7"
isort = "^4.3"
pydocstyle = "^3.0"
black = { version = "^19-beta.0", allow-prereleases = true, python = "^3.6" }
pydocstyle = "^5.0.1"

[tool.poetry.scripts]
berny = "berny.cli:main"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
[tool.black]
target-version = ["py36"]
skip-string-normalization = true
38 changes: 19 additions & 19 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[flake8]
max-complexity = 12
max-line-length = 80
ignore = E501,W503,E741,E203
select = C,E,F,W,B,B9,Q0
ignore = E501,W503,E741,E203,N803,N806,N802
select = C,E,F,N,W,B,B9,Q0

[isort]
multi_line_output = 3
Expand All @@ -11,10 +11,11 @@ line_length = 85
sections = FUTURE,STDLIB,TYPING,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
known_typing = typing, typing_extensions
no_lines_before = TYPING
combine_as_imports = true

[pydocstyle]
add-ignore = D100,D104,D105,D106,D107,D202
match-dir = berny
match-dir = src/berny
ignore-decorators = wraps

[tool:pytest]
Expand All @@ -23,35 +24,34 @@ filterwarnings =

[tox:tox]
minversion = 3.3
requires = tox-venv
envlist = py27
envlist = py37

[testenv]
skip_install = true
setenv =
coverage: EXTRAS1 = -E cov
whitelist_externals =
poetry
setenv =
codecov: COVPREFIX = coverage run -m
deps =
codecov: codecov
commands_pre =
poetry install --no-dev -E test
commands =
poetry install --no-dev -E test {env:EXTRAS1:}
!coverage: pytest -v
coverage: coverage run -m pytest -v
{env:COVPREFIX:} pytest -v tests
codecov: codecov
passenv =
MOPACDIR
codecov: TOXENV CI TRAVIS TRAVIS_*

[coverage:run]
branch = true
source = berny

[testenv:docs]
whitelist_externals = touch
deps =
sphinx
toml
whitelist_externals =
poetry
touch
commands_pre =
poetry install --no-dev -E doc
commands =
sphinx-build -d "{toxworkdir}/docs_doctree" docs docs/build
touch docs/build/.nojekyll

[coverage:run]
branch = true
source = berny
2 changes: 1 addition & 1 deletion berny/Math.py → src/berny/Math.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def quart_min(p):
return minim, np.polyval(p, minim)

# discriminant of d^2y/dx^2=0
D = -(g0 + g1) ** 2 - 2 * g0 * g1 + 6 * (y1 - y0) * (g0 + g1) - 6 * (y1 - y0) ** 2
D = -((g0 + g1) ** 2) - 2 * g0 * g1 + 6 * (y1 - y0) * (g0 + g1) - 6 * (y1 - y0) ** 2
if D < 1e-11:
return None, None
else:
Expand Down
2 changes: 1 addition & 1 deletion berny/__init__.py → src/berny/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
from .berny import Berny
from .coords import angstrom
from .geomlib import Geometry
from .optimizers import optimize
from .optimize import optimize

__all__ = ['optimize', 'Berny', 'geomlib', 'Geometry', 'angstrom']
16 changes: 2 additions & 14 deletions berny/berny.py → src/berny/berny.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import logging
import sys
from collections import namedtuple
from collections.abc import Generator
from itertools import chain

import numpy as np
Expand All @@ -13,11 +13,6 @@
from . import Math
from .coords import InternalCoords

if sys.version_info[:2] >= (3, 5):
from collections.abc import Generator
else:
from ._py2 import Generator # noqa

__version__ = '0.3.0'
__all__ = ['Berny']

Expand Down Expand Up @@ -79,14 +74,7 @@ class State(object):

Point = namedtuple('Point', 'q E g')

def __init__(
self,
geom,
debug=False,
restart=None,
maxsteps=100,
**params
):
def __init__(self, geom, debug=False, restart=None, maxsteps=100, **params):
self._debug = debug
self._maxsteps = maxsteps
self._converged = False
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion berny/geomlib.py → src/berny/geomlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def rho(self):
r"""
Calculate a measure of covalentness.
Returns :math:`\rho_{ij}:=\exp\big(-R_{ij}/(R_i^\text{cov}+R_j^\text{cov})\big)`.
Returns
:math:`\rho_{ij}:=\exp\big(-R_{ij}/(R_i^\text{cov}+R_j^\text{cov})\big)`.
"""
geom = self.supercell()
dist = geom.dist(geom)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 800db3e

Please sign in to comment.