Skip to content

Commit eecf01d

Browse files
committed
pylint
1 parent 96673bc commit eecf01d

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

src/pyhs3/core.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,20 @@ def __init__(
116116
)
117117

118118
self.distributions: dict[str, T.TensorVar] = {}
119-
G: nx.DiGraph[str] = nx.DiGraph()
119+
graph: nx.DiGraph[str] = nx.DiGraph()
120120
for dist in distributions:
121-
G.add_node(dist.name, type="distribution")
121+
graph.add_node(dist.name, type="distribution")
122122
for parameter in dist.parameters:
123123
if not (
124-
parameter in G and G.nodes[parameter]["type"] == "distribution"
124+
parameter in graph
125+
and graph.nodes[parameter]["type"] == "distribution"
125126
):
126-
G.add_node(parameter, type="parameter")
127+
graph.add_node(parameter, type="parameter")
127128

128-
G.add_edge(parameter, dist.name)
129+
graph.add_edge(parameter, dist.name)
129130

130-
for node in nx.topological_sort(G):
131-
if G.nodes[node]["type"] != "distribution":
131+
for node in nx.topological_sort(graph):
132+
if graph.nodes[node]["type"] != "distribution":
132133
continue
133134
self.distributions[node] = distributions[node].expression(
134135
{**self.parameters, **self.distributions}
@@ -309,20 +310,20 @@ class DomainSet:
309310
DomainSet
310311
"""
311312

312-
def __init__(self, axes: list[T.Axis], name: str, type: str):
313+
def __init__(self, axes: list[T.Axis], name: str, dtype: str):
313314
"""
314315
Represents a set of valid domains for parameters.
315316
316317
Args:
317318
axes (list): List of domain configurations.
318319
name (str): Name of the domain set.
319-
type (str): Type of the domain.
320+
dtype (str): Type of the domain.
320321
321322
Attributes:
322323
domains (OrderedDict): Mapping of parameter names to allowed ranges.
323324
"""
324325
self.name = name
325-
self.type = type
326+
self.type = dtype
326327
self.domains: dict[str, tuple[float, float]] = OrderedDict()
327328

328329
for domain_config in axes:
@@ -336,11 +337,11 @@ def __getitem__(self, item: int | str) -> tuple[float, float]:
336337
return self.domains[key]
337338

338339

339-
DistType = TypeVar("DistType", bound="Distribution[T.Distribution]")
340-
DistConfig = TypeVar("DistConfig", bound=T.Distribution)
340+
DistT = TypeVar("DistT", bound="Distribution[T.Distribution]")
341+
DistConfigT = TypeVar("DistConfigT", bound=T.Distribution)
341342

342343

343-
class Distribution(Generic[DistConfig]):
344+
class Distribution(Generic[DistConfigT]):
344345
"""
345346
Distribution
346347
"""
@@ -349,7 +350,7 @@ def __init__(
349350
self,
350351
*,
351352
name: str,
352-
type: str = "Distribution",
353+
dtype: str = "Distribution",
353354
parameters: list[str] | None = None,
354355
**kwargs: Any,
355356
):
@@ -358,21 +359,19 @@ def __init__(
358359
359360
Args:
360361
name (str): Name of the distribution.
361-
type (str): Type identifier.
362+
dtype (str): Type identifier.
362363
363364
Attributes:
364365
name (str): Name of the distribution.
365-
type (str): Type identifier.
366+
dtype (str): Type identifier.
366367
parameters (list[str]): initially empty list to be filled with parameter names.
367368
"""
368369
self.name = name
369-
self.type = type
370+
self.type = dtype
370371
self.parameters = parameters or []
371372
self.kwargs = kwargs
372373

373-
def expression(
374-
self, distributionsandparameters: dict[str, T.TensorVar]
375-
) -> T.TensorVar:
374+
def expression(self, _: dict[str, T.TensorVar]) -> T.TensorVar:
376375
"""
377376
Unimplemented
378377
"""
@@ -381,8 +380,8 @@ def expression(
381380

382381
@classmethod
383382
def from_dict(
384-
cls: type[Distribution[DistConfig]], config: DistConfig
385-
) -> Distribution[DistConfig]:
383+
cls: type[Distribution[DistConfigT]], config: DistConfigT
384+
) -> Distribution[DistConfigT]:
386385
"""
387386
Factory method to create a distribution instance from a dictionary.
388387
@@ -418,7 +417,7 @@ def __init__(self, *, name: str, mean: str, sigma: str, x: str):
418417
x (str): Input variable name.
419418
parameters (list[str]): list containing mean, sigma, and x.
420419
"""
421-
super().__init__(name=name, type="gaussian_dist", parameters=[mean, sigma, x])
420+
super().__init__(name=name, dtype="gaussian_dist", parameters=[mean, sigma, x])
422421
self.mean = mean
423422
self.sigma = sigma
424423
self.x = x
@@ -496,7 +495,7 @@ def __init__(
496495
parameters (list[str]): List of coefficients and summands
497496
"""
498497
super().__init__(
499-
name=name, type="mixture_dist", parameters=[*coefficients, *summands]
498+
name=name, dtype="mixture_dist", parameters=[*coefficients, *summands]
500499
)
501500
self.name = name
502501
self.coefficients = coefficients

src/pyhs3/logging.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111

1212
class AppFilter(logging.Filter):
13+
"""
14+
AppFilter
15+
"""
16+
1317
def filter(self, record: LogRecord) -> bool:
1418
record.filenameStem = Path(record.filename).stem
1519
return True

0 commit comments

Comments
 (0)