-
Notifications
You must be signed in to change notification settings - Fork 23
refactor: update sasview api for test_sas.py #126
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
Changes from 4 commits
96e1ff3
6112cdd
c68f981
5854969
a2d280a
1bdd326
ac23c4c
29ef13e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**Added:** | ||
|
||
* <news item> | ||
|
||
**Changed:** | ||
|
||
* <news item> | ||
|
||
**Deprecated:** | ||
|
||
* <news item> | ||
|
||
**Removed:** | ||
|
||
* <news item> | ||
|
||
**Fixed:** | ||
|
||
* Refactored code utilizing sasmodels to use the new sasview api. | ||
|
||
**Security:** | ||
|
||
* <news item> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -415,6 +415,13 @@ def __call__(self, r): | |
# | ||
# We also have to make a q-spacing small enough to compute out to at | ||
# least the size of the signal. | ||
|
||
# As of release 3.2.0, these are not working but we hope to have | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we would like this comment to be the I am not sure how it is used, but do we also want this behavior in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There doesn't seem to be any issues with instantiating the class so we don't need this error message in the
The |
||
# them working again in a future release. | ||
raise NotImplementedError( | ||
"calculate_ER() is not implemented in sasmodels" | ||
) | ||
|
||
dr = min(0.01, r[1] - r[0]) | ||
ed = 2 * self._model.calculate_ER() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
|
||
from diffpy.srfit.exceptions import ParseError | ||
from diffpy.srfit.fitbase.profileparser import ProfileParser | ||
from diffpy.srfit.sas.sasimport import sasimport | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I deleted the import from this file as not used but I haven't deleted |
||
|
||
|
||
class SASParser(ProfileParser): | ||
|
@@ -102,12 +101,13 @@ def parseFile(self, filename): | |
Raises IOError if the file cannot be read | ||
Raises ParseError if the file cannot be parsed | ||
""" | ||
import sasdata.dataloader.loader as sas_dataloader | ||
|
||
Loader = sasimport("sas.dataloader.loader").Loader | ||
Loader = sas_dataloader.Loader | ||
loader = Loader() | ||
|
||
try: | ||
data = loader.load(filename) | ||
data = loader.load(str(filename)) | ||
except RuntimeError as e: | ||
raise ParseError(e) | ||
except ValueError as e: | ||
|
@@ -118,7 +118,10 @@ def parseFile(self, filename): | |
self._meta["filename"] = filename | ||
self._meta["datainfo"] = data | ||
|
||
self._banks.append([data.x, data.y, data.dx, data.dy]) | ||
for data_obj in data: | ||
self._banks.append( | ||
[data_obj.x, data_obj.y, data_obj.dx, data_obj.dy] | ||
) | ||
self.selectBank(0) | ||
sbillinge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,11 @@ | |
|
||
import numpy | ||
import pytest | ||
from sasmodels.sasview_model import find_model, load_standard_models | ||
|
||
import diffpy.srfit.pdf.characteristicfunctions as cf | ||
from diffpy.srfit.sas.sasimport import sasimport | ||
|
||
load_standard_models() | ||
|
||
# # Global variables to be assigned in setUp | ||
# cf = None | ||
|
@@ -30,11 +32,10 @@ | |
|
||
|
||
def testSphere(sas_available): | ||
if not sas_available: | ||
pytest.skip("sas package not available") | ||
pytest.skip("calculate_ER() not available") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the wrong error message. I think the ER function is not the issue. Just say "sas characteristic functions not currently working. Remove skip when our code is refactored to use the latest sasview API" or sthg like that. Also, let's keep the original skip but commented out. We will need it again when we implement the new code. |
||
radius = 25 | ||
# Calculate sphere cf from SphereModel | ||
SphereModel = sasimport("sas.models.SphereModel").SphereModel | ||
SphereModel = find_model("sphere") | ||
sbillinge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
model = SphereModel() | ||
model.setParam("radius", radius) | ||
ff = cf.SASCF("sphere", model) | ||
|
@@ -51,15 +52,14 @@ def testSphere(sas_available): | |
|
||
|
||
def testSpheroid(sas_available): | ||
if not sas_available: | ||
pytest.skip("sas package not available") | ||
pytest.skip("calculate_ER() not available") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please see above and handle all the models in the same way. |
||
prad = 20.9 | ||
erad = 33.114 | ||
# Calculate cf from EllipsoidModel | ||
EllipsoidModel = sasimport("sas.models.EllipsoidModel").EllipsoidModel | ||
EllipsoidModel = find_model("ellipsoid") | ||
model = EllipsoidModel() | ||
model.setParam("radius_a", prad) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could not find any mention of the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
model.setParam("radius_b", erad) | ||
model.setParam("radius_polar", prad) | ||
sbillinge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
model.setParam("radius_equatorial", erad) | ||
ff = cf.SASCF("spheroid", model) | ||
r = numpy.arange(0, 100, 1 / numpy.pi, dtype=float) | ||
fr1 = ff(r) | ||
|
@@ -74,12 +74,11 @@ def testSpheroid(sas_available): | |
|
||
|
||
def testShell(sas_available): | ||
if not sas_available: | ||
pytest.skip("sas package not available") | ||
pytest.skip("calculate_ER() not available") | ||
radius = 19.2 | ||
thickness = 7.8 | ||
# Calculate cf from VesicleModel | ||
VesicleModel = sasimport("sas.models.VesicleModel").VesicleModel | ||
VesicleModel = find_model("vesicle") | ||
model = VesicleModel() | ||
model.setParam("radius", radius) | ||
model.setParam("thickness", thickness) | ||
|
@@ -97,13 +96,12 @@ def testShell(sas_available): | |
|
||
|
||
def testCylinder(sas_available): | ||
if not sas_available: | ||
pytest.skip("sas package not available") | ||
pytest.skip("calculate_ER() not available") | ||
"""Make sure cylinder works over different r-ranges.""" | ||
radius = 100 | ||
length = 30 | ||
|
||
CylinderModel = sasimport("sas.models.CylinderModel").CylinderModel | ||
CylinderModel = find_model("cylinder") | ||
model = CylinderModel() | ||
model.setParam("radius", radius) | ||
model.setParam("length", length) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's change this to "changed" as "temporarily removed support for SAS characteristic functions until we can migrate to the new sasview api"