Skip to content

Commit

Permalink
Test genmagstr (#97)
Browse files Browse the repository at this point in the history
* Add initial genmagstr test file

* Add initial simple comm/incomm tests

* Add zero nExt test

* Add afm chain test

* Add random structure tests

* Check mag_str not magstr

* Add random test with k

* Add test with existing k

* Add multiatom direct test

* Add helical tests, fix multi-k bug

In the if ~cmplxS... conditional any(k) returns a vector for multi-k
structures, causing a MATLAB:nonLogicalConditional error, fix this
by flattening k first

* Add to helical tests

- Add test with multiple k and n
- Add test with nSpin = nMagAtom
- Add test with nSpin = nMagExt

* Add fourier tests

* Add tile tests

* Add rotate tests

* Add custom func test

* Add default func test

* Add extend and unit tests

* Remove unreachable code

Test for number of magnetic atoms is already performed at beginning
of function

* Add scalar nExt test

* Add more error tests

* Add complex rotate and symbolic tests

* Raise error if invalid S/k are provided, improve random tests

* Raise error with tile and wrong number of input spins

* Improve input documentation

* Error if complex S is provided in helical mode

* Raise error if rotate mode is used without initialisation

* Emit deprecation warning if extend mode is used

* Error if n and S parallel in rotate mode with no phi

* Raise error if imaginary phi is used in rotate mode

* Refactor tests - use TestParameter

* Clarify random mode docstring

* Warn if n || S for helical, and add tests

* Small upates from review comments

- Specify n is converted to a unit vector in docstring
- Remove unreachable n/k size error check

* Warn if nExt is too large in helical, fourier

* Warn on unused inputs

- Also move 'extend' -> 'tile' to the top so tile can be used in unused
  input checks
- Also move valid mode check to in unused warning checks so an invalid
  mode isn't searched for in the struct

* Raise error if nonsensical complex values are provided

- Also move errors before warnings

* Add test with epsilon

* Put phi and phid into parametrised test

* Add test for norm explicitly true/false

* Only test for complex n

Inspecting varargin is more complex than initially thought,
sometimes it can be a struct (e.g. when called from optmagk)

* Account for varargin being a struct

When called from places like optmagstr, varargin is actually a struct.
Also, the struct contains many other additional parameters to do with
fitting, so before calling genmagstr in optmagstr,
warning('off','sw_readparam:UnreadInput') is called. This stops
sw_readparam from issuing warnings. This also stops the
`spinw:genmagstr:UnreadInput` warning from being triggered, which
is why its name has been changed to UnreadInput, to avoid ugly
unecessary warnings.
  • Loading branch information
rebeccafair committed Aug 17, 2022
1 parent 66ac715 commit 4d02dbd
Show file tree
Hide file tree
Showing 3 changed files with 793 additions and 39 deletions.
Loading

0 comments on commit 4d02dbd

Please sign in to comment.