Skip to content

Commit

Permalink
fixed docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Jul 10, 2020
1 parent 424335b commit fea5bfd
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://jishnub.github.io/HalfIntegerArrays.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://jishnub.github.io/HalfIntegerArrays.jl/dev)
[![Build Status](https://github.com/jishnub/HalfIntegerArrays.jl/workflows/CI/badge.svg)](https://github.com/jishnub/HalfIntegerArrays.jl/actions)
[![Build Status](https://travis-ci.com/jishnub/HalfIntegerArrays.jl.svg?branch=master)](https://travis-ci.com/jishnub/HalfIntegerArrays.jl)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/jishnub/HalfIntegerArrays.jl?svg=true)](https://ci.appveyor.com/project/jishnub/HalfIntegerArrays-jl)
[![Coverage](https://codecov.io/gh/jishnub/HalfIntegerArrays.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/jishnub/HalfIntegerArrays.jl)
Expand Down Expand Up @@ -81,7 +80,7 @@ julia> s = SpinMatrix{ComplexF64}(undef, 1//2)
6.91635e-310+6.91637e-310im 6.91637e-310+6.91637e-310im
```

A `SpinMatrix` requires the parent array to have `1`-based indexing. It does not, however, impose any size restriction on the parent array. The only restriction is on the number of dimensions: the parent array needs to be a `Vector` or a `Matrix`.
A `SpinMatrix` requires the parent matrix to have `1`-based indexing and have a size of `(2j+1, 2j+1)`.

## Indexing

Expand Down Expand Up @@ -136,7 +135,7 @@ julia> h[cinds[1,0]]
2
```

Indexing with `CartesianIndices` work as well for arrays with integer indices, where the axes ranges are specified while creating the range.
Indexing with `CartesianIndices` works as well for arrays with integer indices.

## Broadcasting

Expand Down
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
HalfIntegerArrays = "8d01e2c4-1bfe-4abb-85d1-ae030bc38508"

[compat]
Documenter = "0.24"
4 changes: 3 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using HalfIntegerArrays
using Documenter

DocMeta.setdocmeta!(HalfIntegerArrays, :DocTestSetup, :(using HalfIntegerArrays); recursive=true)

makedocs(;
modules=[HalfIntegerArrays],
authors="Jishnu Bhattacharya",
repo="https://github.com/jishnub/HalfIntegerArrays.jl/blob/{commit}{path}#L{line}",
sitename="HalfIntegerArrays.jl",
sitename="HalfIntegerArrays",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://jishnub.github.io/HalfIntegerArrays.jl",
Expand Down
4 changes: 2 additions & 2 deletions src/axes.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
HalfIntegerArrays.OneTo(n)
Define an AbstractUnitRange that behaves like 1:n, with the added distinction that the lower limit is guaranteed (by the type
system) to be 1. The elements are integers of a `HalfInteger` type.
Define an AbstractUnitRange that behaves like `1:n`, with the added distinction that the lower limit is guaranteed (by the type
system) to be `1`. The elements are integers, but of a `HalfInteger` type.
"""
struct OneTo{T<:HalfInteger} <: AbstractUnitRange{T}
stop :: T
Expand Down
16 changes: 8 additions & 8 deletions src/halfintarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ The initializer `init` may be one of `undef`, `missing` or `nothing`.
# Examples
```jldoctest
julia> HalfIntArray{Int}(undef, 0:1, 0:1)
2×2 HalfIntArray(::Array{Int64,2}, 0:1, 0:1) with eltype Int64 with indices 0:1×0:1:
140351285081576 140351285165800
140351284092864 0
julia> HalfIntArray{Union{Int,Missing}}(undef, 0:1, 0:1)
2×2 HalfIntArray(::Array{Union{Missing, Int64},2}, 0:1, 0:1) with eltype Union{Missing, Int64} with indices 0:1×0:1:
missing missing
missing missing
```
"""
HalfIntArray{T,N}(init::ArrayInitializer, inds::Indices{N}) where {T,N} =
Expand Down Expand Up @@ -155,10 +155,10 @@ set by the initializer `init` that may be one of `undef`, `missing` or `nothing`
# Examples
```jldoctest
julia> SpinMatrix{Float64}(undef, 1//2)
2×2 SpinMatrix(::Array{Float64,2}, 1/2) with eltype Float64 with indices -1/2:1/2×-1/2:1/2:
0.0 0.0
2.122e-314 0.0
julia> SpinMatrix{Union{Int,Missing}}(undef, 1//2)
2×2 SpinMatrix(::Array{Union{Missing, Int64},2}, 1/2) with eltype Union{Missing, Int64} with indices -1/2:1/2×-1/2:1/2:
missing missing
missing missing
```
"""
function SpinMatrix{T}(init::ArrayInitializer, j::Real) where {T}
Expand Down
11 changes: 5 additions & 6 deletions src/lincartindexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ julia> h = HalfIntArray(reshape(1:4, 2, 2), -1//2:1//2, -1//2:1//2)
2 4
julia> c = CartesianIndicesHalfInt(h)
2×2 CartesianIndicesHalfInt{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}:
2×2 CartesianIndicesHalfInt{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}} with indices -1/2:1/2×-1/2:1/2:
CartesianIndexHalfInt(-1/2, -1/2) CartesianIndexHalfInt(-1/2, 1/2)
CartesianIndexHalfInt(1/2, -1/2) CartesianIndexHalfInt(1/2, 1/2)
julia> c[1,1]
CartesianIndexHalfInt(-1/2, -1/2)
julia> c[1/2,1/2]
CartesianIndexHalfInt(1/2, 1/2)
```
"""
struct CartesianIndicesHalfInt{N,R} <: AbstractHalfIntegerArray{CartesianIndexHalfInt{N},N}
Expand Down Expand Up @@ -387,7 +387,7 @@ end
"""
LinearIndicesHalfInt(A::AbstractArray)
Return a `LinearIndicesHalfInt` array with the same shape and [`axes`](@ref) as `A`,
Return a `LinearIndicesHalfInt` array with the same shape and `axes` as `A`,
holding the linear index of each entry in `A`. Indexing this array with
cartesian indices allows mapping them to linear indices.
Expand All @@ -405,7 +405,7 @@ therefore the suitable for working with `AbstractHalfIntegerArray`s.
# Examples
```jldoctest
julia> h
julia> h = HalfIntArray(reshape(1:4, 2, 2), -1//2:1//2, -1//2:1//2)
2×2 HalfIntArray(reshape(::UnitRange{Int64}, 2, 2), -1/2:1/2, -1/2:1/2) with eltype Int64 with indices -1/2:1/2×-1/2:1/2:
1 3
2 4
Expand Down Expand Up @@ -437,7 +437,6 @@ julia> lindsv[0]
0
```
"""
# LinearIndices
struct LinearIndicesHalfInt{N,R<:NTuple{N,AbstractUnitRange{Int}}} <: AbstractHalfIntegerArray{HalfInt,N}
lininds :: LinearIndices{N,R}
offsets :: NTuple{N,HalfInt}
Expand Down
10 changes: 5 additions & 5 deletions src/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ julia> h = HalfIntArray(reshape(1:9, 3, 3), -1:1, -1:1)
3 6 9
julia> hv = @view h[-1:1, 0]
3-element HalfIntSubArray(view(reshape(::UnitRange{Int64}, 3, 3), 1:3, 2), -1:1) with eltype Int64 with indices -1:1:
3-element HalfIntSubArray(view(reshape(::UnitRange{Int64}, 3, 3), 1:3, 2), 1:3) with eltype Int64 with indices 1:3:
4
5
6
julia> hv[0]
5
julia> hv[1]
4
julia> h = HalfIntArray(reshape(collect(1:4), 2, 2), -1//2:1//2, -1//2:1//2)
2×2 HalfIntArray(::Array{Int64,2}, -1/2:1/2, -1/2:1/2) with eltype Int64 with indices -1/2:1/2×-1/2:1/2:
Expand All @@ -34,8 +34,8 @@ julia> h = HalfIntArray(reshape(collect(1:4), 2, 2), -1//2:1//2, -1//2:1//2)
julia> hv = @view h[:, 1//2]
2-element HalfIntSubArray(view(::Array{Int64,2}, :, 2), -1/2:1/2) with eltype Int64 with indices -1/2:1/2:
3
10
3
4
julia> hv[1//2] = 10
10
Expand Down

0 comments on commit fea5bfd

Please sign in to comment.