Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Black #429

Merged
merged 6 commits into from Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
@@ -0,0 +1,2 @@
# Run black on .py files
46af8fdc155982f93eee2279496fa5b1efaf907c
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Expand Up @@ -17,13 +17,10 @@ repos:
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.32.0
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: yapf
args: [ "-i", "-r" ]
types: [ "python" ]
additional_dependencies: [ "toml" ]
- id: black
- repo: https://github.com/kynan/nbstripout
rev: 0.6.0
hooks:
Expand Down
1 change: 0 additions & 1 deletion benchmarks/load_nexus.py
Expand Up @@ -2,7 +2,6 @@


class LoadNexus:

def setup(self):
self.file_path = scn.data.get_path('PG3_4844_event.nxs')

Expand Down
1 change: 0 additions & 1 deletion benchmarks/transform_coords.py
Expand Up @@ -6,7 +6,6 @@


class TransformCoords:

def setup(self):
da = scn.load(scn.data.get_path('PG3_4844_event.nxs'))
self.var_tof = da
Expand Down
44 changes: 23 additions & 21 deletions docs/about/release-notes.rst
Expand Up @@ -40,7 +40,7 @@ v0.xy.0 (Unreleased)
Features
~~~~~~~~

* Added :func:`scippneutron.conversion.tof.hkl_vec_from_Q_vec` `427 <https://github.com/scipp/scipp/pull/427>`_.
* Added :func:`scippneutron.conversion.tof.hkl_vec_from_Q_vec` `#427 <https://github.com/scipp/scippneutron/pull/427>`_.

Breaking changes
~~~~~~~~~~~~~~~~
Expand All @@ -57,6 +57,8 @@ Deprecations
Stability, Maintainability, and Testing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Switched to black for Python code formatting `#429 <https://github.com/scipp/scippneutron/pull/429>`_.

Contributors
~~~~~~~~~~~~

Expand All @@ -70,7 +72,7 @@ v23.03.1 (March 2022)
Bugfixes
~~~~~~~~

* Conversion from ``mantid.MaskWorkspace`` now correctly sets ``unit=None`` instead of using dimensionless `424 <https://github.com/scipp/scipp/pull/424>`_.
* Conversion from ``mantid.MaskWorkspace`` now correctly sets ``unit=None`` instead of using dimensionless `#424 <https://github.com/scipp/scippneutron/pull/424>`_.

v23.03.0
--------
Expand All @@ -83,8 +85,8 @@ Breaking Changes
Features
~~~~~~~~

* Coordinate transformation kernel for :math:`\vec{Q}` `412 <https://github.com/scipp/scipp/pull/412>`_.
* Added :func:`scippneutron.io.xye.save_xye` and :func:`scippneutron.io.xye.load_xye` `417 <https://github.com/scipp/scipp/pull/417>`_.
* Coordinate transformation kernel for :math:`\vec{Q}` `#412 <https://github.com/scipp/scippneutron/pull/412>`_.
* Added :func:`scippneutron.io.xye.save_xye` and :func:`scippneutron.io.xye.load_xye` `#417 <https://github.com/scipp/scippneutron/pull/417>`_.

v23.01.0 (January 2023)
-----------------------
Expand All @@ -93,7 +95,7 @@ Breaking Changes
~~~~~~~~~~~~~~~~

* Requires Scipp v23.1.1 and ScippNexus v23.1.1
* :func:`scippneutron.load_nexus` may now return ``scipp.DataGroup`` objects if parts of the file cannot be read `401 <https://github.com/scipp/scipp/pull/401>`_.
* :func:`scippneutron.load_nexus` may now return ``scipp.DataGroup`` objects if parts of the file cannot be read `#401 <https://github.com/scipp/scippneutron/pull/401>`_.

v22.12.4 (December 2022)
------------------------
Expand All @@ -110,17 +112,17 @@ v22.12.0 (December 2022)
Features
~~~~~~~~

* ScippNeutron is now available on PyPI `#384 <https://github.com/scipp/scipp/pull/384>`_.
* ScippNeutron is now available on PyPI `#384 <https://github.com/scipp/scippneutron/pull/384>`_.

Breaking changes
~~~~~~~~~~~~~~~~

* Removed C++ components and CMake package configuration. This only affects users that linked against the C++ part of ScippNeutron `#384 <https://github.com/scipp/scipp/pull/384>`_.
* Removed C++ components and CMake package configuration. This only affects users that linked against the C++ part of ScippNeutron `#384 <https://github.com/scipp/scippneutron/pull/384>`_.

Stability, Maintainability, and Testing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* ScippNeutron no longer depends on a specific version of Scipp`#384 <https://github.com/scipp/scipp/pull/384>`_.
* ScippNeutron no longer depends on a specific version of Scipp`#384 <https://github.com/scipp/scippneutron/pull/384>`_.

Contributors
~~~~~~~~~~~~
Expand All @@ -135,17 +137,17 @@ v0.11.0 (November 2022)
Features
~~~~~~~~

* The instrument view will now use ``plopp`` if it is the current default for plotting `#378 <https://github.com/scipp/scipp/pull/378>`_.
* The instrument view will now use ``plopp`` if it is the current default for plotting `#378 <https://github.com/scipp/scippneutron/pull/378>`_.

Breaking changes
~~~~~~~~~~~~~~~~

* The instrument view no longer accepts a dataset as input, only data arrays are supported `#378 <https://github.com/scipp/scipp/pull/378>`_.
* The instrument view no longer accepts a dataset as input, only data arrays are supported `#378 <https://github.com/scipp/scippneutron/pull/378>`_.

Bugfixes
~~~~~~~~

* :func:`scippneutron.load_nexus` now works with scippnexus 0.4.1 `#380 <https://github.com/scipp/scipp/pull/380>`_.
* :func:`scippneutron.load_nexus` now works with scippnexus 0.4.1 `#380 <https://github.com/scipp/scippneutron/pull/380>`_.

Contributors
~~~~~~~~~~~~
Expand Down Expand Up @@ -190,7 +192,7 @@ v0.9.3 (September 2022)
Features
~~~~~~~~

* Update for compatibility with scippnexus v0.3 `#370 <https://github.com/scipp/scipp/pull/370>`_.
* Update for compatibility with scippnexus v0.3 `#370 <https://github.com/scipp/scippneutron/pull/370>`_.


v0.9.2 (August 2022)
Expand All @@ -199,7 +201,7 @@ v0.9.2 (August 2022)
Features
~~~~~~~~

* Made compatible with scippnexus v0.2 `#369 <https://github.com/scipp/scipp/pull/369>`_.
* Made compatible with scippnexus v0.2 `#369 <https://github.com/scipp/scippneutron/pull/369>`_.

Contributors
~~~~~~~~~~~~
Expand Down Expand Up @@ -229,18 +231,18 @@ v0.9.0 (August 2022)
Features
~~~~~~~~

* Kernels for coordinate transformations are now public in :mod:`scippneutron.conversion` `#361 <https://github.com/scipp/scipp/pull/361>`_.
* Kernels for coordinate transformations are now public in :mod:`scippneutron.conversion` `#361 <https://github.com/scipp/scippneutron/pull/361>`_.

Bugfixes
~~~~~~~~

* Fixed ``dspacing_from_wavelength``, results used to be wrong by a factor of ``10**10`` `#361 <https://github.com/scipp/scipp/pull/361>`_.
* ``two_theta`` as used by coordinate transformations now uses a numerically more stable implementation, the old one had an error of up to ``10**-6`` for small angles `#361 <https://github.com/scipp/scipp/pull/361>`_.
* Fixed ``dspacing_from_wavelength``, results used to be wrong by a factor of ``10**10`` `#361 <https://github.com/scipp/scippneutron/pull/361>`_.
* ``two_theta`` as used by coordinate transformations now uses a numerically more stable implementation, the old one had an error of up to ``10**-6`` for small angles `#361 <https://github.com/scipp/scippneutron/pull/361>`_.

Breaking changes
~~~~~~~~~~~~~~~~

* ``scippneutron.tof.conversions`` has been split into :mod:`scippneutron.conversion.graph.beamline` and :mod:`scippneutron.conversion.graph.tof` `#361 <https://github.com/scipp/scipp/pull/361>`_.
* ``scippneutron.tof.conversions`` has been split into :mod:`scippneutron.conversion.graph.beamline` and :mod:`scippneutron.conversion.graph.tof` `#361 <https://github.com/scipp/scippneutron/pull/361>`_.
* Switched to scipp 0.16.1

Contributors
Expand Down Expand Up @@ -291,7 +293,7 @@ v0.6.0 (May 2022)
Breaking changes
~~~~~~~~~~~~~~~~

* Remove accidental dependency on Mantid. Users now have to install Mantid themselves if they need it `#332 <https://github.com/scipp/scipp/pull/332>`_.
* Remove accidental dependency on Mantid. Users now have to install Mantid themselves if they need it `#332 <https://github.com/scipp/scippneutron/pull/332>`_.
* Removed module ``scippneutron.nexus`` in favor of `scippnexus <https://scipp.github.io/scippnexus/>`_ to implement :func:`scippneutron.load_nexus`.

Bugfixes
Expand Down Expand Up @@ -373,12 +375,12 @@ v0.4.0 (October 2021)
Features
~~~~~~~~

* Add ``tof.conversions`` module with building blocks for custom coordinate transformation graphs `#187 <https://github.com/scipp/scipp/pull/187>`_.
* Add ``tof.conversions`` module with building blocks for custom coordinate transformation graphs `#187 <https://github.com/scipp/scippneutron/pull/187>`_.

Breaking changes
~~~~~~~~~~~~~~~~

* Changed behavior of ``convert`` `#162 <https://github.com/scipp/scipp/pull/162>`_.
* Changed behavior of ``convert`` `#162 <https://github.com/scipp/scippneutron/pull/162>`_.

* It is no longer possible to convert *to* time-of-flight.
* To compensate, it is now possible to convert between wavelength, energy, and d-spacing directly.
Expand Down Expand Up @@ -460,7 +462,7 @@ Features
This includes in particular the instrument view and "unit conversions" for time-of-flight neutron sources.
* Convert supports a greatly enhanced way of obtaining required parameters of the beamline.
Instead of requiring raw component positions it can now work directly with, e.g., ``two_theta``.
* Add scipp ``datetime64`` support in mantid-scipp converters `#39 <https://github.com/scipp/scipp/pull/39>`_.
* Add scipp ``datetime64`` support in mantid-scipp converters `#39 <https://github.com/scipp/scippneutron/pull/39>`_.

Breaking changes
~~~~~~~~~~~~~~~~
Expand Down
80 changes: 50 additions & 30 deletions docs/conf.py
Expand Up @@ -38,12 +38,14 @@ def add_buttons(
l1.append({"type": "link", "text": "scippneutron", "url": f"{base}/scippneutron"})
l1.append({"type": "link", "text": "ess", "url": f"{base}/ess"})
header_buttons = context["header_buttons"]
header_buttons.append({
"type": "group",
"buttons": l1,
"icon": "fa fa-caret-down",
"text": "Related projects"
})
header_buttons.append(
{
"type": "group",
"buttons": l1,
"icon": "fa fa-caret-down",
"text": "Related projects",
}
)
releases = version_info.minor_releases(first='0.4')
if outdated:
current = f"{long_version} (outdated)"
Expand All @@ -55,17 +57,12 @@ def add_buttons(
entries = releases[1:]
lines = [{"type": "link", "text": latest, "url": f"{base}/{project}"}]
for r in entries:
lines.append({
"type": "link",
"text": f"{r}",
"url": f"{base}/{project}/release/{r}"
})
header_buttons.append({
"type": "group",
"buttons": lines,
"icon": "fa fa-caret-down",
"text": current
})
lines.append(
{"type": "link", "text": f"{r}", "url": f"{base}/{project}/release/{r}"}
)
header_buttons.append(
{"type": "group", "buttons": lines, "icon": "fa fa-caret-down", "text": current}
)


sphinx_book_theme.add_launch_buttons = add_buttons
Expand All @@ -82,11 +79,18 @@ def add_buttons(
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.doctest',
'sphinx.ext.intersphinx', 'sphinx.ext.mathjax', 'sphinx.ext.napoleon',
'sphinx_autodoc_typehints', 'sphinx_copybutton', 'sphinxcontrib.bibtex',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx_autodoc_typehints',
'sphinx_copybutton',
'sphinxcontrib.bibtex',
'IPython.sphinxext.ipython_directive',
'IPython.sphinxext.ipython_console_highlighting', 'nbsphinx'
'IPython.sphinxext.ipython_console_highlighting',
'nbsphinx',
]

autodoc_type_aliases = {
Expand All @@ -106,7 +110,7 @@ def add_buttons(
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
'scipp': ('https://scipp.github.io/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
'xarray': ('https://xarray.pydata.org/en/stable/', None)
'xarray': ('https://xarray.pydata.org/en/stable/', None),
}

# autodocs includes everything, even irrelevant API internals. autosummary
Expand Down Expand Up @@ -193,7 +197,8 @@ def add_buttons(
f"⚠️ You are viewing the documentation for an old version of {project}. "
f"Switch to <a href='https://scipp.github.io/{project}' "
"style='color:white;text-decoration:underline;'"
">latest</a> version. ⚠️")
">latest</a> version. ⚠️"
)

html_logo = "_static/logo-2022.svg"
html_favicon = "_static/favicon.ico"
Expand All @@ -216,8 +221,13 @@ def add_buttons(
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'scippneutron.tex', u'scippneutron Documentation', u'Simon Heybrock',
'manual'),
(
master_doc,
'scippneutron.tex',
u'scippneutron Documentation',
u'Simon Heybrock',
'manual',
),
]

# -- Options for manual page output ---------------------------------------
Expand All @@ -232,8 +242,15 @@ def add_buttons(
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'scippneutron', u'scippneutron Documentation', author, 'scippneutron',
'One line description of project.', 'Miscellaneous'),
(
master_doc,
'scippneutron',
u'scippneutron Documentation',
author,
'scippneutron',
'One line description of project.',
'Miscellaneous',
),
]

# -- Options for Matplotlib in notebooks ----------------------------------
Expand All @@ -251,9 +268,12 @@ def add_buttons(

# Using normalize whitespace because many __str__ functions in scipp produce
# extraneous empty lines and it would look strange to include them in the docs.
doctest_default_flags = doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL | \
doctest.DONT_ACCEPT_TRUE_FOR_1 | \
doctest.NORMALIZE_WHITESPACE
doctest_default_flags = (
doctest.ELLIPSIS
| doctest.IGNORE_EXCEPTION_DETAIL
| doctest.DONT_ACCEPT_TRUE_FOR_1
| doctest.NORMALIZE_WHITESPACE
)

# -- Options for linkcheck ------------------------------------------------

Expand Down