My man!
Very nice! @co1emi11er : just letting you know about GitHub - fkastner/NiceNumbers.jl: The nicest numbers in Julia. in case that fits your interests.
New Release: Handcalcs.jl v0.4.0
Hello all,
Here are a few updates to the latest release.
Unitful Integration
I am excited to announce Handcalcs is now integrated with Unitful.jl!
All Added Features
- Added ability to disable handcalcs when doing simulations. You can then turn it back on when you want to print results
- added a color option
- added ability to promote to certain unit using the
|>
operator (more info here) - Unitful integration should be working with Latexify v0.16.4 and UnitfulLatexify v1.6.4
Breaking Change
- now requires at least Latexify v0.16.4 and UnitfulLatexify v1.6.4
Better Documentation Structure
I updated the structure of the docs to be a little better. Please see the docs for the updates!
Very neat! If youâve done the work to support unitful, might it be an easy step to also support DynamicQuantities.jl?
(One nit: in the docs I think References
should maybe be Reference
, is a one letter change that makes a big difference to interpretation )
Does DynamicQuantities.jl have a package like UnitfulLatexify.jl? My package doesnât really handle the latexifying (since that is already what Latexify.jl does). If DynamicQuantities.jl maintainers work to get it working with Latexify properly, then it will work for handcalcs as well.
@MilesCranmer Do you know the status of DynamicQuantities.jl integration with Latexify.jl?
The main issue before was this: Issue when interpolating variables with units under an exponent. But this was fixed in Latexify v0.16.4 and UnitfulLatexify v1.6.4
Is Latexify
using package extensions yet? If not, this could be a good fit for it.
Latexify
allows you to extend it for your types by creating recipes. It was just problematic for Unitful since the recipes didnât allow for some things, but that is fixed now,. Basically any type you want to get working with latexify, you can through recipes, and as a result, it will work in Handcalcs
as well.
This would be good to have. I donât think anybody has created something like this yet. But it should be pretty easy. The entire implementation of printing is:
function Base.show(io::IO, d::AbstractDimensions)
tmp_io = IOBuffer()
for k in filter(k -> !iszero(d[k]), keys(d))
print(tmp_io, dimension_name(d, k))
isone(d[k]) || pretty_print_exponent(tmp_io, d[k])
print(tmp_io, " ")
end
s = String(take!(tmp_io))
s = replace(s, r"^\s*" => "")
s = replace(s, r"\s*$" => "")
print(io, s)
end
Base.show(io::IO, q::UnionAbstractQuantity{<:Real}) = print(io, ustrip(q), " ", dimension(q))
Base.show(io::IO, q::UnionAbstractQuantity) = print(io, "(", ustrip(q), ") ", dimension(q))
function dimension_name(::AbstractDimensions, k::Symbol)
default_dimensions = (length="m", mass="kg", time="s", current="A", temperature="K", luminosity="cd", amount="mol")
return get(default_dimensions, k, string(k))
end
dimension_name
is something that any AbstractDimensions
can overload to map to a string representing the dimensions. (By default it just takes the string representation of the symbol (which are returned by keys
))
Then the pretty_print_exponent(tmp_io, d[k])
can be replaced with print(tmp_io, "^{$(d[k])}")
.