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

Merge macros #4

Merged
merged 36 commits into from
Sep 1, 2022
Merged

Merge macros #4

merged 36 commits into from
Sep 1, 2022

Conversation

hustf
Copy link
Owner

@hustf hustf commented Sep 1, 2022

and other changes, v10.1.

DilumAluthge and others added 30 commits May 31, 2021 22:10
* Showing how to manually cancel units

* Update conversion.md

added the statement that `m/m` is automatically canceled

* Remove contrived examples, fixed typo

* More clear example

This commit changes the expression from which units are shortened to 1km/2.5m, to make clear that the denomenator is part of the expression.

It also fixed a typo (`NoUnit -> NoUnits`)

* Shorten example

It seems like some of the examples did not sit well with some of the contributers. I see their point completely, and in this PR I have made the example minimal and clearer. #LessIsMore

* Added @ref, and more interesting example

I added a reference to the NoUnits type (hopefully - I don't know how to chech that the reference actually works as expected).

I also changed the example to the more complicated one, to make it less trivial and hopefully better showcase the usefullness.

* Update docs/src/conversion.md

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* As per the latest review, which got outdated

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>
`isa(1m, Length)` did not work after `using Unitful` but the corrected version works.
If I had known this would support plot axes with units, I would not have started down the road to PainterQubits#455.
Maybe this elaboration will help someone else.

[skip ci]
I just registered the [UnitfulBuckinghamPi.jl](https://github.com/rmsrosa/UnitfulBuckinghamPi.jl) package. It solves for the adimensional groups in a list of Unitful parameters (quantities, units, dimensions, or combinations thereof).

This PR adds a link to the package in the README.

[skip ci]
* deg2rad and rad2deg

* v1.9

* Update src/pkgdefaults.jl

Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>

Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
Mentioned NaturallyUnitful.jl
* Update .gitignore

* Update .gitignore

Removed binary stuff

[skip ci]
PainterQubits#485)

* Prevent promotion of StepRangeLen eltype when multiplying by unit

* Release 1.9.1
…terQubits#491)

* made Bool-Quantity multiplication symmetric

* added tests for Bool-Quantity multiplication

* Remove unnecessary multiplication methods for Bool, AbstractQuantity

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Remove comment from previous Bool, AbstractQuantity methods

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Add NaN, -Inf tests for multiplication by false

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>
* make `norm` use `norm` rather than `abs`
…ts#478)

* Attempt to allow preferunits to work with non-pure units

Should fix PainterQubits#457. Prior to this change, attempts to use something that
looked like "preferunits(C/ms)" would result in strange behavior, without
throwing any sort of errors. Now, that should work nicely.

* Warn user when preferunits causes redundant units

Issue a warning when preferunits creates redundant units, which could stop
it from sucessfully simplifying certain quantities.

* Fix new upreferred behavior for non-dimensional quantities

* Add tests for preferunits changes

* Update test/runtests.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Fix preferunits tests

* Apply suggestions from code review

Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>

* Fix issues added by removing excess arrays

* No longer use string for key while checking for units of different scales

* Update test/runtests.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Update runtests.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>
Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
* Unit construction macro now defines docs for units

See PainterQubits#436

* Add documentation capabilities to most defined macros

This lets all unit and dimension definition macros repect doc strings
set in unit definition. Additionally, it automatically defines
documentation for derived units using power-of-ten prefixes.

* Add documentation for some units in pkgdefaults

Documentation has been added for all base units and many other SI units, as
well as adding a special case to the documentation so that kg and
documented as being the SI base unit.

* Allow documentation for log scales and units

* Rewrite documentation format for all units through "Liter"

Additionally, changed how the prefixed unit documentation is written; this
now means that prefixed units made by other modules should be properly
documented (tested with UnitfulAstro).

* Added documentation for all remaining units

Documentation is still required for log scales

* Update src/pkgdefaults.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Update src/pkgdefaults.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Update src/pkgdefaults.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Update src/pkgdefaults.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Apply suggestions from code review

Added descriptions of why certain alternate symbols are used (q for electron charge, minute for minutes)

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Remove excess newlines; add names to docstrings

* Add NoDims documentation

* Standardized number and equation format among quantity and unit docs

* Standardize format of dimensions in unit docs

* Apply suggestions from code review

Various minor fixes and changes, mostly typos and format changes.

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Switch from inline to block code blocks in new docstrings.

Also standardize docstrings to `2π` for 2 pi.

* Add automatic documentation for everything defined by the dimension macro

Also removed documentation from the pieces of log units that currently
don't have any sort of automatic documentation generation system in place.

* Fix documentation issues with two different symbols for vacuum permittivity constant.

* Minor formatting fixes

* Use block quotes for prefixed units' doc strings

* Update src/types.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Make automatic documentation optional

Also (optionally) generate automatic documentation for derived dimensions.

* Add dimension info in automatic prefixed unit docs.

* Change method for adding dimensions to prefixed unit documentation

Now no longer tries to `eval` stuff while running the macro.

* Fixes to documentation and code structure for autodocs for various macros

* Apply suggestions from code review

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Various format fixes and liters documentation changes.

* Fix missing optional argument causing test failure

* Remove no-longer-necessary NullLogger for liter and kilogram docs

* Remove unnecessary autodocs arguments for non-SI-prefixed units

* Apply suggestions from code review

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Fix invalid links being created in non-Unitful documentation

* Add spaced out column for autogen parameter where possible

* Apply suggestions from code review

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Update src/user.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* Add tests for autodocs

* Add test for prefixed reference units

* Hopefully fix docstrings and docstring tests on Julia-1.0

* Apply suggestions from code review

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* More documentation changes from code review

Also removed documentation ability for logunit and logscale (as these should be another pull request)

* Apply suggestions from code review

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>
)

* Fix some major invalidations to improve compile times

Unitful.jl was flagged as a major invalidator of compilation downstream. Test:

```julia
# From: https://timholy.github.io/SnoopCompile.jl/stable/snoopr/
using SnoopCompile
invalidations = @Snoopr begin
    using DifferentialEquations

    function lorenz(du,u,p,t)
     du[1] = 10.0(u[2]-u[1])
     du[2] = u[1]*(28.0-u[3]) - u[2]
     du[3] = u[1]*u[2] - (8/3)*u[3]
    end
    u0 = [1.0;0.0;0.0]
    tspan = (0.0,100.0)
    prob = ODEProblem(lorenz,u0,tspan)
    alg = Rodas5()
    tinf = solve(prob,alg)
end;

trees = SnoopCompile.invalidation_trees(invalidations);

@show length(SnoopCompile.uinvalidated(invalidations)) # show total invalidations

show(trees[end]) # show the most invalidated method
```

This method won the prize for the absolute most invalidations 🎉. But I think the bigger issue is that it simply doesn't follow Julia semantics. It fixes the types for issue PainterQubits#127 in a way that gives a stricter type than Julia would do in the normal cases (which is why the invalidation occurs).

After this PR, heterogeneous arrays of numbers with Quantity in there act normally, and compile times are back to normal. Here's a showcase of it being normal:

```julia

using Unitful, Test
m = u"m"
cm = u"cm"

b = Union{Complex,Float64}[0 + 0im, 0.0]
@test b + b == b
@test b .+ b == b
@test eltype(b+b) === Number

b = Number[0 + 0im, 0.0]
@test b + b == b
@test b .+ b == b
@test eltype(b+b) === Number

b = [0.0, 0.0m]
@test b + b == b
@test b .+ b == b
@test eltype(b+b) === Number
```

* Update promotion.jl
…#468)

* deg2rad and rad2deg

* v1.9

* Update src/pkgdefaults.jl

Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>

* fix PainterQubits#465

* test, v1.9.1

* Update src/quantities.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

* positive test

* Update test/runtests.jl

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>
…ties (PainterQubits#514)

* _range(start, ::Nothing, ::Nothing, len)

* _range(::Nothing, ::Nothing, stop, len)

* Add tests for ranges with complex elements

* Use modern  syntax

* Remove unnecessary `<:Real`

* Fix range(start::Quantity{BigFloat}; step::Quantity{BigFloat}; length)

* Fix for missing _rangestyle on 1.8

* Remove `real`

* Use `step` everywhere (instead of `st`)

* Fix range(;step, stop, len) on Julia master

* Fix range(;stop, step, length) for mixed number/quantity

* Add some newlines and comments

* Rename _range_step_stop_length → _unitful_step_stop_length

To avoid confusion with Base.range_step_stop_length

* Refactor _range(start, ::Nothing, stop, length)

* Rename 3-arg `Base._range` → `_unitful_start_stop_length` (`Base._range` always has 4 arguments)
* Move promotion to `_unitful_start_stop_length`

* Refactor _range(start, step, ::Nothing, length)

* Resolve method ambiguity on Julia ≥ 1.7

* Simplify implementation

* Use modern `where` syntax for `colon`

* Add two-argument colon for dimensionless quantities
* Add tests for encoding of μ

* Remove unnecessary code

* Use U+03BC everywhere

* Same changes for U+025B/U+03B5
* Delete export of `convertr`

There is no `convertr`, so don't export it.

* Don't export convertrp

It's not defined
giordano and others added 5 commits April 30, 2022 20:49
* Add `modf` for dimensionless quantities

* Add tests for `modf`

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>

Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>
Merge revised macros and dimension docstrings
modified:   docs/src/conversion.md
modified:   src/Unitfu.jl
modified:   src/pkgdefaults.jl
modified:   src/quantities.jl
modified:   src/units.jl
modified:   src/user.jl
modified:   src/utils.jl
modified:   test/runtests.jl
modified:   src/pkgdefaults.jl   Use new macros, deg rad change
modified:   test/runtests.jl     Add ConstructionBase
@codecov
Copy link

codecov bot commented Sep 1, 2022

Codecov Report

Base: 86.87% // Head: 87.27% // Increases project coverage by +0.40% 🎉

Coverage data is based on head (1763130) compared to base (ca56d72).
Patch coverage: 97.33% of modified lines in pull request are covered.

❗ Current head 1763130 differs from pull request most recent head 1043eae. Consider uploading reports for the commit 1043eae to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master       #4      +/-   ##
==========================================
+ Coverage   86.87%   87.27%   +0.40%     
==========================================
  Files          16       16              
  Lines        1516     1572      +56     
==========================================
+ Hits         1317     1372      +55     
- Misses        199      200       +1     
Impacted Files Coverage Δ
src/Unitfu.jl 100.00% <ø> (ø)
src/utils.jl 82.53% <ø> (ø)
src/pkgdefaults.jl 46.15% <94.11%> (+16.15%) ⬆️
src/quantities.jl 93.44% <95.45%> (+0.46%) ⬆️
src/units.jl 87.24% <100.00%> (ø)
src/user.jl 95.76% <100.00%> (+0.03%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@hustf hustf merged commit 2c1dbbf into master Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.