https://github.com/tpapp/squeezing.jl
Convenient syntax for removing singleton dimensions from array reductions.
https://github.com/tpapp/squeezing.jl
Last synced: 5 months ago
JSON representation
Convenient syntax for removing singleton dimensions from array reductions.
- Host: GitHub
- URL: https://github.com/tpapp/squeezing.jl
- Owner: tpapp
- License: other
- Created: 2018-03-01T13:12:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-12-20T09:19:15.000Z (over 5 years ago)
- Last Synced: 2026-01-20T20:05:12.206Z (5 months ago)
- Language: Julia
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Squeezing
[](http://www.repostatus.org/#wip)
[](https://travis-ci.org/tpapp/Squeezing.jl)
[](https://coveralls.io/github/tpapp/Squeezing.jl?branch=master)
[](http://codecov.io/github/tpapp/Squeezing.jl?branch=master)
Convenient syntax for removing singleton dimensions from array reductions.
## Installation
This package is not (yet) registered. Run
```julia
Pkg.clone("https://github.com/tpapp/Squeezing.jl.git")
```
to install it.
## Usage
Just put `@squeezing` before reducing expressions.
```julia
julia> using Squeezing
julia> @squeezing sum(ones(3, 2), 1)
2-element Array{Float64,1}:
3.0
3.0
julia> @squeezing reducedim(max, A, 1)
4-element Array{Int64,1}:
4
8
12
16
```
Don't forget the `()` if using it as part of an expression:
```julia
@squeezing(sum(ones(3, 2), 1)) == [3.0, 3.0]
```
## How it works
`@squeezing f(args...)` is equivalent to `squeeze(f(args...), last(args))`. It preserves type stability.
## Related
Issue [#16606](https://github.com/JuliaLang/julia/issues/16606), PR [#23500](https://github.com/JuliaLang/julia/pull/23500), [discussion](https://discourse.julialang.org/t/sum-squeeze-as-one-function/2471/11).