Skip to content

Commit 039b19f

Browse files
committed
Bump version to 2.0.0
1 parent 6c0a856 commit 039b19f

4 files changed

Lines changed: 15 additions & 13 deletions

File tree

‎NEWS.md‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ This page describes the most important changes in `TypeUtils`. The format is bas
44
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
55
[Semantic Versioning](https://semver.org).
66

7-
## Unreleased
7+
## Version 2.0.0 (2026-06-12)
88

99
### Breaking changes
1010

11-
- ``adapt_precision` converts all non-integer numbers. The new behavior is that an integer
12-
or complex number with integer real and imaginary parts is left unchanged while a rational
13-
number is converted to floating-point. It is still possible to overcome this behavior for
14-
a custom type by specializing these methods.
11+
- By default, `adapt_precision` only converts non-integer numbers. The former behavior was
12+
to convert all numbers which is not desirable as a general rule for integers (which
13+
include Booleans). The fixed behavior is that an integer or complex number with integer
14+
real and imaginary parts is left unchanged by `adapt_precision` while a rational number is
15+
converted to floating-point. It is still possible to overcome this behavior for a custom
16+
type by specializing `adapt_precision`.
1517

1618
### Changed
1719

‎Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "TypeUtils"
22
uuid = "c3b1956e-8857-4d84-9b79-890df85b1e67"
3-
version = "1.14.0"
3+
version = "2.0.0"
44
authors = ["Éric Thiébaut <eric.thiebaut@univ-lyon1.fr> and contributors"]
55

66
[deps]

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,15 @@ precision is irrelevant or not implemented, `x` is returned unchanged. Setting t
211211
precision shall not change the dimensions of dimensionful numbers. If `T` is
212212
`AbstractFloat`, the default floating-point type `Float64` is assumed.
213213

214-
For a number `x`, `adapt_precision(T, x)` behaves as `convert_real_type(T, x)` and
215-
`adapt_precision(T, typeof(x))` may be used to infer the corresponding type with precision
216-
`T`.
214+
For a non-integer number `x`, `adapt_precision(T, x)` behaves as `convert_real_type(T, x)`
215+
and `adapt_precision(T, typeof(x))` may be used to infer the corresponding type with
216+
precision `T`.
217217

218218
Example:
219219

220220
```julia
221-
julia> adapt_precision(Float32, (1, 0x07, ("hello", 1.0, 3.0 - 2.0im, π)))
222-
(1.0f0, 7.0f0, ("hello", 1.0f0, 3.0f0 - 2.0f0im, 3.1415927f0))
221+
julia> adapt_precision(Float32, (0.5, 1, 3//4, 0x07, ("hello", false, 1.0, 3.0 - 2.0im, π)))
222+
(0.5f0, 1, 0.75f0, 0x07, ("hello", false, 1.0f0, 3.0f0 - 2.0f0im, 3.1415927f0))
223223
```
224224

225225
Basically, `adapt_precision` supports numbers, arrays of numbers, matrix factorizations,

‎src/precision.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ corresponding type with precision `T`.
8686
Example:
8787
8888
```jldoctest; setup=:(using TypeUtils)
89-
julia> adapt_precision(Float32, (1, 3.0 - 2.0im, ("hello", 0x07, 1.0, π)))
90-
(1, 3.0f0 - 2.0f0im, ("hello", 0x07, 1.0f0, 3.1415927f0))
89+
julia> adapt_precision(Float32, (1, 3//4, 3.0 - 2.0im, ("hello", false, 0x07, 1.0, π)))
90+
(1, 0.75f0, 3.0f0 - 2.0f0im, ("hello", false, 0x07, 1.0f0, 3.1415927f0))
9191
```
9292
9393
As can be seen, only non-integer numerical values are converted.

0 commit comments

Comments
 (0)