Skip to content

Commit 61202fb

Browse files
authored
Merge pull request #30 from kif/azimuthal
Update on azimuthal integration
2 parents 605c3f6 + a14a643 commit 61202fb

19 files changed

+161
-92
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
ignore = E203, E266, E501, W503, F403, F401, F405
2+
ignore = E203, E266, E501, W503, F403, F401, F405, F821
33
max-line-length = 120
44
max-complexity = 18
55
select = C,E,F,W,B,B950

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ Redistribution and use in source and binary forms, with or without modification,
88

99
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
1010

11-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ https://BAMresearch.github.io/modacor
6666
Development
6767
===========
6868

69-
For coding contributions, we strongly recommend:
70-
- using flake8 and/or black for consistent formatting.
69+
For coding contributions, we strongly recommend:
70+
- using flake8 and/or black for consistent formatting.
7171
- writing tests for every added functionality -> towards test-driven coding practices.
7272

7373
To run all the tests run::

ci/update.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ def main():
102102
cov_report_path=project_meta["tool"]["coverage"]["report"]["path"],
103103
# Python version to use for general tasks: docs (when tox did not set one)
104104
py_ver=".".join(sys.version.split(".")[:2]),
105-
pypi_token=(
106-
"_".join(pypi_host + ["token"]).upper()
107-
if len(pypi_host)
108-
else "TEST_PYPI_TOKEN"
109-
),
105+
pypi_token=("_".join(pypi_host + ["token"]).upper() if len(pypi_host) else "TEST_PYPI_TOKEN"),
110106
pypi_repo="".join(pypi_host) if len(pypi_host) else "testpypi",
111107
)
112108
)

docs/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
release = version
3737
commit_id = None
3838
try:
39-
commit_id = (
40-
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).strip().decode("ascii")
41-
)
39+
commit_id = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).strip().decode("ascii")
4240
except subprocess.CalledProcessError as e:
4341
print(e)
4442

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ exclude_commit_patterns = ["chore", ".*\\bGHA\\b.*", ".*\\b[gG][hH] actions?\\b.
9999
upload_to_vcs_release = false
100100

101101
[tool.black]
102-
line-length = 100
102+
line-length = 120
103103
preview = true
104104

105105
[tool.isort]
106106
profile = "black"
107-
line_length = 100
107+
line_length = 120
108108
group_by_package = true
109109
known_first_party = "modacor"
110110
ensure_newline_before_comments = true

src/modacor/dataclasses/basedata.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def validate_rank_of_data(instance, attribute, value):
2323
# This assumes that signal is provided and is a valid numpy array.
2424
if instance.signal is not None and value > instance.signal.ndim:
2525
raise ValueError(
26-
f"{attribute.name} ({value}) cannot exceed the dimensionality of signal "
27-
f"(ndim={instance.signal.ndim})."
26+
f"{attribute.name} ({value}) cannot exceed the dimensionality of signal (ndim={instance.signal.ndim})."
2827
)
2928

3029

@@ -48,9 +47,7 @@ class BaseData:
4847
rank_of_data: int = field(factory=int, validator=[v.instance_of(int), validate_rank_of_data])
4948

5049
# Scalers to put on the denominator, sparated from the array for distinct uncertainty
51-
normalization: Optional[np.ndarray] = field(
52-
default=None, validator=v.optional(v.instance_of(np.ndarray))
53-
)
50+
normalization: Optional[np.ndarray] = field(default=None, validator=v.optional(v.instance_of(np.ndarray)))
5451
normalization_factor: float = field(default=1.0, validator=v.instance_of(float))
5552
normalization_factor_variance: float = field(default=0.0, validator=v.instance_of(float))
5653
# Unit information using Pint units - required input (ingest, internal, and display)
@@ -66,11 +63,14 @@ class BaseData:
6663
)
6764
# array with some normalization (exposure time, solid-angle ....)
6865

66+
@property
67+
def shape(self):
68+
return self.signal.shape
69+
6970
def __attrs_post_init__(self):
7071
if self.normalization is None:
71-
self.normalization = np.ones(self.signal.shape)
72+
self.normalization = np.ones(self.shape)
7273

73-
@property
7474
def mean(self) -> np.ndarray:
7575
"""
7676
Returns the signal array with the normalization applied.
@@ -85,13 +85,6 @@ def std(self, kind) -> np.ndarray:
8585
"""
8686
return np.sqrt(self.variances[kind] / self.normalization)
8787

88-
def sem(self, kind) -> np.ndarray:
89-
"""
90-
Returns the uncertainties, i.e. standard deviation
91-
The result is cast to internal units.
92-
"""
93-
return np.sqrt(self.variances[kind]) / self.normalization
94-
9588
@property
9689
def _unit_scale(self, display_units) -> float:
9790
return (1 * self.internal_units).to(display_units).magnitude

src/modacor/dataclasses/integrated_data.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class IntegratedData(BaseData):
2424
\left( \frac{\sigma_A^2}{\mu_A^2} + \frac{\sigma_B^2}{\mu_B^2} \right)
2525
```
2626
"""
27-
28-
average: np.ndarray = field(factory=np.ndarray, validator=[v.instance_of(np.ndarray)])
2927
std: Dict[str, np.ndarray] = field(factory=dict, validator=[v.instance_of(dict)])
3028
sem: Dict[str, np.ndarray] = field(factory=dict, validator=[v.instance_of(dict)])
3129
# Core data array stored as an xarray DataArray
@@ -36,6 +34,4 @@ class IntegratedData(BaseData):
3634

3735
# array with some normalization (exposure time, solid-angle ....)
3836
sum_normalization: np.ndarray = field(factory=np.ndarray, validator=[v.instance_of(np.ndarray)])
39-
sum_normalization_squared: np.ndarray = field(
40-
factory=np.ndarray, validator=[v.instance_of(np.ndarray)]
41-
)
37+
sum_normalization_squared: np.ndarray = field(factory=np.ndarray, validator=[v.instance_of(np.ndarray)])

src/modacor/dataclasses/process_step.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ class ProcessStep:
9191

9292
# a message handler, supporting logging, warnings, errors, etc. emitted by the process
9393
# during execution
94-
message_handler: MessageHandler = field(
95-
default=MessageHandler(), validator=v.instance_of(MessageHandler)
96-
)
94+
message_handler: MessageHandler = field(default=MessageHandler(), validator=v.instance_of(MessageHandler))
9795

9896
# internal variables:
9997
__prepared: bool = field(default=False, validator=v.instance_of(bool))

src/modacor/dataclasses/process_step_describer.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,13 @@ def validate_required_data_keys(instance, attribute, value):
3333
@define
3434
class ProcessStepDescriber:
3535
calling_name: str = field() # short name to identify the calling process for the UI
36-
calling_id: str = (
37-
field()
38-
) # not sure what we were planning here. some UID perhaps? difference with calling_module
36+
calling_id: str = field() # not sure what we were planning here. some UID perhaps? difference with calling_module
3937
calling_module_path: Path = field(
4038
validator=v.instance_of(Path)
4139
) # partial path to the module from src/modacor/modules onwards
4240
calling_version: str = field() # module version being executed
4341
required_data_keys: list[str] = field(factory=list) # list of data keys required by the process
44-
required_arguments: list[str] = field(
45-
factory=list
46-
) # list of argument key-val combos required by the process
42+
required_arguments: list[str] = field(factory=list) # list of argument key-val combos required by the process
4743
calling_arguments: dict[str, Any] = field(factory=dict, validator=validate_required_keys)
4844
works_on: dict[str, list] = field(
4945
factory=dict, validator=v.instance_of(dict)

0 commit comments

Comments
 (0)