From ec8669e959bedc079b444427e9c30c1a861523a8 Mon Sep 17 00:00:00 2001 From: Ben Elkin <8xe8n-cm@online.de> Date: Sat, 13 Sep 2025 20:44:20 +0200 Subject: [PATCH 1/8] add declaration of public variables --- src/Unitful.jl | 4 + src/public.julia | 218 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 src/public.julia diff --git a/src/Unitful.jl b/src/Unitful.jl index 4e65ebce..3c8c1dc3 100644 --- a/src/Unitful.jl +++ b/src/Unitful.jl @@ -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") diff --git a/src/public.julia b/src/public.julia new file mode 100644 index 00000000..bc475ae3 --- /dev/null +++ b/src/public.julia @@ -0,0 +1,218 @@ + +# 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 From 6cde5e4d5f3de2761477547c61bc2b37fa9810cb Mon Sep 17 00:00:00 2001 From: Ben Elkin <8xe8n-cm@online.de> Date: Sat, 13 Sep 2025 21:55:53 +0200 Subject: [PATCH 2/8] check if variables declared as public/exported, or listed as private --- src/public.julia | 3 ++- test/runtests.jl | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/public.julia b/src/public.julia index bc475ae3..5b35bf75 100644 --- a/src/public.julia +++ b/src/public.julia @@ -199,7 +199,8 @@ public AccelerationFreeUnits, AccelerationUnits, ActionFreeUnits, ActionUnits, MolarMassUnits, MolarityFreeUnits, MolarityUnits, MomentumFreeUnits, MomentumUnits, PowerFreeUnits, PowerUnits, PressureFreeUnits, PressureUnits, ScalarUnits, TemperatureFreeUnits, TemperatureUnits, TimeFreeUnits, TimeUnits, Units, - VelocityFreeUnits, VelocityUnits, VoltageFreeUnits, VoltageUnits, + VelocityFreeUnits, + VelocityUnits, VoltageFreeUnits, VoltageUnits, VolumeFlowFreeUnits, VolumeFlowUnits, VolumeFreeUnits, VolumeUnits, WavenumberFreeUnits, WavenumberUnits diff --git a/test/runtests.jl b/test/runtests.jl index c0e560f3..1c2a7fa5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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),)} @@ -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 From 2e41dae729b6813e0dda7a9c06f1b762ac9736a8 Mon Sep 17 00:00:00 2001 From: Ben Elkin <8xe8n-cm@online.de> Date: Mon, 22 Sep 2025 23:01:03 +0200 Subject: [PATCH 3/8] declare public names via macros --- src/Unitful.jl | 4 +- src/pkgdefaults.jl | 104 +++++++++++++-------- src/public.julia | 219 --------------------------------------------- src/user.jl | 91 ++++++++++++------- src/utils.jl | 18 ++++ test/runtests.jl | 38 +++----- 6 files changed, 156 insertions(+), 318 deletions(-) delete mode 100644 src/public.julia diff --git a/src/Unitful.jl b/src/Unitful.jl index 3c8c1dc3..dbab6b2d 100644 --- a/src/Unitful.jl +++ b/src/Unitful.jl @@ -69,9 +69,7 @@ include("complex.jl") include("pkgdefaults.jl") include("dates.jl") -if VERSION >= v"1.11.0-DEV.469" - include("public.julia") -end +@public AbstractQuantity if !isdefined(Base, :get_extension) include("../ext/ConstructionBaseUnitfulExt.jl") diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 352fed1f..431c6733 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -89,7 +89,7 @@ const AbsoluteScaleTemperature = Quantity{T, 𝚯, <:ScalarUnits} where T \nDimension: [`Unitful.𝐉`](@ref)." @refunit cd "cd" Candela 𝐉 true true # the docs for all gram-based units are defined later, to ensure kg is the base unit. -@refunit g "g" Gram 𝐌 true +@refunit g "g" Gram 𝐌 true false true " Unitful.mol \nThe mole, the SI base unit for amount of substance. \nDimension: [`Unitful.𝐍`](@ref)." @@ -108,7 +108,8 @@ const AbsoluteScaleTemperature = Quantity{T, 𝚯, <:ScalarUnits} where T Unitful.deg \nThe degree, a unit of angle. There are 360° in a circle. \nDimension: [`Unitful.NoDims`](@ref)." -((@unit ° "°" Degree pi/180 false), const deg = °) +((@unit ° "°" Degree pi/180 false false true), const deg = °) +@public deg # For numerical accuracy, specific to the degree import Base: sind, cosd, sincosd, tand, secd, cscd, cotd for (_x,_y) in ((:sin,:sind), (:cos,:cosd), (:sincos,:sincosd), (:tan,:tand), @@ -228,35 +229,35 @@ substrate per s. " Unitful.percent \nPercent, a unit meaning parts per hundred. Printed as \"%\". \nDimension: [`Unitful.NoDims`](@ref)." -@unit percent "%" Percent 1//100 false +@unit percent "%" Percent 1//100 false false true " Unitful.permille \nPermille, a unit meaning parts per thousand. Printed as \"‰\". \nDimension: [`Unitful.NoDims`](@ref)." -@unit permille "‰" Permille 1//1000 false +@unit permille "‰" Permille 1//1000 false false true " Unitful.pertenthousand \nPermyriad, a unit meaning parts per ten thousand. Printed as \"‱\". \nDimension: [`Unitful.NoDims`](@ref)." -@unit pertenthousand "‱" Pertenthousand 1//10000 false +@unit pertenthousand "‱" Pertenthousand 1//10000 false false true " Unitful.pcm \nPercentmille, a unit meaning parts per hundred thousand. \nDimension: [`Unitful.NoDims`](@ref)." -@unit pcm "pcm" Percentmille 1//100000 false +@unit pcm "pcm" Percentmille 1//100000 false false true " Unitful.ppm \nPermillion, a unit meaning parts per million. \nDimension: [`Unitful.NoDims`](@ref)." -@unit ppm "ppm" Permillion 1//1000000 false +@unit ppm "ppm" Permillion 1//1000000 false false true " Unitful.ppb \nPerbillion, a unit meaning parts per billion (in the short-scale sense), i.e., 10^-9. \nDimension: [`Unitful.NoDims`](@ref)." -@unit ppb "ppb" Perbillion 1//1000000000 false +@unit ppb "ppb" Perbillion 1//1000000000 false false true " Unitful.ppt \nPertrillion, a unit meaning parts per trillion (in the short-scale sense), i.e., 10^-12. \nDimension: [`Unitful.NoDims`](@ref)." -@unit ppt "ppt" Pertrillion 1//1000000000000 false +@unit ppt "ppt" Pertrillion 1//1000000000000 false false true " Unitful.ppq \nPerquadrillion, a unit meaning parts per quadrillion (in the short-scale sense), i.e., 10^-15. \nDimension: [`Unitful.NoDims`](@ref)." -@unit ppq "ppq" Perquadrillion 1//1000000000000000 false +@unit ppq "ppq" Perquadrillion 1//1000000000000000 false false true # Temperature " Unitful.°C @@ -271,22 +272,22 @@ substrate per s. to avoid confusion with the Julia function `min`. \nDimension: [`Unitful.𝐓`](@ref). \nSee Also: [`Unitful.s`](@ref)." -@unit minute "minute" Minute 60s false +@unit minute "minute" Minute 60s false false true " Unitful.hr \nThe hour, a unit of time defined as 60 minutes. \nDimension: [`Unitful.𝐓`](@ref). \nSee Also: [`Unitful.minute`](@ref)." -@unit hr "hr" Hour 3600s false +@unit hr "hr" Hour 3600s false false true " Unitful.d \nThe day, a unit of time defined as 24 hr. \nDimension: [`Unitful.𝐓`](@ref). \nSee Also: [`Unitful.hr`](@ref)." -@unit d "d" Day 86400s false +@unit d "d" Day 86400s false false true " Unitful.wk \nThe week, a unit of time, defined as 7 d. \nDimension: [`Unitful.𝐓`](@ref). \nSee Also: [`Unitful.d`](@ref)." -@unit wk "wk" Week 604800s false +@unit wk "wk" Week 604800s false false true " Unitful.yr \nThe year, a unit of time, defined as 365.25 d. \nDimension: [`Unitful.𝐓`](@ref). @@ -296,12 +297,12 @@ to avoid confusion with the Julia function `min`. \nRevolutions per second, a unit of rotational speed, defined as 2π rad / s. \nDimension: 𝐓^-1. \nSee Also: [`Unitful.rad`](@ref), [`Unitful.s`](@ref)." -@unit rps "rps" RevolutionsPerSecond 2π*rad/s false +@unit rps "rps" RevolutionsPerSecond 2π*rad/s false false true " Unitful.rpm \nRevolutions per minute, a unit of rotational speed, defined as 2π rad / minute. \nDimension: 𝐓^-1. \nSee Also: [`Unitful.minute`](@ref), [`Unitful.rad`](@ref)." -@unit rpm "rpm" RevolutionsPerMinute 2π*rad/minute false +@unit rpm "rpm" RevolutionsPerMinute 2π*rad/minute false false true # Area # The hectare is used more frequently than any other power-of-ten of an are. @@ -309,12 +310,13 @@ to avoid confusion with the Julia function `min`. \nThe are, a metric unit of area, defined as 100 m^2. \nDimension: 𝐋^2. \nSee Also: [`Unitful.m`](@ref)." -@unit a "a" Are 100m^2 false +@unit a "a" Are 100m^2 false false true " Unitful.ha \nThe hectare, a metric unit of area, defined as 100 a. \nDimension: 𝐋^2. \nSee Also: [`Unitful.a`](@ref)." const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, 𝐋^2}(2, 1//1),), 𝐋^2}() +@public ha " Unitful.b \nThe barn, a metric unit of area, defined as 100 fm^2. \nDimension: 𝐋^2. @@ -328,7 +330,8 @@ const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, 𝐋^2}(2, 1//1),), 𝐋^2}() \nThe liter, a metric unit of volume, defined as 1000 cm^3. \nDimension: 𝐋^3. \nSee Also: [`Unitful.cm`](@ref)." -((@unit L "L" Liter m^3//1000 true), const l = L) +((@unit L "L" Liter m^3//1000 true false true), const l = L) +@public l for (k,v) in prefixdict if k != 0 sym_L = Symbol(v,:L) @@ -343,7 +346,13 @@ for (k,v) in prefixdict See also: [`Unitful.L`](@ref). """ - run = quote @doc $docstring ((const $sym_l = $sym_L), $sym_L) end + expr1 = quote @doc $docstring ((const $sym_l = $sym_L), $sym_L) end + if VERSION >= v"1.11.0-DEV.469" + expr2 = Expr(:public, sym_L, sym_l) + run = Expr(:block, expr1, expr2, nothing) + else + run = Expr(:block, expr1, nothing) + end eval(run) end end @@ -363,6 +372,7 @@ confusion with Euler's number. \nDimension: 𝐈 𝐓. \nSee Also: [`Unitful.C`](@ref)." const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... +@public q " Unitful.eV \nThe electron-volt, a unit of energy, defined as q*V. \nDimension: 𝐋^2 𝐌 𝐓^-2. @@ -399,35 +409,40 @@ const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... \nDimension: 𝐋 𝐓^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const c0 = 299_792_458*m/s # exact +@public c0 " Unitful.c \nThe speed of light in a vacuum, a unit of speed, defined as exactly 2.997,924,58 × 10^8 m/s. \n[`Unitful.c0`](@ref) is a quantity (with units `m/s`) whereas `Unitful.c` is a unit equal to `c0`. \nDimension: 𝐋 𝐓^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit c "c" SpeedOfLight 1c0 false +@unit c "c" SpeedOfLight 1c0 false false true " Unitful.μ0 \nA quantity representing the vacuum permeability constant, defined as 4π × 10^-7 H / m. \nDimension: 𝐋 𝐌 𝐈^-2 𝐓^-2. \nSee also: [`Unitful.H`](@ref), [`Unitful.m`](@ref)." const μ0 = 4π*(1//10)^7*H/m # exact (but gets promoted to Float64...), magnetic constant +@public μ0 " Unitful.ε0 Unitful.ϵ0 \nA quantity representing the vacuum permittivity constant, defined as 1 / (μ0 × c^2). \nDimension: 𝐈^2 𝐓^4 𝐋^-3 𝐌^-1. \nSee also: [`Unitful.μ0`](@ref), [`Unitful.c`](@ref)." ((const ε0 = 1/(μ0*c^2)), const ϵ0 = ε0) # exact, electric constant; changes here may affect test of issue 79. +@public ε0, ϵ0 " Unitful.Z0 \nA quantity representing the impedance of free space, a constant defined as μ0 × c. \nDimension: 𝐋^2 𝐌 𝐈^-2 𝐓^-3. \nSee also: [`Unitful.μ0`](@ref), [`Unitful.c`](@ref)." const Z0 = μ0*c # exact, impedance of free space +@public Z0 " Unitful.G \nA quantity representing the universal gravitational constant, equal to 6.674,30 × 10^-11 m^3 / (kg × s^2) (the CODATA 2018 recommended value). \nDimension: 𝐋^3 𝐌^-1 𝐓^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.kg`](@ref), [`Unitful.s`](@ref)." const G = 6.674_30e-11*m^3/kg/s^2 # (15) gravitational constant +@public G " Unitful.gn \nA quantity representing the nominal acceleration due to gravity in a vacuum near the surface of the earth, defined by standard to be exactly 9.806,65 m / s^2. @@ -435,76 +450,89 @@ near the surface of the earth, defined by standard to be exactly 9.806,65 m / s^ \nDimension: 𝐋 𝐓^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const gn = 9.80665*m/s^2 # exact, standard acceleration of gravity +@public gn " Unitful.h \nA quantity representing Planck's constant, defined as exactly 6.626,070,15 × 10^-34 J × s. \nDimension: 𝐋^2 𝐌 𝐓^-1. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." const h = 6.626_070_15e-34*J*s # exact, Planck constant +@public h " Unitful.ħ \nA quantity representing the reduced Planck constant, defined as h / 2π. \nDimension: 𝐋^2 𝐌 𝐓^-1. \nSee also: [`Unitful.h`](@ref)." const ħ = h/2π # hbar +@public ħ " Unitful.Φ0 \nA quantity representing the superconducting magnetic flux quantum, defined as h / (2 × q). \nDimension: 𝐋^2 𝐌 𝐈^-1 𝐓^-2. \nSee also: [`Unitful.h`](@ref), [`Unitful.q`](@ref)." const Φ0 = h/(2q) # Superconducting magnetic flux quantum +@public Φ0 " Unitful.me \nA quantity representing the rest mass of an electron, equal to 9.109,383,7015 × 10^-31 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.𝐌`](@ref). \nSee also: [`Unitful.kg`](@ref)." const me = 9.109_383_7015e-31*kg # (28) electron rest mass +@public me " Unitful.mn \nA quantity representing the rest mass of a neutron, equal to 1.674,927,498,04 × 10^-27 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.𝐌`](@ref). \nSee also: [`Unitful.kg`](@ref)." const mn = 1.674_927_498_04e-27*kg # (95) neutron rest mass +@public mn " Unitful.mp \nA quantity representing the rest mass of a proton, equal to 1.672,621,923,69 × 10^-27 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.𝐌`](@ref). \nSee also: [`Unitful.kg`](@ref)." const mp = 1.672_621_923_69e-27*kg # (51) proton rest mass +@public mp " Unitful.μB \nA quantity representing the Bohr magneton, equal to q × ħ / (2 × me). \nDimension: 𝐈 𝐋^2. \nSee also: [`Unitful.q`](@ref), [`Unitful.ħ`](@ref), [`Unitful.me`](@ref)." const μB = q*ħ/(2*me) # Bohr magneton +@public μB " Unitful.Na \nA quantity representing Avogadro's constant, defined as exactly 6.022,140,76 × 10^23 / mol. \nDimension: 𝐍^-1. \nSee also: [`Unitful.mol`](@ref)." const Na = 6.022_140_76e23/mol # exact, Avogadro constant +@public Na " Unitful.k \nA quantity representing the Boltzmann constant, defined as exactly 1.380,649 × 10^-23 J / K. \nDimension: 𝐋^2 𝐌 𝚯^-1 𝐓^-2. \nSee also: [`Unitful.J`](@ref), [`Unitful.K`](@ref)." const k = 1.380_649e-23*(J/K) # exact, Boltzmann constant +@public k " Unitful.R \nA quantity representing the molar gas constant, defined as Na × k. \nDimension: 𝐋^2 𝐌 𝐍^-1 𝚯^-1 𝐓^-2. \nSee also: [`Unitful.Na`](@ref), [`Unitful.k`](@ref)." const R = Na*k # molar gas constant +@public R " Unitful.σ \nA quantity representing the Stefan-Boltzmann constant, defined as π^2 × k^4 / (60 × ħ^3 × c^2). \nDimension: 𝐌 𝚯^-4 𝐓^-3. \nSee also: [`Unitful.k`](@ref), [`Unitful.ħ`](@ref), [`Unitful.c`](@ref)." const σ = π^2*k^4/(60*ħ^3*c^2) # Stefan-Boltzmann constant +@public σ " Unitful.R∞ \nA quantity representing the Rydberg constant, equal to 1.097,373,156,8160 × 10^-7 / m (the CODATA 2018 recommended value). \nDimension: 𝐋^-1. \nSee also: [`Unitful.m`](@ref)." const R∞ = 10_973_731.568_160/m # (21) Rydberg constant +@public R∞ " Unitful.u \nThe unified atomic mass unit, or dalton, a unit of mass defined as 1/12 the mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 × 10^-27 kg @@ -512,6 +540,7 @@ mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 × 10^-2 \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.kg`](@ref)." @unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false # (50) +@public u # Acceleration " Unitful.ge @@ -520,7 +549,7 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \n[`Unitful.gn`](@ref) is a quantity (with units `m/s^2`) whereas `Unitful.ge` is a unit equal to `gn`. \nDimension: 𝐋 𝐓^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit ge "ge" EarthGravity gn false +@unit ge "ge" EarthGravity gn false false true # CGS units @@ -580,47 +609,48 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe inch, a US customary unit of length defined as 2.54 cm. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.cm`](@ref)." -@unit inch "inch" Inch (254//10000)*m false +@unit inch "inch" Inch (254//10000)*m false false true " Unitful.mil \nThe mil, a US customary unit of length defined as 1/1000 inch. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.inch`](@ref)." -@unit mil "mil" Mil (1//1000)*inch false +@unit mil "mil" Mil (1//1000)*inch false false true " Unitful.ft \nThe foot, a US customary unit of length defined as 12 inch. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.inch`](@ref)." -@unit ft "ft" Foot 12inch false +@unit ft "ft" Foot 12inch false false true " Unitful.yd \nThe yard, a US customary unit of length defined as 3 ft. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.ft`](@ref)." -@unit yd "yd" Yard 3ft false +@unit yd "yd" Yard 3ft false false true " Unitful.mi \nThe mile, a US customary unit of length defined as 1760 yd. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.yd`](@ref)." -@unit mi "mi" Mile 1760yd false +@unit mi "mi" Mile 1760yd false false true " Unitful.angstrom Unitful.Å \nThe angstrom, a metric unit of length defined as 1/10 nm. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.nm`](@ref)." -((@unit angstrom "Å" Angstrom (1//10)*nm false), const Å = angstrom) +((@unit angstrom "Å" Angstrom (1//10)*nm false false true), const Å = angstrom) +@public Å # Area " Unitful.ac \nThe acre, a US customary unit of area defined as 4840 yd^2. \nDimension: 𝐋^2. \nSee Also: [`Unitful.yd`](@ref)." -@unit ac "ac" Acre (316160658//78125)*m^2 false +@unit ac "ac" Acre (316160658//78125)*m^2 false false true # Temperatures " Unitful.Ra \nThe rankine, a US customary unit of temperature defined as 5/9 K. \nDimension: [`Unitful.𝚯`](@ref). \nSee Also: [`Unitful.K`](@ref)." -@unit Ra "Ra" Rankine (5//9)*K false +@unit Ra "Ra" Rankine (5//9)*K false false true " Unitful.°F \nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0 °F = 459.67 Ra. \nDimension: [`Unitful.𝚯`](@ref). @@ -632,34 +662,34 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe pound-mass, a US customary unit of mass defined as exactly 0.453,592,37 kg. \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.kg`](@ref)." -@unit lb "lb" Pound 0.45359237kg false # is exact +@unit lb "lb" Pound 0.45359237kg false false true # is exact " Unitful.oz \nThe ounce, a US customary unit of mass defined as 1/16 lb. \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.lb`](@ref)." -@unit oz "oz" Ounce lb//16 false +@unit oz "oz" Ounce lb//16 false false true " Unitful.slug \nThe slug, a US customary unit of mass defined as 1 lbf × s^2 / ft. \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.s`](@ref), [`Unitful.ft`](@ref)." -@unit slug "slug" Slug 1lb*ge*s^2/ft false +@unit slug "slug" Slug 1lb*ge*s^2/ft false false true " Unitful.dr \nThe dram, a US customary unit of mass defined as 1/16 oz. \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.oz`](@ref)." -@unit dr "dr" Dram oz//16 false +@unit dr "dr" Dram oz//16 false false true " Unitful.gr \nThe grain, a US customary unit of mass defined as 1/7000 lb. \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.lb`](@ref)." -@unit gr "gr" Grain (32//875)*dr false +@unit gr "gr" Grain (32//875)*dr false false true # Force " Unitful.lbf \nThe pound-force, a US customary unit of force defined as 1 lb × ge. \nDimension: 𝐋 𝐌 𝐓^-2. \nSee Also: [`Unitful.lb`](@ref), [`Unitful.ge`](@ref)." -@unit lbf "lbf" PoundsForce 1lb*ge false +@unit lbf "lbf" PoundsForce 1lb*ge false false true # Energy # Use ISO 31-4 for BTU definition @@ -672,14 +702,14 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06 J. \nDimension: 𝐋^2 𝐌 𝐓^-2. \nSee Also: [`Unitful.J`](@ref)." -@unit btu "btu" BritishThermalUnit 1055.06J false +@unit btu "btu" BritishThermalUnit 1055.06J false false true # Pressure " Unitful.psi \nPounds per square inch, a US customary unit of pressure defined as 1 lbf / inch^2. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.inch`](@ref)." -@unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false +@unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false false true ######### # Logarithmic scales and units diff --git a/src/public.julia b/src/public.julia deleted file mode 100644 index 5b35bf75..00000000 --- a/src/public.julia +++ /dev/null @@ -1,219 +0,0 @@ - -# 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 diff --git a/src/user.jl b/src/user.jl index 8df784c9..8c45aac0 100644 --- a/src/user.jl +++ b/src/user.jl @@ -26,7 +26,7 @@ function register(unit_module::Module) end """ - @dimension(symb, abbr, name, autodocs=false) + @dimension(symb, abbr, name, autodocs=false, makepublic=autodocs) Creates new dimensions. `name` will be used like an identifier in the type parameter for a [`Unitful.Dimension`](@ref) object. `symb` will be a symbol defined in the namespace from which this macro is called that is bound to a @@ -44,6 +44,7 @@ of the newly defined dimension. The type alias for quantities or levels is simpl Note that there is also `LengthFreeUnits`, for example, which is an alias for dispatching on `FreeUnits` with length dimensions. The aliases are not exported. If `autodocs == true`, docstrings will be automatically generated for these aliases. +If `makepublic=true`, makes the dimension name, abbreviation, and corresponding `Units` and `FreeUnits` type names public. !!! compat "Unitful 1.10" Documenting the resulting dimension symbol by adding a docstring before the `@dimension` @@ -59,7 +60,7 @@ Returns the `Dimensions` object to which `symb` is bound. Usage example from `src/pkgdefaults.jl`: `@dimension 𝐋 "𝐋" Length` """ -macro dimension(symb, abbr, name, autodocs=false) +macro dimension(symb, abbr, name, autodocs=false, makepublic=autodocs) s = Symbol(symb) x = Expr(:quote, name) uname = Symbol(name,"Units") @@ -91,7 +92,7 @@ macro dimension(symb, abbr, name, autodocs=false) See also: [`$__module__.$s`](@ref). """ - esc(quote + expr1 = quote $Unitful.abbr(::$Dimension{$x}) = $abbr Base.@__doc__ const global $s = $Dimensions{($Dimension{$x}(1),)}() const global ($name){T,U} = Union{ @@ -99,21 +100,26 @@ macro dimension(symb, abbr, name, autodocs=false) $Level{L,S,$Quantity{T,$s,U}} where {L,S}} const global ($uname){U} = $Units{U,$s} const global ($funame){U} = $FreeUnits{U,$s} + if $autodocs @doc $name_doc $name @doc $unit_doc $uname @doc $funit_doc $funame end $s - end) + end + (VERSION >= v"1.11.0-DEV.469" && makepublic) || return esc(expr1) + expr2 = Expr(:public, Symbol(abbr), name, uname, funame) + esc(Expr(:block, expr1, expr2, s)) end """ - @derived_dimension(name, dims, autodocs=false) + @derived_dimension(name, dims, autodocs=false, makepublic=autodocs) Creates type aliases to allow dispatch on [`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref), and [`Unitful.Units`](@ref) objects of a derived dimension, like area, which is just length squared. The type aliases are not exported. If `autodocs == true`, docstrings will be automatically generated for these aliases. +If `makepublic=true`, makes the dimension name public. !!! compat "Unitful 1.10" The `autodocs` argument requires Unitful 1.10 or later. @@ -127,7 +133,7 @@ Usage examples: - `@derived_dimension Area 𝐋^2` gives `Area` and `AreaUnit` type aliases - `@derived_dimension Speed 𝐋/𝐓` gives `Speed` and `SpeedUnit` type aliases """ -macro derived_dimension(name, dims, autodocs=false) +macro derived_dimension(name, dims, autodocs=false, makepublic=autodocs) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") name_links = __module__ == Unitful ? "[`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)" : "`Unitful.Quantity`, `Unitful.Level`" @@ -154,7 +160,7 @@ macro derived_dimension(name, dims, autodocs=false) A supertype for $funit_links of dimension `$dims`. Equivalent to `Unitful.FreeUnits{U, $dims}`. """ - esc(quote + expr1 = quote const global ($name){T,U} = Union{ $Quantity{T,$dims,U}, $Level{L,S,$Quantity{T,$dims,U}} where {L,S}} @@ -166,12 +172,16 @@ macro derived_dimension(name, dims, autodocs=false) @doc $funit_doc $funame end nothing - end) + end + + (VERSION >= v"1.11.0-DEV.469" && makepublic) || return esc(expr1) + expr2 = Expr(:public, name, uname, funame) + esc(Expr(:block, expr1, expr2, nothing)) end """ - @refunit(symb, abbr, name, dimension, tf, autodocs=false) + @refunit(symb, abbr, name, dimension, tf, autodocs=false, makepublic=autodocs) Define a reference unit, typically SI. Rather than define conversion factors between each and every unit of a given dimension, conversion factors are given between each unit and a reference unit, defined by this macro. @@ -182,6 +192,7 @@ for every power of ten of the unit, using the standard SI prefixes. A `dimension must be given ([`Unitful.Dimensions`](@ref) object) that specifies the dimension of the reference unit. If `autodocs == true`, autogenerated docstrings for SI-prefixed units will be added. This option has no effect when `tf == false`. +If `makepublic=true`, makes the units names public. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@refunit` call requires @@ -204,7 +215,7 @@ Usage example: `@refunit m "m" Meter 𝐋 true` This example, found in `src/pkgdefaults.jl`, generates `km`, `m`, `cm`, ... """ -macro refunit(symb, abbr, name, dimension, tf, autodocs=false) +macro refunit(symb, abbr, name, dimension, tf, autodocs=false, makepublic=autodocs) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -214,14 +225,16 @@ macro refunit(symb, abbr, name, dimension, tf, autodocs=false) if tf push!(expr.args, quote - Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $dimension (1.0, 1) $autodocs + Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $dimension (1.0, 1) $autodocs $makepublic end) else push!(expr.args, quote - Base.@__doc__ $Unitful.@unit_symbols $symb $name $dimension (1.0, 1) + Base.@__doc__ $Unitful.@unit_symbols $symb $name $dimension (1.0, 1) $makepublic end) end + VERSION >= v"1.11.0-DEV.469" && makepublic && push!(expr.args, Expr(:public, symb)) + push!(expr.args, quote $preferunits($symb) $symb @@ -231,12 +244,13 @@ macro refunit(symb, abbr, name, dimension, tf, autodocs=false) end """ - @unit(symb,abbr,name,equals,tf,autodocs=false) + @unit(symb, abbr, name, equals, tf, autodocs=false, makepublic=autodocs) Define a unit. Rather than specifying a dimension like in [`@refunit`](@ref), `equals` should be a [`Unitful.Quantity`](@ref) equal to one of the unit being defined. If `tf == true`, symbols will be made for each power-of-ten prefix. If `autodocs == true`, autogenerated docstrings for SI-prefixed units will be added. This option has no effect when `tf == false`. +If `makepublic=true`, makes the unit name public. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@unit` call requires @@ -248,7 +262,7 @@ Usage example: `@unit mi "mi" Mile (201168//125)*m false` This example will *not* generate `kmi` (kilomiles). """ -macro unit(symb,abbr,name,equals,tf,autodocs=false) +macro unit(symb, abbr, name, equals, tf, autodocs=false, makepublic=autodocs) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -262,14 +276,16 @@ macro unit(symb,abbr,name,equals,tf,autodocs=false) if tf push!(expr.args, quote - Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $d $basef $autodocs + Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $d $basef $autodocs $makepublic end) else push!(expr.args, quote - Base.@__doc__ $Unitful.@unit_symbols $symb $name $d $basef + Base.@__doc__ $Unitful.@unit_symbols $symb $name $d $basef $makepublic end) end + VERSION >= v"1.11.0-DEV.469" && makepublic && push!(expr.args, Expr(:public, symb)) + push!(expr.args, quote $symb end) @@ -278,21 +294,25 @@ macro unit(symb,abbr,name,equals,tf,autodocs=false) end """ - @affineunit(symb, abbr, offset) + @affineunit(symb, abbr, offset, makepublic=true) Macro for easily defining affine units. `offset` gives the zero of the relative scale in terms of an absolute scale; the scaling is the same as the absolute scale. Example: `@affineunit °C "°C" (27315//100)K` is used internally to define degrees Celsius. +If `makepublic=true`, makes the unit name public. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@affineunit` call requires Unitful 1.10 or later. """ -macro affineunit(symb, abbr, offset) +macro affineunit(symb, abbr, offset, makepublic=true) s = Symbol(symb) - return esc(quote + expr1 = quote Base.@__doc__ const global $s = $affineunit($offset) $Base.show(io::$IO, ::$genericunit($s)) = $print(io, $abbr) - end) + end + (VERSION >= v"1.11.0-DEV.469" && makepublic) || return esc(expr1) + expr2 = Expr(:public, s) + esc(Expr(:block, expr1, expr2, s)) end function basefactors_expr(m::Module, n, basefactor) @@ -310,10 +330,11 @@ function basefactors_expr(m::Module, n, basefactor) end """ - @prefixed_unit_symbols(symb,name,dimension,basefactor,autodocs=false) + @prefixed_unit_symbols(symb, name, user_dimension, basefactor, autodocs=false, makepublic=autodocs) Not called directly by the user. Given a unit symbol and a unit's name, will define units for each possible SI power-of-ten prefix on that unit. If `autodocs == true`, it will automatically generate docstrings for these units. +If `makepublic=true`, makes the units names public. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@prefixed_unit_symbols` @@ -323,7 +344,7 @@ will define units for each possible SI power-of-ten prefix on that unit. If Example: `@prefixed_unit_symbols m Meter 𝐋 (1.0,1) true` results in `nm`, `cm`, `m`, `km`, ... all getting defined in the calling namespace, with docstrings automatically defined for SI-prefixed units. """ -macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) +macro prefixed_unit_symbols(symb, name, user_dimension, basefactor, autodocs=false, makepublic=autodocs) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -351,31 +372,37 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) end end end + VERSION >= v"1.11.0-DEV.469" && makepublic && push!(expr.args, Expr(:public, s)) push!(expr.args, ea) end esc(expr) end +# TODO update example in the docstring """ - @unit_symbols(symb,name) + @unit_symbols(symb, name, user_dimension, basefactor, makepublic=false) Not called directly by the user. Given a unit symbol and a unit's name, will define units without SI power-of-ten prefixes. +If `makepublic=true`, makes the unit name public. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@unit_symbols` call requires Unitful 1.10 or later. -Example: `@unit_symbols ft Foot 𝐋` results in `ft` getting defined but not `kft`. +Example: `@unit_symbols ft Foot 𝐋` results in `ft` getting defined but not `kft`. """ -macro unit_symbols(symb,name,user_dimension,basefactor) +macro unit_symbols(symb, name, user_dimension, basefactor, makepublic=false) s = Symbol(symb) n = Meta.quot(Symbol(name)) u = :($Unit{$n, $user_dimension}(0,1//1)) - esc(quote + expr1 = quote $(basefactors_expr(__module__, n, basefactor)) Base.@__doc__ const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() - end) + end + (VERSION >= v"1.11.0-DEV.469" && makepublic) || return esc(expr1) + expr2 = Expr(:public, s) + esc(Expr(:block, expr1, expr2, s)) end """ @@ -577,12 +604,12 @@ end @logunit(symb, abbr, logscale, reflevel) Defines a logarithmic unit. For examples see `src/pkgdefaults.jl`. """ -macro logunit(symb, abbr, logscale, reflevel) +macro logunit(symb, abbr, logscale, reflevel, makepublic=false) quote - $Unitful.abbr(::Level{$(esc(logscale)), $(esc(reflevel))}) = $abbr - const global $(esc(symb)) = - MixedUnits{Level{$(esc(logscale)), $(esc(reflevel))}}() - end + $Unitful.abbr(::Level{$(logscale), $(reflevel)}) = $abbr + const global $(symb) = + MixedUnits{Level{$(logscale), $(reflevel)}}() + end |> esc end """ diff --git a/src/utils.jl b/src/utils.jl index 23efcfdc..4283dccf 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -265,3 +265,21 @@ Base.showerror(io::IO, e::AffineError) = print(io, "AffineError: $(e.x)") fp_overflow_underflow(input, result) = isfinite(input) && !isfinite(result) || !iszero(input) && iszero(result) + +""" + macro public(ex) +Declares variables as public on Julia v1.11 or later, and is noop otherwise. +See https://discourse.julialang.org/t/is-compat-jl-worth-it-for-the-public-keyword/119041 + +Examples: + +``` +julia> @public x +julia> @public x, y +``` +""" +macro public(ex) + @static Base.VERSION >= v"1.11.0-DEV.469" || return nothing + args = ex isa Symbol ? (ex,) : Base.isexpr(ex, :tuple) ? ex.args : error("Macro argument must be single symbol or tuple, see docstring") + return esc(Expr(:public, args...)) +end diff --git a/test/runtests.jl b/test/runtests.jl index 4b830c14..07599fa4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -60,29 +60,6 @@ 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),)} @@ -1728,8 +1705,17 @@ end @testset "Display" begin withenv("UNITFUL_FANCY_EXPONENTS" => false) do - @test string(typeof(1.0m/s)) == "Quantity{Float64, 𝐋 𝐓^-1, FreeUnits{(m, s^-1), 𝐋 𝐓^-1, nothing}}" - @test string(typeof(m/s)) == "FreeUnits{(m, s^-1), 𝐋 𝐓^-1, nothing}" + # Declaring VelocityFreeUnits as public (or exported) results in change of displayed velocity type from FreeUnits to VelocityFreeUnits + # The same with other units, e.g. typeof(Unitful.L) would be displayed, if VolumeFreeUnits is declared as public, as + # VolumeFreeUnits{(L,), nothing} (alias for Unitful.FreeUnits{(L,), 𝐋³, nothing}) + # vs. Unitful.FreeUnits{(L,), 𝐋³, nothing} + if isdefined(Base, :ispublic) && Base.ispublic(Unitful, :VelocityFreeUnits) + @test string(typeof(1.0m/s)) == "Quantity{Float64, 𝐋 𝐓^-1, Unitful.VelocityFreeUnits{(m, s^-1), nothing}}" + @test string(typeof(m/s)) == "Unitful.VelocityFreeUnits{(m, s^-1), nothing}" + else + @test string(typeof(1.0m/s)) == "Quantity{Float64, 𝐋 𝐓^-1, FreeUnits{(m, s^-1), 𝐋 𝐓^-1, nothing}}" + @test string(typeof(m/s)) == "FreeUnits{(m, s^-1), 𝐋 𝐓^-1, nothing}" + end @test string(dimension(1u"m/s")) == "𝐋 𝐓^-1" @test string(NoDims) == "NoDims" end @@ -2570,8 +2556,6 @@ 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 From 47657b43b1800c55f25a3b8ba855f67007546bf4 Mon Sep 17 00:00:00 2001 From: Ben Elkin <8xe8n-cm@online.de> Date: Fri, 26 Sep 2025 23:50:55 +0200 Subject: [PATCH 4/8] change makepublic=autodocs to makepublic=false --- src/pkgdefaults.jl | 182 ++++++++++++++++++++++----------------------- src/user.jl | 36 ++++----- 2 files changed, 109 insertions(+), 109 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 431c6733..7bc6d17e 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -4,66 +4,66 @@ # dimensions from units, and also helps prevent common namespace collisions. " Unitful.𝐋 \nA dimension representing length." -@dimension 𝐋 "𝐋" Length true +@dimension 𝐋 "𝐋" Length true true " Unitful.𝐌 \nA dimension representing mass." -@dimension 𝐌 "𝐌" Mass true +@dimension 𝐌 "𝐌" Mass true true " Unitful.𝐓 \nA dimension representing time." -@dimension 𝐓 "𝐓" Time true +@dimension 𝐓 "𝐓" Time true true " Unitful.𝐈 \nA dimension representing electric current." -@dimension 𝐈 "𝐈" Current true +@dimension 𝐈 "𝐈" Current true true " Unitful.𝚯 \nA dimension representing thermodynamic temperature." -@dimension 𝚯 "𝚯" Temperature true # This one is \bfTheta +@dimension 𝚯 "𝚯" Temperature true true # This one is \bfTheta " Unitful.𝐉 \nA dimension representing luminous intensity." -@dimension 𝐉 "𝐉" Luminosity true +@dimension 𝐉 "𝐉" Luminosity true true " Unitful.𝐍 \nA dimension representing amount of substance." -@dimension 𝐍 "𝐍" Amount true +@dimension 𝐍 "𝐍" Amount true true const RelativeScaleTemperature = Quantity{T, 𝚯, <:AffineUnits} where T const AbsoluteScaleTemperature = Quantity{T, 𝚯, <:ScalarUnits} where T # Define derived dimensions. -@derived_dimension Area 𝐋^2 true -@derived_dimension Volume 𝐋^3 true -@derived_dimension Density 𝐌/𝐋^3 true -@derived_dimension Frequency inv(𝐓) true -@derived_dimension Velocity 𝐋/𝐓 true -@derived_dimension Acceleration 𝐋/𝐓^2 true -@derived_dimension Force 𝐌*𝐋/𝐓^2 true -@derived_dimension Pressure 𝐌*𝐋^-1*𝐓^-2 true -@derived_dimension Energy 𝐌*𝐋^2/𝐓^2 true -@derived_dimension Momentum 𝐌*𝐋/𝐓 true -@derived_dimension Power 𝐋^2*𝐌*𝐓^-3 true -@derived_dimension Charge 𝐈*𝐓 true -@derived_dimension Voltage 𝐈^-1*𝐋^2*𝐌*𝐓^-3 true -@derived_dimension ElectricalResistance 𝐈^-2*𝐋^2*𝐌*𝐓^-3 true -@derived_dimension ElectricalResistivity 𝐈^-2*𝐋^3*𝐌*𝐓^-3 true -@derived_dimension ElectricalConductance 𝐈^2*𝐋^-2*𝐌^-1*𝐓^3 true -@derived_dimension ElectricalConductivity 𝐈^2*𝐋^-3*𝐌^-1*𝐓^3 true -@derived_dimension Capacitance 𝐈^2*𝐋^-2*𝐌^-1*𝐓^4 true -@derived_dimension Inductance 𝐈^-2*𝐋^2*𝐌*𝐓^-2 true -@derived_dimension MagneticFlux 𝐈^-1*𝐋^2*𝐌*𝐓^-2 true -@derived_dimension DField 𝐈*𝐓/𝐋^2 true -@derived_dimension EField 𝐋*𝐌*𝐓^-3*𝐈^-1 true -@derived_dimension HField 𝐈/𝐋 true -@derived_dimension BField 𝐈^-1*𝐌*𝐓^-2 true -@derived_dimension Action 𝐋^2*𝐌*𝐓^-1 true -@derived_dimension DynamicViscosity 𝐌*𝐋^-1*𝐓^-1 true -@derived_dimension KinematicViscosity 𝐋^2*𝐓^-1 true -@derived_dimension Wavenumber inv(𝐋) true -@derived_dimension ElectricDipoleMoment 𝐋*𝐓*𝐈 true -@derived_dimension ElectricQuadrupoleMoment 𝐋^2*𝐓*𝐈 true -@derived_dimension MagneticDipoleMoment 𝐋^2*𝐈 true -@derived_dimension Molarity 𝐍/𝐋^3 true -@derived_dimension Molality 𝐍/𝐌 true -@derived_dimension MolarMass 𝐌/𝐍 true -@derived_dimension MassFlow 𝐌/𝐓 true -@derived_dimension MolarFlow 𝐍/𝐓 true -@derived_dimension VolumeFlow 𝐋^3/𝐓 true +@derived_dimension Area 𝐋^2 true true +@derived_dimension Volume 𝐋^3 true true +@derived_dimension Density 𝐌/𝐋^3 true true +@derived_dimension Frequency inv(𝐓) true true +@derived_dimension Velocity 𝐋/𝐓 true true +@derived_dimension Acceleration 𝐋/𝐓^2 true true +@derived_dimension Force 𝐌*𝐋/𝐓^2 true true +@derived_dimension Pressure 𝐌*𝐋^-1*𝐓^-2 true true +@derived_dimension Energy 𝐌*𝐋^2/𝐓^2 true true +@derived_dimension Momentum 𝐌*𝐋/𝐓 true true +@derived_dimension Power 𝐋^2*𝐌*𝐓^-3 true true +@derived_dimension Charge 𝐈*𝐓 true true +@derived_dimension Voltage 𝐈^-1*𝐋^2*𝐌*𝐓^-3 true true +@derived_dimension ElectricalResistance 𝐈^-2*𝐋^2*𝐌*𝐓^-3 true true +@derived_dimension ElectricalResistivity 𝐈^-2*𝐋^3*𝐌*𝐓^-3 true true +@derived_dimension ElectricalConductance 𝐈^2*𝐋^-2*𝐌^-1*𝐓^3 true true +@derived_dimension ElectricalConductivity 𝐈^2*𝐋^-3*𝐌^-1*𝐓^3 true true +@derived_dimension Capacitance 𝐈^2*𝐋^-2*𝐌^-1*𝐓^4 true true +@derived_dimension Inductance 𝐈^-2*𝐋^2*𝐌*𝐓^-2 true true +@derived_dimension MagneticFlux 𝐈^-1*𝐋^2*𝐌*𝐓^-2 true true +@derived_dimension DField 𝐈*𝐓/𝐋^2 true true +@derived_dimension EField 𝐋*𝐌*𝐓^-3*𝐈^-1 true true +@derived_dimension HField 𝐈/𝐋 true true +@derived_dimension BField 𝐈^-1*𝐌*𝐓^-2 true true +@derived_dimension Action 𝐋^2*𝐌*𝐓^-1 true true +@derived_dimension DynamicViscosity 𝐌*𝐋^-1*𝐓^-1 true true +@derived_dimension KinematicViscosity 𝐋^2*𝐓^-1 true true +@derived_dimension Wavenumber inv(𝐋) true true +@derived_dimension ElectricDipoleMoment 𝐋*𝐓*𝐈 true true +@derived_dimension ElectricQuadrupoleMoment 𝐋^2*𝐓*𝐈 true true +@derived_dimension MagneticDipoleMoment 𝐋^2*𝐈 true true +@derived_dimension Molarity 𝐍/𝐋^3 true true +@derived_dimension Molality 𝐍/𝐌 true true +@derived_dimension MolarMass 𝐌/𝐍 true true +@derived_dimension MassFlow 𝐌/𝐓 true true +@derived_dimension MolarFlow 𝐍/𝐓 true true +@derived_dimension VolumeFlow 𝐋^3/𝐓 true true # Define base units. This is not to imply g is the base SI unit instead of kg. # See the documentation for further details. @@ -71,39 +71,39 @@ const AbsoluteScaleTemperature = Quantity{T, 𝚯, <:ScalarUnits} where T " Unitful.m \nThe meter, the SI base unit of length. \nDimension: [`Unitful.𝐋`](@ref)." -@refunit m "m" Meter 𝐋 true true +@refunit m "m" Meter 𝐋 true true true " Unitful.s \nThe second, the SI base unit of time. \nDimension: [`Unitful.𝐓`](@ref)." -@refunit s "s" Second 𝐓 true true +@refunit s "s" Second 𝐓 true true true " Unitful.A \nThe ampere, the SI base unit of electric current. \nDimension: [`Unitful.𝐈`](@ref)." -@refunit A "A" Ampere 𝐈 true true +@refunit A "A" Ampere 𝐈 true true true " Unitful.K \nThe kelvin, the SI base unit of thermodynamic temperature. \nDimension: [`Unitful.𝚯`](@ref)." -@refunit K "K" Kelvin 𝚯 true true +@refunit K "K" Kelvin 𝚯 true true true " Unitful.cd \nThe candela, the SI base unit of luminous intensity. \nDimension: [`Unitful.𝐉`](@ref)." -@refunit cd "cd" Candela 𝐉 true true +@refunit cd "cd" Candela 𝐉 true true true # the docs for all gram-based units are defined later, to ensure kg is the base unit. @refunit g "g" Gram 𝐌 true false true " Unitful.mol \nThe mole, the SI base unit for amount of substance. \nDimension: [`Unitful.𝐍`](@ref)." -@refunit mol "mol" Mole 𝐍 true true +@refunit mol "mol" Mole 𝐍 true true true # Angles and solid angles " Unitful.sr \nThe steradian, a unit of spherical angle. There are 4π sr in a sphere. \nDimension: [`Unitful.NoDims`](@ref)." -@unit sr "sr" Steradian 1 true true +@unit sr "sr" Steradian 1 true true true " Unitful.rad \nThe radian, a unit of angle. There are 2π rad in a circle. \nDimension: [`Unitful.NoDims`](@ref)." -@unit rad "rad" Radian 1 true true +@unit rad "rad" Radian 1 true true true " Unitful.° Unitful.deg \nThe degree, a unit of angle. There are 360° in a circle. @@ -133,99 +133,99 @@ rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r)) \nThe hertz, an SI unit of frequency, defined as 1 s^-1. \nDimension: 𝐓^-1. \nSee also: [`Unitful.s`](@ref)." -@unit Hz "Hz" Hertz 1/s true true +@unit Hz "Hz" Hertz 1/s true true true " Unitful.N \nThe newton, an SI unit of force, defined as 1 kg × m / s^2. \nDimension: 𝐋 𝐌 𝐓^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit N "N" Newton 1kg*m/s^2 true true +@unit N "N" Newton 1kg*m/s^2 true true true " Unitful.Pa \nThe pascal, an SI unit of pressure, defined as 1 N / m^2. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." -@unit Pa "Pa" Pascal 1N/m^2 true true +@unit Pa "Pa" Pascal 1N/m^2 true true true " Unitful.J \nThe joule, an SI unit of energy, defined as 1 N × m. \nDimension: 𝐋^2 𝐌 𝐓^-2. \nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." -@unit J "J" Joule 1N*m true true +@unit J "J" Joule 1N*m true true true " Unitful.W \nThe watt, an SI unit of power, defined as 1 J / s. \nDimension: 𝐋^2 𝐌 𝐓^-3. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." -@unit W "W" Watt 1J/s true true +@unit W "W" Watt 1J/s true true true " Unitful.C \nThe coulomb, an SI unit of electric charge, defined as 1 A × s. \nDimension: 𝐈 𝐓. \nSee also: [`Unitful.A`](@ref), [`Unitful.s`](@ref)." -@unit C "C" Coulomb 1A*s true true +@unit C "C" Coulomb 1A*s true true true " Unitful.V \nThe volt, an SI unit of electric potential, defined as 1 W / A. \nDimension: 𝐋^2 𝐌 𝐈^-1 𝐓^-3. \nSee also: [`Unitful.W`](@ref), [`Unitful.A`](@ref)" -@unit V "V" Volt 1W/A true true +@unit V "V" Volt 1W/A true true true " Unitful.Ω \nThe ohm, an SI unit of electrical resistance, defined as 1 V / A. \nDimension: 𝐋^2 𝐌 𝐈^-2 𝐓^-3. \nSee also: [`Unitful.V`](@ref), [`Unitful.A`](@ref)." -@unit Ω "Ω" Ohm 1V/A true true +@unit Ω "Ω" Ohm 1V/A true true true " Unitful.S \nThe siemens, an SI unit of electrical conductance, defined as 1 Ω^-1. \nDimension: 𝐈^2 𝐓^3 𝐋^-2 𝐌^-1. \nSee also: [`Unitful.Ω`](@ref)" -@unit S "S" Siemens 1/Ω true true +@unit S "S" Siemens 1/Ω true true true " Unitful.F \nThe farad, an SI unit of electrical capacitance, defined as 1 s^4 × A^2 / (kg × m^2). \nDimension: 𝐈^2 𝐓^4 𝐋^-2 𝐌^-1. \nSee also: [`Unitful.s`](@ref), [`Unitful.A`](@ref), [`Unitful.kg`](@ref), [`Unitful.m`](@ref)." -@unit F "F" Farad 1s^4*A^2/(kg*m^2) true true +@unit F "F" Farad 1s^4*A^2/(kg*m^2) true true true " Unitful.H \nThe henry, an SI unit of electrical inductance, defined as 1 J / A^2. \nDimension: 𝐋^2 𝐌 𝐈^-2 𝐓^-2. \nSee also: [`Unitful.J`](@ref), [`Unitful.A`](@ref)." -@unit H "H" Henry 1J/(A^2) true true +@unit H "H" Henry 1J/(A^2) true true true " Unitful.T \nThe tesla, an SI unit of magnetic B-field strength, defined as 1 kg / (A × s^2). \nDimension: 𝐌 𝐈^-1 𝐓^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." -@unit T "T" Tesla 1kg/(A*s^2) true true +@unit T "T" Tesla 1kg/(A*s^2) true true true " Unitful.Wb \nThe weber, an SI unit of magnetic flux, defined as 1 kg × m^2 / (A × s^2). \nDimension: 𝐋^2 𝐌 𝐈^-1 𝐓^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." -@unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true true +@unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true true true " Unitful.lm \nThe lumen, an SI unit of luminous flux, defined as 1 cd × sr. \nDimension: [`Unitful.𝐉`](@ref). \nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)." -@unit lm "lm" Lumen 1cd*sr true true +@unit lm "lm" Lumen 1cd*sr true true true " Unitful.lx \nThe lux, an SI unit of illuminance, defined as 1 lm / m^2. \nDimension: 𝐉 𝐋^-2. \nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." -@unit lx "lx" Lux 1lm/m^2 true true +@unit lx "lx" Lux 1lm/m^2 true true true " Unitful.Bq \nThe becquerel, an SI unit of radioactivity, defined as 1 nuclear decay per s. \nDimension: 𝐓^-1. \nSee also: [`Unitful.s`](@ref)." -@unit Bq "Bq" Becquerel 1/s true true +@unit Bq "Bq" Becquerel 1/s true true true " Unitful.Gy \nThe gray, an SI unit of ionizing radiation dose, defined as the absorption of 1 J per kg of matter. \nDimension: 𝐋^2 𝐓^-2. \nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." -@unit Gy "Gy" Gray 1J/kg true true +@unit Gy "Gy" Gray 1J/kg true true true " Unitful.Sv \nThe sievert, an SI unit of the biological effect of an ionizing radiation dose. Defined as the health effect of 1 Gy of radiation, scaled by a quality factor. \nDimension: 𝐋^2 𝐓^-2. \nSee also: [`Unitful.Gy`](@ref)." -@unit Sv "Sv" Sievert 1J/kg true true +@unit Sv "Sv" Sievert 1J/kg true true true " Unitful.kat \nThe katal, an SI unit of catalytic activity, defined as 1 mol of catalyzed substrate per s. \nDimension: 𝐍 𝐓^-1. \nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." -@unit kat "kat" Katal 1mol/s true true +@unit kat "kat" Katal 1mol/s true true true " Unitful.percent \nPercent, a unit meaning parts per hundred. Printed as \"%\". \nDimension: [`Unitful.NoDims`](@ref)." @@ -264,7 +264,7 @@ substrate per s. \nThe degree Celsius, an SI unit of temperature, defined such that 0 °C = 273.15 K. \nDimension: [`Unitful.𝚯`](@ref). \nSee also: [`Unitful.K`](@ref)." -@affineunit °C "°C" (27315//100)K +@affineunit °C "°C" (27315//100)K true # Common units of time " Unitful.minute @@ -292,7 +292,7 @@ to avoid confusion with the Julia function `min`. \nThe year, a unit of time, defined as 365.25 d. \nDimension: [`Unitful.𝐓`](@ref). \nSee Also: [`Unitful.hr`](@ref)." -@unit yr "yr" Year 31557600s true true +@unit yr "yr" Year 31557600s true true true " Unitful.rps \nRevolutions per second, a unit of rotational speed, defined as 2π rad / s. \nDimension: 𝐓^-1. @@ -321,7 +321,7 @@ const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, 𝐋^2}(2, 1//1),), 𝐋^2}() \nThe barn, a metric unit of area, defined as 100 fm^2. \nDimension: 𝐋^2. \nSee Also: [`Unitful.fm`](@ref)." -@unit b "b" Barn 100fm^2 true true +@unit b "b" Barn 100fm^2 true true true # Volume # `l` is also an acceptable symbol for liters @@ -362,7 +362,7 @@ end \nA unit for measuring molar concentration, equal to 1 mol/L. \nDimension: 𝐍 𝐋^-3. \nSee Also: [`Unitful.L`](@ref), [`Unitful.mol`](@ref)." -@unit M "M" Molar 1mol/L true true +@unit M "M" Molar 1mol/L true true true # Energy " Unitful.q @@ -377,29 +377,29 @@ const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... \nThe electron-volt, a unit of energy, defined as q*V. \nDimension: 𝐋^2 𝐌 𝐓^-2. \nSee also: [`Unitful.q`](@ref), [`Unitful.V`](@ref)." -@unit eV "eV" eV q*V true true +@unit eV "eV" eV q*V true true true # For convenience " Unitful.Hz2π \nA unit for convenience in angular frequency, equal to 2π Hz. \nDimension: 𝐓^-1. \nSee also: [`Unitful.Hz`](@ref)." -@unit Hz2π "Hz2π" AngHertz 2π/s true true +@unit Hz2π "Hz2π" AngHertz 2π/s true true true " Unitful.bar \nThe bar, a metric unit of pressure, defined as 100 kPa. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee also: [`Unitful.kPa`](@ref)." -@unit bar "bar" Bar 100000Pa true true +@unit bar "bar" Bar 100000Pa true true true " Unitful.atm \nThe standard atmosphere, a unit of pressure, defined as 101,325 Pa. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee also: [`Unitful.Pa`](@ref)." -@unit atm "atm" Atmosphere 101325Pa true true +@unit atm "atm" Atmosphere 101325Pa true true true " Unitful.Torr \nThe torr, a unit of pressure, defined as 1/760 atm. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee also: [`Unitful.atm`](@ref)." -@unit Torr "Torr" Torr 101325Pa//760 true true +@unit Torr "Torr" Torr 101325Pa//760 true true true # Constants (2018 CODATA values) (uncertainties in final digits) " Unitful.c0 @@ -557,47 +557,47 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe gal, a CGS unit of acceleration, defined as 1 cm / s^2. \nDimension: 𝐋 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)." -@unit Gal "Gal" Gal 1cm/s^2 true true +@unit Gal "Gal" Gal 1cm/s^2 true true true " Unitful.dyn \nThe dyne, a CGS unit of force, defined as 1 g × cm / s^2. \nDimension: 𝐋 𝐌 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref), [`Unitful.g`](@ref)." -@unit dyn "dyn" Dyne 1g*cm/s^2 true true +@unit dyn "dyn" Dyne 1g*cm/s^2 true true true " Unitful.erg \nThe erg, a CGS unit of energy, defined as 1 dyn × cm. \nDimension: 𝐋^2 𝐌 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" -@unit erg "erg" Erg 1g*cm^2/s^2 true true +@unit erg "erg" Erg 1g*cm^2/s^2 true true true " Unitful.Ba \nThe barye, a CGS unit of pressure, defined as 1 dyn / cm^2. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" -@unit Ba "Ba" Barye 1g/cm/s^2 true true +@unit Ba "Ba" Barye 1g/cm/s^2 true true true " Unitful.P \nThe poise, a CGS unit of dynamic viscosity, defined as 1 dyn × s / cm^2. \nDimension: 𝐌 𝐋^-1 𝐓^-1. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref), [`Unitful.s`](@ref)" -@unit P "P" Poise 1g/cm/s true true +@unit P "P" Poise 1g/cm/s true true true " Unitful.St \nThe stokes, a CGS unit of kinematic viscosity, defined as 1 cm^2 / s. \nDimension: 𝐌^2 𝐓^-1. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)" -@unit St "St" Stokes 1cm^2/s true true +@unit St "St" Stokes 1cm^2/s true true true " Unitful.Gauss \nThe gauss, a CGS unit of magnetic B-field strength, defined as 1 Mx / cm^2. \nDimension: 𝐌 𝐈^-1 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.Mx`](@ref)" -@unit Gauss "Gauss" Gauss (1//10_000)*T true true +@unit Gauss "Gauss" Gauss (1//10_000)*T true true true " Unitful.Oe \nThe oersted, a CGS unit of magnetic H-field strength, defined as 1000 A / (4π × m). \nDimension: 𝐈 𝐋^-1. \nSee also: [`Unitful.A`](@ref), [`Unitful.m`](@ref)" -@unit Oe "Oe" Oersted (1_000/4π)*A/m true true +@unit Oe "Oe" Oersted (1_000/4π)*A/m true true true " Unitful.Mx \nThe maxwell, a CGS unit of magnetic flux, defined as 1 Gauss × cm^2. \nDimension: 𝐋^2 𝐌 𝐈^-1 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.Gauss`](@ref)" -@unit Mx "Mx" Maxwell (1//100_000_000)*Wb true true +@unit Mx "Mx" Maxwell (1//100_000_000)*Wb true true true ######### @@ -655,7 +655,7 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0 °F = 459.67 Ra. \nDimension: [`Unitful.𝚯`](@ref). \nSee also: [`Unitful.Ra`](@ref)." -@affineunit °F "°F" (45967//100)Ra +@affineunit °F "°F" (45967//100)Ra true # Masses " Unitful.lb @@ -697,7 +697,7 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe calorie, a unit of energy defined as exactly 4.184 J. \nDimension: 𝐋^2 𝐌 𝐓^-2. \nSee Also: [`Unitful.J`](@ref)." -@unit cal "cal" Calorie 4.184J true true +@unit cal "cal" Calorie 4.184J true true true " Unitful.btu \nThe British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06 J. \nDimension: 𝐋^2 𝐌 𝐓^-2. diff --git a/src/user.jl b/src/user.jl index 8c45aac0..9b36637b 100644 --- a/src/user.jl +++ b/src/user.jl @@ -26,7 +26,7 @@ function register(unit_module::Module) end """ - @dimension(symb, abbr, name, autodocs=false, makepublic=autodocs) + @dimension(symb, abbr, name, autodocs=false, makepublic=false) Creates new dimensions. `name` will be used like an identifier in the type parameter for a [`Unitful.Dimension`](@ref) object. `symb` will be a symbol defined in the namespace from which this macro is called that is bound to a @@ -44,7 +44,7 @@ of the newly defined dimension. The type alias for quantities or levels is simpl Note that there is also `LengthFreeUnits`, for example, which is an alias for dispatching on `FreeUnits` with length dimensions. The aliases are not exported. If `autodocs == true`, docstrings will be automatically generated for these aliases. -If `makepublic=true`, makes the dimension name, abbreviation, and corresponding `Units` and `FreeUnits` type names public. +If `makepublic=true`, makes the dimension name, abbreviation, and corresponding `Units` and `FreeUnits` type names public when running on Julia ≥ 1.11. !!! compat "Unitful 1.10" Documenting the resulting dimension symbol by adding a docstring before the `@dimension` @@ -60,7 +60,7 @@ Returns the `Dimensions` object to which `symb` is bound. Usage example from `src/pkgdefaults.jl`: `@dimension 𝐋 "𝐋" Length` """ -macro dimension(symb, abbr, name, autodocs=false, makepublic=autodocs) +macro dimension(symb, abbr, name, autodocs=false, makepublic=false) s = Symbol(symb) x = Expr(:quote, name) uname = Symbol(name,"Units") @@ -114,12 +114,12 @@ macro dimension(symb, abbr, name, autodocs=false, makepublic=autodocs) end """ - @derived_dimension(name, dims, autodocs=false, makepublic=autodocs) + @derived_dimension(name, dims, autodocs=false, makepublic=false) Creates type aliases to allow dispatch on [`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref), and [`Unitful.Units`](@ref) objects of a derived dimension, like area, which is just length squared. The type aliases are not exported. If `autodocs == true`, docstrings will be automatically generated for these aliases. -If `makepublic=true`, makes the dimension name public. +If `makepublic=true`, makes the dimension name public when running on Julia ≥ 1.11. !!! compat "Unitful 1.10" The `autodocs` argument requires Unitful 1.10 or later. @@ -133,7 +133,7 @@ Usage examples: - `@derived_dimension Area 𝐋^2` gives `Area` and `AreaUnit` type aliases - `@derived_dimension Speed 𝐋/𝐓` gives `Speed` and `SpeedUnit` type aliases """ -macro derived_dimension(name, dims, autodocs=false, makepublic=autodocs) +macro derived_dimension(name, dims, autodocs=false, makepublic=false) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") name_links = __module__ == Unitful ? "[`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)" : "`Unitful.Quantity`, `Unitful.Level`" @@ -181,7 +181,7 @@ end """ - @refunit(symb, abbr, name, dimension, tf, autodocs=false, makepublic=autodocs) + @refunit(symb, abbr, name, dimension, tf, autodocs=false, makepublic=false) Define a reference unit, typically SI. Rather than define conversion factors between each and every unit of a given dimension, conversion factors are given between each unit and a reference unit, defined by this macro. @@ -192,7 +192,7 @@ for every power of ten of the unit, using the standard SI prefixes. A `dimension must be given ([`Unitful.Dimensions`](@ref) object) that specifies the dimension of the reference unit. If `autodocs == true`, autogenerated docstrings for SI-prefixed units will be added. This option has no effect when `tf == false`. -If `makepublic=true`, makes the units names public. +If `makepublic=true`, makes the units names public when running on Julia ≥ 1.11. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@refunit` call requires @@ -215,7 +215,7 @@ Usage example: `@refunit m "m" Meter 𝐋 true` This example, found in `src/pkgdefaults.jl`, generates `km`, `m`, `cm`, ... """ -macro refunit(symb, abbr, name, dimension, tf, autodocs=false, makepublic=autodocs) +macro refunit(symb, abbr, name, dimension, tf, autodocs=false, makepublic=false) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -244,13 +244,13 @@ macro refunit(symb, abbr, name, dimension, tf, autodocs=false, makepublic=autodo end """ - @unit(symb, abbr, name, equals, tf, autodocs=false, makepublic=autodocs) + @unit(symb, abbr, name, equals, tf, autodocs=false, makepublic=false) Define a unit. Rather than specifying a dimension like in [`@refunit`](@ref), `equals` should be a [`Unitful.Quantity`](@ref) equal to one of the unit being defined. If `tf == true`, symbols will be made for each power-of-ten prefix. If `autodocs == true`, autogenerated docstrings for SI-prefixed units will be added. This option has no effect when `tf == false`. -If `makepublic=true`, makes the unit name public. +If `makepublic=true`, makes the unit name public when running on Julia ≥ 1.11. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@unit` call requires @@ -262,7 +262,7 @@ Usage example: `@unit mi "mi" Mile (201168//125)*m false` This example will *not* generate `kmi` (kilomiles). """ -macro unit(symb, abbr, name, equals, tf, autodocs=false, makepublic=autodocs) +macro unit(symb, abbr, name, equals, tf, autodocs=false, makepublic=false) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -298,7 +298,7 @@ end Macro for easily defining affine units. `offset` gives the zero of the relative scale in terms of an absolute scale; the scaling is the same as the absolute scale. Example: `@affineunit °C "°C" (27315//100)K` is used internally to define degrees Celsius. -If `makepublic=true`, makes the unit name public. +If `makepublic=true`, makes the unit name public when running on Julia ≥ 1.11. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@affineunit` call @@ -330,11 +330,11 @@ function basefactors_expr(m::Module, n, basefactor) end """ - @prefixed_unit_symbols(symb, name, user_dimension, basefactor, autodocs=false, makepublic=autodocs) + @prefixed_unit_symbols(symb, name, user_dimension, basefactor, autodocs=false, makepublic=false) Not called directly by the user. Given a unit symbol and a unit's name, will define units for each possible SI power-of-ten prefix on that unit. If `autodocs == true`, it will automatically generate docstrings for these units. -If `makepublic=true`, makes the units names public. +If `makepublic=true`, makes the units names public when running on Julia ≥ 1.11. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@prefixed_unit_symbols` @@ -344,7 +344,7 @@ If `makepublic=true`, makes the units names public. Example: `@prefixed_unit_symbols m Meter 𝐋 (1.0,1) true` results in `nm`, `cm`, `m`, `km`, ... all getting defined in the calling namespace, with docstrings automatically defined for SI-prefixed units. """ -macro prefixed_unit_symbols(symb, name, user_dimension, basefactor, autodocs=false, makepublic=autodocs) +macro prefixed_unit_symbols(symb, name, user_dimension, basefactor, autodocs=false, makepublic=false) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -384,13 +384,13 @@ end @unit_symbols(symb, name, user_dimension, basefactor, makepublic=false) Not called directly by the user. Given a unit symbol and a unit's name, will define units without SI power-of-ten prefixes. -If `makepublic=true`, makes the unit name public. +If `makepublic=true`, makes the unit name public when running on Julia ≥ 1.11. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@unit_symbols` call requires Unitful 1.10 or later. -Example: `@unit_symbols ft Foot 𝐋` results in `ft` getting defined but not `kft`. +Example: `@unit_symbols ft Foot 𝐋` results in `ft` getting defined but not `kft`. """ macro unit_symbols(symb, name, user_dimension, basefactor, makepublic=false) s = Symbol(symb) From e7cd2400253b40cf4a03920067abfb3968aec138 Mon Sep 17 00:00:00 2001 From: Ben Elkin <8xe8n-cm@online.de> Date: Sat, 27 Sep 2025 00:55:57 +0200 Subject: [PATCH 5/8] change docstrings due to changed display after declaring vars as public --- docs/src/conversion.md | 4 ++-- src/user.jl | 2 +- src/utils.jl | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/src/conversion.md b/docs/src/conversion.md index d1363e76..22b6d984 100644 --- a/docs/src/conversion.md +++ b/docs/src/conversion.md @@ -140,12 +140,12 @@ the following three cases: ```jldoctest julia> [1.0u"m", 2.0u"m"] -2-element Vector{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}: +2-element Vector{Quantity{Float64, 𝐋, Unitful.LengthFreeUnits{(m,), nothing}}}: 1.0 m 2.0 m julia> [1.0u"m", 2.0u"cm"] -2-element Vector{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}: +2-element Vector{Quantity{Float64, 𝐋, Unitful.LengthFreeUnits{(m,), nothing}}}: 1.0 m 0.02 m diff --git a/src/user.jl b/src/user.jl index 9b36637b..96e69b08 100644 --- a/src/user.jl +++ b/src/user.jl @@ -647,7 +647,7 @@ julia> u"m,kg,s" (m, kg, s) julia> typeof(1.0u"m/s") -Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(m, s^-1), 𝐋 𝐓^-1, nothing}} +Quantity{Float64, 𝐋 𝐓^-1, Unitful.VelocityFreeUnits{(m, s^-1), nothing}} julia> u"ħ" 1.0545718176461565e-34 J s diff --git a/src/utils.jl b/src/utils.jl index 4283dccf..606a05ee 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -69,17 +69,17 @@ the result to PyPlot, for example. ```jldoctest julia> a = [1u"m", 2u"m"] -2-element Vector{Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}: +2-element Vector{Quantity{Int64, 𝐋, Unitful.LengthFreeUnits{(m,), nothing}}}: 1 m 2 m julia> b = ustrip(a) -2-element reinterpret(Int64, ::Vector{Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}): +2-element reinterpret(Int64, ::Vector{Quantity{Int64, 𝐋, Unitful.LengthFreeUnits{(m,), nothing}}}): 1 2 julia> a[1] = 3u"m"; b -2-element reinterpret(Int64, ::Vector{Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}): +2-element reinterpret(Int64, ::Vector{Quantity{Int64, 𝐋, Unitful.LengthFreeUnits{(m,), nothing}}}): 3 2 ``` From 5296073da71c9958dfbf56e792169530acda0018 Mon Sep 17 00:00:00 2001 From: Eben60 <61665180+Eben60@users.noreply.github.com> Date: Sat, 27 Sep 2025 16:30:03 +0200 Subject: [PATCH 6/8] remove empty line Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/user.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/user.jl b/src/user.jl index 96e69b08..1f77f07c 100644 --- a/src/user.jl +++ b/src/user.jl @@ -100,7 +100,6 @@ macro dimension(symb, abbr, name, autodocs=false, makepublic=false) $Level{L,S,$Quantity{T,$s,U}} where {L,S}} const global ($uname){U} = $Units{U,$s} const global ($funame){U} = $FreeUnits{U,$s} - if $autodocs @doc $name_doc $name @doc $unit_doc $uname From 901184662d217e95dac24fd2608d5a410d65612a Mon Sep 17 00:00:00 2001 From: Ben Elkin <8xe8n-cm@online.de> Date: Sat, 27 Sep 2025 22:10:57 +0200 Subject: [PATCH 7/8] set makepublic=false; add testset "Declare Public" --- src/user.jl | 4 +- test/runtests.jl | 103 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 2 deletions(-) diff --git a/src/user.jl b/src/user.jl index 1f77f07c..873e76d5 100644 --- a/src/user.jl +++ b/src/user.jl @@ -293,7 +293,7 @@ macro unit(symb, abbr, name, equals, tf, autodocs=false, makepublic=false) end """ - @affineunit(symb, abbr, offset, makepublic=true) + @affineunit(symb, abbr, offset, makepublic=false) Macro for easily defining affine units. `offset` gives the zero of the relative scale in terms of an absolute scale; the scaling is the same as the absolute scale. Example: `@affineunit °C "°C" (27315//100)K` is used internally to define degrees Celsius. @@ -303,7 +303,7 @@ If `makepublic=true`, makes the unit name public when running on Julia ≥ 1.11. Documenting the resulting unit by adding a docstring before the `@affineunit` call requires Unitful 1.10 or later. """ -macro affineunit(symb, abbr, offset, makepublic=true) +macro affineunit(symb, abbr, offset, makepublic=false) s = Symbol(symb) expr1 = quote Base.@__doc__ const global $s = $affineunit($offset) diff --git a/test/runtests.jl b/test/runtests.jl index 07599fa4..6f3d06c7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2556,6 +2556,109 @@ using REPL # This is necessary to make `@doc` work correctly """ end +VERSION >= v"1.11.0-DEV.469" && @testset "Declare Public" begin + all_public_vars = Symbol[ + :A, :AbstractQuantity, :Acceleration, :AccelerationFreeUnits, :AccelerationUnits, :Action, :ActionFreeUnits, + :ActionUnits, :Amount, :AmountFreeUnits, :AmountUnits, :Area, :AreaFreeUnits, :AreaUnits, :BField, + :BFieldFreeUnits, :BFieldUnits, :Ba, :Bq, :C, :Capacitance, :CapacitanceFreeUnits, :CapacitanceUnits, :Charge, + :ChargeFreeUnits, :ChargeUnits, :Current, :CurrentFreeUnits, :CurrentUnits, :DField, :DFieldFreeUnits, + :DFieldUnits, :Density, :DensityFreeUnits, :DensityUnits, :DynamicViscosity, :DynamicViscosityFreeUnits, + :DynamicViscosityUnits, :EA, :EBa, :EBq, :EC, :EF, :EField, :EFieldFreeUnits, :EFieldUnits, :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, :ElectricDipoleMoment, + :ElectricDipoleMomentFreeUnits, :ElectricDipoleMomentUnits, :ElectricQuadrupoleMoment, + :ElectricQuadrupoleMomentFreeUnits, :ElectricQuadrupoleMomentUnits, :ElectricalConductance, + :ElectricalConductanceFreeUnits, :ElectricalConductanceUnits, :ElectricalConductivity, + :ElectricalConductivityFreeUnits, :ElectricalConductivityUnits, :ElectricalResistance, + :ElectricalResistanceFreeUnits, :ElectricalResistanceUnits, :ElectricalResistivity, + :ElectricalResistivityFreeUnits, :ElectricalResistivityUnits, :Elm, :Elx, :Em, :Emol, :Energy, :EnergyFreeUnits, + :EnergyUnits, :Erad, :Es, :Esr, :Eyr, :EΩ, :F, :Force, :ForceFreeUnits, :ForceUnits, :Frequency, + :FrequencyFreeUnits, :FrequencyUnits, :G, :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, :HField, :HFieldFreeUnits, :HFieldUnits, :Hz, :Hz2π, :Inductance, :InductanceFreeUnits, + :InductanceUnits, :J, :K, :KinematicViscosity, :KinematicViscosityFreeUnits, :KinematicViscosityUnits, :L, + :Length, :LengthFreeUnits, :LengthUnits, :Luminosity, :LuminosityFreeUnits, :LuminosityUnits, :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, :MagneticDipoleMoment, :MagneticDipoleMomentFreeUnits, + :MagneticDipoleMomentUnits, :MagneticFlux, :MagneticFluxFreeUnits, :MagneticFluxUnits, :Mass, :MassFlow, + :MassFlowFreeUnits, :MassFlowUnits, :MassFreeUnits, :MassUnits, :Matm, :Mb, :Mbar, :Mcal, :Mcd, :Mdyn, :MeV, + :Merg, :Mg, :Mkat, :Ml, :Mlm, :Mlx, :Mm, :Mmol, :Molality, :MolalityFreeUnits, :MolalityUnits, :MolarFlow, + :MolarFlowFreeUnits, :MolarFlowUnits, :MolarMass, :MolarMassFreeUnits, :MolarMassUnits, :Molarity, + :MolarityFreeUnits, :MolarityUnits, :Momentum, :MomentumFreeUnits, :MomentumUnits, :Mrad, :Ms, :Msr, :Mx, :Myr, + :MΩ, :N, :Na, :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, :Power, :PowerFreeUnits, :PowerUnits, :Prad, + :Pressure, :PressureFreeUnits, :PressureUnits, :Ps, :Psr, :Pyr, :PΩ, :R, :Ra, :R∞, :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, :Temperature, + :TemperatureFreeUnits, :TemperatureUnits, :Terg, :Tg, :Time, :TimeFreeUnits, :TimeUnits, :Tkat, :Tl, :Tlm, :Tlx, + :Tm, :Tmol, :Torr, :Trad, :Ts, :Tsr, :Tyr, :TΩ, :V, :Velocity, :VelocityFreeUnits, :VelocityUnits, :Voltage, + :VoltageFreeUnits, :VoltageUnits, :Volume, :VolumeFlow, :VolumeFlowFreeUnits, :VolumeFlowUnits, :VolumeFreeUnits, + :VolumeUnits, :W, :Wavenumber, :WavenumberFreeUnits, :WavenumberUnits, :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Ω, :Z0, :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, :c0, :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, :deg, :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, :gn, :gr, :h, :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, :k, :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, :me, :meV, :merg, :mg, :mi, :mil, :minute, :mkat, + :ml, :mlm, :mlx, :mm, :mmol, :mn, :mol, :mp, :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, :pcm, :pdyn, :peV, :percent, :perg, :permille, :pertenthousand, :pg, :pkat, :pl, :plm, :plx, :pm, :pmol, + :ppb, :ppm, :ppq, :ppt, :prad, :ps, :psi, :psr, :pyr, :pΩ, :q, :rad, :rpm, :rps, :s, :sr, :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, :Å, :ħ, :Φ0, :Ω, :ε0, :μ0, :μA, :μB, :μ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, :μΩ, :σ, :ϵ0, :𝐈, :𝐉, :𝐋, :𝐌, :𝐍, :𝐓, :𝚯] + + private_vars = Symbol[ + :AbsoluteScaleTemperature, :Affine, :AffineError, :AffineQuantity, :AffineUnits, :B, :B_p, :B_rp, :Bel, + :BracketStyle, :Centineper, :ContextUnits, :Decibel, :Dimension, :DimensionError, :DimensionlessUnits, :Dimensions, + :FixedUnits, :FreeOrContextUnits, :FreeUnits, :IsRootPowerRatio, :LogInfo, :LogScaled, :MixedUnits, :Neper, + :NoBrackets, :Np, :Np_p, :Np_rp, :PowerRatio, :RealOrRealQuantity, :ReferenceQuantity, :RelativeScaleTemperature, + :RootPowerRatio, :RoundBrackets, :ScalarQuantity, :ScalarUnits, :SquareBrackets, :Unit, :Unitlike, :Units, :abbr, + :abs2_fast, :abs_fast, :affinetranslation, :affineunit, :base, :basefactor, :basefactors_expr, :cNp, :cNp_p, + :cNp_rp, :colon, :colonstartstop, :conj_fast, :convfact, :convfact_floattype, :dB, :dBFS, :dBHz, :dBS, :dBSPL, :dBV, + :dB_p, :dB_rp, :dBm, :dBu, :dBΩ, :dBμV, :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] + + @test Base.ispublic.(Ref(Unitful), all_public_vars) |> all + @test Base.ispublic.(Ref(Unitful), private_vars) |> any |> ! +end + # Test precompiled Unitful extension modules mktempdir() do load_path mktempdir() do load_cache_path From 13218612a0a5e5aca1903a275a29d2c26bf7814b Mon Sep 17 00:00:00 2001 From: Eben60 Date: Mon, 29 Sep 2025 13:00:52 +0200 Subject: [PATCH 8/8] replace explicit declaration of :u as public by @unit macro argument --- src/pkgdefaults.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 7bc6d17e..e52a21a9 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -539,8 +539,7 @@ mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 × 10^-2 (the CODATA 2018 recommended value). \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.kg`](@ref)." -@unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false # (50) -@public u +@unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false false true# (50) # Acceleration " Unitful.ge