From f013c2a8ebfd818d773917fdea52be08749895d4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 19:15:40 +0000 Subject: [PATCH 1/2] chore: update pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.10 → v0.11.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.10...v0.11.0) --- .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 581f8f756..8a85b684b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.10 + rev: v0.11.0 hooks: - id: ruff args: [--fix, --show-fixes] From bb59432f21dba163dc592a79b2d8272eb8d1bf49 Mon Sep 17 00:00:00 2001 From: Andres Rios Tascon Date: Mon, 17 Mar 2025 15:25:32 -0400 Subject: [PATCH 2/2] Fixed lint issues --- src/uproot/_dask.py | 12 ++++-------- src/uproot/behaviors/TBranch.py | 2 +- src/uproot/models/RNTuple.py | 2 +- src/uproot/writing/_cascade.py | 10 +++++----- src/uproot/writing/_cascadetree.py | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/uproot/_dask.py b/src/uproot/_dask.py index 6a87ded19..0b2b4633c 100644 --- a/src/uproot/_dask.py +++ b/src/uproot/_dask.py @@ -632,9 +632,7 @@ def real_filter_branch(branch): assert steps_per_file is not unset # either assigned or assumed to be 1 total_files = len(ttrees) total_entries = sum(ttree.num_entries for ttree in ttrees) - step_size = max( - 1, int(math.ceil(total_entries / (total_files * steps_per_file))) - ) + step_size = max(1, math.ceil(total_entries / (total_files * steps_per_file))) if count == 0: raise ValueError( @@ -672,7 +670,7 @@ def real_filter_branch(branch): ) step_sum += int(ttree_step) - entry_step = int(round(step_sum / len(ttrees))) + entry_step = round(step_sum / len(ttrees)) assert entry_step >= 1 for key in common_keys: @@ -1490,9 +1488,7 @@ def real_filter_branch(branch): assert steps_per_file is not unset # either assigned or assumed to be 1 total_files = len(ttrees) total_entries = sum(ttree.num_entries for ttree in ttrees) - step_size = max( - 1, int(math.ceil(total_entries / (total_files * steps_per_file))) - ) + step_size = max(1, math.ceil(total_entries / (total_files * steps_per_file))) if count == 0: raise ValueError( @@ -1528,7 +1524,7 @@ def real_filter_branch(branch): ) step_sum += int(ttree_step) - entry_step = int(round(step_sum / len(ttrees))) + entry_step = round(step_sum / len(ttrees)) divisions = [0] partition_args = [] diff --git a/src/uproot/behaviors/TBranch.py b/src/uproot/behaviors/TBranch.py index dc8c22c38..ebf86b6e8 100644 --- a/src/uproot/behaviors/TBranch.py +++ b/src/uproot/behaviors/TBranch.py @@ -3242,7 +3242,7 @@ def _hasbranches_num_entries_for( if total_bytes == 0: num_entries = 0 else: - num_entries = int(round(target_num_bytes * total_entries / total_bytes)) + num_entries = round(target_num_bytes * total_entries / total_bytes) if num_entries <= 0: return 1 else: diff --git a/src/uproot/models/RNTuple.py b/src/uproot/models/RNTuple.py index e406ddac4..311cac693 100644 --- a/src/uproot/models/RNTuple.py +++ b/src/uproot/models/RNTuple.py @@ -166,7 +166,7 @@ def _num_entries_for(in_ntuple, target_num_bytes, filter_name): if total_bytes == 0: num_entries = 0 else: - num_entries = int(round(target_num_bytes * total_entries / total_bytes)) + num_entries = round(target_num_bytes * total_entries / total_bytes) if num_entries <= 0: return 1 else: diff --git a/src/uproot/writing/_cascade.py b/src/uproot/writing/_cascade.py index 690cd9c1c..8dc5e481b 100644 --- a/src/uproot/writing/_cascade.py +++ b/src/uproot/writing/_cascade.py @@ -1581,8 +1581,8 @@ def add_object( if replaces is None: next_key = key.copy_to(self._data.next_location) if self._data.num_bytes + next_key.num_bytes > self._data.allocation: - requested_num_bytes = int( - math.ceil(1.5 * (self._data.allocation + next_key.num_bytes + 8)) + requested_num_bytes = math.ceil( + 1.5 * (self._data.allocation + next_key.num_bytes + 8) ) self._reallocate_data(requested_num_bytes) next_key = key.copy_to(self._data.next_location) @@ -1597,8 +1597,8 @@ def add_object( self._data.num_bytes + new_key.num_bytes - original_key.num_bytes > self._data.allocation ): - requested_num_bytes = int( - math.ceil(1.5 * (self._data.allocation + new_key.num_bytes + 8)) + requested_num_bytes = math.ceil( + 1.5 * (self._data.allocation + new_key.num_bytes + 8) ) self._reallocate_data(requested_num_bytes) original_key = self._data.get_key(replaces.name.string, replaces.cycle) @@ -1685,7 +1685,7 @@ def add_directory(self, sink, name, initial_directory_bytes, uuid, flush=True): next_key = subdirectory_key.copy_to(self._data.next_location) if self._data.num_bytes + next_key.num_bytes > self._data.allocation: self._reallocate_data( - int(math.ceil(1.5 * (self._data.allocation + next_key.num_bytes + 8))) + math.ceil(1.5 * (self._data.allocation + next_key.num_bytes + 8)) ) next_key = subdirectory_key.copy_to(self._data.next_location) next_key._location = self._data.next_location diff --git a/src/uproot/writing/_cascadetree.py b/src/uproot/writing/_cascadetree.py index 0c5619ab6..6019af610 100644 --- a/src/uproot/writing/_cascadetree.py +++ b/src/uproot/writing/_cascadetree.py @@ -462,7 +462,7 @@ def extend(self, file, sink, data): if self._num_baskets >= self._basket_capacity - 1: self._basket_capacity = max( self._basket_capacity + 1, - int(math.ceil(self._basket_capacity * self._resize_factor)), + math.ceil(self._basket_capacity * self._resize_factor), ) for datum in self._branch_data: