Skip to content

Commit

Permalink
Merge pull request #136 from naik-aakash/add_units_to_plotters
Browse files Browse the repository at this point in the history
Add units to plotters
  • Loading branch information
JaGeo authored Sep 13, 2023
2 parents 57ca842 + f8a49fb commit b78ba40
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
# run this locally to update tests durations
# pytest --cov=lobsterpy --cov-append --splits 1 --group 1 --durations-path ./lobsterpy/TestData/.pytest-split-durations --store-durations
run: |
pytest --cov=lobsterpy --cov-report term-missing --cov-append --splits 5 --group ${{ matrix.split }} --durations-path ./lobsterpy/TestData/.pytest-split-durations
pytest --cov=lobsterpy --cov-report term-missing --cov-append --splits 5 --group ${{ matrix.split }} --durations-path ./lobsterpy/TestData/.pytest-split-durations
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion lobsterpy/TestData/interactive_plotter_ref/analyse_K3Sb.json
100644 → 100755

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lobsterpy/TestData/interactive_plotter_ref/analyse_NaCl.json
100644 → 100755

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lobsterpy/TestData/interactive_plotter_ref/analyse_NaCl_label.json
100644 → 100755

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lobsterpy/TestData/interactive_plotter_ref/analyse_NaSi.json
100644 → 100755

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lobsterpy/TestData/interactive_plotter_ref/fig_mp8818.json
100644 → 100755

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lobsterpy/plotting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ def get_plot(
"Plot data should not contain COBI and COOP data at same time"
)
else:
cohp_label = "COHP"
cohp_label = "COHP" + " (eV)"

if plot_negative is None:
plot_negative = (not self.are_coops) and (not self.are_cobis)

if integrated:
cohp_label = "I" + cohp_label + " (eV)"
cohp_label = "I" + cohp_label

if plot_negative:
cohp_label = "$-$" + cohp_label
Expand Down Expand Up @@ -495,21 +495,21 @@ def get_plot(
"Plot data should not contain COBI and COOP data at same time"
)
else:
cohp_label = "COHP"
cohp_label = "COHP" + " (eV)"

if plot_negative is None:
plot_negative = (not self.are_coops) and (not self.are_cobis)

if integrated:
cohp_label = "I" + cohp_label + " (eV)"
cohp_label = "I" + cohp_label

if plot_negative:
cohp_label = "\u2212" + cohp_label

if self.zero_at_efermi:
energy_label = "$E - E_f$ (eV)"
energy_label = "$E - E_f \\text{ (eV)}$"
else:
energy_label = "$E$ (eV)"
energy_label = "$E \\text{ (eV)}$"

# Setting up repeating color scheme (same as for matplotlib plots in .mplstyle)
if colors is None:
Expand Down
6 changes: 3 additions & 3 deletions lobsterpy/plotting/test/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def test_add_all_relevant_cohps_NaCl(self):
self.iplotter.add_all_relevant_cohps(
analyse=self.analyse_NaCl, label_resolved=False, suffix=""
)
# self.assertIn("Please select COHP label here", self.iplotter._cohps)
self.assertIn("All", self.iplotter._cohps)
self.assertEqual(len(self.iplotter._cohps), 1)

Expand Down Expand Up @@ -246,7 +245,7 @@ def test_plot_labels(self):
self.plotter = PlainCohpPlotter()
fig = self.plotter.get_plot().gca()

self.assertEqual(fig.get_xlabel(), "$-$COHP")
self.assertEqual(fig.get_xlabel(), "$-$COHP (eV)")

# interactive plotter
self.iplotter = InteractiveCohpPlotter(are_cobis=True)
Expand All @@ -262,7 +261,8 @@ def test_plot_labels(self):
self.iplotter = InteractiveCohpPlotter()
fig = self.iplotter.get_plot()

self.assertEqual(fig.layout.xaxis["title"]["text"], "−COHP")
self.assertEqual(fig.layout.xaxis["title"]["text"], "−COHP (eV)")
self.assertEqual(fig.layout.yaxis["title"]["text"], "$E - E_f \\text{ (eV)}$")


class IcohpDistancePlotterTest(unittest.TestCase):
Expand Down

0 comments on commit b78ba40

Please sign in to comment.