forked from pydata/xarray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make dataset.unstack faster by skipping reindex if not necessary. * Remove prints, add comment * added asv benchmark for unstacking * Added test * Simplified test * Added whats-new entry * PEP8 * Made asv test faster
- Loading branch information
Showing
4 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import numpy as np | ||
import xarray as xr | ||
|
||
from . import requires_dask | ||
|
||
|
||
class Unstacking(object): | ||
def setup(self): | ||
data = np.random.RandomState(0).randn(1, 1000, 500) | ||
self.ds = xr.DataArray(data).stack(flat_dim=['dim_1', 'dim_2']) | ||
|
||
def time_unstack_fast(self): | ||
self.ds.unstack('flat_dim') | ||
|
||
def time_unstack_slow(self): | ||
self.ds[:, ::-1].unstack('flat_dim') | ||
|
||
|
||
class UnstackingDask(Unstacking): | ||
def setup(self, *args, **kwargs): | ||
requires_dask() | ||
super(UnstackingDask, self).setup(**kwargs) | ||
self.ds = self.ds.chunk({'flat_dim': 50}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters