Skip to content

Commit

Permalink
improved warnings, MulensData._get_name() added
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoleski committed Jun 16, 2023
1 parent 7bcac6c commit 84c5ea1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions source/MulensModel/mulensdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ def __init__(self, data_list=None, file_name=None,
self._ephemerides_file = ephemerides_file

def __repr__(self):
if 'label' in self.plot_properties:
name = self.plot_properties['label']
else:
name = self._file_name
name = self._get_name()

out = "{:25} n_epochs ={:>5}, n_bad ={:>5}".format(
name+":", self.n_epochs, np.sum(self.bad))
Expand All @@ -185,6 +182,15 @@ def __repr__(self):

return out

def _get_name(self):
"""extract the name of dataset"""
if 'label' in self.plot_properties:
name = self.plot_properties['label']
else:
name = self._file_name

return name

def _import_photometry(self, data_list, **kwargs):
"""import time, brightness, and its uncertainty"""
# Import the photometry...
Expand Down Expand Up @@ -444,14 +450,16 @@ def _plot_datapoints(

if show_errorbars:
if np.any(y_err[self.good] < 0.):
warnings.warn("Cannot plot errorbars with negative values.")
warnings.warn("Cannot plot errorbars with negative values. "
"Skipping dataset: " + self._get_name())
return
container = self._plt_errorbar(time_good, y_good,
y_err[self.good], properties)
if show_bad:
if np.any(y_err[self.bad] < 0.):
warnings.warn("Cannot plot errorbars with negative "
"values (bad data).")
warnings.warn(
"Cannot plot errorbars with negative values (bad "
"data). Skipping dataset: " + self._get_name())
return
if not ('color' in properties_bad or 'c' in properties_bad):
properties_bad['color'] = container[0].get_color()
Expand Down
2 changes: 1 addition & 1 deletion source/MulensModel/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.16.5"
__version__ = "2.16.6"

0 comments on commit 84c5ea1

Please sign in to comment.