Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin development of 0.2 series #29

Merged
merged 8 commits into from
Nov 7, 2024
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.8'
- '1.9'
- '1'
- 'nightly'
os:
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Next]

### Added
- Package extensions for `LinearAlgebra` and `StaticArraysCore` to add methods to
`LinearAlgebra.dot`, `LinearAlgebra.normalize`, `StaticArraysCore.similar_type`.

### Removed
- **[BREAKING]** `CliffordNumbers.normalize` is no longer exported to avoid a name conflict with
`LinearAlgebra.normalize`.
- **[BREAKING]** Support for Julia 1.8 due to the use of package extensions.

## [0.1.10] - 2024-11-06

### Added
Expand Down Expand Up @@ -130,6 +141,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Initial release of CliffordNumbers.jl

[Next]: https://github.com/brainandforce/CliffordNumbers.jl/tree/next
[Unreleased]: https://github.com/brainandforce/CliffordNumbers.jl
[0.1.10]: https://github.com/brainandforce/CliffordNumbers.jl/releases/tag/v0.1.10
[0.1.9]: https://github.com/brainandforce/CliffordNumbers.jl/releases/tag/v0.1.9
Expand Down
15 changes: 12 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
name = "CliffordNumbers"
uuid = "3998ac73-6bd4-4031-8035-f167dd3ed523"
authors = ["Brandon Flores"]
version = "0.1.10"
version = "0.2.0-dev"

[weakdeps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[extensions]
CliffordNumbersLinearAlgebraExt = "LinearAlgebra"
CliffordNumbersStaticArraysCoreExt = "StaticArraysCore"
CliffordNumbersUnitfulExt = "Unitful"

[compat]
Aqua = "0.8"
LinearAlgebra = "1"
StaticArrays = "1"
StaticArraysCore = "1"
Test = "1"
Unitful = "1"
julia = "1.8"
julia = "1.9"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["Aqua", "Test", "Unitful"]
test = ["Aqua", "LinearAlgebra", "StaticArrays", "Test", "Unitful"]
9 changes: 9 additions & 0 deletions ext/CliffordNumbersLinearAlgebraExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module CliffordNumbersLinearAlgebraExt

using CliffordNumbers
using LinearAlgebra

LinearAlgebra.dot(x::AbstractCliffordNumber, y::AbstractCliffordNumber) = CliffordNumbers.dot(x, y)
LinearAlgebra.normalize(x::AbstractCliffordNumber) = CliffordNumbers.normalize(x)

end
14 changes: 14 additions & 0 deletions ext/CliffordNumbersStaticArraysCoreExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module CliffordNumbersStaticArraysCoreExt

using CliffordNumbers
using StaticArraysCore

function StaticArraysCore.similar_type(::Type{C}, args...) where C<:AbstractCliffordNumber
return CliffordNumbers.similar_type(C, args...)

Check warning on line 7 in ext/CliffordNumbersStaticArraysCoreExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/CliffordNumbersStaticArraysCoreExt.jl#L6-L7

Added lines #L6 - L7 were not covered by tests
end

function StaticArraysCore.similar_type(x::AbstractCliffordNumber, args...)
return CliffordNumbers.similar_type(x, args...)
end

end
2 changes: 1 addition & 1 deletion src/CliffordNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ include("math/arithmetic.jl")
include("math/duals.jl")
# Scalar products, absolute values, scalar multiplication
include("math/scalar.jl")
export isscalar, scalar, ispseudoscalar, scalar_product, normalize
export isscalar, scalar, ispseudoscalar, scalar_product
# Definitions of operators for products
include("math/products.jl")
export left_contraction, right_contraction, wedge, regressive, commutator, anticommutator
Expand Down
10 changes: 10 additions & 0 deletions src/abstract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ form must be wrapped in a `Val` to preserve type stability.

This function must be defined with all its arguments for each concrete type subtyping
`AbstractCliffordNumber`.

# Note on function export

This function is nearly identical in semantics to `StaticArraysCore.similar_type`. However, since
this package does not depend on `StaticArraysCore`, this function is not exported to avoid name
conflicts whenever any package exporting `StaticArraysCore.similar_type` is loaded.

If a package exports `StaticArraysCore.similar_type`, that function will have methods added which
match the methods in this package with the same signature. This may be triggered explicitly if
desired with a `using` or `import` directive.
"""
function similar_type(x::AbstractCliffordNumber, T::Type{<:BaseNumber}, Q::Val)
return similar_type(typeof(x), T, Q)
Expand Down
6 changes: 6 additions & 0 deletions test/ext/LinearAlgebra.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@testset "LinearAlgebra extensions" begin
k = KVector{1,VGA(3)}(4, 2, 0)
l = KVector{2,VGA(3)}(0, 6, 9)
@test CliffordNumbers.dot(k, l) === LinearAlgebra.dot(k, l)
@test CliffordNumbers.normalize(k) === LinearAlgebra.normalize(k)
end
4 changes: 4 additions & 0 deletions test/ext/StaticArraysCore.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@testset "StaticArraysCore extension" begin
k = KVector{1,VGA(3)}(4, 2, 0)
@test CliffordNumbers.similar_type(k, Float32) === StaticArrays.similar_type(k, Float32)
end
9 changes: 5 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CliffordNumbers
using Aqua, Test, Unitful
using Aqua, Test
using LinearAlgebra, StaticArrays, Unitful

Aqua.test_all(CliffordNumbers; unbound_args = false)

Expand All @@ -15,7 +16,7 @@ Aqua.test_all(CliffordNumbers; unbound_args = false)
include("indexing.jl")
include("conversion.jl")
include("operations.jl")
if VERSION >= v"1.9.0"
include("ext/Unitful.jl")
end
include("ext/LinearAlgebra.jl")
include("ext/StaticArraysCore.jl")
include("ext/Unitful.jl")
end
Loading