class kanon.tables.hcolumn.HColumn(data=None, name=None, dtype=None, shape=(), length=0, description=None, unit=None, format=None, meta=None, copy=False, copy_indices=True, basedtype: TTypeBasedReal | None = None)[source] [edit on github]

Bases: Column, Truncable, Generic[TTypeBasedReal]

Column subclass with better support of BasedReal values.

Attributes Summary



ColumnInfo with basedtype


If this column contains BasedReal values, return the minimum significant of all values.

Methods Summary

astype(dtype[, order, casting, subok, copy])

Copy of the array, cast to a specified type.



resize(new_shape[, refcheck])

Change shape and size of array in-place.


Attributes Documentation


ColumnInfo with basedtype


If this column contains BasedReal values, return the minimum significant of all values. Else returns None

Methods Documentation

astype(dtype, order='K', casting='unsafe', subok=True, copy=True)[source] [edit on github]

Copy of the array, cast to a specified type.

dtypestr or dtype

Typecode or data-type to which the array is cast.

order{‘C’, ‘F’, ‘A’, ‘K’}, optional

Controls the memory layout order of the result. ‘C’ means C order, ‘F’ means Fortran order, ‘A’ means ‘F’ order if all the arrays are Fortran contiguous, ‘C’ order otherwise, and ‘K’ means as close to the order the array elements appear in memory as possible. Default is ‘K’.

casting{‘no’, ‘equiv’, ‘safe’, ‘same_kind’, ‘unsafe’}, optional

Controls what kind of data casting may occur. Defaults to ‘unsafe’ for backwards compatibility.

  • ‘no’ means the data types should not be cast at all.

  • ‘equiv’ means only byte-order changes are allowed.

  • ‘safe’ means only casts which can preserve values are allowed.

  • ‘same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed.

  • ‘unsafe’ means any data conversions may be done.

subokbool, optional

If True, then sub-classes will be passed-through (default), otherwise the returned array will be forced to be a base-class array.

copybool, optional

By default, astype always returns a newly allocated array. If this is set to false, and the dtype, order, and subok requirements are satisfied, the input array is returned instead of a copy.


Unless copy is False and the other conditions for returning the input array are satisfied (see description for copy input parameter), arr_t is a new array of the same shape as the input array, with dtype, order given by dtype, order.


When casting from complex to float or int. To avoid this, one should use a.real.astype(t).


Changed in version 1.17.0: Casting between a simple data type and a structured one is possible only for “unsafe” casting. Casting to multiple fields is allowed, but casting from multiple fields is not.

Changed in version 1.9.0: Casting from numeric to string types in ‘safe’ casting mode requires that the string dtype length is long enough to store the max integer/float value converted.


>>> x = np.array([1, 2, 2.5])
>>> x
array([1. ,  2. ,  2.5])
>>> x.astype(int)
array([1, 2, 2])
ceil(significant: int | None = None) HColumn[TTypeBasedReal][source] [edit on github]
floor(significant: int | None = None) HColumn[TTypeBasedReal][source] [edit on github]
resize(new_shape, refcheck=True)[source] [edit on github]

Change shape and size of array in-place.

new_shapetuple of ints, or n ints

Shape of resized array.

refcheckbool, optional

If False, reference count will not be checked. Default is True.


If a does not own its own data or references or views to it exist, and the data memory must be changed. PyPy only: will always raise if the data memory must be changed, since there is no reliable way to determine if references or views to it exist.


If the order keyword argument is specified. This behaviour is a bug in NumPy.

See also


Return a new array with the specified shape.


This reallocates space for the data area if necessary.

Only contiguous arrays (data elements consecutive in memory) can be resized.

The purpose of the reference count check is to make sure you do not use this array as a buffer for another Python object and then reallocate the memory. However, reference counts can increase in other ways so if you are sure that you have not shared the memory for this array with another Python object, then you may safely set refcheck to False.


Shrinking an array: array is flattened (in the order that the data are stored in memory), resized, and reshaped:

>>> a = np.array([[0, 1], [2, 3]], order='C')
>>> a.resize((2, 1))
>>> a
>>> a = np.array([[0, 1], [2, 3]], order='F')
>>> a.resize((2, 1))
>>> a

Enlarging an array: as above, but missing entries are filled with zeros:

>>> b = np.array([[0, 1], [2, 3]])
>>> b.resize(2, 3) # new_shape parameter doesn't have to be a tuple
>>> b
array([[0, 1, 2],
       [3, 0, 0]])

Referencing an array prevents resizing…

>>> c = a
>>> a.resize((1, 1))
Traceback (most recent call last):
ValueError: cannot resize an array that references or is referenced ...

Unless refcheck is False:

>>> a.resize((1, 1), refcheck=False)
>>> a
>>> c
truncate(significant: int | None = None) HColumn[TTypeBasedReal][source] [edit on github]