Skip to content

Commit

Permalink
docstrings for zs, rc, ... setters
Browse files Browse the repository at this point in the history
  • Loading branch information
missing-user committed Dec 18, 2024
1 parent 4f4e214 commit 29bc558
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions src/simsopt/geo/surfacerzfourier.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,63 +551,87 @@ def _validate_mn(self, m, n):

@property
def rc_array(self):
"""
rc (np.ndarray): Array of cosine coefficients for the radial coordiante.
"""
return self.rc

@property
def zs_array(self):
"""
zs (np.ndarray): Array of sine coefficients for the Z coordiante.
"""
return self.zs

@property
def zc_array(self):
"""
zc (np.ndarray): Array of cosine coefficients for the Z coordiante.
"""
if self.stellsym:
raise ValueError(
'zc does not exist for this stellarator-symmetric surface.')
return self.zc

@property
def rs_array(self):
"""
rs (np.ndarray): Array of sine coefficients for the R coordiante.
"""
if self.stellsym:
raise ValueError(
'rs does not exist for this stellarator-symmetric surface.')
return self.rs

@rc_array.setter
def rc_array(self, rc):
"""
Setter to overwrite the entire rc array, triggering the recompute_bell.
To overwrite individual coefficients, use the set_rc method instead.
"""
print(self.rc.shape, rc.shape)
if rc.shape != (self.mpol + 1, self.ntor * 2 + 1):
raise ValueError('rc must have shape (mpol+1, 2*ntor+1)')
self.rc = rc
self.recompute_bell()
self.local_full_x = self.get_dofs()

@zs_array.setter
def zs_array(self, zs):
"""
Setter to overwrite the entire zs array, triggering the recompute_bell.
To overwrite individual coefficients, use the set_zs method instead.
"""
if zs.shape != (self.mpol + 1, self.ntor * 2 + 1):
raise ValueError('zs must have shape (mpol+1, 2*ntor+1)')
self.zs = zs
self.recompute_bell()
self.local_full_x = self.get_dofs()

@rs_array.setter
def rs_array(self, rs):
"""
Setter to overwrite the entire rs array, triggering the recompute_bell.
To overwrite individual coefficients, use the set_rs method instead.
"""
if rs.shape != (self.mpol + 1, self.ntor * 2 + 1):
raise ValueError('rs must have shape (mpol+1, 2*ntor+1)')
if self.stellsym:
raise ValueError(
'rs does not exist for this stellarator-symmetric surface.')
self.rs = rs
self.recompute_bell()
self.local_full_x = self.get_dofs()

@zc_array.setter
def zc_array(self, zc):
"""
Setter to overwrite the entire zc array, triggering the recompute_bell.
To overwrite individual coefficients, use the set_zc method instead.
"""
if zc.shape != (self.mpol + 1, self.ntor * 2 + 1):
raise ValueError('zc must have shape (mpol+1, 2*ntor+1)')
if self.stellsym:
raise ValueError(
'zc does not exist for this stellarator-symmetric surface.')
self.zc = zc
self.recompute_bell()
self.local_full_x = self.get_dofs()

def get_rc(self, m, n):
Expand Down Expand Up @@ -647,6 +671,7 @@ def get_zs(self, m, n):
def set_rc(self, m, n, val):
"""
Set a particular `rc` Parameter.
Modifyting the `rc` array directly is discouraged, since it doesn't trigger the recompute_bell().
"""
self._validate_mn(m, n)
self.rc[m, n + self.ntor] = val
Expand All @@ -655,6 +680,7 @@ def set_rc(self, m, n, val):
def set_rs(self, m, n, val):
"""
Set a particular `rs` Parameter.
Modifyting the `rs` array directly is discouraged, since it doesn't trigger the recompute_bell().
"""
if self.stellsym:
return ValueError(
Expand All @@ -666,6 +692,7 @@ def set_rs(self, m, n, val):
def set_zc(self, m, n, val):
"""
Set a particular `zc` Parameter.
Modifyting the `zc` array directly is discouraged, since it doesn't trigger the recompute_bell().
"""
if self.stellsym:
return ValueError(
Expand All @@ -677,6 +704,7 @@ def set_zc(self, m, n, val):
def set_zs(self, m, n, val):
"""
Set a particular `zs` Parameter.
Modifyting the `zs` array directly is discouraged, since it doesn't trigger the recompute_bell().
"""
self._validate_mn(m, n)
self.zs[m, n + self.ntor] = val
Expand Down

0 comments on commit 29bc558

Please sign in to comment.