Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions doc/_extensions/numfig.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from docutils.nodes import figure, caption, Text, reference, raw, SkipNode
from docutils.nodes import SkipNode, Text, caption, figure, raw, reference
from sphinx.roles import XRefRole


# Element classes

class page_ref(reference):
Expand Down
3 changes: 1 addition & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -24,7 +24,6 @@
print("\n".join(sys.path))
import sasmodels


nitpick_ignore = [
('py:class', 'argparse.Namespace'),
('py:class', 'bumps.parameter.Parameter'),
Expand Down
16 changes: 9 additions & 7 deletions doc/genmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,28 @@
have one.
"""

import sys
import os
from os import makedirs
from os.path import basename, dirname, realpath, join as joinpath, exists
import argparse
import math
import os
import re
import shutil
import argparse
import subprocess
import sys
from os import makedirs
from os.path import basename, dirname, exists, realpath
from os.path import join as joinpath

import numpy as np

# TODO: Remove this line when genmodel is moved to the sasmodels directory.
sys.path.insert(0, realpath(joinpath(dirname(__file__), '..')))
from sasmodels import generate, core
from sasmodels.direct_model import DirectModel, call_profile
from sasmodels import core, generate
from sasmodels.data import empty_data1D, empty_data2D
from sasmodels.direct_model import DirectModel, call_profile

try:
from typing import Any

from sasmodels.kernel import KernelModel
from sasmodels.modelinfo import ModelInfo
except ImportError:
Expand Down
7 changes: 5 additions & 2 deletions doc/gentoc.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@

import sys

# make sure sasmodels is on the path
sys.path.append('..')

from os import mkdir
from os.path import basename, exists, join as joinpath
from os.path import basename, exists
from os.path import join as joinpath

from sasmodels.core import load_model_info

try:
from typing import Optional, BinaryIO
from typing import BinaryIO, Optional
except ImportError:
pass

Expand Down
4 changes: 2 additions & 2 deletions example/batch_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
environment variable to set them.
"""

import sys
import os
import sys

import numpy as np
import matplotlib.pyplot as plt
import numpy as np
from bumps.dream.views import tile_axes # make a grid of plots

# GET INPUT AND ENSURE MODEL AND DATA FILES ARE DEFINED
Expand Down
5 changes: 3 additions & 2 deletions example/cylinder_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
Minimal example of calling a kernel for a specific set of q values.
"""

from numpy import logspace
from matplotlib import pyplot as plt
from numpy import logspace

from sasmodels.core import load_model
from sasmodels.direct_model import call_kernel, call_Fq
from sasmodels.direct_model import call_Fq, call_kernel

model = load_model('cylinder')
q = logspace(-3, -1, 200)
Expand Down
4 changes: 3 additions & 1 deletion example/fit.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env python

import sys

from bumps.names import FitProblem

from sasmodels.bumps_model import Experiment, Model
from sasmodels.core import load_model
from sasmodels.bumps_model import Model, Experiment
from sasmodels.data import load_data, set_beam_stop, set_top

""" IMPORT THE DATA USED """
Expand Down
3 changes: 2 additions & 1 deletion example/model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python

from bumps.names import FitProblem

from sasmodels.bumps_model import Experiment, Model
from sasmodels.core import load_model
from sasmodels.bumps_model import Model, Experiment
from sasmodels.data import load_data, set_beam_stop, set_top

""" IMPORT THE DATA USED """
Expand Down
4 changes: 2 additions & 2 deletions example/multiscatfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"""

from bumps.names import FitProblem

from sasmodels.bumps_model import Experiment, Model
from sasmodels.core import load_model
from sasmodels.bumps_model import Model, Experiment
from sasmodels.data import load_data

from sasmodels.multiscat import MultipleScattering

## Load the data
Expand Down
6 changes: 3 additions & 3 deletions example/oriented_usans.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from bumps.names import FitProblem
import numpy as np
from bumps.names import FitProblem

from sasmodels.data import load_data
from sasmodels.bumps_model import Experiment, Model
from sasmodels.core import load_model
from sasmodels.bumps_model import Model, Experiment
from sasmodels.data import load_data

# Spherical particle data, not ellipsoids
sans, usans = load_data('latex_smeared.xml', index='all')
Expand Down
1 change: 1 addition & 0 deletions example/polynomial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from numpy import inf

parameters = [
["n", "", 1, [1,5], "", "number of coefficients (or degree+1)"],
["c[n]", "", 0, [-inf, inf], "", "coefficients to c_n x^n"],
Expand Down
3 changes: 1 addition & 2 deletions example/sesans_parameters_css-hs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""
This is a data file used to load in sesans data and fit it using the bumps engine
"""
from bumps.names import Parameter

import sesansfit
from bumps.names import Parameter

# Enter the model name to use
model_name = "core_shell_sphere*hardsphere"
Expand Down
3 changes: 1 addition & 2 deletions example/sesans_parameters_sphere.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""
This is a data file used to load in sesans data and fit it using the bumps engine
"""
from bumps.names import Parameter

import sesansfit
from bumps.names import Parameter

# Enter the model name to use
model_name = "sphere"
Expand Down
3 changes: 1 addition & 2 deletions example/sesans_sphere_2micron.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""
This is a data file used to load in sesans data and fit it using the bumps engine
"""
from bumps.names import Parameter

import sesansfit
from bumps.names import Parameter

# Enter the model name to use
model_name = "sphere"
Expand Down
7 changes: 5 additions & 2 deletions example/sesansfit.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import logging
import numpy as np

import numpy as np
from bumps.names import FitProblem
from sasmodels import core, bumps_model

from sasdata.dataloader.loader import Loader

from sasmodels import bumps_model, core


def get_bumps_model(model_name):
kernel = core.load_model(model_name)
model = bumps_model.Model(kernel)
Expand Down
4 changes: 2 additions & 2 deletions example/sesansfit_CodeCampIII.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from bumps.names import FitProblem, Parameter
import numpy as np
from bumps.names import FitProblem, Parameter

from sasmodels import core, bumps_model
from sasmodels import bumps_model, core

if True: # fix when data loader exists
# from sas.dataloader.readers\
Expand Down
5 changes: 3 additions & 2 deletions example/simul_fit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from bumps.names import FitProblem, FreeVariables
import numpy as np
from bumps.names import FitProblem, FreeVariables

from sasmodels.bumps_model import Experiment, Model
from sasmodels.core import load_model
from sasmodels.bumps_model import Model, Experiment
from sasmodels.data import load_data

# latex data, same sample usans and sans
Expand Down
4 changes: 2 additions & 2 deletions example/slurm_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
## SBATCH options as comments do not seem to work. Maybe they neeed to be before
## the doc string? For now they are hardcoded in the sbatch call in submit_job.

import sys
import os
import tempfile
import shutil
import sys
import tempfile

DEFAULT_TIME_LIMIT = 2

Expand Down
3 changes: 2 additions & 1 deletion example/weights/cyclic_gaussian.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import numpy as np
from numpy import exp, sin, pi, radians, degrees
from numpy import degrees, exp, pi, radians, sin

from sasmodels.weights import Dispersion as BaseDispersion


class Dispersion(BaseDispersion):
r"""
Cyclic gaussian dispersion on orientation.
Expand Down
1 change: 1 addition & 0 deletions example/weights/gaussian_eq.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from sasmodels.weights import Dispersion as BaseDispersion


class Dispersion(BaseDispersion):
r"""
Gaussian dispersion, with 1-$\sigma$ width.
Expand Down
1 change: 1 addition & 0 deletions example/weights/laplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from sasmodels import weights


class Dispersion(weights.Dispersion):
r"""
Laplace distribution
Expand Down
7 changes: 4 additions & 3 deletions example/weights/maier_saupe.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import numpy as np
from numpy import exp, sin, degrees, radians, pi, sqrt
from numpy import degrees, exp, pi, radians, sin, sqrt

from sasmodels.weights import Dispersion as BaseDispersion


class Dispersion(BaseDispersion):
r"""
Maier-Saupe dispersion on orientation.
Expand Down Expand Up @@ -97,7 +98,7 @@ def _weights(self, center, sigma, lb, ub):


def P_2(a):
from numpy import pi, sqrt, exp
from numpy import exp, pi, sqrt
from scipy.special import erfi

# Double precision e^x overflows so do a Taylor expansion around infinity
Expand All @@ -114,8 +115,8 @@ def P_2_inv(S):
return fsolve(lambda x: P_2(x) - S, 1.0)[0]

def P_2_numerical(a):
from numpy import cos, exp, pi, sin
from scipy.integrate import romberg
from numpy import cos, sin, pi, exp
def num(beta):
return (1.5 * cos(beta)**2 - 0.5) * exp(a * cos(beta)**2) * sin(beta)
def denom(beta):
Expand Down
3 changes: 2 additions & 1 deletion example/weights/maier_saupe_eq.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import numpy as np
from numpy import exp, sin, degrees, pi, sqrt
from numpy import degrees, exp, pi, sin, sqrt

from sasmodels.weights import Dispersion as BaseDispersion


class Dispersion(BaseDispersion):
r"""
Maier-Saupe dispersion on orientation (equal weights).
Expand Down
2 changes: 1 addition & 1 deletion explore/angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import re

import sympy as sp
from sympy import pi, sqrt, sin, cos, Matrix, Eq
from sympy import Eq, Matrix, cos, pi, sin, sqrt

# Select output
OUTPUT = ""
Expand Down
6 changes: 3 additions & 3 deletions explore/angular_pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
dispersity and possible replacement algorithms.
"""
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, CheckButtons

import numpy as np
from numpy import cos, sin, exp, radians
from matplotlib.widgets import CheckButtons, Slider
from numpy import cos, exp, radians, sin


def draw_sphere(ax, radius=10., steps=100):
u = np.linspace(0, 2 * np.pi, steps)
Expand Down
21 changes: 15 additions & 6 deletions explore/asymint.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@

import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
import warnings

import numpy as np
import mpmath as mp
from numpy import pi, sin, cos, degrees, log10, arccos
from numpy.polynomial.legendre import leggauss
from scipy.integrate import dblquad, simps, romb, romberg
import numpy as np
import pylab
from numpy import arccos, cos, degrees, log10, pi, sin
from numpy.polynomial.legendre import leggauss
from scipy.integrate import dblquad, romb, romberg, simps

import sasmodels.special as sp

Expand Down Expand Up @@ -442,8 +443,16 @@ def quadpy_method(q, rule):
warnings.warn("use 'pip install quadpy' to enable quadpy.sphere tests")
return

from quadpy.sphere import (AlbrechtCollatz, BazantOh, HeoXu,
FliegeMaier, Lebedev, McLaren, Stroud, integrate_spherical)
from quadpy.sphere import (
AlbrechtCollatz,
BazantOh,
FliegeMaier,
HeoXu,
Lebedev,
McLaren,
Stroud,
integrate_spherical,
)
RULES = {
'AlbrechtCollatz': AlbrechtCollatz,
'BazantOh': BazantOh,
Expand Down
Loading
Loading