From cde3807ae76634e8f5e1a05b57568f18c339e598 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 28 May 2024 21:35:53 +0200 Subject: [PATCH 1/5] np.unicode_ will be removed in np2 --- pocean/tests/test_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pocean/tests/test_utils.py b/pocean/tests/test_utils.py index 75fd097..b5e01bd 100644 --- a/pocean/tests/test_utils.py +++ b/pocean/tests/test_utils.py @@ -203,7 +203,7 @@ def test_normalization_of_string_arrays_netcdf4(self): # Single str (no dimension) ncd.createVariable('single_str', str) - ncd.createVariable('single_unicode_', np.unicode_) + ncd.createVariable('single_unicode_', np.str_) ncd.createVariable('single_U', ' Date: Tue, 18 Jun 2024 09:01:08 +0200 Subject: [PATCH 2/5] Group dependabot's PRs --- .github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 563dd9b..204a481 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,3 +9,7 @@ updates: interval: "daily" labels: - "Bot" + groups: + github-actions: + patterns: + - '*' \ No newline at end of file From 6eede3d716a8462224c75f717124d09989060015 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 18 Jun 2024 10:04:53 +0200 Subject: [PATCH 3/5] easier diffs --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e6afae1..1ffc334 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] os: [windows-latest, ubuntu-latest, macos-latest] fail-fast: false From 79c42282a7ae74c05a653cf620abcd5bad42da89 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 18 Jun 2024 10:05:04 +0200 Subject: [PATCH 4/5] update --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ddfd7e3..e5cadad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - requirements-dev.txt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.8 + rev: v0.4.9 hooks: - id: ruff From 0906ca63b3fc8e40dab2cf19955217a2757cbdfe Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 18 Jun 2024 10:05:46 +0200 Subject: [PATCH 5/5] upscale int8 to int16 for numpy 2.0 --- pocean/dsg/trajectoryProfile/cr.py | 2 ++ pocean/tests/test_utils.py | 2 +- pocean/utils.py | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pocean/dsg/trajectoryProfile/cr.py b/pocean/dsg/trajectoryProfile/cr.py index 89b858e..7ce50a3 100644 --- a/pocean/dsg/trajectoryProfile/cr.py +++ b/pocean/dsg/trajectoryProfile/cr.py @@ -20,6 +20,7 @@ get_ncdata_from_series, nativize_times, normalize_countable_array, + upscale_int8, ) @@ -323,6 +324,7 @@ def to_dataframe(self, clean_cols=True, clean_rows=True, **kwargs): df_data[dnam] = vdata df = pd.DataFrame(df_data) + df = upscale_int8(df) # Drop all data columns with no data if clean_cols: diff --git a/pocean/tests/test_utils.py b/pocean/tests/test_utils.py index b5e01bd..ceb7e45 100644 --- a/pocean/tests/test_utils.py +++ b/pocean/tests/test_utils.py @@ -138,7 +138,7 @@ def test_generic_masked_bad_min_max_value(self): # to make sure it doesn't error b = ncd.createVariable('imabyte', 'b') b.valid_min = 0 - b.valid_max = 600 # this is over a byte and thus invalid + b.valid_max = np.int16(600) # this is over a byte and thus invalid b[:] = 3 r = generic_masked(b[:], attrs=ncd.vatts(b.name)) assert np.all(r.mask == False) # noqa diff --git a/pocean/utils.py b/pocean/utils.py index ef32bc1..06b5b51 100644 --- a/pocean/utils.py +++ b/pocean/utils.py @@ -458,6 +458,13 @@ def dict_update(d, u): return d +def upscale_int8(df): + """Numpy 2.0 no linger upcast dtypes. + In order to preserve the data's original dtype we upcast it here after reading it. + + """ + return df.astype({col: "int16" for col in df.columns[df.dtypes == "int8"]}) + class JSONEncoder(json.JSONEncoder): def default(self, obj):