Releases: emmt/TypeUtils.jl
v2.0.0
Version 2.0.0 of TypeUtils (2026-06-12)
Breaking changes
- By default,
adapt_precisiononly converts non-integer numbers. The former behavior wasto convert all numbers which is not desirable as a general rule for integers (which include Booleans). The fixed behavior is that an integer or complex number with integer real and imaginary parts is left unchanged byadapt_precisionwhile a rational number is converted to floating-point. It is still possible to overcome this behavior for a custom type by specializingadapt_precision.
Changed
-
get_precisioncan work on any types and instances. -
Minimal Julia version is 1.0, this bound is imposed by the
InverseFunctionspackage.
Added
-
Function
adapt_multiplier_precision(α, x)to adapt the precision of a scalar numerical multiplierαto that of the other operandx(an array). -
is_unitless(x)returns whether numberx(a numeric value or type) is a unitless number. -
is_static_number(x)returns whether numberx(a numeric value or type) is a static number, i.e. a number whose value is known considering its type.
v1.14.0
TypeUtils v1.14.0
This new minor version essentially provides lazymap (see below).
Added
B = lazymap([T::Type,], f, A[, f_inv])yields an objectBthat lazily maps functionfto array or iteratorA. Optional argumentTis the element-type ofBwhich is automatically inferred if not specified. IfAis an (abstract) array,f_invmay be provided to specify the inverse off. Related type aliasLazyMap{T,N,F,typeof(A)}can be used to specialize on the typeBwithN = ndims(A)andF = typeof(f).
Change
-
The former function
as_eltype(T,A)is now a shortcut forlazymap(T,identity,A)unlessT == eltype(A)holds in which caseAis returned. -
Private type
TypeUtils.AsEltype(formerly used byas_eltytpe) no longer exists.
v1.13.0
TypeUtils v1.13.0
Added
units_of(x)andunits_of(typeof(x))yield the units of the numberx. The units are a trait which only depends on the type of the argument. This function is a replacement forUnitful.unitwhen this package is not yet loaded.
Merged pull requests:
- Bump actions/checkout from 5 to 6 (#4) (@dependabot[bot])
v1.12.0
TypeUtils v1.12.0
Fixed
get_precisionon n-tuples yields a correct result and is inferable.
Added
get_precision()yieldsAbtractFloatinstead of throwing aMethodError.
v1.11.0
TypeUtils v1.11.0
Fixed
-
Fix tests for Julia 1.12 and above.
-
Syntax
@public a, b, cis allowed.
Merged pull requests:
- Bump actions/checkout from 4 to 5 (#3) (@dependabot[bot])
v1.10.0
TypeUtils v1.10.0
Added
-
With multiple arguments,
get_precision(x, y...)yields the best precision of all the given arguments. -
nearest(T, x)can deal with dimensionful numbers and types.
v1.9.0
TypeUtils v1.9.0
This new minor version adds methods to deal with the numerical precision of numbers and objects.
Added
-
get_precision(x)yields the numerical precision ofx. -
adapt_precision(T, x)yields a version ofxwith numerical precisionT. -
destructure(Vector, x)anddestructure(Vector{T}, x)yield a vector whiledestructure(Tuple, x)yields a tuple asdestructure(x).
v1.8.0
TypeUtils v1.8.0
Added
-
convert_eltype(T,A)forAan instance ofLinearAgebra.Factorization. -
Tests with
Aqua.jl.
Fixed
-
A few minor things detected by
Aqua.jlhave been fixed. -
Better rule for element type conversion of
AbstractUnitRangeinstances. -
Fix specialization of
Base.return_typeswhich shall return a vector of types.
v1.7.1
TypeUtils v1.7.1
Fixed
is_signed(x)is false ifxis a complex number with unsigned rational parts.
v1.7.0
TypeUtils v1.7.0
- New
is_signedmethod to infer whether a value of a given numeric type can be negated while retaining the same type. - Extend
similarfor the type of arrays returned byas_eltype.