Skip to content

Commit

Permalink
CLN: Remove name mangling from AxesArray _ax_map
Browse files Browse the repository at this point in the history
I added it before I knew what name mangling was for
  • Loading branch information
Jacob-Stevens-Haas committed Jan 4, 2024
1 parent c101a5a commit 4ac044f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pysindy/utils/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,16 @@ def __new__(cls, input_array, axes):
if axes is None:
axes = {}
in_ndim = len(input_array.shape)
obj.__ax_map = _AxisMapping(axes, in_ndim)
obj._ax_map = _AxisMapping(axes, in_ndim)
return obj

@property
def axes(self):
return self.__ax_map.compat_axes
return self._ax_map.compat_axes

@property
def _reverse_map(self):
return self.__ax_map.reverse_map
return self._ax_map.reverse_map

@property
def shape(self):
Expand All @@ -183,7 +183,7 @@ def __getattr__(self, name):
if parts[0] == "ax":
return self.axes[name]
if parts[0] == "n":
fwd_map = self.__ax_map.fwd_map
fwd_map = self._ax_map.fwd_map
shape = tuple(self.shape[ax_id] for ax_id in fwd_map["ax_" + parts[1]])
if len(shape) == 1:
return shape[0]
Expand Down Expand Up @@ -296,13 +296,13 @@ def __getitem__(self, key: Indexer | Sequence[Indexer], /):
pass
# mulligan structured arrays, etc.
new_map = _AxisMapping(
self.__ax_map.remove_axis(remove_axes), len(in_dim) - len(remove_axes)
self._ax_map.remove_axis(remove_axes), len(in_dim) - len(remove_axes)
)
new_map = _AxisMapping(
new_map.insert_axis(new_axes),
len(in_dim) - len(remove_axes) + len(new_axes),
)
output.__ax_map = new_map
output._ax_map = new_map
return output

def __array_wrap__(self, out_arr, context=None):
Expand All @@ -319,7 +319,7 @@ def __array_finalize__(self, obj) -> None:
not hasattr(self, "__ax_map"),
)
):
self.__ax_map = _AxisMapping({})
self._ax_map = _AxisMapping({})
# required by ravel() and view() used in numpy testing. Also for zeros_like...
elif all(
(
Expand All @@ -328,7 +328,7 @@ def __array_finalize__(self, obj) -> None:
self.shape == obj.shape,
)
):
self.__ax_map = _AxisMapping(obj.axes, len(obj.shape))
self._ax_map = _AxisMapping(obj.axes, len(obj.shape))
# maybe add errors for incompatible views?

def __array_ufunc__(
Expand Down Expand Up @@ -364,7 +364,7 @@ def __array_ufunc__(
):
axes = None
if kwargs["axis"] is not None:
axes = self.__ax_map.remove_axis(axis=kwargs["axis"])
axes = self._ax_map.remove_axis(axis=kwargs["axis"])
else:
axes = self.axes
final_results = []
Expand Down

0 comments on commit 4ac044f

Please sign in to comment.