Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: fix fortran IO test for big-endian architectures #4577

Merged
merged 1 commit into from
Jul 17, 2023
Merged
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
10 changes: 7 additions & 3 deletions yt/utilities/tests/test_cython_fortran_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import struct

import numpy as np
import pytest

Expand All @@ -12,9 +14,11 @@ def test_raise_error_when_file_does_not_exist():
def test_read(tmp_path):
dummy_file = tmp_path / "test.bin"
# Write a Fortran-formatted file containing one record with 4 doubles
dummy_file.write_bytes(
b" \x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x08@\x00\x00\x00\x00\x00\x00\x10@ \x00\x00\x00"
)
# The format is a 32bit integer with value 4*sizeof(double)=32
# followed by 4 doubles and another 32bit integer with value 32
# Note that there is no memory alignment, hence the "=" below
buff = struct.pack("=i 4d i", 32, 1.0, 2.0, 3.0, 4.0, 32)
dummy_file.write_bytes(buff)
with FortranFile(str(dummy_file)) as f:
np.testing.assert_equal(
f.read_vector("d"),
Expand Down