Skip to content

Support for pure python 2D models - #781

Open
pkienzle wants to merge 20 commits into
masterfrom
py-Iqabc
Open

pkienzle wants to merge 20 commits into
masterfrom
py-Iqabc

Conversation

@pkienzle

@pkienzle pkienzle commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Add support for Iqac and Iqabc in pure python models. #695

Fixes polydispersity and volume normalization for pure python models.

Defaults *_pd_n to 35. #746

There is still a descrepency between c models and their python equivalent with theta orientational dispersion. If it is not yet clear whether it is problem in the C kernel or the python kernel. If it is not fixed in this PR then add as a separate issue.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@krzywon krzywon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code looks reasonable, but I do have a couple of comments and questions. I haven't tested, but unit tests in CI pass.

If possible, adding new tests to the tetrahedron and prism models would be nice to have but the values would need validating, so I understand why they aren't included.

Comment thread sasmodels/kernelpy.py
parameters = self._parameter_vector
n_pars = len(parameters)
# Skip scale and background
parameters[:] = values[2:n_pars+2]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are the first two parameters always guaranteed to be scale and background now and into the future?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They are that way now. If it changes in the future we can update this code.

They parameter vector layout is assumed in a few places within the package, but third party code shouldn't need to know it.

Comment thread sasmodels/kernelpy.py Resolved
Comment thread sasmodels/kernelpy.py Outdated
if (rot != self._rotate[:2]).any():
print(rot)
print(self._rotate[:2])
raise Hell

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔥🔥🔥

}, [0.01, 0.05, 0.2], [87.50350037, 63.95202427, 0.27889988]
},
[0.01, 0.05, 0.2],
[87.24724230561272, 64.13160420356327, 0.2767562850617265],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are these test values changing now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

length_pd_n now defaults to 35 (issue #746 resolved incidentally in this PR because it helped with testing)

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No quality gates enabled for this code.

See analysis details in CodeScene

Quality Gate Profile: Custom Configuration
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@pkienzle
pkienzle added this pull request to stack #801 November 10, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants