Skip to content

Commit 4034a3d

Browse files
committed
lint
1 parent 114f464 commit 4034a3d

File tree

12 files changed

+36
-17
lines changed

12 files changed

+36
-17
lines changed

.prospector.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ max-line-length: 120
22
test-warnings: false
33
doc-warnings: false
44
strictness: medium
5+
with: []
6+
uses: []
57
ignore-paths:
68
- docs
79
- tests
@@ -21,6 +23,7 @@ pycodestyle:
2123

2224
pylint:
2325
disable:
26+
- django-not-available
2427
- unsubscriptable-object
2528
- invalid-name
2629
- arguments-differ # to account for jobflow

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ enabled = true
114114
[dependency-groups]
115115
dev = [
116116
"black>=24.8.0",
117+
"prospector>=1.10.3",
117118
"pytest>=7.1.3",
118119
"pytest-cov>=4.0.0",
119120
]

src/pylattica/core/neighborhood_builders.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ def get(self, struct: PeriodicStructure, site_class: str = None) -> Neighborhood
139139
else:
140140
sites_to_process = struct.sites(site_class=site_class)
141141

142-
n_sites = len(all_sites)
143-
144142
# Extract locations and IDs as arrays for vectorized operations
145143
locations = np.array([s[LOCATION] for s in all_sites])
146144
site_ids = np.array([s[SITE_ID] for s in all_sites])
@@ -174,9 +172,6 @@ def get(self, struct: PeriodicStructure, site_class: str = None) -> Neighborhood
174172
# Build KD-tree with periodic boundary conditions
175173
tree = cKDTree(frac_coords_wrapped, boxsize=boxsize)
176174

177-
# Create index mapping from site_id to array index
178-
id_to_idx = {sid: idx for idx, sid in enumerate(site_ids)}
179-
180175
# Process each site
181176
sites_to_process_ids = set(s[SITE_ID] for s in sites_to_process)
182177

src/pylattica/core/runner/asynchronous_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AsynchronousRunner(Runner):
2727
that this mode should be used with the is_async initialization parameter.
2828
"""
2929

30-
def _run(
30+
def _run( # pylint: disable=too-many-positional-arguments
3131
self,
3232
_: SimulationState,
3333
result: SimulationResult,

src/pylattica/core/runner/synchronous_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, parallel: bool = False, workers: int = None) -> None:
3838
self.parallel = parallel
3939
self.workers = workers
4040

41-
def _run(
41+
def _run( # pylint: disable=too-many-positional-arguments
4242
self,
4343
initial_state: SimulationState,
4444
result: SimulationResult,

src/pylattica/core/simulation_result.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ def __init__(
8989
self._checkpoint_step: int = 0
9090
self._total_steps: int = 0
9191

92+
def get_diffs(self) -> list[dict]:
93+
"""Returns the list of diffs.
94+
95+
Returns
96+
-------
97+
list[dict]
98+
The list of state diffs.
99+
"""
100+
return self._diffs
101+
92102
def add_step(self, updates: Dict[int, Dict]) -> None:
93103
"""Takes a set of updates as a dictionary mapping site IDs
94104
to the new values for various state parameters. For instance, if at the
@@ -335,9 +345,9 @@ def compress_result(result: SimulationResult, num_steps: int):
335345
total_compress_freq = exact_sample_freq * result.compress_freq
336346
compressed_result = SimulationResult(i_state, compress_freq=total_compress_freq)
337347

338-
live_state = SimulationState(copy.deepcopy(i_state._state))
348+
live_state = SimulationState(copy.deepcopy(i_state.get_state()))
339349
next_sample_step = exact_sample_freq
340-
for i, diff in enumerate(result._diffs):
350+
for i, diff in enumerate(result.get_diffs()):
341351
curr_step = i + 1
342352
live_state.batch_update(diff)
343353
if curr_step > next_sample_step:

src/pylattica/core/simulation_state.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,15 @@ def copy(self) -> SimulationState:
183183
def as_state_update(self) -> Dict:
184184
return copy.deepcopy(self._state)
185185

186+
def get_state(self) -> Dict:
187+
"""Returns the internal state dictionary.
188+
189+
Returns
190+
-------
191+
Dict
192+
The internal state dictionary.
193+
"""
194+
return self._state
195+
186196
def __eq__(self, other: SimulationState) -> bool:
187197
return self._state == other._state

src/pylattica/structures/square_grid/grid_setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def setup_particle(
145145
)
146146
return Simulation(state, structure)
147147

148-
def setup_random_particles(
148+
def setup_random_particles( # pylint: disable=too-many-positional-arguments
149149
self,
150150
size: int,
151151
radius: int,
@@ -188,7 +188,7 @@ def setup_random_particles(
188188

189189
return Simulation(state, structure)
190190

191-
def add_particle_to_state(
191+
def add_particle_to_state( # pylint: disable=too-many-positional-arguments
192192
self,
193193
structure: PeriodicStructure,
194194
state: SimulationState,
@@ -276,7 +276,7 @@ def setup_noise(self, size: int, phases: typing.List[str]) -> Simulation:
276276
)
277277
return Simulation(state, structure)
278278

279-
def setup_random_sites(
279+
def setup_random_sites( # pylint: disable=too-many-positional-arguments
280280
self,
281281
size: int,
282282
num_sites_desired: int,

src/pylattica/structures/square_grid/growth_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, phase_set: PhaseSet, dim=2):
3131
self._phases = phase_set
3232
self.dim = dim
3333

34-
def grow(
34+
def grow( # pylint: disable=too-many-positional-arguments
3535
self,
3636
size: int,
3737
num_sites_desired: int,

src/pylattica/visualization/result_artist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
_dsr_globals = {}
1414

1515

16-
def default_annotation_builder(step, step_no):
16+
def default_annotation_builder(_step, step_no):
1717
return f"Step {step_no}"
1818

1919

@@ -97,7 +97,7 @@ def jupyter_play(self, cell_size: int = 20, wait: int = 1, **kwargs):
9797
wait : int, optional
9898
The time duration between frames in the animation. Defaults to 1., by default 1
9999
"""
100-
from IPython.display import clear_output, display # pragma: no cover
100+
from IPython.display import clear_output, display # pylint: disable=import-error # pragma: no cover
101101

102102
imgs = self._get_images(cell_size=cell_size, **kwargs) # pragma: no cover
103103
for img in imgs: # pragma: no cover

0 commit comments

Comments
 (0)