Skip to content

Commit bedcd18

Browse files
ryan-kipawaclaude
andcommitted
Apply the last review's wording and test suggestions
The changelog says it is the file axis's attributes that are written, the Flush docstring no longer credits C# for deferring a bad value, and the bad file axis test checks that the file is closed through Flush, not a field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b366af3 commit bedcd18

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
assigning an item's `Name` or `Quantity`, or changing an attribute of its
1414
`SpatialAxis` (such as `X0`), writes the change to the file. For a static
1515
item, `WriteStaticItemData` writes it. On a dfs1, dfs2 or dfs3 file,
16-
changing `SpatialAxis` updates every dynamic item on `Flush` or `Close`,
17-
and the static items with the same type of axis on `Close`. As in the C#
18-
library, a new name is truncated or padded to the length of the old one,
19-
and changing `Quantity.Item` or `Quantity.Unit` in place is not written.
20-
`SpatialAxis` of a dfs1, dfs2 or dfs3 file is now a copy of the first
21-
item's axis, as in the C# library, so changing it in a file opened for
22-
reading no longer changes that item's axis
16+
changing an attribute of the file's `SpatialAxis` updates every dynamic
17+
item on `Flush` or `Close`, and the static items with the same type of
18+
axis on `Close`. As in the C# library, a new name is truncated or padded
19+
to the length of the old one, and changing `Quantity.Item` or
20+
`Quantity.Unit` in place is not written. `SpatialAxis` of a dfs1, dfs2 or
21+
dfs3 file is now a copy of the first item's axis, as in the C# library, so
22+
changing it in a file opened for reading no longer changes that item's
23+
axis
2324
([#38](https://github.com/DHI/mikecore-python/issues/38)).
2425
- `DfsuFile.Flush()` flushes the file instead of raising `TypeError`, and
2526
`DfsFileFactory.DfsuFileOpenAppend` no longer requires `parameters`, like the

‎mikecore/Dfs123File.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def Flush(self):
6464
dynamic items here, and to the static items only on Close: writing a
6565
static item moves the file pointer, so a time step appended after
6666
Flush would overwrite another. The C# library writes both on Flush.
67-
As in the C# library, a value the file axis cannot hold is only
68-
rejected here or on Close, not when it is set.
67+
A value the file axis cannot hold is only rejected here or on Close,
68+
not when it is set.
6969
The whole file axis is written to each item, replacing changes made
7070
to an item's own axis, as in the C# library.
7171
"""

‎tests/test_dfs_edit.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,8 @@ def test_file_axis_reaches_an_item_whose_axis_was_replaced(fileAxisCase, replace
781781

782782
def test_bad_file_axis_value_is_rejected_on_flush_and_close(fileAxisCase):
783783
"""
784-
As in the C# library, a value the file axis cannot hold is accepted when
785-
set and rejected on Flush and Close. The file is still closed, unchanged.
784+
A value the file axis cannot hold is accepted when set and rejected on
785+
Flush and Close. The file is still closed, unchanged.
786786
"""
787787
case = fileAxisCase
788788
original = readBytes(case.filename)
@@ -794,5 +794,6 @@ def test_bad_file_axis_value_is_rejected_on_flush_and_close(fileAxisCase):
794794
with pytest.raises(AttributeError):
795795
file.Close()
796796

797-
assert file.filePointer.value is None
797+
with pytest.raises(OSError):
798+
file.Flush()
798799
assert original == readBytes(case.filename)

0 commit comments

Comments
 (0)