-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
69 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,45 @@ | ||
# NullBroadcasts.jl | ||
|
||
A small package for defining null broadcasted types and behaviors | ||
||| | ||
|---------------------:|:----------------------------------------------| | ||
| **Docs Build** | [![docs build][docs-bld-img]][docs-bld-url] | | ||
| **Documentation** | [![dev][docs-dev-img]][docs-dev-url] | | ||
| **GHA CI** | [![gha ci][gha-ci-img]][gha-ci-url] | | ||
| **Code Coverage** | [![codecov][codecov-img]][codecov-url] | | ||
|
||
[docs-bld-img]: https://github.com/CliMA/NullBroadcasts.jl/actions/workflows/docs.yml/badge.svg | ||
[docs-bld-url]: https://github.com/CliMA/NullBroadcasts.jl/actions/workflows/docs.yml | ||
|
||
[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg | ||
[docs-dev-url]: https://CliMA.github.io/NullBroadcasts.jl/dev/ | ||
|
||
[gha-ci-img]: https://github.com/CliMA/NullBroadcasts.jl/actions/workflows/ci.yml/badge.svg | ||
[gha-ci-url]: https://github.com/CliMA/NullBroadcasts.jl/actions/workflows/ci.yml | ||
|
||
[codecov-img]: https://codecov.io/gh/CliMA/NullBroadcasts.jl/branch/main/graph/badge.svg | ||
[codecov-url]: https://codecov.io/gh/CliMA/NullBroadcasts.jl | ||
|
||
This package defines `NullBroadcasted()`, which can be added to, subtracted | ||
from, or multiplied by any value in a broadcast expression without incurring a | ||
runtime performance penalty. | ||
|
||
# Example | ||
|
||
```julia | ||
using NullBroadcasts: NullBroadcasted | ||
using Test | ||
|
||
x = [1]; y = [1] | ||
a = NullBroadcasted() | ||
@. x = x + a + y | ||
@test x[1] == 2 # passes | ||
|
||
x = [1]; y = [1] | ||
@. x = x - a + y | ||
@test x[1] == 2 # passes | ||
|
||
@. x = x + (x * a) # equivalent to @. x = x | ||
|
||
@. x = x * a # not allowed, errors | ||
@. x = a # not allowed, errors | ||
``` |
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,2 +1,3 @@ | ||
# NullBroadcasts.jl | ||
|
||
Under construction. Please see the readme for the latest documentation. |
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