Skip to content

Enforce explicit unitless instead of allowing None in unit connections #66

@enricostragiotti

Description

@enricostragiotti

Summary

In building larger and more robust OpenMDAO models, we've noticed that connections between variables with units=None and those with real units (e.g., "m", "kg", and especially "unitless") can lead to silent modeling bugs.

Currently:

  • Connecting output: units='m'input: units=None issues only a warning.
  • Connecting output: units=Noneinput: units='m' raises an error.
  • Connecting output: units="unitless"input: units=None only warns.
  • Connecting output: units=Noneinput: units="unitless" raises an error.

This inconsistent behavior makes None problematic for modeling, and difficult to detect during development unless warnings are explicitly checked.

Proposal

We propose in CS25 to:

  1. Deprecate the use of implicit units=None when declaring input variables in favor of explicitly using "unitless" where appropriate.
  2. Disallow connections involving units=None, even if both ends are None, to prevent ambiguity.

Motivation

  • We want all unit mismatches to raise errors — not just warnings — for better model safety.
  • "unitless" is explicit and supports dimensional analysis; None does not.
  • Prevents silent failures when unitless variables are incorrectly connected to dimensional ones.

CS25 Unit Test Observations

We noticed that in the cs25 unit tests, many warnings are issued due to connections where variables with units=None are connected to variables with units like "m" or "deg". This indicates a real-world example of the problem due to None being allowed.
We need to fix those cases.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions