Skip to content

Commit

Permalink
Migrate from defaultdict to Counter
Browse files Browse the repository at this point in the history
To fix:
src/correctionlib/schemav2.py:419:37: B910 Use Counter() instead of defaultdict(int) to avoid excessive memory use
  • Loading branch information
nsmith- committed Dec 9, 2024
1 parent 79832f6 commit e1fc0ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/correctionlib/schemav2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import math
import sys
from collections import defaultdict
from collections import Counter
from typing import Dict, List, Optional, Set, Tuple, Union

from pydantic import (
Expand Down Expand Up @@ -416,7 +416,7 @@ def validate_output(cls, output: Variable) -> Variable:
return output

def summary(self) -> Tuple[Dict[str, int], Dict[str, _SummaryInfo]]:
nodecount: Dict[str, int] = defaultdict(int)
nodecount: Dict[str, int] = Counter()
inputstats = {var.name: _SummaryInfo() for var in self.inputs}
if not isinstance(self.data, float):
self.data.summarize(nodecount, inputstats)
Expand Down

0 comments on commit e1fc0ec

Please sign in to comment.