Skip to content
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

Removed load_data & save_data functions and tests. Fixes #495 #625

Merged
merged 2 commits into from
May 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions arviz/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Code for loading and manipulating data structures."""
from .inference_data import InferenceData, concat
from .io_netcdf import from_netcdf, to_netcdf, load_data, save_data
from .io_netcdf import from_netcdf, to_netcdf
from .datasets import load_arviz_data, list_datasets, clear_data_home
from .base import numpy_to_data_array, dict_to_dataset
from .converters import convert_to_dataset, convert_to_inference_data
Expand Down Expand Up @@ -31,6 +31,4 @@
"from_tfp",
"from_netcdf",
"to_netcdf",
"load_data",
"save_data",
]
57 changes: 1 addition & 56 deletions arviz/data/io_netcdf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Input and output support for data."""
import warnings

from .inference_data import InferenceData
from .converters import convert_to_inference_data

Expand Down Expand Up @@ -41,58 +41,3 @@ def to_netcdf(data, filename, *, group="posterior", coords=None, dims=None):
inference_data = convert_to_inference_data(data, group=group, coords=coords, dims=dims)
file_name = inference_data.to_netcdf(filename)
return file_name


def load_data(filename):
"""Load netcdf file back into an arviz.InferenceData.

Parameters
----------
filename : str
name or path of the file to load trace

Note
----
This function is deprecated and will be removed in 0.4.
Use `from_netcdf` instead.
"""
warnings.warn(
"The 'load_data' function is deprecated as of 0.3.2, use 'from_netcdf' instead",
DeprecationWarning,
)
return from_netcdf(filename=filename)


def save_data(data, filename, *, group="posterior", coords=None, dims=None):
"""Save dataset as a netcdf file.

WARNING: Only idempotent in case `data` is InferenceData

Parameters
----------
data : InferenceData, or any object accepted by `convert_to_inference_data`
Object to be saved
filename : str
name or path of the file to load trace
group : str (optional)
In case `data` is not InferenceData, this is the group it will be saved to
coords : dict (optional)
See `convert_to_inference_data`
dims : dict (optional)
See `convert_to_inference_data`

Returns
-------
str
filename saved to

Note
----
This function is deprecated and will be removed in 0.4.
Use `to_netcdf` instead.
"""
warnings.warn(
"The 'save_data' function is deprecated as of 0.3.2, use 'to_netcdf' instead",
DeprecationWarning,
)
return to_netcdf(data=data, filename=filename, group=group, coords=coords, dims=dims)
10 changes: 0 additions & 10 deletions arviz/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
from_netcdf,
from_tfp,
to_netcdf,
load_data,
save_data,
load_arviz_data,
list_datasets,
clear_data_home,
Expand Down Expand Up @@ -664,14 +662,6 @@ def test_io_function(self, data, eight_schools_params):
assert hasattr(inference_data2, "posterior")
os.remove(filepath)
assert not os.path.exists(filepath)
# Test deprecated functions
save_data(inference_data, filepath)
assert os.path.exists(filepath)
assert os.path.getsize(filepath) > 0
inference_data3 = load_data(filepath)
assert hasattr(inference_data3, "posterior")
os.remove(filepath)
assert not os.path.exists(filepath)

def test_io_method(self, data, eight_schools_params):
inference_data = self.get_inference_data( # pylint: disable=W0612
Expand Down