Module hub.core.partial_sample

Expand source code
from typing import Tuple, Optional, Union
import numpy as np


class PartialSample:
    """Represents a sample that is initialized by just shape and the data is updated later."""

    def __init__(
        self,
        sample_shape: Tuple[int, ...],
        tile_shape: Optional[Tuple[int, ...]] = None,
        dtype: Union[str, np.dtype] = np.dtype("uint8"),
    ):
        self.sample_shape = sample_shape
        self.tile_shape = tile_shape
        self.dtype = dtype

    @property
    def shape(self):
        return self.sample_shape

    def astype(self, dtype: Union[str, np.dtype]):
        return self.__class__(self.sample_shape, self.tile_shape, dtype)

Classes

class PartialSample (sample_shape, tile_shape=None, dtype=dtype('uint8'))

Represents a sample that is initialized by just shape and the data is updated later.

Expand source code
class PartialSample:
    """Represents a sample that is initialized by just shape and the data is updated later."""

    def __init__(
        self,
        sample_shape: Tuple[int, ...],
        tile_shape: Optional[Tuple[int, ...]] = None,
        dtype: Union[str, np.dtype] = np.dtype("uint8"),
    ):
        self.sample_shape = sample_shape
        self.tile_shape = tile_shape
        self.dtype = dtype

    @property
    def shape(self):
        return self.sample_shape

    def astype(self, dtype: Union[str, np.dtype]):
        return self.__class__(self.sample_shape, self.tile_shape, dtype)

Instance variables

var shape
Expand source code
@property
def shape(self):
    return self.sample_shape

Methods

def astype(self, dtype)
Expand source code
def astype(self, dtype: Union[str, np.dtype]):
    return self.__class__(self.sample_shape, self.tile_shape, dtype)