Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #811 +/- ##
=========================================
Coverage ? 88.90%
=========================================
Files ? 21
Lines ? 1722
Branches ? 0
=========================================
Hits ? 1531
Misses ? 191
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/public.julia
Outdated
There was a problem hiding this comment.
- Why
.juliaextension instead of.jl? - This file is simply unmaintainable. Adding an option to macros like
@unit/@dimension/@derived_dimensionto make the symbol public looks a much more sustainable solution going forward
There was a problem hiding this comment.
Adding an option to macros
I agree, and would look into a macro solution.
Independent on that: Before I continue, I'd prefer to know whether the the variables sorting into private and public, as currently implemented in public.julia is OK, or needs any changes.
May I ask the maintainers to have a look?
There was a problem hiding this comment.
I would declare the following as public:
- all physical constants,
- everything defined through
@dimension/@derived_dimension, AbstractQuantity,- all non-logarithmic units (most of them are defined through
@refunit/@unit, but some, likehaandÅ, will have to be treated manually). For@affineunit, adding an extra argument to the macro has less of an advantage, since it only defines one symbol, but it could be done just to be consistent with@refunit/@unit.
Those are all the symbols I would declare public right now. Others can be added later.
I’m not sure about the logarithmic units. I wouldn’t declare them public for now, since I consider them broken in a way that cannot be fixed without major (and breaking) changes, but on the other hand, they can be accesssed through u"…" and are widely used (I think).
There was a problem hiding this comment.
@sostock On log units: They are intended for the package user, not for some internal purposes. Therefore IMO they should be declared public, too. I'd suggest adding a warning to the docstrings about their experimental nature.
There was a problem hiding this comment.
Another question: @dimension returns the dimension, @unit returns the unit, whereas @derived_dimension returns nothing. If that is intended, what's the reason? Otherwise I'd change @derived_dimension to return the dimension, too
There was a problem hiding this comment.
@dimension 𝐋 "𝐋" Length true returns Unitful.𝐋 (not Unitful.Length), so if @derived_dimension Area 𝐋^2 true returned something, it should return 𝐋^2, anything else would be inconsistent. But the value 𝐋^2 is not bound to any symbol by the macro, so I can see why there is no use in returning it.
There was a problem hiding this comment.
everything defined through @dimension/@derived_dimension
Each @dimension defines four bindings, eg. for Lenth we create and declare as public
𝐋, Length, LengthUnits, LengthFreeUnits. My current macro implementation makes all them public - but I'm not sure it is what you meant, or was it just the first two of them.
There was a problem hiding this comment.
My current macro implementation makes all them public
That’s what I would do as well.
b7fd95f to
2e41dae
Compare
sostock
left a comment
There was a problem hiding this comment.
I haven’t reviewed the code yet, these comments are just about the default value of the new argument and the docstrings.
Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>
src/pkgdefaults.jl
Outdated
| \nDimension: [`Unitful.𝐌`](@ref). | ||
| \nSee Also: [`Unitful.kg`](@ref)." | ||
| @unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false # (50) | ||
| @public u |
There was a problem hiding this comment.
Is there a reason why the new macro argument isn’t used here?
There was a problem hiding this comment.
changed to use macro argument
|
I'd also suggest to declare |
| """ | ||
| end | ||
|
|
||
| VERSION >= v"1.11.0-DEV.469" && @testset "Declare Public" begin |
There was a problem hiding this comment.
The display tests above use if isdefined(Base, :ispublic) instead of VERSION >= v"1.11.0-DEV.469" to test whether public is available. They should all use the same test.
| end | ||
|
|
||
| VERSION >= v"1.11.0-DEV.469" && @testset "Declare Public" begin | ||
| all_public_vars = Symbol[ |
There was a problem hiding this comment.
In my opinion, we don’t need to test all of these. Testing every public symbol means that someone needs to maintain this list (new units get added sometimes). We just need to test that the macros work, so I would test the following:
- all symbols for one
@dimension - all symbols for one
@derived_dimension - one
@refunit(the non-prefixed unit and one SI-prefixed unit) - one
@unit(the non-prefixed unit and one SI-prefixed unit) - one
@affineunit
| esc(expr) | ||
| end | ||
|
|
||
| # TODO update example in the docstring |
There was a problem hiding this comment.
This TODO should be addressed.
| :μatm, :μb, :μbar, :μcal, :μcd, :μdyn, :μeV, :μerg, :μg, :μkat, :μl, :μlm, :μlx, :μm, :μmol, :μrad, :μs, :μsr, | ||
| :μyr, :μΩ, :σ, :ϵ0, :𝐈, :𝐉, :𝐋, :𝐌, :𝐍, :𝐓, :𝚯] | ||
|
|
||
| private_vars = Symbol[ |
There was a problem hiding this comment.
In my opinion, we don’t need to test which symbols are private. The fact that they are private means that they can change at any point, so this list would need constant maintenance. I would just remove it.
Yes, I would also declare |
|
Howdy, have there been any updates on this? Thanks all for your work here! |
|
I am busy right now on my day job: the deadline is theoretically 2026-03-01. After I am finished there, I hope to be able to continue here. |
|
Appreciate the update, no rush! |
Declaration of public symbols as requested in #749
Notes:
public.julialists non-public symbols, too. That is for maintainers to have an overview, can be removed later, of course.public.juliahas non-standard suffix because I remember having some issues with.jlsuffix in such a case. It could be CodeCov, not sure. Can be changed to.jlif desired.public.juliawas generated.testsetto check if all variables are declared in one way or another. Thistestsetis put it to the top ofruntest.jlbecause I got errors elswhere (see below).VelocityFreeUnitsaspublic(or exported, for that case) leads to failure of the "Display" testset. No idea why, but reproduced on Mac and Ubuntu. For debugging, see https://github.com/Eben60/Unitful.jl/tree/mark_public_units_debug