Skip to content

Commit 120c449

Browse files
Merge branch 'v4-dev' into unit_conversion_bug
2 parents fb33010 + 8669a13 commit 120c449

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
build/*
22
docs/_build/*
33
docs/_downloads
4-
lib/
5-
bin/
6-
parcels_examples
74

8-
*.so
95
*.log
106
*.nc
117
*.nc4
128
!*testfields*.nc
139
out-*
14-
*.c
1510
*.pyc
16-
*.dSYM/*
1711
**/*.zarr/*
1812
.DS_store
1913

tests/utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import struct
56
from pathlib import Path
67
from typing import TYPE_CHECKING
78

@@ -133,3 +134,16 @@ def assert_valid_field_data(data: xr.DataArray, grid: XGrid):
133134
if ax_actual is None:
134135
continue # None is ok
135136
assert ax_actual == ax_expected, f"Expected axis {ax_expected} for dimension '{dim}', got {ax_actual}"
137+
138+
139+
def hash_float_array(arr):
140+
# Adapted from https://cs.stackexchange.com/a/37965
141+
h = 1
142+
for f in arr:
143+
# Mimic Float.floatToIntBits: converts float to 4-byte binary, then interprets as int
144+
float_as_int = struct.unpack("!i", struct.pack("!f", f))[0]
145+
h = 31 * h + float_as_int
146+
147+
# Mimic Java's HashMap hash transformation
148+
h ^= (h >> 20) ^ (h >> 12)
149+
return h ^ (h >> 7) ^ (h >> 4)

0 commit comments

Comments
 (0)