diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 4e9273c2cd..1379485e74 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,10 +1,9 @@ name: Benchmarks on: - pull_request: + pull_request_target: branches: - master - pull_request_target: types: [opened, synchronize] workflow_dispatch: inputs: diff --git a/desc/optimize/optimizer.py b/desc/optimize/optimizer.py index 48e016b67c..99a57c926d 100644 --- a/desc/optimize/optimizer.py +++ b/desc/optimize/optimizer.py @@ -209,9 +209,11 @@ def optimize( # noqa: C901 - FIXME: simplify this objective, nonlinear_constraints = _maybe_wrap_nonlinear_constraints( eq, objective, nonlinear_constraints, self.method, options ) - if not isinstance(objective, ProximalProjection): - for t in things: - linear_constraints = maybe_add_self_consistency(t, linear_constraints) + is_prox = isinstance(objective, ProximalProjection) + for t in things: + if isinstance(t, Equilibrium) and is_prox: + continue # don't add Equilibrium self-consistency if proximal is used + linear_constraints = maybe_add_self_consistency(t, linear_constraints) linear_constraint = _combine_constraints(linear_constraints) nonlinear_constraint = _combine_constraints(nonlinear_constraints) diff --git a/desc/plotting.py b/desc/plotting.py index 3a6dcdd76a..def22fa14d 100644 --- a/desc/plotting.py +++ b/desc/plotting.py @@ -1354,6 +1354,8 @@ def plot_section( * ``phi``: float, int or array-like. Toroidal angles to plot. If an integer, plot that number equally spaced in [0,2pi/NFP). Default 1 for axisymmetry and 6 for non-axisymmetry + * ``fill`` : bool, Whether the contours are filled, i.e. whether to use + `contourf` or `contour`. Default to ``fill=True`` Returns ------- @@ -1442,7 +1444,7 @@ def plot_section( R = coords["R"].reshape((nt, nr, nz), order="F") Z = coords["Z"].reshape((nt, nr, nz), order="F") data = data.reshape((nt, nr, nz), order="F") - + op = "contour" + ("f" if kwargs.pop("fill", True) else "") contourf_kwargs = {} if log: data = np.abs(data) # ensure data is positive for log plot @@ -1474,7 +1476,9 @@ def plot_section( for i in range(nphi): divider = make_axes_locatable(ax[i]) - cntr = ax[i].contourf(R[:, :, i], Z[:, :, i], data[:, :, i], **contourf_kwargs) + cntr = getattr(ax[i], op)( + R[:, :, i], Z[:, :, i], data[:, :, i], **contourf_kwargs + ) cax = divider.append_axes("right", **cax_kwargs) cbar = fig.colorbar(cntr, cax=cax) cbar.update_ticks() diff --git a/tests/baseline/test_section_chi_contour.png b/tests/baseline/test_section_chi_contour.png new file mode 100644 index 0000000000..ac8c342c18 Binary files /dev/null and b/tests/baseline/test_section_chi_contour.png differ diff --git a/tests/test_plotting.py b/tests/test_plotting.py index 8488c91a87..44a3c5c2da 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -429,6 +429,14 @@ def test_section_J(self): return fig + @pytest.mark.unit + @pytest.mark.mpl_image_compare(remove_text=True, tolerance=tol_2d) + def test_section_chi_contour(self): + """Test plotting poincare section of poloidal flux, with fill=False.""" + eq = get("DSHAPE_CURRENT") + fig, ax = plot_section(eq, "chi", fill=False, levels=20) + return fig + @pytest.mark.unit @pytest.mark.mpl_image_compare(remove_text=True, tolerance=tol_2d) def test_section_F(self):