Compare commits
4 Commits
3b02071ac0
...
ead887f314
Author | SHA1 | Date | |
---|---|---|---|
ead887f314 | |||
806b9b667f | |||
e61838d85f | |||
3ebe2bb824 |
12
CHANGELOG.md
12
CHANGELOG.md
@ -2,6 +2,18 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [0.9.3](https://gitea.deepak.science:2222/physics/pdme/compare/0.9.2...0.9.3) (2024-02-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* adds util func for calculating arg using sign instead of complex arithmetic ([3ebe2bb](https://gitea.deepak.science:2222/physics/pdme/commit/3ebe2bb82430d677680383c42a1c269df83d99cd))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fixes stupid cost shape issue ([ed9dd2c](https://gitea.deepak.science:2222/physics/pdme/commit/ed9dd2c94f88a08c36f581f05b26a87a6b780d5b))
|
||||
|
||||
### [0.9.2](https://gitea.deepak.science:2222/physics/pdme/compare/0.9.1...0.9.2) (2023-07-24)
|
||||
|
||||
|
||||
|
@ -98,3 +98,11 @@ def fast_s_nonlocal_dipoleses(
|
||||
|
||||
_logger.debug(f"Raw pair calc: [{alphses1 * alphses2 * bses}]")
|
||||
return numpy.einsum("...j->...", alphses1 * alphses2 * bses)
|
||||
|
||||
|
||||
def signarg(x, **kwargs):
|
||||
"""
|
||||
uses numpy.sign to implement Arg for real numbers only. Should return pi for negative inputs, 0 for positive.
|
||||
Passes through args to numpy.sign
|
||||
"""
|
||||
return numpy.pi * (numpy.sign(x, **kwargs) - 1) / (-2)
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "pdme"
|
||||
version = "0.9.2"
|
||||
version = "0.9.3"
|
||||
description = "Python dipole model evaluator"
|
||||
authors = ["Deepak <dmallubhotla+github@gmail.com>"]
|
||||
license = "GPL-3.0-only"
|
||||
@ -15,7 +15,7 @@ scipy = "~1.10"
|
||||
pytest = ">=6"
|
||||
flake8 = "^4.0.0"
|
||||
pytest-cov = "^4.1.0"
|
||||
mypy = "^0.961"
|
||||
mypy = "^1.9"
|
||||
ipython = "^8.2.0"
|
||||
black = "^22.3.0"
|
||||
syrupy = "^4.0.8"
|
||||
|
20
tests/util/__snapshots__/test_fast_nonlocal_spectrum.ambr
Normal file
20
tests/util/__snapshots__/test_fast_nonlocal_spectrum.ambr
Normal file
@ -0,0 +1,20 @@
|
||||
# serializer version: 1
|
||||
# name: test_arg
|
||||
list([
|
||||
list([
|
||||
-0.0,
|
||||
-0.0,
|
||||
-0.0,
|
||||
]),
|
||||
list([
|
||||
3.141592653589793,
|
||||
-0.0,
|
||||
-0.0,
|
||||
]),
|
||||
list([
|
||||
-0.0,
|
||||
-0.0,
|
||||
3.141592653589793,
|
||||
]),
|
||||
])
|
||||
# ---
|
@ -0,0 +1,13 @@
|
||||
# serializer version: 1
|
||||
# name: test_fast_nonlocal_calc_multidipole_phase_snapshot
|
||||
list([
|
||||
list([
|
||||
-0.0,
|
||||
-0.0,
|
||||
]),
|
||||
list([
|
||||
-0.0,
|
||||
3.141592653589793,
|
||||
]),
|
||||
])
|
||||
# ---
|
@ -53,3 +53,11 @@ def test_fast_nonlocal_frequency_check():
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
pdme.util.fast_nonlocal_spectrum.fast_s_nonlocal(dot_pairs, dipoles)
|
||||
|
||||
|
||||
def test_arg(snapshot):
|
||||
|
||||
test_input = numpy.array([[1, 2, 3], [-1, 1, 3], [3, 5, -1]])
|
||||
|
||||
actual_result = pdme.util.fast_nonlocal_spectrum.signarg(test_input)
|
||||
assert actual_result.tolist() == snapshot
|
||||
|
@ -53,3 +53,24 @@ def test_fast_nonlocal_frequency_check_multidipole():
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
pdme.util.fast_nonlocal_spectrum.fast_s_nonlocal_dipoleses(dot_pairs, dipoles)
|
||||
|
||||
|
||||
def test_fast_nonlocal_calc_multidipole_phase_snapshot(snapshot):
|
||||
d1 = [1, 2, 3, 4, 5, 6, 7]
|
||||
d2 = [1, 2, 3, 4, 5, 6, 8]
|
||||
d3 = [2, 5, 3, 4, -5, -6, 2]
|
||||
d4 = [-3, 2, 1, 4, 5, 6, 10]
|
||||
|
||||
dipoleses = numpy.array([[d1, d2], [d3, d4]])
|
||||
|
||||
dot_pairs = numpy.array(
|
||||
[[[-1, -2, -3, 11], [-1, 2, 5, 11]], [[-1, -2, -3, 6], [2, 4, 6, 6]]]
|
||||
)
|
||||
|
||||
# this is a bit silly but just set the logger to debug so that the coverage stats don't get affected by the debug statements.
|
||||
pdme.util.fast_nonlocal_spectrum._logger.setLevel(logging.DEBUG)
|
||||
|
||||
actual_phases = pdme.util.fast_nonlocal_spectrum.signarg(
|
||||
pdme.util.fast_nonlocal_spectrum.fast_s_nonlocal_dipoleses(dot_pairs, dipoleses)
|
||||
)
|
||||
assert actual_phases.tolist() == snapshot
|
||||
|
Loading…
x
Reference in New Issue
Block a user