Skip to content

Commit

Permalink
Black formatter gets run upon commit (pre-commit hook).
Browse files Browse the repository at this point in the history
  • Loading branch information
canismarko committed Jun 9, 2022
1 parent 1b31bbc commit 6fcea00
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 30 deletions.
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.10
19 changes: 9 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,38 @@

# -- Project information -----------------------------------------------------

project = 'haven'
copyright = '2022, Argonne National Laboratory'
author = 'Mark Wolfman'
project = "haven"
copyright = "2022, Argonne National Laboratory"
author = "Mark Wolfman"

# The full version, including alpha/beta/rc tags
release = '0.1.0'
release = "0.1.0"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
extensions = []

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'classic'
html_theme = "classic"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
15 changes: 4 additions & 11 deletions environment_2022_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ dependencies:
# --- Python core packages
- python=3.9
- ipython
- ipykernel
- jupyter
- jupyterlab
- notebook
- pip
- psutil

# --- testing and quality assurance
- pre-commit
- black
- flake8
- pylint
- pytest
- pytest-cov

# --- Qt
- pyqt=5
Expand Down Expand Up @@ -61,19 +64,13 @@ dependencies:

# # --- packaging and publishing
- poetry
- sphinx
# - conda-build
# - coverage
- sphinx
# - sphinxcontrib-napoleon
# - twine
# - versioneer

# Code linting and formatting
- black
- flake8

- ipykernel

- pip:
- apstools
- area-detector-handlers
Expand All @@ -91,7 +88,3 @@ dependencies:
# --- optional Bluesky framework packages for evaluation
# - bluesky-webclient is NOT Python software, don't install it this way
# https://github.com/bluesky/bluesky-webclient

# Testing
- pytest
- pytest-cov
10 changes: 4 additions & 6 deletions haven/plans/align_slits.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ def align_slits(slit_motors=[], ion_chamber=None):
for motor in slit_motors:
# Set up the live fit object to process the results
def gaussian(x, A, sigma, x0):
return A*np.exp(-(x - x0)**2/(2 * sigma**2))
return A * np.exp(-((x - x0) ** 2) / (2 * sigma**2))

model = lmfit.Model(gaussian)
init_guess = {'A': 2,
'sigma': lmfit.Parameter('sigma', 3, min=0),
'x0': -0.2}
fit = LiveFit(model, ion_chamber.name, {'x': motor.name}, init_guess)
init_guess = {"A": 2, "sigma": lmfit.Parameter("sigma", 3, min=0), "x0": -0.2}
fit = LiveFit(model, ion_chamber.name, {"x": motor.name}, init_guess)
scan = subs_decorator(fit)(align_slit_scan)
# Execute the scan
yield from scan(ion_chamber=ion_chamber, slit_motor=motor)
# Move the slit motor to the center of the Gaussian peak
new_center = fit.result.values['x0']
new_center = fit.result.values["x0"]
yield from bps.mv(motor, new_center)
1 change: 1 addition & 0 deletions tests/run_engine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from bluesky import RunEngine


class RunEngineStub(RunEngine):
pass
14 changes: 11 additions & 3 deletions tests/test_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@ class PlanUnitTests(unittest.TestCase):
else-where.
"""

RE = RunEngineStub()

def test_align_slits(self):
"""Check the plan to aligns the slits."""
# Prepare a fake detector and slit motor
slit_motor = sim.motor
I0 = sim.SynGauss('det', sim.motor, 'motor', center=-0.5, Imax=1, sigma=1,
labels={'detectors'})
I0 = sim.SynGauss(
"det",
sim.motor,
"motor",
center=-0.5,
Imax=1,
sigma=1,
labels={"detectors"},
)
# Execute the plan
self.RE(align_slits(slit_motors=[slit_motor], ion_chamber=I0))
# Check that the slit positions have been set
Expand Down

0 comments on commit 6fcea00

Please sign in to comment.