Skip to content

Releases: emmt/TypeUtils.jl

v1.5.1

12 Apr 09:33

Choose a tag to compare

TypeUtils v1.5.1

Diff since v1.5.0

Changed

  • Relax type restriction on T in convert_bare_type(T, x), convert_real_type(T, x), and convert_floating_point_type(T, x).

Fixed

  • Fix new_array(T) and new_array(T,()) yield a 0-dimensional array.

v1.5.0

14 Mar 12:00

Choose a tag to compare

TypeUtils v1.5.0

Diff since v1.4.2

  • Non-exported public constructor c = TypeUtils.Converter(f,T::Type) such that c is callable and c(x) yields f(T,x) for any x. This replaces and generalizes private type As.

  • Methods as(T), nearest(T), convert_bare_type(T), convert_real_type(T), convert_floating_point_type(T), and convert_eltype(T) yield converters to type T.

  • Inference works for more than 3 arguments for bare_type(args...), real_type(args...), and floating_point_type(args...).

v1.4.2

13 Feb 13:18

Choose a tag to compare

TypeUtils v1.4.2

Diff since v1.4.1

  • New nearest(T,x) method to return the value of type T that is the nearest to x. For T integer and x real, it can be seen as rounding with clamping.
  • Non-exported TypeUtils.@public macro is now public.

v1.4.1

10 Feb 09:34

Choose a tag to compare

TypeUtils v1.4.1

Diff since v1.4.0

User visible changes:

  • AbstractUnitRange{<:Integer} has been replaced by AbstractRange{<:Integer} as the eligible type for specifying an array axis. Methods as_array_axis, as_array_axes, and as_array_shape convert index ranges to AbstractUnitRange{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) for AbstractUnitRange{<:Integer} ranges.

  • The exported alias RelaxedArrayShape{N} reflects the above change. Exported alias ArrayShape{N} is restricted to integers and integer-valued unit-ranges which better correspond to Julia's way of representing an N-dimensional array shape.

  • New macro @public used 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 type X to have convert_eltype(T, x::X) work for instances x of that type.

  • TypeStableFunction(f, argtypes...) better tries to infer a suitable concrete type for f with arguments of types argtypes....

v1.4.0

25 Sep 08:22

Choose a tag to compare

TypeUtils v1.4.0

Diff since v1.3.0

  • Non-exported type TypeUtils.Unsupported may 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 type T and shape defined by inds.... The returned array is an OffsetArray{T} if inds... contains any index range other than Base.OneTo and an Array{T} otherwise. In the former case, an exception is thrown if the package OffsetArrays has not been loaded.

v1.3.0

24 Sep 13:43

Choose a tag to compare

TypeUtils v1.3.0

Diff since v1.2.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 representing N-dimensional array axes.

  • ArrayShape{N} is an alias to the N-tuple of array dimensions and/or index ranges to which as_array_shape, as_array_size, or as_array_axes are applicable.

  • as_array_shape converts its argument(s) to canonical array axes or to canonical array size.

  • as_array_axes converts its argument(s) to canonical array axes, that is a N-tuple of type ArrayAxes{N}. as_array_axis converts its argument to a single array axis of type ArrayAxis.

  • as_array_size converts its argument(s) to a canonical array size, that is a N-tuple of type Dims{N}. as_array_dim converts its argument to a single array dimension length of type eltype(Dims).

v1.2.0

24 Sep 08:46

Choose a tag to compare

TypeUtils v1.2.0

Diff since v1.1.0

  • to_same_type(x...) is a substitute to promote(x...) that warrants that returned instances have the same type and that calls as(T,x), not convert(T,x), if any conversion is needed.

  • to_same_concrete_type(T...) is a substitute to promote_type(T...) that throws an exception if types T... cannot be promoted to a common concrete type.

v1.1.0

08 Jun 10:25

Choose a tag to compare

TypeUtils v1.1.0

Diff since v1.0.0

  • convert_eltype can be applied to a number which makes sense since eltype is applicable to a number.

v1.0.0

15 May 08:34

Choose a tag to compare

TypeUtils v1.0.0

Diff since v0.3.8

All methods and types formerly provided by Unitless are now provided by TypeUtils which supersedes Unitless.

v0.3.8

23 Apr 19:40

Choose a tag to compare

TypeUtils v0.3.8

Diff since v0.3.7

TwoDimensional is no longer an extension because TwoDimensional version 0.5 directly extends convert as expected by TypeUtils.