Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
mawc2019 committed May 12, 2023
1 parent 0b737c8 commit b87cb53
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
8 changes: 6 additions & 2 deletions python/adjoint/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,9 @@ def indicator_solid(x, c, filter_f, threshold_f, resolution, periodic_axes=None)
filtered_field = npa.tile(filtered_field, (3, 1))
if 1 in periodic_axes:
filtered_field = npa.tile(filtered_field, (1, 3))
gradient_filtered_field = _centered(npa.array(npa.gradient(filtered_field)), (2,) + x.shape)
gradient_filtered_field = _centered(
npa.array(npa.gradient(filtered_field)), (2,) + x.shape
)

grad_mag = (gradient_filtered_field[0] * resolution) ** 2 + (
gradient_filtered_field[1] * resolution
Expand Down Expand Up @@ -953,7 +955,9 @@ def indicator_void(x, c, filter_f, threshold_f, resolution, periodic_axes=None):
filtered_field = npa.tile(filtered_field, (3, 1))
if 1 in periodic_axes:
filtered_field = npa.tile(filtered_field, (1, 3))
gradient_filtered_field = _centered(npa.array(npa.gradient(filtered_field)), (2,) + x.shape)
gradient_filtered_field = _centered(
npa.array(npa.gradient(filtered_field)), (2,) + x.shape
)

grad_mag = (gradient_filtered_field[0] * resolution) ** 2 + (
gradient_filtered_field[1] * resolution
Expand Down
24 changes: 16 additions & 8 deletions python/tests/test_adjoint_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,9 +1056,11 @@ def test_periodic_design(self):
self.design_region_resolution,
periodic_axes,
)
solid_grad_row_shift = np.vstack((solid_grad[idx_row_shift:, :], solid_grad[0:idx_row_shift, :]))
solid_grad_row_shift = np.vstack(
(solid_grad[idx_row_shift:, :], solid_grad[0:idx_row_shift, :])
)
self.assertAlmostEqual(
np.sum(abs(solid_grad_row_shift-solid_row_shift_grad)),
np.sum(abs(solid_grad_row_shift - solid_row_shift_grad)),
0,
places=places,
)
Expand All @@ -1072,9 +1074,11 @@ def test_periodic_design(self):
self.design_region_resolution,
periodic_axes,
)
void_grad_row_shift = np.vstack((void_grad[idx_row_shift:, :], void_grad[0:idx_row_shift, :]))
void_grad_row_shift = np.vstack(
(void_grad[idx_row_shift:, :], void_grad[0:idx_row_shift, :])
)
self.assertAlmostEqual(
np.sum(abs(void_grad_row_shift-void_row_shift_grad)),
np.sum(abs(void_grad_row_shift - void_row_shift_grad)),
0,
places=places,
)
Expand Down Expand Up @@ -1119,9 +1123,11 @@ def test_periodic_design(self):
self.design_region_resolution,
periodic_axes,
)
solid_grad_col_shift = np.hstack((solid_grad[:, idx_col_shift:], solid_grad[:, 0:idx_col_shift]))
solid_grad_col_shift = np.hstack(
(solid_grad[:, idx_col_shift:], solid_grad[:, 0:idx_col_shift])
)
self.assertAlmostEqual(
np.sum(abs(solid_grad_col_shift-solid_col_shift_grad)),
np.sum(abs(solid_grad_col_shift - solid_col_shift_grad)),
0,
places=places,
)
Expand All @@ -1135,9 +1141,11 @@ def test_periodic_design(self):
self.design_region_resolution,
periodic_axes,
)
void_grad_col_shift = np.hstack((void_grad[:, idx_col_shift:], void_grad[:, 0:idx_col_shift]))
void_grad_col_shift = np.hstack(
(void_grad[:, idx_col_shift:], void_grad[:, 0:idx_col_shift])
)
self.assertAlmostEqual(
np.sum(abs(void_grad_col_shift-void_col_shift_grad)),
np.sum(abs(void_grad_col_shift - void_col_shift_grad)),
0,
places=places,
)
Expand Down

0 comments on commit b87cb53

Please sign in to comment.