Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 21, 2024
1 parent d167f20 commit bcce7f1
Show file tree
Hide file tree
Showing 20 changed files with 252 additions and 262 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ repos:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
}
}
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
import sys

import versioningit

sys.path.insert(0, os.path.abspath("../src"))
Expand Down Expand Up @@ -59,7 +60,9 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "alabaster" # "sphinx_rtd_theme", please add corresponding package to environment.yml if you want to use it
html_theme = (
"alabaster" # "sphinx_rtd_theme", please add corresponding package to environment.yml if you want to use it
)
autosummary_generate = True

# Napoleon settings
Expand Down
473 changes: 237 additions & 236 deletions docs/ex_h5py_NXtas.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/tavi/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import os
import shutil

from configparser import ConfigParser
from pathlib import Path

from mantid.kernel import Logger

logger = Logger("PACKAGENAME")
Expand Down
1 change: 0 additions & 1 deletion src/tavi/data/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class Scan(object):
"""

def __init__(self, name: str, nexus_dict: NexusEntry) -> None:

self.name: str = name
self._nexus_dict: NexusEntry = nexus_dict
self.data: dict = self.get_data_columns()
Expand Down
2 changes: 0 additions & 2 deletions src/tavi/data/scan_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class ScanData1D(object):
ZERO = 1e-6

def __init__(self, x: np.ndarray, y: np.ndarray) -> None:

# ind = np.argsort(x)
# self.x = x[ind]
# self.y = y[ind]
Expand Down Expand Up @@ -188,7 +187,6 @@ def rebin_grid_renorm(self, rebin_params: tuple, norm_col: np.ndarray, norm_val:


class ScanData2D(object):

ZEROS = 1e-6

def __init__(self, x: np.ndarray, y: np.ndarray, z: np.ndarray) -> None:
Expand Down
2 changes: 0 additions & 2 deletions src/tavi/data/scan_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def _get_data_1d(
norm_to: Optional[tuple[float, str]],
**rebin_params_dict: Optional[tuple],
) -> ScanData1D:

x_axis, y_axis = axes
x_array = np.array([])
y_array = np.array([])
Expand Down Expand Up @@ -130,7 +129,6 @@ def _get_data_2d(
norm_to: Optional[tuple[float, str]],
**rebin_params_dict: Optional[tuple],
) -> ScanData2D:

if not isinstance(rebin_params, tuple):
raise ValueError(f"rebin parameters ={rebin_params} needs to be a tuple.")
if not len(rebin_params) == 2:
Expand Down
6 changes: 3 additions & 3 deletions src/tavi/data/spice_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def read_spice_ubconf(ub_file_name: str) -> dict:
Returns:
"""
ubconf: dict[str, Any] = {}
with open(ub_file_name, 'r', encoding="utf-8") as f:
with open(ub_file_name, "r", encoding="utf-8") as f:
all_content = f.readlines()

for idx, line in enumerate(all_content):
Expand Down Expand Up @@ -129,8 +129,8 @@ def _create_spicelogs(path_to_scan_file: str) -> dict:

scan_path = os.path.abspath(path_to_scan_file)
(*folder_path, _, _) = scan_path.split("/")
ub_file_path = os.path.join('/',*folder_path,"UBConf", metadata["ubconf"])
ub_temp_file_path = os.path.join('/',*folder_path,"UBConf", "temp", metadata["ubconf"])
ub_file_path = os.path.join("/", *folder_path, "UBConf", metadata["ubconf"])
ub_temp_file_path = os.path.join("/", *folder_path, "UBConf", "temp", metadata["ubconf"])

if os.path.isfile(ub_file_path):
ub_conf_dict = {"file_path": ub_file_path}
Expand Down
2 changes: 1 addition & 1 deletion src/tavi/instrument/instrument_params/cg4c.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@
"v_post_sample": 600,
"v_post_ana": 600
}
}
}
2 changes: 1 addition & 1 deletion src/tavi/instrument/instrument_params/hb1a.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
"v_post_sample": 600,
"v_post_ana": 600
}
}
}
2 changes: 1 addition & 1 deletion src/tavi/instrument/instrument_params/hb3.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@
"v_post_sample": 300,
"v_post_ana": 600
}
}
}
2 changes: 1 addition & 1 deletion src/tavi/instrument/instrument_params/hb3_mnte.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@
"v_post_sample": 120,
"v_post_ana": 120
}
}
}
2 changes: 1 addition & 1 deletion src/tavi/instrument/instrument_params/takin_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
"v_post_sample": 30,
"v_post_ana": 30
}
}
}
1 change: 0 additions & 1 deletion src/tavi/instrument/resolution/ellipse_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def generate_plot(self, ax, c="black", linestyle="solid"):
pts = self.generate_ellipse()

if self.grid_helper is None:

s = ax.plot(
pts[0],
pts[1],
Expand Down
1 change: 0 additions & 1 deletion src/tavi/instrument/resolution/ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(
sample: Xtal,
projection: Optional[tuple] = ((1, 0, 0), (0, 1, 0), (0, 0, 1)),
) -> None:

self.STATUS: Optional[bool] = None
self.q: Optional[tuple[float, float, float]] = None
self.hkl: tuple[float, float, float] = hkl
Expand Down
2 changes: 1 addition & 1 deletion src/tavi/instrument/tas.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def calculate_ub_matrix(self, peaks: tuple[Peak, ...]):
if not isinstance(self.sample, Xtal):
raise ValueError("sample needs to be Xtal class for UB calculation.")

match (num_of_peaks := len(peaks)):
match num_of_peaks := len(peaks):
case 2:
ubconf = self._find_u_from_two_peaks(peaks)
self.sample.set_orientation(ubconf)
Expand Down
2 changes: 0 additions & 2 deletions tests/test_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


def test_fit_single_peak():

nexus_file_name = "./test_data/IPTS32124_CG4C_exp0424/scan0042.h5"
_, s1 = Scan.from_nexus_file(nexus_file_name)

Expand All @@ -26,7 +25,6 @@ def test_fit_single_peak():


def test_fit_two_peak():

nexus_file_name = "./test_data/IPTS32124_CG4C_exp0424/scan0042.h5"
_, s1 = Scan.from_nexus_file(nexus_file_name)

Expand Down
3 changes: 0 additions & 3 deletions tests/test_nxentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def test_get_from_daslogs():


def test_spice_to_nexus_one():

path_to_spice_folder = "./test_data/exp424"
path_to_nexus = "./test_data/spice_to_nxdict_test_scan0034.h5"
scan0034 = NexusEntry.from_spice(path_to_spice_folder, 34)
Expand All @@ -157,7 +156,6 @@ def test_spice_to_nexus_one():


def test_spice_to_nexus_empty():

path_to_spice_folder = "./test_data/exp815"
path_to_nexus = "./test_data/spice_to_nxdict_test_empty.h5"
scan0002 = NexusEntry.from_spice(path_to_spice_folder, 2)
Expand Down Expand Up @@ -191,7 +189,6 @@ def test_get_dataset_names():

@pytest.fixture
def nexus_entries():

analyser = {
"attrs": {"EX_required": "true", "NX_class": "NXcrystal", "type": "NX_CHAR"},
"a1": {
Expand Down
1 change: 0 additions & 1 deletion tests/test_tavi_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def tavi_exp0424():


def test_get_scan(tavi_exp0424):

scan0034 = tavi_exp0424.get_scan(scan_num=("IPTS32124_CG4C_exp0424", 34))
assert scan0034.name == "scan0034"
assert scan0034.scan_info.scan_num == 34
Expand Down

0 comments on commit bcce7f1

Please sign in to comment.