Releases: emmt/TypeUtils.jl
v1.5.1
TypeUtils v1.5.1
Changed
- Relax type restriction on
Tinconvert_bare_type(T, x),convert_real_type(T, x), andconvert_floating_point_type(T, x).
Fixed
- Fix
new_array(T)andnew_array(T,())yield a 0-dimensional array.
v1.5.0
TypeUtils v1.5.0
-
Non-exported public constructor
c = TypeUtils.Converter(f,T::Type)such thatcis callable andc(x)yieldsf(T,x)for anyx. This replaces and generalizes private typeAs. -
Methods
as(T),nearest(T),convert_bare_type(T),convert_real_type(T),convert_floating_point_type(T), andconvert_eltype(T)yield converters to typeT. -
Inference works for more than 3 arguments for
bare_type(args...),real_type(args...), andfloating_point_type(args...).
v1.4.2
TypeUtils v1.4.2
- New
nearest(T,x)method to return the value of typeTthat is the nearest tox. ForTinteger andxreal, it can be seen as rounding with clamping. - Non-exported
TypeUtils.@publicmacro is now public.
v1.4.1
TypeUtils v1.4.1
User visible changes:
-
AbstractUnitRange{<:Integer}has been replaced byAbstractRange{<:Integer}as the eligible type for specifying an array axis. Methodsas_array_axis,as_array_axes, andas_array_shapeconvert index ranges toAbstractUnitRange{Int}throwing an exception if any range does not have unit step. The downside is that this must be explicitly checked for non-AbstractUnitRange{<:Integer}ranges while it can be inferred by type (it is a trait) forAbstractUnitRange{<:Integer}ranges. -
The exported alias
RelaxedArrayShape{N}reflects the above change. Exported aliasArrayShape{N}is restricted to integers and integer-valued unit-ranges which better correspond to Julia's way of representing anN-dimensional array shape. -
New macro
@publicused to declare non-exported public symbols. Does nothing for Julia versions older than 1.11. -
For other packages, it may be sufficient to extend
convert_eltype(T, X)to a given typeXto haveconvert_eltype(T, x::X)work for instancesxof that type. -
TypeStableFunction(f, argtypes...)better tries to infer a suitable concrete type forfwith arguments of typesargtypes....
v1.4.0
TypeUtils v1.4.0
-
Non-exported type
TypeUtils.Unsupportedmay be used to provide a fallback implementation of a method for given types of arguments that is only supported when some extension is loaded. -
new_array(T, inds...)creates an array with elements of typeTand shape defined byinds.... The returned array is anOffsetArray{T}ifinds...contains any index range other thanBase.OneToand anArray{T}otherwise. In the former case, an exception is thrown if the packageOffsetArrayshas not been loaded.
v1.3.0
TypeUtils v1.3.0
Add a few types and methods related to array size and axes:
-
ArrayAxis = AbstractUnitRange{eltype(Dims)}is an alias to the possible canonical types representing a single array index range. -
ArrayAxes{N} = NTuple{N,ArrayAxis}is an alias to the possible canonical types representingN-dimensional array axes. -
ArrayShape{N}is an alias to theN-tuple of array dimensions and/or index ranges to whichas_array_shape,as_array_size, oras_array_axesare applicable. -
as_array_shapeconverts its argument(s) to canonical array axes or to canonical array size. -
as_array_axesconverts its argument(s) to canonical array axes, that is aN-tuple of typeArrayAxes{N}.as_array_axisconverts its argument to a single array axis of typeArrayAxis. -
as_array_sizeconverts its argument(s) to a canonical array size, that is aN-tuple of typeDims{N}.as_array_dimconverts its argument to a single array dimension length of typeeltype(Dims).
v1.2.0
TypeUtils v1.2.0
-
to_same_type(x...)is a substitute topromote(x...)that warrants that returned instances have the same type and that callsas(T,x), notconvert(T,x), if any conversion is needed. -
to_same_concrete_type(T...)is a substitute topromote_type(T...)that throws an exception if typesT...cannot be promoted to a common concrete type.
v1.1.0
TypeUtils v1.1.0
convert_eltypecan be applied to a number which makes sense sinceeltypeis applicable to a number.
v1.0.0
TypeUtils v1.0.0
All methods and types formerly provided by Unitless are now provided by TypeUtils which supersedes Unitless.
v0.3.8
TypeUtils v0.3.8
TwoDimensional is no longer an extension because TwoDimensional version 0.5 directly extends convert as expected by TypeUtils.