graviti.paging.page#

Page related class.

Module Contents#

Classes#

PageBase

PageBase is the base class of array wrapper and represents a page in paging list.

Page

Page is an array wrapper and represents a page in paging list.

SlicedPage

SlicedPage is an array wrapper and represents a sliced page in paging list.

LazyPage

LazyPage is a placeholder when the paging list page is not loaded yet.

LazySlicedPage

LazySlicedPage is a placeholder when the sliced paging list page is not loaded yet.

MappedPageBase

MappedPageBase is the base class of the page with mapper, is used for nested DataFrame.

MappedPage

MappedPage is an array wrapper and represents a page in paging list.

MappedSlicedPage

MappedSlicedPage is an array wrapper and represents a sliced page in paging list.

MappedLazyPage

LazyPage with a mapper for converting every item in the source array.

MappedLazySlicedPage

LazySlicedPage with a mapper for converting every item in the source array.

class graviti.paging.page.PageBase[source]#

Bases: Sequence[_T]

PageBase is the base class of array wrapper and represents a page in paging list.

get_item(self, index)[source]#

Return the item at the given index.

Parameters

index (int) – Position of the mutable sequence.

Returns

The item at the given index.

Return type

_T

abstract get_slice(self, start=None, stop=None, step=None)[source]#

Return a sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Raises

NotImplementedError – The method of the base class should not be called.

Return type

PageBase[_T]

abstract get_array(self)[source]#

Get the array inside the page.

Raises

NotImplementedError – The method of the base class should not be called.

Return type

Sequence[_T]

class graviti.paging.page.Page(array)[source]#

Bases: PageBase[_T]

Page is an array wrapper and represents a page in paging list.

Parameters

array (Sequence[_T]) – The internal sequence of page.

get_slice(self, start=None, stop=None, step=None)[source]#

Return a sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

SlicedPage[_T]

get_array(self)[source]#

Get the array inside the page.

Returns

The array inside the page.

Return type

Sequence[_T]

class graviti.paging.page.SlicedPage(ranging, source_array)[source]#

Bases: PageBase[_T]

SlicedPage is an array wrapper and represents a sliced page in paging list.

Parameters
  • ranging (range) – The range instance of this page.

  • array – The internal sequence of page.

  • source_array (Sequence[_T]) –

get_slice(self, start=None, stop=None, step=None)[source]#

Return a sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

SlicedPage[_T]

get_array(self)[source]#

Get the array inside the page.

Returns

The array inside the page.

Return type

Sequence[_T]

class graviti.paging.page.LazyPage(length, array_getter)[source]#

Bases: PageBase[_T]

LazyPage is a placeholder when the paging list page is not loaded yet.

Parameters
  • length (int) – The length of this page.

  • array_getter (Callable[[], Sequence[_T]]) – A callable object to get the source array.

get_slice(self, start=None, stop=None, step=None)[source]#

Return a lazy sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

LazySlicedPage[_T]

get_array(self)[source]#

Get the array inside the page.

Returns

The array inside the page.

Return type

Sequence[_T]

class graviti.paging.page.LazySlicedPage(ranging, array_getter)[source]#

Bases: PageBase[_T]

LazySlicedPage is a placeholder when the sliced paging list page is not loaded yet.

Parameters
  • ranging (range) – The range instance of this page.

  • array_getter (Callable[[], Sequence[_T]]) – A callable object to get the source array.

get_slice(self, start=None, stop=None, step=None)[source]#

Return a lazy sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

LazySlicedPage[_T]

get_array(self)[source]#

Get the array inside the page.

Returns

The array inside the page.

Return type

Sequence[_T]

class graviti.paging.page.MappedPageBase[source]#

Bases: PageBase[_T]

MappedPageBase is the base class of the page with mapper, is used for nested DataFrame.

abstract copy(self, copier, mapper)[source]#

Return a copy of the mapped page.

Parameters
  • copier (Callable[[Any], Any]) – A callable object to convert loaded items in the source page to the copied page.

  • mapper (Callable[[Any], Any]) – The mapper of the new mapped page.

Raises

NotImplementedError – The method of the base class should not be called.

Return type

MappedPageBase[_T]

class graviti.paging.page.MappedPage(array)[source]#

Bases: MappedPageBase[_T], Page[_T]

MappedPage is an array wrapper and represents a page in paging list.

Parameters

array (Sequence[_T]) –

get_slice(self, start=None, stop=None, step=None)[source]#

Return a sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

MappedSlicedPage[_T]

copy(self, copier, mapper)[source]#

Return a copy of the mapped page.

Parameters
  • copier (Callable[[_T], _T]) – A callable object to convert loaded items in the source page to the copied page.

  • mapper (Callable[[Any], Any]) – The mapper of the new mapped page.

Returns

A copy of the mapped page.

Return type

MappedPage[_T]

class graviti.paging.page.MappedSlicedPage(ranging, source_array)[source]#

Bases: MappedPageBase[_T], SlicedPage[_T]

MappedSlicedPage is an array wrapper and represents a sliced page in paging list.

Parameters
  • ranging (range) –

  • source_array (Sequence[_T]) –

get_slice(self, start=None, stop=None, step=None)[source]#

Return a sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

MappedSlicedPage[_T]

copy(self, copier, mapper)[source]#

Return a copy of the mapped page.

Parameters
  • copier (Callable[[Any], Any]) – A callable object to convert loaded items in the source page to the copied page.

  • mapper (Callable[[Any], Any]) – The mapper of the new mapped page.

Returns

A copy of the mapped page.

Return type

MappedPage[_T]

class graviti.paging.page.MappedLazyPage(length, array_getter, mapper)[source]#

Bases: MappedPageBase[_T]

LazyPage with a mapper for converting every item in the source array.

Parameters
  • length (int) – The length of this page.

  • array_getter (Callable[[], Sequence[_T]]) – A callable object to get the source array.

  • mapper (Callable[[Any], Any]) – A callable object to convert every item in the source array.

get_slice(self, start=None, stop=None, step=None)[source]#

Return a lazy sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

Union[MappedLazySlicedPage[_T], MappedSlicedPage[_T]]

get_array(self)[source]#

Get the array inside the page.

Returns

The array inside the page.

Return type

Sequence[_T]

copy(self, copier, mapper)[source]#

Return a copy of the mapped page.

Parameters
  • copier (Callable[[Any], Any]) – A callable object to convert loaded items in the source page to the copied page.

  • mapper (Callable[[Any], Any]) – The mapper of the new mapped page.

Returns

A copy of the mapped page.

Return type

Union[MappedPage[_T], MappedLazyPage[_T]]

class graviti.paging.page.MappedLazySlicedPage(ranging, array_getter, mapper)[source]#

Bases: MappedPageBase[_T]

LazySlicedPage with a mapper for converting every item in the source array.

Parameters
  • ranging (range) – The range instance of this page.

  • array_getter (Callable[[], Sequence[_T]]) – A callable object to get the source array.

  • mapper (Callable[[Any], Any]) – A callable object to convert every item in the source array.

get_slice(self, start=None, stop=None, step=None)[source]#

Return a lazy sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

Union[MappedLazySlicedPage[_T], MappedSlicedPage[_T]]

get_array(self)[source]#

Get the array inside the page.

Returns

The array inside the page.

Return type

Sequence[_T]

copy(self, copier, mapper)[source]#

Return a copy of the mapped page.

Parameters
  • copier (Callable[[Any], Any]) – A callable object to convert loaded items in the source page to the copied page.

  • mapper (Callable[[Any], Any]) – The mapper of the new mapped page.

Returns

A copy of the mapped page.

Return type

Union[MappedPage[_T], MappedLazySlicedPage[_T]]