Skip to content

Positional constructors and Units #1822

Description

@luke-kiernan

Get positional constructors to accept units-bearing values. Right now, only the keyword argument ones do, which is a weird inconsistency.

There's also the question of whether units should be required, and if so, what that looks like. Taking ACBus as an example, the following args have implicit units:

  ACBus(
      number::Int,
      name::String,
      available::Bool,
      bustype::Union{Nothing, ACBusTypes.Value},
      angle::Union{Nothing, Float},                     # NU, radians
      magnitude::Union{Nothing, Float},                 # CU
      voltage_limits::Union{Nothing, MinMax},           # CU
      base_voltage::Union{Nothing, Float},              # NU, kV
      area::Union{Nothing, Area} = nothing,
      load_zone::Union{Nothing, LoadZone} = nothing;
  ) -> ACBus

Aside: it'd make things marginally easier on the user if our positional constructors had typed arguments. As-is, if you mangle the constructor call, the "closest candidates" are listed as ACBus(::Any, ::Any, ... ::Any), which isn't terribly helpful.

Activity

  1. self-assigned this
    on Sep 28, 2026
  2. kdayday commented on Sep 29, 2026

    @kdayday
    Contributor

    I'm not sure how much people use the positional constructors; I was told at some point to avoid them and always use the kwarg ones. That's what we show in tutorials. This seems to overlap with this documentation issue, where we're not printing either kwarg or positional function signatures in docstrings: #1824

    Optionally, we could ignore this and rely on better docstrings to point people to the kwarg constructors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions