| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
If its useful, I wrote a chunks strategy here: though it does generate non-uniform chunks |
Sorry, something went wrong.
@dcherian I also wrote one at dask/dask#9374 😆 It will be useful eventually, but right now we're trying to get the testing framework in place that the chunk strategy would plug into. The chunk-generating strategy would be called by the cubed_random_array strategy. |
Sorry, something went wrong.
|
|
||
|
|
||
| class CreationTests(DuckArrayTestMixin): | ||
| @settings(suppress_health_check=[HealthCheck.differing_executors]) |
There was a problem hiding this comment.
@Zac-HD the fact we had to add this seems to indicate a possibly-serious misuse of hypothesis, but in some way that @keewis and I struggled to properly understand from looking at the docs.
https://hypothesis.readthedocs.io/en/latest/settings.html#hypothesis.HealthCheck.differing_executors
Sorry, something went wrong.
There was a problem hiding this comment.
see HypothesisWorks/hypothesis#3446 for the motivating cases; if you inherit an @given() test onto multiple child classes with different behavior you can get some pretty weird behaviors.
If you don't observe anything like that, it's probably okay albeit fragile.
Sorry, something went wrong.
There was a problem hiding this comment.
In the very limited running we did today, we didn't observe anything unexpected after we disabled the health check.
But is there some other pattern we should be using here?
Sorry, something went wrong.
There was a problem hiding this comment.
I don't have any concrete suggestions; inheritance for code-sharing is both useful in this kind of situation, and also prone to sharing slightly more state than we want it to. A design that doesn't use inheritance would be safer but I'm not sure it's worth the trouble.
Sorry, something went wrong.
There was a problem hiding this comment.
Okay thanks. Sounds like perhaps we should disable this warning globally (if possible) and just report if it actually causes problems.
if you inherit an @given() test onto multiple child classes with different behavior
We are not actually ever going to be inheriting one given test onto multiple child classes, only onto one child class (per downstream package). So maybe that makes it okay?
...actually the one exception to that statement would be in Xarray itself, where we would inherit once to test wrapping numpy, once to test wrapping dask etc. But we could probably still set up our CI to ensure that only one child test class (suite of children really) gets run per CI job.
Sorry, something went wrong.
There was a problem hiding this comment.
Should be fine, iirc it's only an issue if you're replaying test cases from the database and the underlying sequence of choices is different and you hit a particular unlucky situation.
Sorry, something went wrong.
There was a problem hiding this comment.
actually the one exception to that statement would be in Xarray itself
not only that, unfortunately: if you want to check how dask and cupy work together, for example, cupy-xarray would have to create both the suite for cupy and the dask+cupy one.
The other option we'd have is to generate a single test class within a function:
def generate_tests(name, array_strategy, array_type, xp):
@rename_class(f"Test{name.title().replace('_', '')}Array")
class TestDuckArray:
class TestCreation:
array_strategy_fn = array_strategy
...
return TestDuckArray
TestNumpyArray = generate_tests("numpy", create_numpy_array, np.ndarray, np)which would avoid the reuse of a single given, but this quickly becomes tricky to read because of the deeply nested structure.
Sorry, something went wrong.
There was a problem hiding this comment.
I've tried to work around this in #7 by delaying the application of given.
Sorry, something went wrong.
Sorry, something went wrong.
| # TODO hypothesis doesn't like us using random inside strategies | ||
| rng = np.random.default_rng() |
There was a problem hiding this comment.
Consider using a Hypothesis-provided seed? I'd also be happy to accept a PR to generate Numpy prng instances 🙂
Sorry, something went wrong.
There was a problem hiding this comment.
we should probably try using xps.arrays() instead (though I guess that only works for array API compliant duck arrays)
Sorry, something went wrong.
There was a problem hiding this comment.
The other argument against is that sometimes you just want a faster PRNG for the elements; the distribution is a bit less likely to find bugs but setting elements individually is a lot slower (even though we do a sparse subset)
Sorry, something went wrong.
That dtype is currently not part of the spec.
|
there's two distinct failures here:
|
Sorry, something went wrong.
|
@tomwhite, I just tried to get xarray to allow you to define __array_function__ on cubed. This was surprisingly simple, I just had to:
with those four changes, xarray's test suite still passes in my environment, and the tests here don't fail because cubed has been eagerly computed. However, there's some floating point issues we still have to resolve (mostly floating-point errors for float32 / complex64). |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
No description provided.