-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update CI configuration * Update to Static.jl v0.8 * Increase package version to v0.14.6 * format * Fix docstring for PowerMeasure Co-authored-by: Chad Scherrer <[email protected]> * Rename dslength and dssize --------- Co-authored-by: Chad Scherrer <[email protected]>
- Loading branch information
Showing
9 changed files
with
127 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "MeasureBase" | ||
uuid = "fa1605e6-acd5-459c-a1e6-7e635759db14" | ||
authors = ["Chad Scherrer <[email protected]> and contributors"] | ||
version = "0.14.5" | ||
version = "0.14.6" | ||
|
||
[deps] | ||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" | ||
|
@@ -48,6 +48,6 @@ NaNMath = "0.3, 1" | |
PrettyPrinting = "0.3, 0.4" | ||
Reexport = "1" | ||
SpecialFunctions = "2" | ||
Static = "0.5, 0.6" | ||
Static = "0.8" | ||
Tricks = "0.1" | ||
julia = "1.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
""" | ||
MeasureBase.IntegerLike | ||
Equivalent to `Union{Integer,Static.StaticInt}`. | ||
""" | ||
const IntegerLike = Union{Integer,Static.StaticInt} | ||
|
||
""" | ||
MeasureBase.one_to(n::IntegerLike) | ||
Creates a range from one to n. | ||
Returns an instance of `Base.OneTo` or `Static.SOneTo`, depending | ||
on the type of `n`. | ||
""" | ||
@inline one_to(n::Integer) = Base.OneTo(n) | ||
@inline one_to(::Static.StaticInt{N}) where {N} = Static.SOneTo{N}() | ||
|
||
_dynamic(x::Number) = dynamic(x) | ||
_dynamic(::Static.SOneTo{N}) where {N} = Base.OneTo(N) | ||
_dynamic(r::AbstractUnitRange) = minimum(r):maximum(r) | ||
|
||
""" | ||
MeasureBase.fill_with(x, sz::NTuple{N,<:IntegerLike}) where N | ||
Creates an array of size `sz` filled with `x`. | ||
Returns an instance of `FillArrays.Fill`. | ||
""" | ||
function fill_with end | ||
|
||
@inline function fill_with(x::T, sz::Tuple{Vararg{<:IntegerLike,N}}) where {T,N} | ||
fill_with(x, map(one_to, sz)) | ||
end | ||
|
||
@inline function fill_with(x::T, axs::Tuple{Vararg{<:AbstractUnitRange,N}}) where {T,N} | ||
# While `FillArrays.Fill` (mostly?) works with axes that are static unit | ||
# ranges, some operations that automatic differentiation requires do fail | ||
# on such instances of `Fill` (e.g. `reshape` from dynamic to static size). | ||
# So need to use standard ranges for the axes for now: | ||
dyn_axs = map(_dynamic, axs) | ||
FillArrays.Fill(x, dyn_axs) | ||
end | ||
|
||
""" | ||
MeasureBase.maybestatic_length(x)::IntegerLike | ||
Returns the length of `x` as a dynamic or static integer. | ||
""" | ||
maybestatic_length(x) = length(x) | ||
maybestatic_length(x::AbstractUnitRange) = length(x) | ||
function maybestatic_length(::Static.OptionallyStaticUnitRange{StaticInt{A},StaticInt{B}}) where {A,B} | ||
StaticInt{B - A + 1}() | ||
end | ||
|
||
""" | ||
MeasureBase.maybestatic_size(x)::Tuple{Vararg{IntegerLike}} | ||
Returns the size of `x` as a tuple of dynamic or static integers. | ||
""" | ||
maybestatic_size(x) = size(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5bba40f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
5bba40f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/84550
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: