Skip to content

numpkg

Type part of a name or a dotted path

Small package with numpy-style docstrings.

Exists so the parser tests cover the numpy section syntax (underlined section titles, name : type parameter lines).

Classes

NameDescription
GridA rectangular grid of samples.

Functions

NameDescription
resampleScale a grid by a factor.

Gridclass#

class Grid(width: int, height: int)

A rectangular grid of samples.

Parameters

NameTypeDescription
widthintNumber of columns.
heightintNumber of rows.

Attributes

NameTypeDescription
widthintNumber of columns.
heightintNumber of rows.

heightattributeinstance attribute#

height = height

widthattributeinstance attribute#

width = width

areamethod#

def area() -> int

Compute the number of cells.

Returns

int
Width multiplied by height.

resamplefunction#

def resample(grid: Grid, factor: float = 2.0) -> Grid

Scale a grid by a factor.

Parameters

NameTypeDefaultDescription
gridGridrequiredThe grid to scale.
factorfloat2.0Multiplier applied to both dimensions, by default 2.0.

Returns

Grid
A new, scaled grid.

Raises

ValueError
If factor is not positive.

Examples

>>> resample(Grid(2, 3), 2.0).area()
24