Skip to content

Commit

Permalink
chore: Update minimum Python version (#61)
Browse files Browse the repository at this point in the history
* chore: Update minimum Python version

* tmp: install orquestra-python-dev from branch

* chore: fix typing issues

* Revert "tmp: install orquestra-python-dev from branch"

This reverts commit 7888b0b.

* fix: mypy mistakes axes3D for axes

* fix: isort issues

---------

Co-authored-by: Athena Caesura <mathmeetsmusic@gmail.com>
  • Loading branch information
jamesclark-Zapata and AthenaCaesura authored Oct 19, 2023
1 parent 60c4156 commit 26bfd50
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest"]
python: ["3.8", "3.9", "3.10"]
python: ["3.9", "3.10", "3.11"]

name: Coverage - Python ${{ matrix.python }} - ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# Run jobs for a couple of Python versions.
strategy:
matrix:
python: ["3.8", "3.9", "3.10"]
python: ["3.9", "3.10", "3.11"]

name: Style - Python ${{ matrix.python }}

Expand Down
6 changes: 4 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ author_email = info@zapatacomputing.com,
license = Apache Software License
license_file = LICENSE
classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Operating System :: OS Independent
License :: OSI Approved :: Apache Software License
Topic :: Scientific/Engineering
[options]
package_dir =
= src
packages = find:
python_requires = >=3.7
python_requires = >=3.9

install_requires =
numpy>=1.14.6
Expand Down
14 changes: 8 additions & 6 deletions src/orqviz/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

import matplotlib.pyplot as plt
import matplotlib.ticker as tck
import mpl_toolkits
import numpy as np
from matplotlib.cm import ScalarMappable


def normalize_color_and_colorbar(
Expand Down Expand Up @@ -40,9 +42,11 @@ def normalize_color_and_colorbar(
"Provided ax does not contain an image in ax.images or ax.collections"
) from e

image.colorbar.remove()
image.set_clim(vmin=min_val, vmax=max_val)
image.set_cmap(cmap)
assert isinstance(image, ScalarMappable)
if image.colorbar is not None:
image.colorbar.remove()
image.set_clim(vmin=min_val, vmax=max_val) # type: ignore
image.set_cmap(cmap) # type: ignore
fig.colorbar(image, ax=ax)


Expand All @@ -62,7 +66,6 @@ def get_colorbar_from_ax(
_, ax = _check_and_create_fig_ax(ax=ax)

if image_index is None:

len_collections = len(ax.collections)
len_images = len(ax.images)

Expand Down Expand Up @@ -155,7 +158,6 @@ def _check_and_create_fig_ax(
fig: Optional[plt.Figure] = None,
ax: Optional[plt.Axes] = None,
) -> Tuple[plt.Figure, plt.Axes]:

if fig is None:
fig = plt.gcf()

Expand All @@ -167,7 +169,7 @@ def _check_and_create_fig_ax(

def _check_and_create_3D_ax(
ax: Optional[plt.Axes] = None,
) -> plt.Axes:
) -> mpl_toolkits.mplot3d.Axes3D:
if ax is None:
fig = plt.figure()
ax = fig.add_subplot(projection="3d")
Expand Down
17 changes: 8 additions & 9 deletions src/orqviz/scans/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import matplotlib
import numpy as np

# this import is unused but solves issues with older matplotlib versions and 3d plots
from mpl_toolkits.mplot3d import Axes3D

from ..plot_utils import _check_and_create_3D_ax, _check_and_create_fig_ax
from .data_structures import Scan1DResult, Scan2DResult

Expand Down Expand Up @@ -161,7 +158,9 @@ def plot_2D_scan_result_as_3D(
plot_kwargs: kwargs for plotting with matplotlib.pyplot.plot_surface
(plt.plot_surface)
"""
ax = _check_and_create_3D_ax(ax=ax)
ax3D = _check_and_create_3D_ax(ax=ax)

assert ax3D is not None

x, y = scan2D_result._get_coordinates_on_directions(
in_units_of_direction=in_units_of_direction
Expand All @@ -171,10 +170,10 @@ def plot_2D_scan_result_as_3D(
plot_kwargs_defaults = {"cmap": "viridis", "alpha": 0.8}
plot_kwargs = {**plot_kwargs_defaults, **plot_kwargs}

ax.plot_surface(XX, YY, scan2D_result.values, **plot_kwargs)
ax3D.plot_surface(XX, YY, scan2D_result.values, **plot_kwargs)

ax.view_init(elev=35, azim=-70)
ax3D.view_init(elev=35, azim=-70)

ax.set_xlabel("Scan Direction x")
ax.set_ylabel("Scan Direction y")
ax.set_zlabel("Loss Value")
ax3D.set_xlabel("Scan Direction x")
ax3D.set_ylabel("Scan Direction y")
ax3D.set_zlabel("Loss Value")

0 comments on commit 26bfd50

Please sign in to comment.