diff --git a/examples/example_16/ulens_model_fit.py b/examples/example_16/ulens_model_fit.py index c409787d..f45fb353 100644 --- a/examples/example_16/ulens_model_fit.py +++ b/examples/example_16/ulens_model_fit.py @@ -38,7 +38,7 @@ except Exception: raise ImportError('\nYou have to install MulensModel first!\n') -__version__ = '0.34.0' +__version__ = '0.34.1' class UlensModelFit(object): @@ -3131,10 +3131,7 @@ def _second_Y_axis_get_fluxes(self, ylim): flux_max = mm.Utils.get_flux_from_mag(ylim[1]) (source_flux, blend_flux) = self._event.get_ref_fluxes() - if self._model.n_sources == 1: - total_source_flux = source_flux - else: - total_source_flux = sum(source_flux) + total_source_flux = sum(source_flux) A_min = (flux_min - blend_flux) / total_source_flux A_max = (flux_max - blend_flux) / total_source_flux @@ -3146,11 +3143,11 @@ def _second_Y_axis_optimal(self, ax2, A_min, A_max): """ ax2.set_ylim(A_min, A_max) A_values = ax2.yaxis.get_ticklocs().round(7) - A_values = A_values[(A_values >= 1.) & (A_values < A_max)] + A_values = A_values[(A_values >= max(1, A_min)) & (A_values < A_max)] is_integer = [mag.is_integer() for mag in A_values] if all(is_integer): labels = [f"{int(x):d}" for x in A_values] - return (A_values.tolist(), labels, False) + return (A_values, labels, False) fnum = np.array([str(x)[::-1].find(".") for x in A_values]) labels = np.array([f"%0.{max(fnum)}f" % x for x in A_values]) @@ -3158,11 +3155,11 @@ def _second_Y_axis_optimal(self, ax2, A_min, A_max): msg = ("The computed magnifications for the second Y scale cover" " a range too small to be shown: {:}") warnings.warn(msg.format(A_values)) - return (A_values.tolist(), labels.tolist(), True) + return (A_values, labels.tolist(), True) if max(fnum) >= 4: labels = np.array([f"{x:0.3f}" for x in A_values]) - return (A_values[fnum < 4].tolist(), labels[fnum < 4].tolist(), False) + return (A_values[fnum < 4], labels[fnum < 4].tolist(), False) def _second_Y_axis_warnings(self, flux, labels, A_values, A_min, A_max): """ @@ -3183,7 +3180,7 @@ def _second_Y_axis_warnings(self, flux, labels, A_values, A_min, A_max): "side) Y-axis scale are from {:} to {:},\nbut the range " "of plotted magnifications is from {:} to {:}, hence, " "the second scale is not plotted") - args = [min(A_values), max(A_values), A_min[0], A_max[0]] + args = [np.min(A_values), np.max(A_values), A_min[0], A_max[0]] warnings.warn(msg.format(*args)) return True