# Licensed to Modin Development Team under one or more contributor license agreements.
# See the NOTICE file distributed with this work for additional information regarding
# copyright ownership.  The Modin Development Team licenses this file to you under the
# Apache License, Version 2.0 (the "License"); you may not use this file except in
# compliance with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.

from modin.engines.base.frame.partition_manager import BaseFrameManager
from .axis_partition import (
    PandasOnPythonFrameColumnPartition,
    PandasOnPythonFrameRowPartition,
)
from .partition import PandasOnPythonFramePartition


class PythonFrameManager(BaseFrameManager):
    """This method implements the interface in `BaseFrameManager`."""

    # This object uses RayRemotePartition objects as the underlying store.
    _partition_class = PandasOnPythonFramePartition
    _column_partitions_class = PandasOnPythonFrameColumnPartition
    _row_partition_class = PandasOnPythonFrameRowPartition

    def __init__(self, partitions):
        self.partitions = partitions

    # We override these for performance reasons.
    # Lengths of the blocks
    _lengths_cache = None
    # Widths of the blocks
    _widths_cache = None

    # These are set up as properties so that we only use them when we need
    # them. We also do not want to trigger this computation on object creation.
    @property
    def block_lengths(self):
        """Gets the lengths of the blocks.

        Note: This works with the property structure `_lengths_cache` to avoid
            having to recompute these values each time they are needed.
        """
        if self._lengths_cache is None:
            # The first column will have the correct lengths. We have an
            # invariant that requires that all blocks be the same length in a
            # row of blocks.
            self._lengths_cache = (
                [obj.length() for obj in self._partitions_cache.T[0]]
                if len(self._partitions_cache.T) > 0
                else []
            )
        return self._lengths_cache

    @property
    def block_widths(self):
        """Gets the widths of the blocks.

        Note: This works with the property structure `_widths_cache` to avoid
            having to recompute these values each time they are needed.
        """
        if self._widths_cache is None:
            # The first column will have the correct lengths. We have an
            # invariant that requires that all blocks be the same width in a
            # column of blocks.
            self._widths_cache = (
                [obj.width() for obj in self._partitions_cache[0]]
                if len(self._partitions_cache) > 0
                else []
            )
        return self._widths_cache

@@ -1382,1786 +1382,4 @@
 ion%0A
-%0A    def __init__(self, partitions):%0A        self.partitions = partitions%0A%0A    # We override these for performance reasons.%0A    # Lengths of the blocks%0A    _lengths_cache = None%0A    # Widths of the blocks%0A    _widths_cache = None%0A%0A    # These are set up as properties so that we only use them when we need%0A    # them. We also do not want to trigger this computation on object creation.%0A    @property%0A    def block_lengths(self):%0A        %22%22%22Gets the lengths of the blocks.%0A%0A        Note: This works with the property structure %60_lengths_cache%60 to avoid%0A            having to recompute these values each time they are needed.%0A        %22%22%22%0A        if self._lengths_cache is None:%0A            # The first column will have the correct lengths. We have an%0A            # invariant that requires that all blocks be the same length in a%0A            # row of blocks.%0A            self._lengths_cache = (%0A                %5Bobj.length() for obj in self._partitions_cache.T%5B0%5D%5D%0A                if len(self._partitions_cache.T) %3E 0%0A                else %5B%5D%0A            )%0A        return self._lengths_cache%0A%0A    @property%0A    def block_widths(self):%0A        %22%22%22Gets the widths of the blocks.%0A%0A        Note: This works with the property structure %60_widths_cache%60 to avoid%0A            having to recompute these values each time they are needed.%0A        %22%22%22%0A        if self._widths_cache is None:%0A            # The first column will have the correct lengths. We have an%0A            # invariant that requires that all blocks be the same width in a%0A            # column of blocks.%0A            self._widths_cache = (%0A                %5Bobj.width() for obj in self._partitions_cache%5B0%5D%5D%0A                if len(self._partitions_cache) %3E 0%0A                else %5B%5D%0A            )%0A        return self._widths_cache%0A

Remove dead code from `PythonFrameManager`