-
Notifications
You must be signed in to change notification settings - Fork 523
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
Add a new StatisticsError exception class #2760
Conversation
Also make an outer `with Env():` optional when using an opened dataset as a context manager. Resolves #2759
@@ -439,6 +440,7 @@ cdef class DatasetBase: | |||
self._closed = True | |||
|
|||
def __enter__(self): | |||
self._env.enter_context(env_ctx_if_needed()) |
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 feel dumb for not seeing this until now. I could have done this for 1.3.0!
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.
dataset.enter_context(Env())
is like a retroactive version of
with Env():
with dataset as dataset:
...
It lets us add an outer context (Env()
) to the inner one (dataset
), from within the inner one.
@@ -60,13 +60,13 @@ def xy( | |||
col : int | |||
Pixel column. | |||
z : float, optional | |||
Height associated with coordinates. Primarily used for RPC based | |||
coordinate transformations. Ignored for affine based |
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 looked in this module to remind myself how I was using ExitStack and found some trailing whitespace to remove. It's related 😉
@@ -72,16 +68,6 @@ def test_dataset_readonly_attributes(path_rgb_byte_tif): | |||
dataset.crs = "foo" | |||
|
|||
|
|||
def test_statistics(path_rgb_byte_tif): |
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.
Moved to its own test module.
_ = dataset.statistics(1) | ||
|
||
captured = capsys.readouterr() | ||
assert "ERROR 1" not in captured.err |
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.
Without the change to _base.pyx, this assertion fails.
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.
Thanks @sgillies 👍
Also make an outer
with Env():
optional when using an opened dataset as a context manager.Resolves #2759