Skip to content

Commit 22f145e

Browse files
committed
Fix typos and reformat
1 parent af8349e commit 22f145e

File tree

8 files changed

+88
-93
lines changed

8 files changed

+88
-93
lines changed

src/arrays.jl

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ tuple of `AbstractUnitRange{eltype(Dims)}`s. Any integer in `args...` is replace
88
instance of `Base.OneTo{eltype(Dims)}`.
99
1010
The array dimensions or ranges may also be provided as a tuple.
11-
[`RelaxedArrayShape{N}`](@ref) is the union of types of `N`-tuples to which
12-
`as_array_axes` is applicable.
11+
[`RelaxedArrayShape{N}`](@ref) is the union of types of `N`-tuples to which `as_array_axes`
12+
is applicable.
1313
1414
Also see [`as_array_shape`](@ref), [`as_array_size`](@ref), [`as_array_axis`](@ref),
1515
[`ArrayAxes`](@ref), `Dims`, and [`new_array`](@ref).
@@ -25,8 +25,8 @@ as_array_axes(args::RelaxedArrayShape) = map(as_array_axis, args)
2525
2626
converts array dimension or range `arg` to a canonical array axis, that is an instance of
2727
`AbstractUnitRange{eltype(Dims)}`. If `arg` is an integer, `Base.OneTo{eltype(Dims)}(arg)`
28-
is returned. [`eltype(RelaxedArrayShape)`](@ref RelaxedArrayShape) is the union of types
29-
to which `as_array_axis` is applicable.
28+
is returned. [`eltype(RelaxedArrayShape)`](@ref RelaxedArrayShape) is the union of types to
29+
which `as_array_axis` is applicable.
3030
3131
Also see [`as_array_axes`](@ref), [`as_array_dim`](@ref), and `Dims`.
3232
@@ -62,20 +62,19 @@ as_array_dim(rng::AbstractRange{<:Integer}) =
6262
6363
converts array dimensions or ranges `args...` to a canonical form of array shape, one of:
6464
65-
* array size, that is a tuple of `Int`s. This is the result if all of `args...` are
66-
integers or instances of `Base.OneTo`, the latter, if any, being replaced by their
67-
lengths.
65+
* array size, that is a tuple of `Int`s. This is the result if all of `args...` are integers
66+
or instances of `Base.OneTo`, the latter, if any, being replaced by their lengths.
6867
6968
* array axes, that is a tuple of `AbstractUnitRange{Int}`s. This is the result if any of
7069
`args...` are non-`Base.OneTo` ranges, the integers being converted to instances of
7170
`Base.OneTo{eltype(Dims)}`.
7271
7372
The array dimensions or ranges may also be provided as a tuple.
74-
[`RelaxedArrayShape{N}`](@ref) is the union of types of `N`-tuples to which
75-
`as_array_shape` is applicable.
73+
[`RelaxedArrayShape{N}`](@ref) is the union of types of `N`-tuples to which `as_array_shape`
74+
is applicable.
7675
77-
Also see [`as_array_size`](@ref), [`as_array_axes`](@ref), [`ArrayAxes`](@ref), `Dims`,
78-
and [`new_array`](@ref).
76+
Also see [`as_array_size`](@ref), [`as_array_axes`](@ref), [`ArrayAxes`](@ref), `Dims`, and
77+
[`new_array`](@ref).
7978
8079
"""
8180
as_array_shape(::Tuple{}) = ()
@@ -90,11 +89,11 @@ converts array dimensions or ranges `args...` to a canonical form of array size,
9089
tuple of `eltype(Dims)`s. Any range in `args...` is replaced by its length.
9190
9291
The array dimensions or ranges may also be provided as a tuple.
93-
[`RelaxedArrayShape{N}`](@ref) is the union of types of `N`-tuples to which
94-
`as_array_size` is applicable.
92+
[`RelaxedArrayShape{N}`](@ref) is the union of types of `N`-tuples to which `as_array_size`
93+
is applicable.
9594
96-
Also see [`as_array_shape`](@ref), [`as_array_axes`](@ref), [`as_array_dim`](@ref),
97-
`Dims`, and [`new_array`](@ref).
95+
Also see [`as_array_shape`](@ref), [`as_array_axes`](@ref), [`as_array_dim`](@ref), `Dims`,
96+
and [`new_array`](@ref).
9897
9998
"""
10099
as_array_size(::Tuple{}) = ()
@@ -110,8 +109,8 @@ create a new array with element type `T` and shape defined by `inds...`, a list
110109
dimension lengths and/or index ranges. The shape may also be specified as a tuple.
111110
112111
If `inds...` contains any index range other than `Base.OneTo`, an `OffsetArray{T}` is
113-
returned; otherwise an `Array{T}` is returned. In the former case, an exception is thrown
114-
if the package `OffsetArrays` has not been loaded.
112+
returned; otherwise an `Array{T}` is returned. In the former case, an exception is thrown if
113+
the package `OffsetArrays` has not been loaded.
115114
116115
Also see [`as_array_shape`](@ref), [`as_array_axes`](@ref), and [`as_array_size`](@ref).
117116
@@ -158,10 +157,9 @@ convert_eltype(::Type{T}, ::Type{X}) where {T,X} =
158157
error("don't know how to convert the element type of type `$X` to `$T`")
159158

160159
# As of Julia 1.11 `AbstractMatrix{T}(A)` or `AbstractArray{T}(A)` can be used to convert
161-
# element type of `A` for Adjoint, Bidiagonal, Diagonal, Hermitian,
162-
# LinearAlgebra.LQPackedQ, LowerTriangular, SymTridiagonal, Symmetric, Transpose,
163-
# Tridiagonal, UnitLowerTriangular, UnitUpperTriangular, UpperHessenberg, UpperTriangular,
164-
# etc.
160+
# element type of `A` for Adjoint, Bidiagonal, Diagonal, Hermitian, LinearAlgebra.LQPackedQ,
161+
# LowerTriangular, SymTridiagonal, Symmetric, Transpose, Tridiagonal, UnitLowerTriangular,
162+
# UnitUpperTriangular, UpperHessenberg, UpperTriangular, etc.
165163
convert_eltype(::Type{T}, A::AbstractArray{T}) where {T} = A
166164
convert_eltype(::Type{T}, A::AbstractArray) where {T} = AbstractArray{T}(A)
167165
convert_eltype(::Type{T}, ::Type{<:Array{<:Any,N}}) where {T,N} = Array{T,N}
@@ -193,8 +191,8 @@ end
193191
# Convert element type for numbers.
194192
convert_eltype(::Type{T}, ::Type{<:Number}) where {T} = T
195193

196-
# Convert element type for tuples. See `_countuple` in `base/tuple.jl` for the best
197-
# way to extract the number of elements in a tuple given its type.
194+
# Convert element type for tuples. See `_countuple` in `base/tuple.jl` for the best way to
195+
# extract the number of elements in a tuple given its type.
198196
convert_eltype(::Type{T}, ::Type{<:NTuple{N,Any}}) where {N,T} = NTuple{N,T}
199197
convert_eltype(::Type{T}, A::NTuple{N,T}) where {N,T} = A
200198
convert_eltype(::Type{T}, A::Tuple) where {T} = map(as(T), A)
@@ -237,8 +235,8 @@ convert_eltype(::Type{T}) where {T} = Converter(convert_eltype, T)
237235
yields an array which lazily converts its entries to type `T`. More specifically, a call
238236
like `B[i]` yields `as(T,A[i])`.
239237
240-
Consider using [`convert_eltype(T, A)`](@ref convert_eltype) to perform the conversion
241-
once and immediately.
238+
Consider using [`convert_eltype(T, A)`](@ref convert_eltype) to perform the conversion once
239+
and immediately.
242240
243241
"""
244242
as_eltype(::Type{T}, A::AbstractArray{T}) where {T} = A

src/funcs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"""
44
return_type(f, argtypes...) -> T
55
6-
yields the type of the result returned by the callable object `f` when called
7-
with arguments of types `argtypes...`.
6+
yields the type of the result returned by the callable object `f` when called with arguments
7+
of types `argtypes...`.
88
99
See the warning in the documentation of `Base.promote_op` for the fragility of such
1010
inference in some cases. There are no such issues if `f` is an instance of

src/macros.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
22
TypeUtils.@public args...
33
4-
declares `args...` as being `public` even though they are not exported. For Julia version
5-
< 1.11, this macro does nothing. Using this macro also avoid errors with CI and coverage
4+
declares `args...` as being `public` even though they are not exported. For Julia version <
5+
1.11, this macro does nothing. Using this macro also avoid errors with CI and coverage
66
tools.
77
88
"""

src/methods.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ as(::Type{Tuple}, x::CartesianIndex) = Tuple(x)
1414
as(::Type{Tuple}, x::CartesianIndices) = x.indices
1515
for X in (:CartesianIndex, :CartesianIndices)
1616
@eval begin
17-
# For more specific tuple types, first extract tuple contents, then
18-
# convert to the requested tuple type.
17+
# For more specific tuple types, first extract tuple contents, then convert to the
18+
# requested tuple type.
1919
as(::Type{T}, x::$X) where {T<:Tuple} = as(T, as(Tuple, x))
2020

2121
# Use the constructors to convert tuples to Cartesian index/indices.
@@ -149,13 +149,13 @@ Array
149149
#
150150
# - https://stackoverflow.com/questions/42229901/getting-the-parameter-less-type
151151
#
152-
# The latter leads to define the method as (in old versions of Julia, the field
153-
# name was `:primary`, but since Julia 0.7, it should be `:wrapper`):
152+
# The latter leads to define the method as (in old versions of Julia, the field name was
153+
# `:primary`, but since Julia 0.7, it should be `:wrapper`):
154154
#
155155
# @inline parameterless(::Type{T}) where {T} = getfield(Base.typename(T), :wrapper)
156156
#
157-
# The actual implementation is borrowed from `ConstructionBase` and should be
158-
# less likely to be broken by internal changes in Julia:
157+
# The actual implementation is borrowed from `ConstructionBase` and should be less likely to
158+
# be broken by internal changes in Julia:
159159
#
160160
parameterless(::Type{T}) where {T} = getfield(parentmodule(T), nameof(T))
161161

@@ -165,8 +165,8 @@ parameterless(::Type{T}) where {T} = getfield(parentmodule(T), nameof(T))
165165
166166
yield whether number `x` can be negated while retaining the same type. The result only
167167
depends on the type of `x`. The result is `false` for `typeof(x) <:
168-
Union{U,Rational{U},Complex{U}} where {U<:Union{Bool,Unsigned}}` as well as quantities
169-
based on these bare numeric types.
168+
Union{U,Rational{U},Complex{U}} where {U<:Union{Bool,Unsigned}}` as well as quantities based
169+
on these bare numeric types.
170170
171171
"""
172172
is_signed(x::Number) = is_signed(typeof(x))

src/numbers.jl

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
bare_type(x) -> T <: Union{Real,Complex}
55
66
yields the bare numeric type `T` backing the storage of `x` which may be a number or a
7-
numeric type. If `x` has units, they are discarded. Hence `T` is always a dimensionless
8-
real or complex type.
7+
numeric type. If `x` has units, they are discarded. Hence `T` is always a dimensionless real
8+
or complex type.
99
1010
Examples:
1111
@@ -27,8 +27,8 @@ yields the promoted bare numeric type of `args...`.
2727
---
2828
bare_type() -> TypeUtils.BareNumber
2929
30-
yields the union of bare numeric types that may be returned by `bare_type` when called
31-
with no arguments.
30+
yields the union of bare numeric types that may be returned by `bare_type` when called with
31+
no arguments.
3232
3333
"""
3434
bare_type() = BareNumber
@@ -43,8 +43,8 @@ bare_type(::Type{T}) where {T<:Number} = typeof(one(T))
4343
4444
yields the bare numeric type `T` backing the storage of `x` which may be a number of a
4545
numeric type. If `x` is a complex, `T` is the bare numeric type of the real and imaginary
46-
parts of `x`. If `x` has units, they are discarded. Hence `T` is always a dimensionless
47-
real type.
46+
parts of `x`. If `x` has units, they are discarded. Hence `T` is always a dimensionless real
47+
type.
4848
4949
Examples:
5050
@@ -89,12 +89,12 @@ end
8989
"""
9090
convert_bare_type(T, x)
9191
92-
converts `x` so that its bare numeric type is that of `T`. Argument `x` may be a number or
93-
a numeric type, while argument `T` must be a numeric type. If `x` is one of `missing`,
92+
converts `x` so that its bare numeric type is that of `T`. Argument `x` may be a number or a
93+
numeric type, while argument `T` must be a numeric type. If `x` is one of `missing`,
9494
`nothing`, `undef`, or the type of one of these singletons, `x` is returned.
9595
96-
This method may be extended with `T<:TypeUtils.BareNumber` and for `x` of
97-
non-standard numeric type.
96+
This method may be extended with `T<:TypeUtils.BareNumber` and for `x` of non-standard
97+
numeric type.
9898
9999
"""
100100
convert_bare_type(::Type{T}, x) where {T} = convert_bare_type(bare_type(T), x)
@@ -197,10 +197,9 @@ floating_point_type() = AbstractFloat
197197
"""
198198
convert_floating_point_type(T, x)
199199
200-
converts `x` so that its bare real type is the floating-point type of `T`. Argument `x`
201-
may be a number or a numeric type, while argument `T` must be a numeric type. If `x` is
202-
one of `missing`, `nothing`, `undef`, or the type of one of these singletons, `x` is
203-
returned.
200+
converts `x` so that its bare real type is the floating-point type of `T`. Argument `x` may
201+
be a number or a numeric type, while argument `T` must be a numeric type. If `x` is one of
202+
`missing`, `nothing`, `undef`, or the type of one of these singletons, `x` is returned.
204203
205204
This method may be extended with `T<:AbstractFloat` and for `x` of non-standard numeric
206205
type.
@@ -212,8 +211,8 @@ convert_floating_point_type(::Type{T}, x) where {T} =
212211
"""
213212
convert_floating_point_type(T) -> f
214213
215-
yields a callable object `f` such that `f(x)` yields `convert_floating_point_type(T, x)`
216-
for any `x`.
214+
yields a callable object `f` such that `f(x)` yields `convert_floating_point_type(T, x)` for
215+
any `x`.
217216
218217
"""
219218
convert_floating_point_type(::Type{T}) where {T} =
@@ -265,8 +264,8 @@ assert_floating_point(name::Union{Symbol,AbstractString}, ::Type{T}) where {T} =
265264
"""
266265
nearest(T::Type, x) -> y::T
267266
268-
yields the value or instance of type `T` that is the nearest to `x`. For `T` integer and
269-
`x` real, it can be seen as rounding with clamping.
267+
yields the value or instance of type `T` that is the nearest to `x`. For `T` integer and `x`
268+
real, it can be seen as rounding with clamping.
270269
271270
"""
272271
nearest(::Type{T}, x::T) where {T} = x
@@ -293,8 +292,8 @@ end
293292

294293
# Non-integer real to nearest integer.
295294
function nearest(::Type{T}, x::Real) where {T<:Integer}
296-
# We cannot use `ifelse` here because conversion may throw an `InexactError`. This
297-
# will occur anyway for `NaN`s.
295+
# We cannot use `ifelse` here because conversion may throw an `InexactError`. This will
296+
# occur anyway for `NaN`s.
298297
r = round(x)
299298
if r (lo = typemin(T))
300299
return lo

src/precision.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ get_precision(::Type{S}, ::Type{T}) where {S<:AbstractFloat,T<:AbstractFloat} =
6565
6666
yields an object `y` similar to `x` but with numerical precision specified by the
6767
floating-point type `T`. If `x` has already the required precision or if setting its
68-
precision is irrelevant or not implemented, `x` is returned unchanged. Setting the
69-
precision shall not change the dimensions of dimensionful numbers. If `T` is
70-
`AbstractFloat`, the default floating-point type [`TypeUtils.default_precision`](@ref) is
71-
assumed.
68+
precision is irrelevant or not implemented, `x` is returned unchanged. Setting the precision
69+
shall not change the dimensions of dimensionful numbers. If `T` is `AbstractFloat`, the
70+
default floating-point type [`TypeUtils.default_precision`](@ref) is assumed.
7271
7372
For a number `x`, `adapt_precision(T, x)` behaves as [`convert_real_type(T, x)`](@ref
7473
convert_real_type) and `adapt_precision(T, typeof(x))` may be used to infer the
@@ -90,8 +89,8 @@ specialized for other object types defined in foreign packages by specializing:
9089
TypeUtils.adapt_precision(::Type{T}, x::SomeType) where {T<:TypeUtils.Precision} = ...
9190
```
9291
93-
where `SomeType` is the object type and where the restriction `T<:TypeUtils.Precision` is
94-
to make sure the above method is only called with a concrete floating-point type `T`.
92+
where `SomeType` is the object type and where the restriction `T<:TypeUtils.Precision` is to
93+
make sure the above method is only called with a concrete floating-point type `T`.
9594
9695
See also [`get_precision`](@ref), [`convert_real_type`](@ref),
9796
[`TypeUtils.Precision`](@ref), and [`TypeUtils.default_precision`](@ref).

src/structs.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
destructure(Vector, obj) -> vals::Vector
55
destructure(Vector{T}, obj) -> vals::Vector{T}
66
7-
destructure object `obj` as a tuple or a vector of field values. Any structures in `obj`
8-
are recursively destructured. For example, a complex is destructured as two reals.
7+
destructure object `obj` as a tuple or a vector of field values. Any structures in `obj` are
8+
recursively destructured. For example, a complex is destructured as two reals.
99
1010
See also [`destructure!`](@ref), [`restructure`](@ref), and [`struct_length`](@ref).
1111
@@ -84,8 +84,8 @@ end
8484
restructures values `vals[offset+1:offset+n]` into an object `obj` of type `T`. Here `n =
8585
struct_length(T)` is the total number of values stored by an object of type `T`.
8686
87-
The default constructor must exist for type `T` and, recursively, for any structured
88-
fields of `T`.
87+
The default constructor must exist for type `T` and, recursively, for any structured fields
88+
of `T`.
8989
9090
See also [`destructure`](@ref), [`destructure!`](@ref), and [`struct_length`](@ref).
9191
@@ -133,8 +133,8 @@ end
133133
struct_length(x) -> n
134134
struct_length(typeof(x)) -> n
135135
136-
yield the total number of values stored by the fields of a structured object `x`. The
137-
result only depends on the type of `x`.
136+
yield the total number of values stored by the fields of a structured object `x`. The result
137+
only depends on the type of `x`.
138138
139139
"""
140140
struct_length(x) = struct_length(typeof(x))

0 commit comments

Comments
 (0)