New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inventory copy #2322
Inventory copy #2322
Conversation
c07d251
to
e705f20
Compare
Rebased on current master and force-pushed so that we have fresh CI results tomorrow. |
obspy/core/inventory/inventory.py
Outdated
|
||
>>> from obspy import read_inventory | ||
>>> inv = read_inventory() | ||
>>> inv2 = inv2.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inv2 = inv.copy()
obspy/core/tests/test_inventory.py
Outdated
self.assertEqual(inv, inv2) | ||
# make sure changing inv2 doesnt affect inv | ||
original_latitude = inv2[0][0][0].latitude | ||
inv2[0][0][0].latitudue = original_latitude + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latitudue - latitude
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how to understand this test...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just checks whether the memory copy works by modifying the copied reference and checking it doesn't touch the original reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
um.. but the latitude is never actually changed anywhere.. so i agree with @ThomasLecocq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the typo has to be fixed.. but the point is to prove that the two objects don't reference the same point in memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the typo already and also amended the test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, can be merged on green CI
CI all green so far, only 1-2 appveyor jobs not yet done |
@megies all green (except unrelated evalresp) |
Bääääm! 🚀 |
What does this PR do?
Adds a copy method to
Inventory
to be consistent withCatalog
andStream
which both have copy methods that created deep copies.Why was it initiated? Any relevant Issues?
PR Checklist
master
for new features,maintenance_...
for bug fixesJust remove the space in the following string after the + sign: "+ DOCS"
(e.g.
clients.fdsn,clients.arclink
) after the colon in the following magic string: "+TESTS:"(you can also add "ALL" to just simply run all tests across all modules)
CHANGELOG.txt
.CONTRIBUTORS.txt
.