diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8b778b4f..29a02de9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,7 +4,11 @@ Change Log v2.3.6 ------ -Fix superscript in ``sumo-optplot`` + +Bugfixes: + +- Allow "BREAK" keyword in CASTEP band paths - and ignore it. (@azanre, #201) +- Fix superscript in ``sumo-optplot`` (@utf, #203) v2.3.5 ------ diff --git a/README.rst b/README.rst index 3b0dacb7..79fdb651 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ Sumo ==== -.. image:: https://img.shields.io/github/workflow/status/smtg-ucl/sumo/Run%20tests +.. image:: https://img.shields.io/github/actions/workflow/status/smtg-ucl/sumo/tests.yml?branch=master :target: https://github.com/SMTG-UCL/sumo/actions?query=workflow%3A%22Run+tests%22 :alt: Build Status diff --git a/sumo/io/castep.py b/sumo/io/castep.py index 708213dc..3bfab75c 100644 --- a/sumo/io/castep.py +++ b/sumo/io/castep.py @@ -486,12 +486,14 @@ def labels_from_cell(cell_file, phonon=False): line = f.readline() # Skip past block start line while blockend.match(line.lower()) is None: - kpt = tuple(map(float, line.split()[:3])) - if len(line.split()) > 3: - label = line.split()[-1] - if label.lower() in ("g", "gamma"): - label = r"\Gamma" - labels[label] = kpt + # Do not parse break lines + if 'break' not in line.lower(): + kpt = tuple(map(float, line.split()[:3])) + if len(line.split()) > 3: + label = line.split()[-1] + if label.lower() in ("g", "gamma"): + label = r"\Gamma" + labels[label] = kpt line = f.readline() if line == "": logging.error("Could not find end of k-point block in cell file.") diff --git a/sumo/plotting/__init__.py b/sumo/plotting/__init__.py index 1a1e27b4..2e9aab9f 100644 --- a/sumo/plotting/__init__.py +++ b/sumo/plotting/__init__.py @@ -169,7 +169,7 @@ def power_tick(val, pos, times_sign=r"\times"): coeff = val / 10**exponent prec = 0 if coeff % 1 == 0 else 1 - return rf"$\mathregular{{{coeff:.{prec}f} {times_sign} 10^{exponent:2d}}}$" + return rf"${coeff:.{prec}f}\mathrm{{{times_sign}}}10^{{{exponent:2d}}}$" def colorline( diff --git a/sumo/plotting/optics_plotter.py b/sumo/plotting/optics_plotter.py index 03096334..5e4d3ac0 100644 --- a/sumo/plotting/optics_plotter.py +++ b/sumo/plotting/optics_plotter.py @@ -243,12 +243,8 @@ def get_plot( if spectrum_key == "absorption": font = findfont(FontProperties(family=["sans-serif"])) - if "Whitney" in font: - times_sign = "x" - else: - times_sign = r"\times" ax.yaxis.set_major_formatter( - FuncFormatter(curry_power_tick(times_sign=times_sign)) + FuncFormatter(curry_power_tick(times_sign=r"\times")) ) ax.yaxis.set_major_locator(MaxNLocator(5)) diff --git a/tests/data/Pt/Pt.cell b/tests/data/Pt/Pt.cell new file mode 100644 index 00000000..5b6e8662 --- /dev/null +++ b/tests/data/Pt/Pt.cell @@ -0,0 +1,27 @@ +%BLOCK LATTICE_CART +ang # angstrom units + 1.961550000000000 1.961550000000000 0.000000000000000 + 1.961550000000000 0.000000000000000 1.961550000000000 + 0.000000000000000 1.961550000000000 1.961550000000000 +%ENDBLOCK LATTICE_CART + +%BLOCK POSITIONS_FRAC +Pt 0.000000000000000 0.000000000000000 0.000000000000000 +%ENDBLOCK POSITIONS_FRAC + +SYMMETRY_GENERATE + +KPOINT_MP_SPACING: 0.04 +SPECTRAL_KPOINT_PATH_SPACING : 0.04 + +%BLOCK SPECTRAL_KPOINT_PATH +0 0 0 ! \Gamma +0.5 0 0.5 ! X +0.625 0.25 0.625 ! U +BREAK +0.375 0.375 0.75 ! K +0 0 0 ! \Gamma +0.5 0.5 0.5 ! L +0.5 0.25 0.75 ! W +0.5 0 0.5 ! X +%ENDBLOCK SPECTRAL_KPOINT_PATH diff --git a/tests/tests_io/test_castep.py b/tests/tests_io/test_castep.py index b5fdaaaa..64d16d54 100644 --- a/tests/tests_io/test_castep.py +++ b/tests/tests_io/test_castep.py @@ -241,6 +241,26 @@ def test_castep_bands_read_header(self): self.assertEqual(header, ref_header) +class BandStructureTestCasePathBreak(unittest.TestCase): + def setUp(self): + self.pt_cell = resource_filename( + __name__, path_join("..", "data", "Pt", "Pt.cell") + ) + self.ref_labels = { + r"\Gamma": (0.0, 0.0, 0.0), + "X": (0.5, 0.0, 0.5), + "U": (0.625, 0.25, 0.625), + "K": (0.375, 0.375, 0.75), + "L": (0.5, 0.5, 0.5), + "W": (0.5, 0.25, 0.75) + } + + def test_castep_parse_break_in_k_path(self): + labels = labels_from_cell(self.pt_cell) + print(labels) + self.assertEqual(labels, self.ref_labels) + + # To generate reference file:: # # sumo-phonon-bandplot -f zns.phonon --units cm-1 --to-json zns_phonon.json