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

Issue54 #55

Merged
merged 4 commits into from
Jun 24, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 4 additions & 3 deletions pypet/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@

import numpy as np
import scipy.sparse as spsp
from pandas import DataFrame, Series, Panel
from pandas import DataFrame, Series


import pypet.pypetconstants as pypetconstants
from pypet.naturalnaming import NNLeafNode
Expand Down Expand Up @@ -1954,7 +1955,7 @@ class Result(BaseResult):
__slots__ = ('_data_',)

SUPPORTED_DATA = set((np.ndarray, ObjectTable,
DataFrame, Series, Panel,
DataFrame, Series,
dict, tuple, list, np.matrix) +
pypetconstants.PARAMETER_SUPPORTED_DATA)

Expand Down Expand Up @@ -2484,4 +2485,4 @@ def _load(self, load_dict):
self.v_protocol = PickleParameter._get_protocol(dump)
for key in load_dict:
val = load_dict[key]
self._data[key] = pickle.loads(val)
self._data[key] = pickle.loads(val)
15 changes: 7 additions & 8 deletions pypet/storageservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import tables.parameters as ptpa

import numpy as np
from pandas import DataFrame, Series, Panel, HDFStore
from pandas import DataFrame, Series, HDFStore

import pypet.pypetconstants as pypetconstants
import pypet.pypetexceptions as pex
Expand Down Expand Up @@ -422,9 +422,6 @@ class HDF5StorageService(StorageService, HasLogger):
SERIES = pypetconstants.SERIES
''' Store data as pandas Series '''

PANEL = pypetconstants.PANEL
''' Store data as pandas Panel(4D) '''

SPLIT_TABLE = pypetconstants.SPLIT_TABLE
''' If a table was split due to too many columns'''

Expand All @@ -446,7 +443,6 @@ class HDF5StorageService(StorageService, HasLogger):
np.matrix: CARRAY,
DataFrame: FRAME,
Series: SERIES,
Panel: PANEL,
shared.SharedTable: SHARED_DATA,
shared.SharedArray: SHARED_DATA,
shared.SharedPandasFrame: SHARED_DATA,
Expand Down Expand Up @@ -3835,7 +3831,8 @@ def _prm_store_from_dict(self, fullname, store_dict, hdf5_group, store_flags, kw
flag=flag, **kwargs)
elif flag in (HDF5StorageService.SERIES,
HDF5StorageService.FRAME,
HDF5StorageService.PANEL):
# HDF5StorageService.PANEL
):
# self._logger.log(1, 'SUB-Storing %s PANDAS', key)
self._prm_write_pandas_data(key, data_to_store, hdf5_group, fullname,
flag, **kwargs)
Expand Down Expand Up @@ -4017,7 +4014,8 @@ def _shared_write_shared_data(self, key, hdf5_group, full_name, **kwargs):

elif flag in (HDF5StorageService.FRAME,
HDF5StorageService.SERIES,
HDF5StorageService.PANEL) :
# HDF5StorageService.PANEL
) :

self._prm_write_pandas_data(key, data,
hdf5_group,
Expand Down Expand Up @@ -4675,7 +4673,8 @@ def _prm_load_into_dict(self, full_name, load_dict, hdf5_group, instance,
to_load = self._prm_read_array(node, full_name)
elif load_type in (HDF5StorageService.FRAME,
HDF5StorageService.SERIES,
HDF5StorageService.PANEL):
# HDF5StorageService.PANEL
):
to_load = self._prm_read_pandas(node, full_name)
elif load_type.startswith(HDF5StorageService.SHARED_DATA):
to_load = self._prm_read_shared_data(node, instance)
Expand Down
4 changes: 1 addition & 3 deletions pypet/tests/testutils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ def simple_calculations(traj, arg1, simple_kwarg):

myseries = myframe['TC1']

mypanel = pd.Panel({'Item1' : pd.DataFrame(np.ones((4, 3))),'Item2' : pd.DataFrame(np.ones((4, 2)))})

traj.f_add_result('myseries', myseries, comment='dd')
traj.f_store_item('myseries')
traj.f_add_result('mypanel', mypanel, comment='dd')
Copy link
Owner

@SmokinCaterpillar SmokinCaterpillar Jun 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this line, too? Otherwise the tests fail.

Expand Down Expand Up @@ -403,4 +401,4 @@ def compare_trajectories(self,traj1,traj2):

if not node.v_annotations.f_is_empty():
second_anns = traj2.f_get(node.v_full_name).v_annotations
self.assertTrue(str(node.v_annotations) == str(second_anns))
self.assertTrue(str(node.v_annotations) == str(second_anns))
6 changes: 1 addition & 5 deletions pypet/tests/unittests/parameter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,11 +818,7 @@ def setUp(self):

myseries = myframe['TC1']

mypanel = pd.Panel({'Item1' : pd.DataFrame(np.random.randn(4, 3)),
'Item2' : pd.DataFrame(np.random.randn(4, 2))})

self.data['series'] = myseries
self.data['panel'] = mypanel

self.make_constructor()
self.make_results()
Expand Down Expand Up @@ -1053,4 +1049,4 @@ def make_results(self):

if __name__ == '__main__':
opt_args = parse_args()
run_suite(**opt_args)
run_suite(**opt_args)
7 changes: 0 additions & 7 deletions pypet/utils/comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,6 @@ def nested_equal(a, b):
else:
return not np.any((a != b).data)

a_panel = isinstance(a, pd.Panel)
b_panel = isinstance(b, pd.Panel)
if a_panel != b_panel:
return False
if a_panel:
return nested_equal(a.to_frame(), b.to_frame())

a_series = isinstance(a, pd.Series)
b_series = isinstance(b, pd.Series)
if a_series != b_series:
Expand Down