Skip to content

Commit

Permalink
Merge branch 'master' into TwoYukawa
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Kienzle committed Jan 29, 2024
2 parents 626ec28 + 59f5bae commit 8a2a933
Show file tree
Hide file tree
Showing 78 changed files with 2,491 additions and 1,171 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -59,3 +59,12 @@ jobs:
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
make -j 4 -C doc SPHINXOPTS="-W --keep-going -n" html
- name: Publish samodels docs
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'}}
uses: actions/upload-artifact@v3
with:
name: sasmodels-docs-${{ matrix.os }}-${{ matrix.python-version }}
path: |
doc/_build/html
if-no-files-found: error
21 changes: 21 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
Release notes
=============

v1.0.7 2023-02-??
------------------
* Doc upate: corefunc and optimizer documentation
* Doc update: various models (cylinder, gel_fit, paracrystal, core_shell_ellipsoid)
* Fix error in BCC and FCC paracrystaline models
* Fix rare race condition causing errors
* Fix to allow multiple scattering scripts to run
* Fix problem with models containing complex amplitudes not compiling on the fly
* Restructuring and cross-linking of sasmodels docs
* Update web links and contributor list

v1.0.6 2022-03-17
------------------
* implements generalized 3D description of magnetic SANS
* adds Boucher-type SLD profile to the selection in the model spherical_sld
* improves naming conventions of constants in magnetic SANS
* composite mixture models with multiplicity are now allowed
* improvements to the superball model
* fix to bug in magnetic SLD calculations
* updates to documentation

v1.0.5 2021-01-26
------------------
* fix probelm with P(Q) scaling when using a shell type form factors
Expand Down
3 changes: 2 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2009-2021, SasView Developers
Copyright (c) 2009-2022, SasView Developers


All rights reserved.

Expand Down
7 changes: 6 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

nitpick_ignore = [
('py:class', 'argparse.Namespace'),
('py:class', 'bumps.parameter.Parameter'),
('py:class', 'collections.OrderedDict'),
('py:class', 'cuda.Context'),
('py:class', 'cuda.Function'),
Expand All @@ -51,10 +50,16 @@
('py:class', 'Data1D'),
('py:class', 'Data2D'),
('py:class', 'Kernel'),
('py:class', 'KernelModel'),
('py:class', 'ModelInfo'),
('py:class', 'module'),
('py:class', 'SesansData'),
('py:class', 'SourceModule'),
# KernelModel and Calculator breaking on git actions tests, even though
# KernelModel is already listed. astropy example sometimes includes full
# path to complaining symbol. Let's see if that helps here:
('py:class', 'sasmodels.compare.Calculator'),
('py:class', 'sasmodels.kernel.KernelModel'),
]

# -- General configuration -----------------------------------------------------
Expand Down
56 changes: 43 additions & 13 deletions doc/genmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import re
import shutil
import argparse
import subprocess

# CRUFT: python 2.7 backport of makedirs(path, exist_ok=False)
if sys.version_info[0] >= 3:
Expand Down Expand Up @@ -148,8 +149,10 @@ def make_figure(model_info, opts):
"""
import matplotlib.pyplot as plt

print("Build model")
model = core.build_model(model_info)

print("Set up figure")
fig_height = 3.0 # in
fig_left = 0.6 # in
fig_right = 0.5 # in
Expand All @@ -167,8 +170,10 @@ def make_figure(model_info, opts):
ax_width = ax_height/ratio # square axes
fig = plt.figure(figsize=aspect)
ax2d = fig.add_axes([0.5+ax_left, ax_bottom, ax_width, ax_height])
print("2D plot")
plot_2d(model, opts, ax2d)
ax1d = fig.add_axes([ax_left, ax_bottom, ax_width, ax_height])
print("1D plot")
plot_1d(model, opts, ax1d)
#ax.set_aspect('square')
else:
Expand All @@ -182,11 +187,14 @@ def make_figure(model_info, opts):
aspect = (fig_width, fig_height)
fig = plt.figure(figsize=aspect)
ax1d = fig.add_axes([ax_left, ax_bottom, ax_width, ax_height])
print("1D plot")
plot_1d(model, opts, ax1d)

if model_info.profile:
print("Profile inset")
plot_profile_inset(model_info, ax1d)

print("Save")
# Save image in model/img
makedirs(joinpath(TARGET_DIR, 'img'), exist_ok=True)
path = joinpath(TARGET_DIR, 'img', figfile(model_info))
Expand Down Expand Up @@ -290,7 +298,7 @@ def gen_docs(model_info, outfile):
print('------------------------------------------------------------------')
docstr += insertion

with open(outfile, 'w') as fid:
with open(outfile, 'w', encoding='utf-8') as fid:
fid.write(docstr)

def make_figure_cached(model_info, opts):
Expand All @@ -311,7 +319,9 @@ def make_figure_cached(model_info, opts):
# check if we are caching
cache_dir = os.environ.get('SASMODELS_BUILD_CACHE', None)
if cache_dir is None:
print("Nothing cashed, creating...")
make_figure(model_info, opts)
print("Made a figure")
return

# TODO: changing default parameters won't trigger a rebuild.
Expand Down Expand Up @@ -387,31 +397,57 @@ def process_model(py_file, force=False):
}

# Generate the RST file and the figure. Order doesn't matter.
print("generating", rst_file)
print("generating rst", rst_file)
print("1: docs")
gen_docs(model_info, rst_file)
print("2: figure", end='')
if force:
print()
make_figure(model_info, PLOT_OPTS)
else:
print(" (cached)")
make_figure_cached(model_info, PLOT_OPTS)
print("Done process_model")

return rst_file

def run_sphinx(rst_files, output):
"""
Use sphinx to build *rst_files*, storing the html in *output*.
"""

print("Building index...")

conf_dir = dirname(realpath(__file__))
with open(joinpath(TARGET_DIR, 'index.rst'), 'w') as fid:
fid.write(".. toctree::\n\n")
for path in rst_files:
fid.write(" %s\n"%basename(path))

print("Running sphinx command...")

command = [
sys.executable,
"-m", "sphinx",
"-c", conf_dir,
TARGET_DIR,
output,
]
os.system(" ".join(repr(s) for s in command))

process = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE)

# Make sure we can see process output in real time
while True:

output = process.stdout.readline()

if process.poll() is not None:
break

if output:
print(output.strip())



def main():
"""
Expand Down Expand Up @@ -442,19 +478,13 @@ def main():
sys.exit(1)
makedirs(TARGET_DIR, exist_ok=True)

if args.cpus == -1:
cpus = int(os.environ.get("SASMODELS_BUILD_CPUS", "0"))
else:
cpus = args.cpus
if cpus != 1 and not args.force:
import multiprocessing
p = multiprocessing.Pool(cpus if cpus > 0 else None)
rst_files = p.map(process_model, args.files)
else:
rst_files = [process_model(py_file, args.force)
print("** 'Normal' processing **")
rst_files = [process_model(py_file, args.force)
for py_file in args.files]
print("normal .rst file processing complete")

if args.sphinx:
print("running sphinx")
run_sphinx(rst_files, args.build)


Expand Down
Loading

0 comments on commit 8a2a933

Please sign in to comment.