Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Unitful.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ include("complex.jl")
include("pkgdefaults.jl")
include("dates.jl")

if VERSION >= v"1.11.0-DEV.469"
include("public.julia")
end

if !isdefined(Base, :get_extension)
include("../ext/ConstructionBaseUnitfulExt.jl")
include("../ext/InverseFunctionsUnitfulExt.jl")
Expand Down
219 changes: 219 additions & 0 deletions src/public.julia
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why .julia extension instead of .jl?
  2. This file is simply unmaintainable. Adding an option to macros like @unit/@dimension/@derived_dimension to make the symbol public looks a much more sustainable solution going forward

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, like ha and Å, 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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sostock

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My current macro implementation makes all them public

That’s what I would do as well.

Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@

# underline prepended names
"""
_Quantity, _affineerror, _basefactors, _colon, _convfact_floattype, _dimerr, _fma,
_gconv, _isapprox, _isless, _le, _lt, _muladd, _offset_for_steprangelen,
_promote_unit, _rounderr, _unitful_start_step_length, _unitful_start_stop,
_unitful_start_stop_length, _unitful_step_stop_length
"""

# module names
"""
DefaultSymbols
"""

# Base names
"""
GC, TP, _colon, cd, cot, csc, eval, include, sec, slug, ≤
"""

# private fns
"""
abbr, abs2_fast, abs_fast, affinetranslation, affineunit, base, basefactor,
basefactors_expr, colon, colonstartstop, conj_fast, convfact, convfact_floattype,
dimtype, expfn, fp_overflow_underflow, fromlog, gaintype, genericunit, get_T,
has_unit_spacing, inv_fast, isrootpower, isrootpower_dim, isunitless, leveltype,
logfn, lookup_units, name, numtype, power, prefactor, preferunits, prefix,
print_closing_bracket, print_opening_bracket, printed_length, promote_to_derived,
promote_unit, quantitytype, register, showrep, showval, sign_fast, sortexp,
superscript, tens, tensfactor, tolog, try_uconvert, uconvert_affine, unwrap,
ustrcheck_bool
"""

# nodims units
public deg, pcm, percent, permille, pertenthousand, ppb, ppm, ppq, ppt, rad, sr, °

# phys constants
public G, Na, R, R∞, Z0, c0, gn, h, k, me, mn, mp, q, ħ, Φ0, ε0, μ0, μB, σ, ϵ0

# basic dims
public Amount, Current, Length, Luminosity, Mass, Temperature, Time

# compound dims
public Acceleration, Action, Area, BField, Capacitance, Charge, DField, Density,
DynamicViscosity, EField, ElectricDipoleMoment, ElectricQuadrupoleMoment,
ElectricalConductance, ElectricalConductivity, ElectricalResistance,
ElectricalResistivity, Energy, Force, Frequency, HField, Inductance,
KinematicViscosity, MagneticDipoleMoment, MagneticFlux, MassFlow, Molality,
MolarFlow, MolarMass, Molarity, Momentum, Power, Pressure, Velocity, Voltage, Volume,
VolumeFlow, Wavenumber

# unit names
public A, Ba, Bq, C, EA, EBa, EBq, EC, EF, EGal, EGauss, EGy, EH, EHz, EHz2π, EJ, EK, EL,
EM, EMx, EN, EOe, EP, EPa, ES, ESt, ESv, ET, ETorr, EV, EW, EWb, Eatm, Eb, Ebar,
Ecal, Ecd, Edyn, EeV, Eerg, Eg, Ekat, El, Elm, Elx, Em, Emol, Erad, Es, Esr, Eyr, EΩ,
F, GA, GBa, GBq, GF, GGal, GGauss, GGy, GH, GHz, GHz2π, GJ, GK, GL, GM, GMx, GN, GOe,
GP, GPa, GS, GSt, GSv, GT, GTorr, GV, GW, GWb, Gal, Gatm, Gauss, Gb, Gbar, Gcal, Gcd,
Gdyn, GeV, Gerg, Gg, Gkat, Gl, Glm, Glx, Gm, Gmol, Grad, Gs, Gsr, Gy, Gyr, GΩ, H, Hz,
Hz2π, J, K, L, M, MA, MBa, MBq, MC, MF, MGal, MGauss, MGy, MH, MHz, MHz2π, MJ, MK,
ML, MM, MMx, MN, MOe, MP, MPa, MS, MSt, MSv, MT, MTorr, MV, MW, MWb, Matm, Mb, Mbar,
Mcal, Mcd, Mdyn, MeV, Merg, Mg, Mkat, Ml, Mlm, Mlx, Mm, Mmol, Mrad, Ms, Msr, Mx, Myr,
MΩ, N, Oe, P, PA, PBa, PBq, PC, PF, PGal, PGauss, PGy, PH, PHz, PHz2π, PJ, PK, PL,
PM, PMx, PN, POe, PP, PPa, PS, PSt, PSv, PT, PTorr, PV, PW, PWb, Pa, Patm, Pb, Pbar,
Pcal, Pcd, Pdyn, PeV, Perg, Pg, Pkat, Pl, Plm, Plx, Pm, Pmol, Prad, Ps, Psr, Pyr, PΩ,
Ra, S, St, Sv, T, TA, TBa, TBq, TC, TF, TGal, TGauss, TGy, TH, THz, THz2π, TJ, TK,
TL, TM, TMx, TN, TOe, TPa, TS, TSt, TSv, TT, TTorr, TV, TW, TWb, Tatm, Tb, Tbar,
Tcal, Tcd, Tdyn, TeV, Terg, Tg, Tkat, Tl, Tlm, Tlx, Tm, Tmol, Torr, Trad, Ts, Tsr,
Tyr, TΩ, V, W, Wb, YA, YBa, YBq, YC, YF, YGal, YGauss, YGy, YH, YHz, YHz2π, YJ, YK,
YL, YM, YMx, YN, YOe, YP, YPa, YS, YSt, YSv, YT, YTorr, YV, YW, YWb, Yatm, Yb, Ybar,
Ycal, Ycd, Ydyn, YeV, Yerg, Yg, Ykat, Yl, Ylm, Ylx, Ym, Ymol, Yrad, Ys, Ysr, Yyr, YΩ,
ZA, ZBa, ZBq, ZC, ZF, ZGal, ZGauss, ZGy, ZH, ZHz, ZHz2π, ZJ, ZK, ZL, ZM, ZMx, ZN,
ZOe, ZP, ZPa, ZS, ZSt, ZSv, ZT, ZTorr, ZV, ZW, ZWb, Zatm, Zb, Zbar, Zcal, Zcd, Zdyn,
ZeV, Zerg, Zg, Zkat, Zl, Zlm, Zlx, Zm, Zmol, Zrad, Zs, Zsr, Zyr, ZΩ, a, aA, aBa, aBq,
aC, aF, aGal, aGauss, aGy, aH, aHz, aHz2π, aJ, aK, aL, aM, aMx, aN, aOe, aP, aPa, aS,
aSt, aSv, aT, aTorr, aV, aW, aWb, aatm, ab, abar, ac, acal, acd, adyn, aeV, aerg, ag,
akat, al, alm, alx, am, amol, angstrom, arad, as, asr, atm, ayr, aΩ, b, bar, btu, c,
cA, cBa, cBq, cC, cF, cGal, cGauss, cGy, cH, cHz, cHz2π, cJ, cK, cL, cM, cMx, cN,
cOe, cP, cPa, cS, cSt, cSv, cT, cTorr, cV, cW, cWb, cal, catm, cb, cbar, ccal, ccd,
cdyn, ceV, cerg, cg, ckat, cl, clm, clx, cm, cmol, crad, cs, csr, cyr, cΩ, d, dA,
dBa, dBq, dC, dF, dGal, dGauss, dGy, dH, dHz, dHz2π, dJ, dK, dL, dM, dMx, dN, dOe,
dP, dPa, dS, dSt, dSv, dT, dTorr, dV, dW, dWb, daA, daBa, daBq, daC, daF, daGal,
daGauss, daGy, daH, daHz, daHz2π, daJ, daK, daL, daM, daMx, daN, daOe, daP, daPa,
daS, daSt, daSv, daT, daTorr, daV, daW, daWb, daatm, dab, dabar, dacal, dacd, dadyn,
daeV, daerg, dag, dakat, dal, dalm, dalx, dam, damol, darad, das, dasr, datm, dayr,
daΩ, db, dbar, dcal, dcd, ddyn, deV, derg, dg, dkat, dl, dlm, dlx, dm, dmol, dr,
drad, ds, dsr, dyn, dyr, dΩ, eV, erg, fA, fBa, fBq, fC, fF, fGal, fGauss, fGy, fH,
fHz, fHz2π, fJ, fK, fL, fM, fMx, fN, fOe, fP, fPa, fS, fSt, fSv, fT, fTorr, fV, fW,
fWb, fatm, fb, fbar, fcal, fcd, fdyn, feV, ferg, fg, fkat, fl, flm, flx, fm, fmol,
frad, fs, fsr, ft, fyr, fΩ, g, ge, gr, hA, hBa, hBq, hC, hF, hGal, hGauss, hGy, hH,
hHz, hHz2π, hJ, hK, hL, hM, hMx, hN, hOe, hP, hPa, hS, hSt, hSv, hT, hTorr, hV, hW,
hWb, ha, hatm, hb, hbar, hcal, hcd, hdyn, heV, herg, hg, hkat, hl, hlm, hlx, hm,
hmol, hr, hrad, hs, hsr, hyr, hΩ, inch, kA, kBa, kBq, kC, kF, kGal, kGauss, kGy, kH,
kHz, kHz2π, kJ, kK, kL, kM, kMx, kN, kOe, kP, kPa, kS, kSt, kSv, kT, kTorr, kV, kW,
kWb, kat, katm, kb, kbar, kcal, kcd, kdyn, keV, kerg, kg, kkat, kl, klm, klx, km,
kmol, krad, ks, ksr, kyr, kΩ, l, lb, lbf, lm, lx, m, mA, mBa, mBq, mC, mF, mGal,
mGauss, mGy, mH, mHz, mHz2π, mJ, mK, mL, mM, mMx, mN, mOe, mP, mPa, mS, mSt, mSv, mT,
mTorr, mV, mW, mWb, matm, mb, mbar, mcal, mcd, mdyn, meV, merg, mg, mi, mil, minute,
mkat, ml, mlm, mlx, mm, mmol, mol, mrad, ms, msr, myr, mΩ, nA, nBa, nBq, nC, nF,
nGal, nGauss, nGy, nH, nHz, nHz2π, nJ, nK, nL, nM, nMx, nN, nOe, nP, nPa, nS, nSt,
nSv, nT, nTorr, nV, nW, nWb, natm, nb, nbar, ncal, ncd, ndyn, neV, nerg, ng, nkat,
nl, nlm, nlx, nm, nmol, nrad, ns, nsr, nyr, nΩ, oz, pA, pBa, pBq, pC, pF, pGal,
pGauss, pGy, pH, pHz, pHz2π, pJ, pK, pL, pM, pMx, pN, pOe, pP, pPa, pS, pSt, pSv, pT,
pTorr, pV, pW, pWb, patm, pb, pbar, pcal, pcd, pdyn, peV, perg, pg, pkat, pl, plm,
plx, pm, pmol, prad, ps, psi, psr, pyr, pΩ, rpm, rps, s, u, wk, yA, yBa, yBq, yC, yF,
yGal, yGauss, yGy, yH, yHz, yHz2π, yJ, yK, yL, yM, yMx, yN, yOe, yP, yPa, yS, ySt,
ySv, yT, yTorr, yV, yW, yWb, yatm, yb, ybar, ycal, ycd, yd, ydyn, yeV, yerg, yg,
ykat, yl, ylm, ylx, ym, ymol, yr, yrad, ys, ysr, yyr, yΩ, zA, zBa, zBq, zC, zF, zGal,
zGauss, zGy, zH, zHz, zHz2π, zJ, zK, zL, zM, zMx, zN, zOe, zP, zPa, zS, zSt, zSv, zT,
zTorr, zV, zW, zWb, zatm, zb, zbar, zcal, zcd, zdyn, zeV, zerg, zg, zkat, zl, zlm,
zlx, zm, zmol, zrad, zs, zsr, zyr, zΩ, °C, °F, Å, Ω, μA, μBa, μBq, μC, μF, μGal,
μGauss, μGy, μH, μHz, μHz2π, μJ, μK, μL, μM, μMx, μN, μOe, μP, μPa, μS, μSt, μSv, μT,
μTorr, μV, μW, μWb, μatm, μb, μbar, μcal, μcd, μdyn, μeV, μerg, μg, μkat, μl, μlm,
μlx, μm, μmol, μrad, μs, μsr, μyr, μΩ

# basic units
public amol, cmol, damol, dmol, Emol, fmol, Gmol, hmol, kmol, Mmol, mmol, mol, nmol,
Pmol, pmol, Tmol, Ymol, ymol, Zmol, zmol, μmol, A, aA, cA, dA, daA, EA, fA, GA, hA,
kA, MA, mA, nA, PA, pA, TA, YA, yA, ZA, zA, μA, am, angstrom, cm, dam, dm, Em, fm,
ft, Gm, hm, inch, km, m, mi, mil, Mm, mm, nm, Pm, pm, Tm, yd, Ym, ym, Zm, zm, Å, μm,
acd, alm, ccd, cd, clm, dacd, dalm, dcd, dlm, Ecd, Elm, fcd, flm, Gcd, Glm, hcd, hlm,
kcd, klm, lm, Mcd, mcd, Mlm, mlm, ncd, nlm, Pcd, pcd, Plm, plm, Tcd, Tlm, Ycd, ycd,
Ylm, ylm, Zcd, zcd, Zlm, zlm, μcd, μlm, ag, cg, dag, dg, dr, Eg, fg, g, Gg, gr, hg,
kg, lb, Mg, mg, ng, oz, Pg, pg, slug, Tg, u, Yg, yg, Zg, zg, μg, aK, cK, daK, dK, EK,
fK, GK, hK, K, kK, MK, mK, nK, PK, pK, Ra, TK, YK, yK, ZK, zK, °C, °F, μK, as, ayr,
cs, cyr, d, das, dayr, ds, dyr, Es, Eyr, fs, fyr, Gs, Gyr, hr, hs, hyr, ks, kyr,
minute, Ms, ms, Myr, myr, ns, nyr, Ps, ps, Pyr, pyr, s, Ts, Tyr, wk, yr, Ys, ys, Yyr,
yyr, Zs, zs, Zyr, zyr, μs, μyr

# compound units
public aGal, cGal, daGal, dGal, EGal, fGal, Gal, ge, GGal, hGal, kGal, MGal, mGal, nGal,
PGal, pGal, TGal, YGal, yGal, ZGal, zGal, μGal, a, ab, ac, b, cb, dab, db, Eb, fb,
Gb, ha, hb, kb, Mb, mb, nb, Pb, pb, Tb, Yb, yb, Zb, zb, μb, aGauss, aT, cGauss, cT,
daGauss, daT, dGauss, dT, EGauss, ET, fGauss, fT, Gauss, GGauss, GT, hGauss, hT,
kGauss, kT, MGauss, mGauss, MT, mT, nGauss, nT, PGauss, pGauss, PT, pT, T, TGauss,
TT, YGauss, yGauss, YT, yT, ZGauss, zGauss, ZT, zT, μGauss, μT, aF, cF, daF, dF, EF,
F, fF, GF, hF, kF, MF, mF, nF, PF, pF, TF, YF, yF, ZF, zF, μF, aC, C, cC, daC, dC,
EC, fC, GC, hC, kC, MC, mC, nC, PC, pC, TC, YC, yC, ZC, zC, μC, aP, cP, daP, dP, EP,
fP, GP, hP, kP, MP, mP, nP, P, PP, pP, TP, YP, yP, ZP, zP, μP, aS, cS, daS, dS, ES,
fS, GS, hS, kS, MS, mS, nS, PS, pS, S, TS, YS, yS, ZS, zS, μS, aΩ, cΩ, daΩ, dΩ, EΩ,
fΩ, GΩ, hΩ, kΩ, MΩ, mΩ, nΩ, PΩ, pΩ, TΩ, YΩ, yΩ, ZΩ, zΩ, μΩ, Ω, acal, aerg, aeV, aJ,
btu, cal, ccal, cerg, ceV, cJ, dacal, daerg, daeV, daJ, dcal, derg, deV, dJ, Ecal,
Eerg, EeV, EJ, erg, eV, fcal, ferg, feV, fJ, Gcal, Gerg, GeV, GJ, hcal, herg, heV,
hJ, J, kcal, kerg, keV, kJ, Mcal, mcal, Merg, merg, MeV, meV, MJ, mJ, ncal, nerg,
neV, nJ, Pcal, pcal, Perg, perg, PeV, peV, PJ, pJ, Tcal, Terg, TeV, TJ, Ycal, ycal,
Yerg, yerg, YeV, yeV, YJ, yJ, Zcal, zcal, Zerg, zerg, ZeV, zeV, ZJ, zJ, μcal, μerg,
μeV, μJ, adyn, aN, cdyn, cN, dadyn, daN, ddyn, dN, dyn, Edyn, EN, fdyn, fN, Gdyn, GN,
hdyn, hN, kdyn, kN, lbf, Mdyn, mdyn, MN, mN, N, ndyn, nN, Pdyn, pdyn, PN, pN, Tdyn,
TN, Ydyn, ydyn, YN, yN, Zdyn, zdyn, ZN, zN, μdyn, μN, aBq, aHz, aHz2π, Bq, cBq, cHz,
cHz2π, daBq, daHz, daHz2π, dBq, dHz, dHz2π, EBq, EHz, EHz2π, fBq, fHz, fHz2π, GBq,
GHz, GHz2π, hBq, hHz, hHz2π, Hz, Hz2π, kBq, kHz, kHz2π, MBq, mBq, MHz, mHz, MHz2π,
mHz2π, nBq, nHz, nHz2π, PBq, pBq, PHz, pHz, PHz2π, pHz2π, rpm, rps, TBq, THz, THz2π,
YBq, yBq, YHz, yHz, YHz2π, yHz2π, ZBq, zBq, ZHz, zHz, ZHz2π, zHz2π, μBq, μHz, μHz2π,
aOe, cOe, daOe, dOe, EOe, fOe, GOe, hOe, kOe, MOe, mOe, nOe, Oe, POe, pOe, TOe, YOe,
yOe, ZOe, zOe, μOe, aH, cH, daH, dH, EH, fH, GH, H, hH, kH, MH, mH, nH, PH, pH, TH,
YH, yH, ZH, zH, μH, aSt, cSt, daSt, dSt, ESt, fSt, GSt, hSt, kSt, MSt, mSt, nSt, PSt,
pSt, St, TSt, YSt, ySt, ZSt, zSt, μSt, aMx, aWb, cMx, cWb, daMx, daWb, dMx, dWb, EMx,
EWb, fMx, fWb, GMx, GWb, hMx, hWb, kMx, kWb, MMx, mMx, MWb, mWb, Mx, nMx, nWb, PMx,
pMx, PWb, pWb, TMx, TWb, Wb, YMx, yMx, YWb, yWb, ZMx, zMx, ZWb, zWb, μMx, μWb, akat,
ckat, dakat, dkat, Ekat, fkat, Gkat, hkat, kat, kkat, Mkat, mkat, nkat, Pkat, pkat,
Tkat, Ykat, ykat, Zkat, zkat, μkat, aM, cM, daM, dM, EM, fM, GM, hM, kM, M, MM, mM,
nM, PM, pM, TM, YM, yM, ZM, zM, μM, aW, cW, daW, dW, EW, fW, GW, hW, kW, MW, mW, nW,
PW, pW, TW, W, YW, yW, ZW, zW, μW, aatm, aBa, abar, aPa, atm, aTorr, Ba, bar, catm,
cBa, cbar, cPa, cTorr, daatm, daBa, dabar, daPa, datm, daTorr, dBa, dbar, dPa, dTorr,
Eatm, EBa, Ebar, EPa, ETorr, fatm, fBa, fbar, fPa, fTorr, Gatm, GBa, Gbar, GPa,
GTorr, hatm, hBa, hbar, hPa, hTorr, katm, kBa, kbar, kPa, kTorr, Matm, matm, MBa,
mBa, Mbar, mbar, MPa, mPa, MTorr, mTorr, natm, nBa, nbar, nPa, nTorr, Pa, Patm, patm,
PBa, pBa, Pbar, pbar, PPa, pPa, psi, PTorr, pTorr, Tatm, TBa, Tbar, Torr, TPa, TTorr,
Yatm, yatm, YBa, yBa, Ybar, ybar, YPa, yPa, YTorr, yTorr, Zatm, zatm, ZBa, zBa, Zbar,
zbar, ZPa, zPa, ZTorr, zTorr, μatm, μBa, μbar, μPa, μTorr, c, aV, cV, daV, dV, EV,
fV, GV, hV, kV, MV, mV, nV, PV, pV, TV, V, YV, yV, ZV, zV, μV, aL, al, cL, cl, daL,
dal, dL, dl, EL, El, fL, fl, GL, Gl, hL, hl, kL, kl, L, l, ML, Ml, mL, ml, nL, nl,
PL, Pl, pL, pl, TL, Tl, YL, Yl, yL, yl, ZL, Zl, zL, zl, μL, μl

# dim abbreviations
public 𝐈, 𝐉, 𝐋, 𝐌, 𝐍, 𝐓, 𝚯

# quantities
public AbsoluteScaleTemperature, RelativeScaleTemperature

# unit types
public AccelerationFreeUnits, AccelerationUnits, ActionFreeUnits, ActionUnits,
AffineUnits, AmountFreeUnits, AmountUnits, AreaFreeUnits, AreaUnits, BFieldFreeUnits,
BFieldUnits, CapacitanceFreeUnits, CapacitanceUnits, ChargeFreeUnits, ChargeUnits,
ContextUnits, CurrentFreeUnits, CurrentUnits, DFieldFreeUnits, DFieldUnits,
DensityFreeUnits, DensityUnits, DimensionlessUnits, DynamicViscosityFreeUnits,
DynamicViscosityUnits, EFieldFreeUnits, EFieldUnits, ElectricDipoleMomentFreeUnits,
ElectricDipoleMomentUnits, ElectricQuadrupoleMomentFreeUnits,
ElectricQuadrupoleMomentUnits, ElectricalConductanceFreeUnits,
ElectricalConductanceUnits, ElectricalConductivityFreeUnits,
ElectricalConductivityUnits, ElectricalResistanceFreeUnits,
ElectricalResistanceUnits, ElectricalResistivityFreeUnits,
ElectricalResistivityUnits, EnergyFreeUnits, EnergyUnits, FixedUnits, ForceFreeUnits,
ForceUnits, FreeOrContextUnits, FreeUnits, FrequencyFreeUnits, FrequencyUnits,
HFieldFreeUnits, HFieldUnits, InductanceFreeUnits, InductanceUnits,
KinematicViscosityFreeUnits, KinematicViscosityUnits, LengthFreeUnits, LengthUnits,
LuminosityFreeUnits, LuminosityUnits, MagneticDipoleMomentFreeUnits,
MagneticDipoleMomentUnits, MagneticFluxFreeUnits, MagneticFluxUnits,
MassFlowFreeUnits, MassFlowUnits, MassFreeUnits, MassUnits, MolalityFreeUnits,
MolalityUnits, MolarFlowFreeUnits, MolarFlowUnits, MolarMassFreeUnits,
MolarMassUnits, MolarityFreeUnits, MolarityUnits, MomentumFreeUnits, MomentumUnits,
PowerFreeUnits, PowerUnits, PressureFreeUnits, PressureUnits, ScalarUnits,
TemperatureFreeUnits, TemperatureUnits, TimeFreeUnits, TimeUnits, Units,
VelocityFreeUnits,
VelocityUnits, VoltageFreeUnits, VoltageUnits,
VolumeFlowFreeUnits, VolumeFlowUnits, VolumeFreeUnits, VolumeUnits,
WavenumberFreeUnits, WavenumberUnits

# log units
public B, B_p, B_rp, Np, Np_p, Np_rp, cNp, cNp_p, cNp_rp, dB, dBFS, dBHz, dBS, dBSPL,
dBV, dB_p, dB_rp, dBm, dBu, dBΩ, dBμV

# abstract types
public AbstractQuantity, AffineQuantity, BracketStyle, LogScaled, ScalarQuantity,
Unitlike

# concrete types
public Affine, AffineError, Bel, Centineper, Decibel, Dimension, DimensionError,
Dimensions, IsRootPowerRatio, LogInfo, MixedUnits, Neper, NoBrackets, PowerRatio,
RealOrRealQuantity, ReferenceQuantity, RootPowerRatio, RoundBrackets, SquareBrackets,
Unit
25 changes: 25 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,29 @@ end

is_finite_nonzero(x) = isfinite(x) && !iszero(x)

VERSION >= v"1.11.0-DEV.469" && @testset "public variables" begin
module_names = [:DefaultSymbols]
private_vars = [:BCAST_PROPAGATE_CALLS, :allowed_funcs, :basefactors, :prefixdict, :promotion, :si_no_prefix, :si_prefixes, :unitmodules]
private_fns = [:abbr, :abs2_fast, :abs_fast, :affinetranslation, :affineunit, :base, :basefactor, :basefactors_expr, :colon,
:colonstartstop, :conj_fast, :convfact, :convfact_floattype, :dimtype, :expfn, :fp_overflow_underflow, :fromlog,
:gaintype, :genericunit, :get_T, :has_unit_spacing, :inv_fast, :isrootpower, :isrootpower_dim, :isunitless, :leveltype,
:logfn, :lookup_units, :name, :numtype, :power, :prefactor, :preferunits, :prefix, :print_closing_bracket,
:print_opening_bracket, :printed_length, :promote_to_derived, :promote_unit, :quantitytype, :register, :showrep, :showval,
:sign_fast, :sortexp, :superscript, :tens, :tensfactor, :tolog, :try_uconvert, :uconvert_affine, :unwrap, :ustrcheck_bool]

_basenames = names(Base; all=true)
unitful_ids = filter(x -> !startswith(string(x), r"#|@"), names(Unitful; all=true))
base_overloaded_names = filter(x -> x in _basenames, unitful_ids)
undescored_names = filter(x -> startswith(string(x), "_"), unitful_ids)
private_names = vcat(module_names, private_fns, private_vars, undescored_names)
exported_names = filter(x -> Base.isexported(Unitful, x), unitful_ids)
public_names = filter(x -> Base.ispublic(Unitful, x), unitful_ids)
other_names = setdiff(unitful_ids, union(private_names, exported_names, base_overloaded_names, public_names))
isempty(other_names) ||
@warn """For variables in $(other_names): declare as public or exported, or prepend underscore, or add to a private variables list in testset "public variables" """

@test isempty(other_names)
end
@testset "Construction" begin
@test isa(NoUnits, FreeUnits)
@test typeof(𝐋) === Unitful.Dimensions{(Unitful.Dimension{:Length}(1),)}
Expand Down Expand Up @@ -2547,6 +2570,8 @@ using REPL # This is necessary to make `@doc` work correctly
"""
end



# Test precompiled Unitful extension modules
mktempdir() do load_path
mktempdir() do load_cache_path
Expand Down
Loading