Skip to content

Conversation

@cako
Copy link

@cako cako commented Nov 29, 2025

Description

plot_perturbation has a small bug where the nbl is not properly addressed when plotting. This PR addressed that by applying the same slicing as plot_velocity.

Fix plotting of nbl
Copy link
Contributor

@EdCaunt EdCaunt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, but generally a useful fix. Thanks!

dv = np.transpose(model.vp.data) - np.transpose(model1.vp.data)
slices = tuple(slice(model.nbl, -model.nbl) for _ in range(2))
slices1 = tuple(slice(model1.nbl, -model1.nbl) for _ in range(2))
dv = np.transpose(model.vp.data[slices]) - np.transpose(model1.vp.data[slices1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally check model.nbl == model1.nbl and raise a suitable ValueError if not (probably also check the size of both models match whilst you're at it).

That way you only need a single slices which would be tidier and easier to read in my opinion.

Minor note, you can also do slices = (slice(model.nbl, -model.nbl),) * 2 for concision, although this is arguably less explicit. A matter of personal preference I would say.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b2d1d4f!

domain_size = 1.e-3 * np.array(model.domain_size)
extent = [model.origin[0], model.origin[0] + domain_size[0],
model.origin[1] + domain_size[1], model.origin[1]]
assert model.nbl == model1.nbl, ValueError("model and model1 have different values for nbl")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an fstring here so you get the actual names of the model objects

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

extent = [model.origin[0], model.origin[0] + domain_size[0],
model.origin[1] + domain_size[1], model.origin[1]]
dv = np.transpose(model.vp.data) - np.transpose(model1.vp.data)
assert model.nbl == model1.nbl, ValueError("model and model1 have different values for nbl")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the correct synthax is

if model.nbl != model1.nbl:
    raise ValueError("model and model1 have different values for nbl")

the second arg of assert a, b is a plain string passed to AssertionError

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

Copy link
Contributor

@EdCaunt EdCaunt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this once CI is green

@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.97%. Comparing base (f020eb1) to head (24f5fd4).
⚠️ Report is 60 commits behind head on main.

Files with missing lines Patch % Lines
examples/seismic/plotting.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2797      +/-   ##
==========================================
- Coverage   82.98%   78.97%   -4.01%     
==========================================
  Files         248      248              
  Lines       51012    50823     -189     
  Branches     4491     4391     -100     
==========================================
- Hits        42332    40139    -2193     
- Misses       7909     9881    +1972     
- Partials      771      803      +32     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX ?
pytest-gpu-nvc-nvidiaX ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants