Skip to content

Commit

Permalink
Removed deprecated from FitData.get_residuals(), flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
rapoliveira committed Jan 18, 2024
1 parent ee68f57 commit 902838a
Showing 1 changed file with 23 additions and 34 deletions.
57 changes: 23 additions & 34 deletions source/MulensModel/fitdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,8 @@ def scale_fluxes(self, source_flux, blend_flux):

return (flux, err_flux)

def get_residuals(
self, phot_fmt=None, source_flux=None, blend_flux=None, bad=False,
type=None):
def get_residuals(self, phot_fmt=None, source_flux=None, blend_flux=None,
bad=False):
"""
Calculate the residuals for each datapoint relative to the model.
Expand All @@ -492,9 +491,6 @@ def get_residuals(
magnification for each point to ensure that there are values
even for bad datapoints.
type:
DEPRECATED, see "phot_fmt" above.
Returns :
residuals: *np.ndarray*
the residuals for the corresponding dataset.
Expand All @@ -503,20 +499,13 @@ def get_residuals(
the scaled errorbars for each point. For plotting
errorbars for the residuals.
"""
if type is not None:
if type == 'mag':
warnings.warn(
'"mag" returns residuals in the original data flux' +
'system. To scale the residuals, use "scaled".')
warnings.warn(
'type keyword will be deprecated. Use "phot_fmt" instead.',
FutureWarning)
phot_fmt = type

if bad:
self._calculate_magnifications(bad=True)

if phot_fmt == 'mag':
warnings.warn(
'"mag" returns residuals in the original data flux system.' +
' To scale the residuals, use "scaled".')
residuals = self._dataset.mag - self.get_model_magnitudes()
errorbars = self._dataset.err_mag
elif phot_fmt == 'flux':
Expand Down Expand Up @@ -651,24 +640,24 @@ def get_d_A_d_params_for_point_lens_model(self, parameters):

return d_A_d_params

def get_d_A_d_rho(self):
"""
Calculate d A / d rho for a point lens model.
# def get_d_A_d_rho(self):
# """
# Calculate d A / d rho for a point lens model.

No Inputs
# No Inputs

Returns :
dA_drho: *np.array*
Values are the partial derivatives for rho
evaluated at each data point.
"""
# Need to consider what happens when we move to 2 sources.
if self._data_magnification_curve is None:
self._set_data_magnification_curves()
# Returns :
# dA_drho: *np.array*
# Values are the partial derivatives for rho
# evaluated at each data point.
# """
# # Need to consider what happens when we move to 2 sources.
# if self._data_magnification_curve is None:
# self._set_data_magnification_curves()

d_A_d_params = self._data_magnification_curve.get_d_A_d_rho()
# d_A_d_params = self._data_magnification_curve.get_d_A_d_rho()

return d_A_d_params
# return d_A_d_params

def get_dataset_trajectory(self):
"""
Expand Down Expand Up @@ -897,7 +886,7 @@ def gamma(self):
class FSPL_Derivatives(object):

def __init__(self, fit):
raise NotImplementedError(
'The FSPL_Derivatives class was deprecated in Version 3. ' +
'Its various functions were incorporated into the new ' +
'PointLens classes.')
raise NotImplementedError(
'The FSPL_Derivatives class was deprecated in Version 3. ' +
'Its various functions were incorporated into the new ' +
'PointLens classes.')

3 comments on commit 902838a

@rpoleski
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change in get_residuals() - I could have missed that it's not just removing parts of the code.

The second change I don't get - you're removing something that @jenniferyee added recently?

The last change is OK, but it inspired me to make a note: remove the code that was deprecated in v2, but not in v3.

@rapoliveira
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpoleski the method get_d_A_d_rho() is defined twice (lines 654 and 689). Flake8 was complaining and I commented one of them: which one should be removed then?

I can correct it today before going to the next deprecated cases.

@rpoleski
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug introduced by Jen in Version3_1 branch. Please leave the 2 functions as they were before. I've informed Jen that she should take care of that (link).

Please sign in to comment.