diff --git a/bfit/fit.py b/bfit/fit.py index c72a675..9b061ba 100644 --- a/bfit/fit.py +++ b/bfit/fit.py @@ -26,7 +26,7 @@ from timeit import default_timer as timer import numpy as np -from scipy.optimize import NonlinearConstraint, minimize +from scipy.optimize import minimize, NonlinearConstraint from bfit.measure import KLDivergence, Measure, SquaredDifference diff --git a/bfit/greedy.py b/bfit/greedy.py index ae72984..cf3a279 100644 --- a/bfit/greedy.py +++ b/bfit/greedy.py @@ -27,7 +27,7 @@ import numpy as np from scipy.optimize import nnls -from bfit.fit import KLDivergenceFPI, ScipyFit, _BaseFit +from bfit.fit import _BaseFit, KLDivergenceFPI, ScipyFit from bfit.measure import SquaredDifference from bfit.model import AtomicGaussianDensity diff --git a/bfit/test/test_greedy.py b/bfit/test/test_greedy.py index beed48a..118cafa 100644 --- a/bfit/test/test_greedy.py +++ b/bfit/test/test_greedy.py @@ -26,10 +26,10 @@ import numpy.testing as npt from bfit.greedy import ( - GreedyKLFPI, - GreedyLeastSquares, get_next_choices, get_two_next_choices, + GreedyKLFPI, + GreedyLeastSquares, pick_two_lose_one, remove_redundancies, ) diff --git a/bfit/test/test_grid.py b/bfit/test/test_grid.py index 3c4ee39..f985ccb 100644 --- a/bfit/test/test_grid.py +++ b/bfit/test/test_grid.py @@ -25,7 +25,7 @@ import numpy as np from numpy.testing import assert_almost_equal, assert_raises -from bfit.grid import ClenshawRadialGrid, CubicGrid, UniformRadialGrid, _BaseRadialGrid +from bfit.grid import _BaseRadialGrid, ClenshawRadialGrid, CubicGrid, UniformRadialGrid def test_raises_base(): diff --git a/docs/conf.py b/docs/conf.py index 1e90644..edbaf69 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -29,20 +29,20 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.napoleon', - 'sphinx.ext.autodoc', - 'sphinx.ext.todo', - 'sphinx.ext.mathjax', - 'sphinx.ext.viewcode', - 'sphinx.ext.githubpages', - 'numpydoc', + "sphinx.ext.napoleon", + "sphinx.ext.autodoc", + "sphinx.ext.todo", + "sphinx.ext.mathjax", + "sphinx.ext.viewcode", + "sphinx.ext.githubpages", + "numpydoc", # 'sphinx.ext.autosummary', - 'sphinx.ext.doctest', + "sphinx.ext.doctest", # for adding “copy to clipboard” buttons to all text/code boxes - 'sphinx_copybutton', - 'autoapi.extension', - 'nbsphinx', - #'sphinxcontrib.bibtex' + "sphinx_copybutton", + "autoapi.extension", + "nbsphinx", + # 'sphinxcontrib.bibtex', ] # Add any paths that contain templates here, relative to this directory. diff --git a/examples/atomdb_db.py b/examples/atomdb_db.py index da48b36..68ab094 100644 --- a/examples/atomdb_db.py +++ b/examples/atomdb_db.py @@ -11,16 +11,17 @@ import numpy as np from atomdb import load -from bfit.density import SlaterAtoms -from bfit.fit import KLDivergenceFPI, ScipyFit +from bfit.fit import KLDivergenceFPI from bfit.grid import ClenshawRadialGrid -from bfit.measure import KLDivergence from bfit.model import AtomicGaussianDensity from bfit.parse_ugbs import get_ugbs_exponents +# change the path to the location of the AtomDB data as needed +DATAPATH = ("/home/ali-tehrani/SoftwareProjects/AtomDBdata",) + results_final = {} atoms = ["H", "C", "N", "O", "F", "P", "S", "Cl"] -atomic_numbs = [1, 6, 7, 8, 9, 15, 16, 17] #[1 + i for i in range(0, len(atoms))] +atomic_numbs = [1, 6, 7, 8, 9, 15, 16, 17] # [1 + i for i in range(0, len(atoms))] mult = [2, 3, 4, 3, 2, 4, 3, 2] for k, element in enumerate(atoms): print("Start Atom %s" % element) @@ -28,7 +29,11 @@ # Construct a integration grid atomic_numb = atomic_numbs[k] grid = ClenshawRadialGrid( - atomic_numb, num_core_pts=10000, num_diffuse_pts=899, include_origin=True#, extra_pts=[50,75,100], + atomic_numb, + num_core_pts=10000, + num_diffuse_pts=899, + include_origin=True, + # extra_pts=[50,75,100], ) # Initial Guess constructed from UGBS @@ -41,15 +46,19 @@ e_0 = np.array(exps_s + exps_p) * 2.0 # Construct Atomic Density and Fitting Object - #density = SlaterAtoms(element=element).atomic_density(grid.points) + # density = SlaterAtoms(element=element).atomic_density(grid.points) # Use AtomDB to calculate the density - atom = load(elem=element, charge=0, mult=mult[k], dataset="hci", datapath="/home/ali-tehrani/SoftwareProjects/AtomDBdata") + atom = load( + elem=element, + charge=0, + mult=mult[k], + dataset="hci", + datapath=DATAPATH, + ) dens = atom.dens_func() density = dens(grid.points) - import matplotlib.pyplot as plt - # plt.plot(grid.points, density, "bo-") # plt.show() print(density[-1], grid.points[-1], grid.points[0:3]) @@ -69,7 +78,9 @@ # measure = KLDivergence(mask_value=1e-18) # fit_KL_slsqp = ScipyFit(grid, density, model, measure=measure, method="SLSQP", spherical=True) # # Run the SLSQP optimization algorithm - # results = fit_KL_slsqp.run(coeffs, e_0, maxiter=10000, disp=True, with_constraint=True, tol=1e-14) + # results = fit_KL_slsqp.run( + # coeffs, e_0, maxiter=10000, disp=True, with_constraint=True, tol=1e-14 + # ) print("KL-FPI INFO") print("-----------") diff --git a/examples/table/table_3.py b/examples/table/table_3.py index 1e01478..7b795dc 100644 --- a/examples/table/table_3.py +++ b/examples/table/table_3.py @@ -9,7 +9,7 @@ import numpy as np from bfit.density import SlaterAtoms -from bfit.fit import KLDivergenceFPI, ScipyFit +from bfit.fit import ScipyFit from bfit.grid import ClenshawRadialGrid from bfit.measure import KLDivergence from bfit.model import AtomicGaussianDensity diff --git a/pyproject.toml b/pyproject.toml index 82541aa..6028a1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -127,15 +127,6 @@ line-length = 100 # ) # ''' -[tool.isort] -profile = "black" -known_first_party = ["bfit"] -# If you need to exclude files from having their imports sorted -#extend_skip_glob = [ -# "bfit/somefile.py", -# "bfit/somedir/*", -#] - # https://beta.ruff.rs/docs [tool.ruff] line-length = 100 @@ -329,4 +320,3 @@ disable=[ "no-else-return", "too-many-statements", ] - diff --git a/tox.ini b/tox.ini index 2b9d4eb..271382b 100644 --- a/tox.ini +++ b/tox.ini @@ -26,6 +26,9 @@ commands = ignore_errors = true [testenv:linters] +ignore_errors = true +# allow for linters to fail +# ignore_outcome = true deps = numpy scipy @@ -39,15 +42,13 @@ deps = # black bandit commands = - flake8 bfit/ bfit/test + python -m flake8 --config=tox.ini bfit/ bfit/test pylint bfit --rcfile=pyproject.toml --disable=similarities # black -l 100 --check ./ # black -l 100 --diff ./ # Use bandit configuration file bandit -r bfit -c .bandit.yml -ignore_errors = true - [testenv:coverage-report] deps = coverage>=4.2 skip_install = true @@ -93,8 +94,10 @@ exclude = .eggs, max-line-length = 100 -import-order-style = google -ignore = +; import-order-style = google +import-order-style = smarkets +application-import-names = bfit +extend-ignore = # E121 : continuation line under-indented for hanging indent E121, # E123 : closing bracket does not match indentation of opening bracket’s line @@ -191,3 +194,4 @@ source = bfit .tox/*/lib/python*/site-packages/bfit .tox/pypy*/site-packages/bfit +