Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import datetime
import os

from sphinx.domains.python import PythonDomain

from sasdata import __version__ as sasdata_version

if os.path.exists('rst_prolog'):
Expand Down Expand Up @@ -31,4 +33,26 @@
# -- Options for HTML output -------------------------------------------------

html_theme = 'default'
html_static_path = ['_static']

# Ignore missing references to sections in SasView documentation
def on_missing_reference(app, env, node, contnode):
if node["reftarget"] in [
"file_converter_tool",
"image_viewer_tool",
"sans_calculator_tool",
]:
return contnode
else:
return None

# Bypass stupid sphinx handling of multiple classes with members named *type*
class PatchedPythonDomain(PythonDomain):
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
if 'refspecific' in node:
del node['refspecific']
return super(PatchedPythonDomain, self).resolve_xref(
env, fromdocname, builder, typ, target, node, contnode)

def setup(app):
app.connect("missing-reference", on_missing_reference)
app.add_domain(PatchedPythonDomain, override=True)
4 changes: 3 additions & 1 deletion docs/source/dev/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ Developer Documentation
.. toctree::
:maxdepth: 8

SasData <generated/sasdata>
SasData <generated/sasdata>

Modules <generated/modules>
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ requires = [
"h5py",
"lxml",
"numpy",
"scipy",
"matplotlib",
]
build-backend = "hatchling.build"

Expand Down Expand Up @@ -94,6 +96,7 @@ header = "SasData"
[[tool.hatch.build.targets.wheel.hooks.sphinx.tools]]
tool = "build"
format = "html"
warnings = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Please let me know if any additional hatch-sphinx features are needed for this work!)

source = "source"
out_dir = "../build/docs"
environment = { PYTHONPATH=".." }
Expand Down
38 changes: 19 additions & 19 deletions sasdata/data_util/averaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ def __call__(self, data2d: Data2D) -> Data1D:


class CircularAverage(PolarROI):
"""
Calculate I(|Q|) by circularly averaging 2D data between 2 radial limits.
r"""
Calculate I(\|Q\|) by circularly averaging 2D data between 2 radial limits.

This class is initialised by specifying lower and upper limits on the
magnitude of Q values to consider during the averaging, though currently
Expand All @@ -290,13 +290,13 @@ def __init__(
nbins: int = 100,
base: float | None = None,
) -> None:
"""
r"""
Set up the lower and upper radial limits as well as the number of bins.

The units are A^-1 for the radial parameters.
:param r_min: Lower limit for |Q| values to use during averaging.
:param r_max: Upper limit for |Q| values to use during averaging.
:param nbins: The number of bins data is sorted into along |Q| the axis
:param r_min: Lower limit for \|Q\| values to use during averaging.
:param r_max: Upper limit for \|Q\| values to use during averaging.
:param nbins: The number of bins data is sorted into along \|Q\| the axis
"""
super().__init__(r_range=r_range, center=center)
self.nbins: int = nbins
Expand Down Expand Up @@ -396,12 +396,12 @@ def __init__(
nbins: int = 100,
base: float | None = None,
) -> None:
"""
r"""
Set up the lower and upper radial limits as well as the number of bins.

The units are A^-1 for the radial parameters.
:param r_min: Lower limit for |Q| values to use during averaging.
:param r_max: Upper limit for |Q| values to use during averaging.
:param r_min: Lower limit for \|Q\| values to use during averaging.
:param r_max: Upper limit for \|Q\| values to use during averaging.
:param nbins: The number of bins data is sorted into along Phi the axis
"""
super().__init__(r_range=r_range, center=center)
Expand Down Expand Up @@ -549,7 +549,7 @@ def __call__(self, data2d: Data2D = None) -> Data1D:


class SectorQ(PolarROI):
"""
r"""
Project I(Q, φ) data onto I(Q) within a region defined by Cartesian limits.

The projection is computed by averaging together datapoints with the same
Expand All @@ -558,7 +558,7 @@ class SectorQ(PolarROI):

This class is initialised by specifying lower and upper limits on both the
magnitude of Q and the angle φ. These four parameters specify the primary
Region Of Interest, however there is a secondary ROI with the same |Q|
Region Of Interest, however there is a secondary ROI with the same \|Q\|
values on the opposite side of the origin (φ + π). How this secondary ROI
is treated depends on the value of the `fold` parameter. If fold is set to
True, data on opposite sides of the origin are averaged together and the
Expand All @@ -579,14 +579,14 @@ def __init__(
fold: bool = True,
base: float | None = None,
) -> None:
"""
r"""
Set up the ROI boundaries, the binning of the output 1D data, and fold.

The units are A^-1 for radial parameters, and radians for anglar ones.
:param r_range: Tuple (r_min, r_max) defining limits for |Q| values to use during averaging.
:param r_range: Tuple (r_min, r_max) defining limits for \|Q\| values to use during averaging.
:param phi_range: Tuple (phi_min, phi_max) defining limits for φ in radians (in the primary ROI).
:Defaults to full circle (0, 2*pi).
:param nbins: The number of bins data is sorted into along the |Q| axis
:param nbins: The number of bins data is sorted into along the \|Q\| axis
:param fold: Whether the primary and secondary ROIs should be folded
together during averaging.
"""
Expand Down Expand Up @@ -709,14 +709,14 @@ def __init__(
nbins: int = 100,
base: float | None = None,
) -> None:
"""
r"""
Set up the ROI boundaries, and the binning of the output 1D data.

The units are A^-1 for radial parameters, and radians for anglar ones.
:param r_range: Tuple (r_min, r_max) defining limits for |Q| values to use during averaging.
:param r_range: Tuple (r_min, r_max) defining limits for \|Q\| values to use during averaging.
:param phi_range: Tuple (phi_min, phi_max) defining limits for φ in radians (in the primary ROI).
:Defaults to full circle (0, 2*pi).
:param nbins: The number of bins data is sorted into along the |Q| axis
:param nbins: The number of bins data is sorted into along the \|Q\| axis
"""
super().__init__(r_range=r_range, phi_range=phi_range, center=center)
self.nbins: int = nbins
Expand Down Expand Up @@ -791,11 +791,11 @@ def __init__(
nbins: int = 100,
base: float | None = None,
) -> None:
"""
r"""
Set up the ROI boundaries, and the binning of the output 1D data.

The units are A^-1 for radial parameters, and radians for anglar ones.
:param r_range: Tuple (r_min, r_max) defining limits for |Q| values to use during averaging.
:param r_range: Tuple (r_min, r_max) defining limits for \|Q\| values to use during averaging.
:param phi_range: Tuple (phi_min, phi_max) defining angular bounds in radians.
Defaults to full circle (0, 2*pi).
:param nbins: The number of bins data is sorted into along the φ axis.
Expand Down
2 changes: 1 addition & 1 deletion sasdata/data_util/binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def get_bin_index(self, value):
2pi to 0 discontinuity.

:param value: A coordinate value in the binning interval along the major axis,
whose bin index should be returned. Must be between min_value and max_value.
whose bin index should be returned. Must be between min_value and max_value.

The general formula logarithm binning is:
bin = floor(N * (log(x) - log(min)) / (log(max) - log(min)))
Expand Down
1 change: 1 addition & 0 deletions sasdata/data_util/manipulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ class SlabX(SlabX):

Old signature:
SlabX(x_min=0, x_max=0, y_min=0, y_max=0, bin_width=0.001, fold=False)

New signature uses nbins; translate bin_width -> nbins using ceil(range/bin_width)
"""
def __init__(self, x_min=0.0, x_max=0.0, y_min=0.0,
Expand Down
10 changes: 5 additions & 5 deletions sasdata/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,11 @@ def meta_tags(obj: dataclass) -> list[str]:

Example:

>@dataclass
class Thermometer:
temperature: float
units: str
params: list
> @dataclass
> class Thermometer:
> temperature: float
> units: str
> params: list
> item = Example()
> item.temperature = 273
> item.units = "K"
Expand Down
8 changes: 4 additions & 4 deletions sasdata/model_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ def slit_resolution(q_calc, q, width, length, n_length=30):

where $I(u_j)$ is the value at the mid-point, and $\Delta u_j$ is the
difference between consecutive edges which have been first converted
to $u$. Only $u_j \in [0, \Delta q_\perp]$ are used, which corresponds
to $q_j \in \left[q, \sqrt{q^2 + \Delta q_\perp}\right]$, so
to $u$. Only $u_j \in [0, \Delta q\_\perp]$ are used, which corresponds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spot checked these ones and found:

Image

(screenshot from downloading the artifact from CI and unzipping the whl)

Looking at the sphinx config, it's not actually loading any sort of dollar-math or mathjax sphinx extension - presumably this has actually been broken in the docs since they separated from sasview (which has its own private dollar-math sphinx extension).

Perhaps also time to add that?

https://github.com/matthew-brett/texext (packaged for Debian and used by a few packages)
https://github.com/sympy/sphinx-math-dollar/ (not packaged for Debian)
https://github.com/SasView/sasview/blob/main/docs/sphinx-docs/source/_extensions/dollarmath.py (sasview version)

to $q_j \in \left[q, \sqrt{q^2 + \Delta q\_\perp}\right]$, so

.. math::

Expand Down Expand Up @@ -447,8 +447,8 @@ def slit_resolution(q_calc, q, width, length, n_length=30):
\left[q-\Delta q_\parallel, q+\Delta q_\parallel\right]

However, we need to support cases were $u_j < 0$, which means using
$2 (q_{j+1} - q_j)$ when $q_j \in \left[0, q_\parallel-q_i\right]$.
This is not an issue for $q_i > q_\parallel$.
$2 (q_{j+1} - q_j)$ when $q_j \in \left[0, q\_\parallel-q\_i\right]$.
This is not an issue for $q_i > q\_\parallel$.

For both $q_\perp > 0$ and $q_\parallel > 0$ we perform a 2 dimensional
integration with
Expand Down
14 changes: 0 additions & 14 deletions sasdata/quantities/absolute_temperature.py

This file was deleted.

Loading
Loading