Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2.2.1
-------------------

*2026-01-14*
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, missed this during review, but FYI:

When creating new changelog entries, use UNRELEASED for the date like this:

Suggested change
*2026-01-14*
*UNRELEASED*

This way it is clear this release was not done yet when looking at master, and this is naturally updated to the actual release date as part of the release process.


* Fixed ``UnboundLocalError`` bug when performing multiplication in an empty array.

2.2.0
-----

Expand Down
6 changes: 6 additions & 0 deletions src/barril/units/_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ def _DoOperation(self, p1: SelfT, p2: SelfT, operation: str) -> SelfT:
q, v = operation_func(q1, q2, v0, v1)
result.append(v)

# When there are no values to iterate, `q` would end up being undefined.
if not result:
q = Quantity.CreateDerived(
q1.GetCategoryToUnitAndExps() | q2.GetCategoryToUnitAndExps()
Comment thread
nicoddemus marked this conversation as resolved.
)

if values_iteration.IsTuple():
result = tuple(result) # type:ignore[assignment]
return self.__class__.CreateWithQuantity(q, result) # type:ignore[return-value]
13 changes: 10 additions & 3 deletions src/barril/units/_tests/test_array.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from typing import List
from typing import Tuple

import pytest
from collections import OrderedDict
from pytest import approx
Expand All @@ -20,6 +17,16 @@ def testEmptyArray() -> None:
arr = arr.CreateCopy(category="temperature", unit="degC")
assert arr.HasCategory()

array: Array = Array([], "m") * 2
assert array.GetValues() == []
assert array.category == "length"
assert array.unit == "m"

array = 2 * Array([], "m")
assert array.GetValues() == []
assert array.category == "length"
assert array.unit == "m"


def testValues() -> None:
array = units.Array("length", values=[100, 150, 200], unit="m")
Expand Down
Loading