JuliaPhysics / JuliaPhysics/Unitful.jl

Proposal: add EnergyTraits

Open
#512 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
675
Forks
124
Avg merge
3h 38m
Merged PRs (30d)
1

Description

I propose adding a dependency to Unitful.jl based on a new trait package [EnergyTraits.jl](https://github.com/JuliaAstro/EnergyTraits.jl). As a proof of concept, these traits allow functional dispatch on the units involved in the equation `E = h * nu = h * c0 / lambda`.

I have yet to register this package, because I want to see what the feelings over here are. Part of my idea of making EnergyTraits potentially so powerful is having it work with units out of the box. To that end, I have tried to make the package as lightweight as possible (no dependencies, 1 function, 3 types) and I've created a function that automatically tests the trait interface, so actually adding the code should be very easy.

**What would the changes look like?**

Well, I took a stab at this already in this snippet https://github.com/JuliaAstro/EnergyTraits.jl/blob/d21a2c46cb430ebc6c758937a1f469bfa046bb5f/test/runtests.jl#L7-L9

I'm not positive how the dimensions cascade (i.e., while they always simplify?). If so, would the above lines be sufficient for *all* the units? It works in the example in that test file, so I'm eager!

So, would this be a welcome effort in Unitful.jl? I am happy to make the necessary PRs, and add any documentation requested. Thanks for your time!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the proposed EnergyTraits.jl interface and the referenced test/runtests.jl lines 7-9, then inspect Unitful.jl's existing trait and unit-dispatch APIs. The issue does not name a Unitful.jl target file or test; done would require an agreed integration design and confirmation that the trait behavior works across the relevant units.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.