Skip to content

Commit

Permalink
add index_origin to all aranges
Browse files Browse the repository at this point in the history
  • Loading branch information
OriolAbril committed Feb 16, 2021
1 parent 29abd7f commit 480d99a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arviz/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import numpy as np
import pkg_resources
import numpy as np
import xarray as xr

try:
Expand Down Expand Up @@ -133,7 +134,7 @@ def generate_dims_coords(
dims[idx] = dim_name
dim_name = dims[idx]
if dim_name not in coords:
coords[dim_name] = utils.arange(index_origin, dim_len+index_origin)
coords[dim_name] = np.arange(index_origin, dim_len + index_origin)
coords = {key: coord for key, coord in coords.items() if any(key == dim for dim in dims)}
return dims, coords

Expand Down Expand Up @@ -209,10 +210,11 @@ def numpy_to_data_array(
if "chain" not in dims and "chain" in default_dims:
dims = ["chain"] + dims

index_origin = rcParams["data.index_origin"]
if "chain" not in coords and "chain" in default_dims:
coords["chain"] = utils.arange(n_chains)
coords["chain"] = np.arange(index_origin, n_chains + index_origin)
if "draw" not in coords and "draw" in default_dims:
coords["draw"] = utils.arange(n_samples)
coords["draw"] = np.arange(index_origin, n_samples + index_origin)

# filter coords based on the dims
coords = {key: xr.IndexVariable((key,), data=coords[key]) for key in dims}
Expand Down

0 comments on commit 480d99a

Please sign in to comment.