Skip to content

Commit

Permalink
Make from_spec class methods and serialize focus for Gridgen's to_spe…
Browse files Browse the repository at this point in the history
…c and from_spec
  • Loading branch information
ricaenriquez committed Nov 13, 2018
1 parent 64254fc commit 9ad8400
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pygridgen/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,9 @@ def to_spec(self):
output_spec.append(focuspoint.to_dict())
return output_spec

def from_spec(foci):
f = Focus()
@classmethod
def from_spec(cls, foci):
f = cls()
for focuspoint in foci:
f.add_focus(**focuspoint)
return f
Expand Down Expand Up @@ -985,16 +986,16 @@ def generate_grid(self):
super(Gridgen, self).__init__(x, y)

def to_spec(self):
focus = Focus.from_spec(self.focus.to_spec())
output_dict = {'xbry': self.xbry, 'ybry': self.ybry,
'beta': self.beta, 'shape': self.shape,
'focus': self.focus}
'focus': focus}

return output_dict

def from_spec(attributes):
# print(attributes)
g = Gridgen(**attributes)
return g
@classmethod
def from_spec(cls, attributes):
return cls(**attributes)


def rho_to_vert(xr, yr, pm, pn, ang): # pragma: no cover
Expand Down

0 comments on commit 9ad8400

Please sign in to comment.