Skip to content

Commit

Permalink
Merge branch 'master' into types
Browse files Browse the repository at this point in the history
  • Loading branch information
YigitElma authored Nov 12, 2024
2 parents 13f0a46 + f83b8dd commit f41f806
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Benchmarks

on:
pull_request:
pull_request_target:
branches:
- master
pull_request_target:
types: [opened, synchronize]
workflow_dispatch:
inputs:
Expand Down
8 changes: 5 additions & 3 deletions desc/optimize/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 6 additions & 2 deletions desc/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Binary file added tests/baseline/test_section_chi_contour.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit f41f806

Please sign in to comment.