Skip to content

Commit

Permalink
minor edits in param.py
Browse files Browse the repository at this point in the history
 - get_sample_dict became get_samples_df (since it retuns a datafram
 - set_parameter_dict no longer 'pops', resulting in an empty dict
  • Loading branch information
jameshensman committed Jul 9, 2016
1 parent 1388d9f commit 5ae3f60
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions GPflow/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ def get_parameter_dict(self, d):
d[self.long_name] = self.value

def set_parameter_dict(self, d):
self._array[...] = d.pop(self.long_name)
self._array[...] = d[self.long_name]

def get_samples_dict(self, samples):
def get_samples_df(self, samples):
"""
Given a numpy array where each row is a valid free-state vector, return
a dictionary which contains the parameter name and associated samples
a pandas.DataFrame which contains the parameter name and associated samples
in the correct form (e.g. with positive constraints applied).
"""
if self.fixed:
Expand All @@ -185,7 +185,7 @@ def get_samples_dict(self, samples):
samples = samples[:, start:end]
samples = samples.reshape((samples.shape[0],) + self.shape)
samples = self.transform.forward(samples)
return pd.Series([v for v in samples], name=self.long_name)
return pd.Series([v.squeeze() for v in samples], name=self.long_name)

def make_tf_array(self, free_array):
"""
Expand Down Expand Up @@ -524,15 +524,15 @@ def set_parameter_dict(self, d):
for p in self.sorted_params:
p.set_parameter_dict(d)

def get_samples_dict(self, samples):
def get_samples_df(self, samples):
"""
Given a numpy array where each row is a valid free-state vector, return
a dictionary which contains the parameter name and associated samples
a pandas.DataFrame which contains the parameter name and associated samples
in the correct form (e.g. with positive constraints applied).
"""
d = pd.DataFrame()
for p in self.sorted_params:
d = pd.concat([d, p.get_samples_dict(samples)], axis=1)
d = pd.concat([d, p.get_samples_df(samples)], axis=1)
return d

def __getattribute__(self, key):
Expand Down

0 comments on commit 5ae3f60

Please sign in to comment.