-
Notifications
You must be signed in to change notification settings - Fork 24
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
Merge FreeMagnetismInterface feature enhancement #232
Open
acaruana2009
wants to merge
66
commits into
reflectometry:master
Choose a base branch
from
acaruana2009:magnetism-interface-AJC-webview
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 57 commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
acc2954
ENH: add free interface in addition to free layer for magnetism.
92a70ee
FIX: length of vectors not equal when dthetaM is not defined
acaruana2009 9c88dcb
Merge pull request #101 from acaruana2009/magnetism-interface
bmaranville a243cf0
FIX: Make thetaM behave the same as rhoM
acaruana2009 a60f384
Lint
acaruana2009 0e3c6d5
FIX: nans in mono.py as result of divide by zero
acaruana2009 ad869e8
FIX: changed FreeMagnetismInterface thetaM above or below default val…
acaruana2009 be0a13c
Additional Edits for FreeMagnetismInterface
acaruana2009 155b1aa
Merge pull request #147 from reflectometry/magnetism-interface
acaruana2009 bb5edf9
create self-extracting version of unstable windows .exe.zip
bmaranville 31e462a
numba required for readthedocs build
pkienzle 7258b39
set max initial ylim on spin asymmetry plot
bmaranville 3da1e10
add link to unstable release page
bmaranville c64268e
ENH: add free interface in addition to free layer for magnetism.
a9b4c6f
FIX: length of vectors not equal when dthetaM is not defined
acaruana2009 e060d04
FIX: Make thetaM behave the same as rhoM
acaruana2009 7441f89
Lint
acaruana2009 145d624
FIX: nans in mono.py as result of divide by zero
acaruana2009 3db9b1f
FIX: changed FreeMagnetismInterface thetaM above or below default val…
acaruana2009 1c041d3
Additional Edits for FreeMagnetismInterface
acaruana2009 22029f8
Merge branch 'magnetism-interface-AJC' of https://github.com/reflecto…
acaruana2009 b9fd580
ENH: add free interface in addition to free layer for magnetism.
fc1799f
FIX: length of vectors not equal when dthetaM is not defined
acaruana2009 67739a2
FIX: Make thetaM behave the same as rhoM
acaruana2009 20037d7
Lint
acaruana2009 f962e6f
FIX: nans in mono.py as result of divide by zero
acaruana2009 9ec9eb9
FIX: changed FreeMagnetismInterface thetaM above or below default val…
acaruana2009 5449100
Additional Edits for FreeMagnetismInterface
acaruana2009 d61f1e8
ENH: add free interface in addition to free layer for magnetism.
60fd5e3
FIX: Make thetaM behave the same as rhoM
acaruana2009 8cb9239
Additional Edits for FreeMagnetismInterface
acaruana2009 717af74
Merge remote-tracking branch 'origin/magnetism-interface-AJC' into ma…
acaruana2009 73231d4
ENH: add free interface in addition to free layer for magnetism.
1422661
FIX: length of vectors not equal when dthetaM is not defined
acaruana2009 87b5f66
FIX: Make thetaM behave the same as rhoM
acaruana2009 34bec09
Lint
acaruana2009 39d654d
FIX: nans in mono.py as result of divide by zero
acaruana2009 b2201e8
FIX: changed FreeMagnetismInterface thetaM above or below default val…
acaruana2009 12acec5
Additional Edits for FreeMagnetismInterface
acaruana2009 a92bd1b
ENH: add free interface in addition to free layer for magnetism.
6beb4f4
FIX: Make thetaM behave the same as rhoM
acaruana2009 40c5b96
Additional Edits for FreeMagnetismInterface
acaruana2009 f0c66be
ENH: add free interface in addition to free layer for magnetism.
6d0833f
FIX: length of vectors not equal when dthetaM is not defined
acaruana2009 197cc95
FIX: changed FreeMagnetismInterface thetaM above or below default val…
acaruana2009 b548ded
Additional Edits for FreeMagnetismInterface
acaruana2009 231ebb7
Merge remote-tracking branch 'origin/magnetism-interface-AJC' into ma…
acaruana2009 0d7e3ad
Merge pull request #1 from acaruana2009/magnetism-interface-AJC
acaruana2009 f7b423c
Linting and bringing in line with master
acaruana2009 b6d57f7
Maint: Serialize `FreeMagnetismInterface`
acaruana2009 8158209
Tidying up to minimise changes
acaruana2009 410a858
Fix: Serializing/De-serializing of FreeInterface
acaruana2009 84153e3
Tidy up imports
acaruana2009 f5d41cb
Sorting Merge conflicts
acaruana2009 62ce7cb
Further import tidy up
acaruana2009 cf702e8
Merge branch 'master' into magnetism-interface-AJC-webview
acaruana2009 66e354b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6aa2d2e
Updated dataclass types for `FreeMagnetismInterface`
acaruana2009 4f50fbc
minor fixup on stored attribute types (they are always stored as Para…
bmaranville 8c1de01
fixes to FreeInterface class, adding magnetism and setting last eleme…
bmaranville 7aa06d0
add FreeMagnetismInterface class
bmaranville 689653a
add FreeMagnetismInterface to names
bmaranville 2a65ec0
Merge remote-tracking branch 'origin/magnetism-interface-AJC-webview'…
acaruana2009 25a0be0
FIX: Limits of rhoM should be +- inf in `FreeMagnetism`
acaruana2009 ab5ca3e
ENH: add magnetism attr to `FreeLayer`
acaruana2009 a5e9d34
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
from numpy import asarray, clip, cumsum, diff, hstack, inf, sort | ||
|
||
from . import util | ||
from .magnetism import BaseMagnetism | ||
from .material import Scatterer | ||
from .model import Layer | ||
|
||
|
||
|
@@ -115,16 +117,19 @@ class FreeInterface(Layer): | |
with slabs. | ||
""" | ||
|
||
name: Optional[str] | ||
below: Optional[Any] | ||
above: Optional[Any] | ||
name: str | ||
below: Scatterer | ||
above: Scatterer | ||
thickness: Par | ||
interface: Par | ||
dz: List[Union[float, Par]] | ||
dp: List[Union[float, Par]] | ||
dz: List[Par] | ||
dp: List[Par] | ||
magnetism: Optional[BaseMagnetism] = None | ||
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. Can this really be any |
||
# inflections: List[Any] | ||
|
||
def __init__(self, thickness=0, interface=0, below=None, above=None, dz=None, dp=None, name="Interface"): | ||
def __init__( | ||
self, thickness=0, interface=0, below=None, above=None, dz=None, dp=None, name="Interface", magnetism=None | ||
): | ||
self.name = name | ||
self.below, self.above = below, above | ||
self.thickness = Par.default(thickness, limits=(0, inf), name=name + " thickness") | ||
|
@@ -146,6 +151,7 @@ def __init__(self, thickness=0, interface=0, below=None, above=None, dz=None, dp | |
self.dp = [Par.default(p, name=name + " dp[%d]" % i, limits=(0, inf)) for i, p in enumerate(dp)] | ||
self.inflections = Par(name=name + " inflections") | ||
self.inflections.equals(ParFunction(inflections, dx=self.dz, dy=self.dp)) | ||
self.magnetism = magnetism | ||
|
||
def parameters(self): | ||
return { | ||
|
@@ -156,6 +162,7 @@ def parameters(self): | |
"below": self.below.parameters(), | ||
"above": self.above.parameters(), | ||
"inflections": self.inflections, | ||
"magnetism": self.magnetism.parameters() if self.magnetism is not None else None, | ||
} | ||
|
||
def to_dict(self): | ||
|
@@ -175,14 +182,22 @@ def profile(self, Pz): | |
if p[-1] == 0: | ||
p[-1] = 1 | ||
p *= 1 / p[-1] | ||
# AJC included condition as if z[-1] == 0 then z *= thickness/z[-1] == [nan]*len(z) | ||
# This then ends with bumps.mono.Monospline adding an extra element as a result of | ||
# line 42 in bumps.mono.Monospline | ||
if z[-1] == 0: | ||
z[-1] = 1 | ||
z *= thickness / z[-1] | ||
profile = clip(monospline(z, p, Pz), 0, 1) | ||
return profile | ||
|
||
def render(self, probe, slabs): | ||
thickness = self.thickness.value | ||
|
||
# TODO: why is provided if it is ignored? | ||
# interface ignored for FreeInterface | ||
# interface = self.interface.value | ||
|
||
below_rho, below_irho = self.below.sld(probe) | ||
above_rho, above_irho = self.above.sld(probe) | ||
# Pz is the center, Pw is the width | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@bmaranville I am not sure if this is the current style that you are using for typing. I.e. would you prefer to remove
Any
andOptional
?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.
It's not really a question of style - the dataclass attribute types should be exactly what will be stored in those attributes after init + post_init. There can be different types for the arguments of the init function, if they are going to be coerced before being stored in the attribute. For example, an argument will often be of type
Union[float, Parameter]
but then we store it asParameter.default(value)
which coerces it to a Parameter, soParameter
should be the type of the attribute (not the Union)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.
OK so in this case, we could drop the
Optional
since we probably don't wantNone
as one of the types? That saidtabove
andtbelow
do takeNone
as the default arg.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.
The typing of the arg is not the same as the typing of the attribute -
tbelow
andtabove
are both initialized asParameter
objects during init, even if they areNone
as an argument. The type of the attributes should beParameter