Skip to content

Commit

Permalink
syntax fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisi committed Jun 23, 2021
1 parent a5bdbb2 commit 22bdca9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 35 deletions.
71 changes: 44 additions & 27 deletions examples/testing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,55 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 9,
"id": "fc2e1903-6b3a-46c5-a998-b971e3a98451",
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'gwtones'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-b3ad7db6056e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mgwtones\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'gwtones'"
]
}
],
"outputs": [],
"source": [
"import gwtones"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "53cf9041-135b-4660-95fb-9b742278854b",
"execution_count": 19,
"id": "50aa3305-03ba-4107-a4ff-c362f10b3862",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
"<module 'gwtones' from '/Users/maxisi/src/gwtones/gwtones/__init__.py'>"
]
},
"execution_count": 3,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"int(False)"
"from importlib import reload\n",
"reload(gwtones)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "d3e9e64a-83c7-4f64-b889-f31b1e0f9716",
"execution_count": 7,
"id": "53cf9041-135b-4660-95fb-9b742278854b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<module 'gwtones.data' from '/Users/maxisi/src/gwtones/gwtones/data.py'>"
"0"
]
},
"execution_count": 10,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from importlib import reload\n",
"reload(gwtones.data)"
"int(False)"
]
},
{
Expand Down Expand Up @@ -235,12 +223,41 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 21,
"id": "59435f45-79b5-448b-b297-7c20cb4e594a",
"metadata": {},
"outputs": [],
"source": [
"f2 = gwtones.data.Fit('ftau')"
"f2 = gwtones.Fit('kerr')"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "d7201ff8-ae92-4a62-832c-b239c2c99b67",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['A_max',\n",
" 'f_coeffs',\n",
" 'g_coeffs',\n",
" 'perturb_f',\n",
" 'perturb_tau',\n",
" 'df_max',\n",
" 'dtau_max',\n",
" 'chi_min',\n",
" 'chi_max']"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f2.valid_model_options"
]
},
{
Expand Down
3 changes: 1 addition & 2 deletions gwtones/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from pylab import *
from . import qnms
from . import data
from . import stats
from . import sampling
from . import fit

# ############################################################################
# rcParams
Expand Down
14 changes: 8 additions & 6 deletions gwtones/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ def _model_specific_defaults(self):
f_coeff, g_coeff = self.spectral_coefficients
default.update(dict(
f_coeffs=f_coeff,
f_coeffs=g_coeff,
g_coeffs=g_coeff,
perturb_f=zeros(self.nmodes or 1),
perturb_tau=zeros(self.nmodes or 1),
df_max=0.9,
dtau_max=0.9,
M_min=None,
M_max=None,
chi_min=0,
chi_max=0.99,
))
Expand All @@ -134,7 +136,7 @@ def update_prior(**kws):
self._model_input[k] = v
else:
raise ValueError('{} is not a valid model argument.'
'Valid options are: {}'.format(k, valid_keys)
'Valid options are: {}'.format(k, valid_keys))

@property
def model_input(self):
Expand Down Expand Up @@ -257,8 +259,8 @@ def set_target(self, t0, ra=None, dec=None, psi=None, delays=None,
# TODO: warn or fail if self.results is not None?
def update_target(self, **kws):
target = dict(**self.target)
target.update(dict(k=getattr(self,k) for k in
['duration', 'n_analyze', 'antenna_patterns']))
target.update({k: getattr(self,k) for k in
['duration', 'n_analyze', 'antenna_patterns']})
target.update(kws)
self.set_target(**target)

Expand All @@ -269,7 +271,7 @@ def duration(self):
return self._nanalyze*self.data[self.ifos[0]].delta_t
else:
print("Add data to compute duration (n_analyze = {})".format(
self._nanalyze)
self._nanalyze))
return None
else:
return self._duration
Expand All @@ -296,7 +298,7 @@ def n_analyze(self):
return int(round(self._duration/dt))
else:
print("Add data to compute n_analyze (duration = {})".format(
self._duration)
self._duration))
return None
elif self.data and self.has_target:
# set n_analyze to fit shortest data set
Expand Down

0 comments on commit 22bdca9

Please sign in to comment.