Skip to content

Commit

Permalink
Merge pull request #16173 from eerovaher/rm-make-getter
Browse files Browse the repository at this point in the history
Remove `astropy.coordinates.representation.base._make_getter()`
  • Loading branch information
mhvk committed Mar 7, 2024
2 parents b293ac5 + 629fe45 commit 52d2b36
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions astropy/coordinates/representation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,25 +517,6 @@ def __repr__(self):
)


def _make_getter(component):
"""Make an attribute getter for use in a property.
Parameters
----------
component : str
The name of the component that should be accessed. This assumes the
actual value is stored in an attribute of that name prefixed by '_'.
"""
# This has to be done in a function to ensure the reference to component
# is not lost/redirected.
component = "_" + component

def get_component(self):
return getattr(self, component)

return get_component


class RepresentationInfo(BaseRepresentationOrDifferentialInfo):
@property
def _represent_as_dict_attrs(self):
Expand Down Expand Up @@ -650,7 +631,7 @@ def __init_subclass__(cls, **kwargs):
cls,
component,
property(
_make_getter(component),
lambda self, comp=f"_{component}": getattr(self, comp),
doc=f"The '{component}' component of the points(s).",
),
)
Expand Down Expand Up @@ -1301,7 +1282,7 @@ def __init_subclass__(cls, **kwargs):
cls,
component,
property(
_make_getter(component),
lambda self, comp=f"_{component}": getattr(self, comp),
doc=f"Component '{component}' of the Differential.",
),
)
Expand Down

0 comments on commit 52d2b36

Please sign in to comment.