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 Aug 12, 2024
1 parent d2ac0a7 commit fc06e49
Show file tree
Hide file tree
Showing 23 changed files with 260 additions and 283 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.

1 change: 0 additions & 1 deletion scripts/test_plotter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import matplotlib.pylab as plt

from tavi.data.tavi import TAVI
from tavi.instrument.resolution.cooper_nathans import CN
from tavi.plotter import Plot1DManager, Plot2DManager
Expand Down
1 change: 0 additions & 1 deletion scripts/test_rez.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# from tavi.instrument.instrument_params.python_dicts.takin_test import instrument_params
# from tests.test_data_folder.test_samples.python_samples.sample_test import test_xtal
import matplotlib.pylab as plt

from tavi.instrument.resolution.cooper_nathans import CN
from tavi.plotter import Plot1DManager, Plot2DManager

Expand Down
1 change: 0 additions & 1 deletion scripts/test_scan.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import matplotlib.pyplot as plt

from tavi.data.tavi import TAVI


Expand Down
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
2 changes: 0 additions & 2 deletions src/tavi/data/scan_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def __init__(
signal_axes=(None, None, None),
background_axes=(None, None, None),
):

self.signals = signals
self.backgrounds = backgrounds
self.signal_axes = list(signal_axes)
Expand Down Expand Up @@ -165,7 +164,6 @@ def plot_waterfall(self, contour_plot, shifts=None, ylim=None, xlim=None, fmt="o
fig, ax = plt.subplots()
shift = 0
for i in range(num):

if np.isnan(z[:, i]).all(): # all nan
continue
else:
Expand Down
11 changes: 4 additions & 7 deletions src/tavi/data/spice_to_nexus.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import numpy as np
import h5py
import os
from pathlib import Path
from datetime import datetime
from pathlib import Path

import h5py
import numpy as np

# from tavi.instrument.instrument_params.takin_test import instrument_params

Expand Down Expand Up @@ -421,7 +422,6 @@ def spicelogs_to_nexus(nxentry):
# mcu

if spice_logs.attrs["preset_type"] == "normal":

preset_channel = spice_logs.attrs["preset_channel"]

nxentry["monitor"].create_dataset(name="mode", data=preset_channel, maxshape=None)
Expand Down Expand Up @@ -458,7 +458,6 @@ def spicelogs_to_nexus(nxentry):
# --------------------------- data links ---------------------------

def find_val(val, grp, prefix=""):

for obj_name, obj in grp.items():
if obj_name in ("SPICElogs", "data"):
continue
Expand Down Expand Up @@ -749,7 +748,6 @@ def convert_spice_to_nexus(path_to_spice_folder, path_to_hdf5):
p = Path(path_to_spice_folder)

with h5py.File(path_to_hdf5, "w") as root:

# ----------------------------- ub info ------------------------------------
ub_files = sorted((p / "UBConf").glob("*.ini"))
tmp_ub_files = sorted((p / "UBConf/tmp").glob("*.ini"))
Expand Down Expand Up @@ -797,7 +795,6 @@ def convert_spice_to_nexus(path_to_spice_folder, path_to_hdf5):
# metadata to attibutes
exp_str = ["scan_title", "users", "local_contact", "experiment"]
for k, v in headers.items():

if "," in v and k not in exp_str: # vectors
spice_logs.attrs[k] = np.array([float(v0) for v0 in v.split(",")])
elif v.replace(".", "").isnumeric(): # numebrs only
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/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
}
}
}
1 change: 0 additions & 1 deletion src/tavi/instrument/instrument_params/python_dicts/hb3.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np

from tavi.utilities import *

source = {
Expand Down
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
}
}
}
4 changes: 2 additions & 2 deletions src/tavi/instrument/resolution/backups/cooper_nathans_bak.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np
import numpy.linalg as la
from tavi.utilities import *
from tavi.instrument.tas import TAS
from tavi.instrument.resolution.reso_ellipses import ResoEllipsoid
from tavi.instrument.tas import TAS
from tavi.utilities import *


class CN(TAS):
Expand Down
13 changes: 5 additions & 8 deletions src/tavi/instrument/resolution/backups/reso_ellipses_bak.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import numpy as np
import numpy.linalg as la
import mpl_toolkits.mplot3d as mplot3d
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import numpy.linalg as la
from tavi.utilities import *


np.set_printoptions(floatmode="fixed", precision=4)


Expand All @@ -25,7 +23,6 @@ class ResoEllipsoid(object):
g_eps = 1e-8

def __init__(self):

self.q = None
self.en = None
self.frame = None
Expand Down Expand Up @@ -279,9 +276,9 @@ def ellfkt(rad, vecs, phi):
labelQup = "Qup (1/A)"

if use_tex:
labelQpara = "$Q_{\parallel}$ (\AA$^{-1}$)"
labelQperp = "$Q_{\perp}$ (\AA$^{-1}$)"
labelQup = "$Q_{up}$ (\AA$^{-1}$)"
labelQpara = r"$Q_{\parallel}$ (\AA$^{-1}$)"
labelQperp = r"$Q_{\perp}$ (\AA$^{-1}$)"
labelQup = r"$Q_{up}$ (\AA$^{-1}$)"

# Qpara, E axis

Expand Down
1 change: 0 additions & 1 deletion src/tavi/instrument/resolution/cooper_nathans.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import numpy.linalg as la

from tavi.instrument.resolution.reso_ellipses import ResoEllipsoid
from tavi.instrument.tas import TAS
from tavi.utilities import *
Expand Down
6 changes: 2 additions & 4 deletions src/tavi/instrument/resolution/reso_ellipses.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import matplotlib.pyplot as plt
import numpy as np
import numpy.linalg as la
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist import Subplot, Axes
from mpl_toolkits.axisartist import Axes, Subplot
from mpl_toolkits.axisartist.grid_finder import MaxNLocator
from mpl_toolkits.axisartist.grid_helper_curvelinear import GridHelperCurveLinear
from tavi.utilities import *
Expand Down Expand Up @@ -141,7 +141,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 Expand Up @@ -196,7 +195,6 @@ class ResoEllipsoid(object):
g_eps = 1e-8

def __init__(self):

self.STATUS = None
self.q = None
self.hkl = None
Expand Down
1 change: 0 additions & 1 deletion src/tavi/instrument/tas_cmponents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np

from tavi.utilities import *


Expand Down
9 changes: 1 addition & 8 deletions src/tavi/plotter.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import matplotlib.pylab as plt
from mpl_toolkits.axisartist import Axes
import numpy as np
from mpl_toolkits.axisartist import Axes


class Plot1DManager(object):
"""Manage a plot"""

def __init__(self) -> None:

_, self.ax = plt.subplots()
self.title = None
self.xlim = None
Expand All @@ -16,7 +15,6 @@ def __init__(self) -> None:
self.ylabel = None

def set_labels(self):

if self.xlim is not None:
self.ax.set_xlim(left=self.xlim[0], right=self.xlim[1])
if self.ylim is not None:
Expand All @@ -29,7 +27,6 @@ def set_labels(self):
self.ax.legend()

def rez_plot_1D(self, tas, projection, hkl, en, ef, R0, axis):

rez = tas.cooper_nathans(
ei=ef + en,
ef=ef,
Expand Down Expand Up @@ -61,7 +58,6 @@ class Plot2DManager(object):
"""Manage a plot"""

def __init__(self, grid_helper=None) -> None:

self.fig = plt.figure(figsize=(10, 6))
self.ax = self.fig.add_subplot(111, axes_class=Axes, grid_helper=grid_helper)

Expand All @@ -76,7 +72,6 @@ def __init__(self, grid_helper=None) -> None:
self.cmap = "turbo"

def set_labels(self):

if self.xlim is not None:
self.ax.set_xlim(left=self.xlim[0], right=self.xlim[1])
if self.ylim is not None:
Expand Down Expand Up @@ -122,7 +117,6 @@ def plot_contour(
self.set_labels()

def rez_plot(self, tas, projection, q1, q2, q3, en, ef, R0):

qe_list = np.empty((4,), dtype=object)
plot_axes = []
perp_axes = []
Expand All @@ -142,7 +136,6 @@ def rez_plot(self, tas, projection, q1, q2, q3, en, ef, R0):
for q2 in qe_list[1]:
for q3 in qe_list[2]:
for ei0 in qe_list[3]:

h, k, l = tuple(np.array(p1) * q1 + np.array(p2) * q2 + np.array(p3) * q3)

rez = tas.cooper_nathans(
Expand Down
1 change: 0 additions & 1 deletion src/tavi/sample/sample.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np

from tavi.utilities import *

np.set_printoptions(floatmode="fixed", precision=4)
Expand Down
1 change: 0 additions & 1 deletion src/tavi/sample/xtal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np

from tavi.sample.sample import Sample
from tavi.utilities import *

Expand Down
1 change: 0 additions & 1 deletion tests/test_sample.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import pytest

from tavi.sample.xtal import Xtal


Expand Down

0 comments on commit fc06e49

Please sign in to comment.