Skip to content

Commit 93320e9

Browse files
committed
lint: complied with flake8, added some exceptions.
1 parent d003376 commit 93320e9

File tree

8 files changed

+15
-35
lines changed

8 files changed

+15
-35
lines changed

floatcsep/commands/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def run(config: str, **kwargs) -> None:
9090
exp.make_repr()
9191

9292
log.info("Finalized")
93-
log.debug(f"-------- END OF RUN --------")
93+
log.debug("-------- END OF RUN --------")
9494

9595

9696
def plot(config: str, **kwargs) -> None:

floatcsep/evaluation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
import os
3-
from typing import Dict, Callable, Union, Sequence, List, Optional, Any
3+
from typing import Dict, Callable, Union, Sequence, List, Any
44

55
from csep.core.catalogs import CSEPCatalog
66
from csep.core.forecasts import GriddedForecast
@@ -297,7 +297,7 @@ def plot_results(
297297
pyplot.show()
298298
# Single model test plots (e.g., test distribution)
299299
# todo: handle this more elegantly
300-
except AttributeError as msg:
300+
except AttributeError:
301301
if self.type in ["consistency", "comparative"]:
302302
for time_str in timewindow:
303303
results = self.read_results(time_str, models)
@@ -311,7 +311,9 @@ def plot_results(
311311
ax = func(result, plot_args=fargs, **fkwargs, show=False)
312312
if "code" in fargs:
313313
exec(fargs["code"])
314-
pyplot.savefig(fig_path, dpi=dpi)
314+
fig = ax.get_figure()
315+
fig.savefig(fig_path, dpi=dpi)
316+
315317
if show:
316318
pyplot.show()
317319

floatcsep/experiment.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,6 @@ class Experiment:
8888
intervals=1, region='csep-italy', ...)``
8989
"""
9090

91-
"""
92-
Data management
93-
94-
Model:
95-
- FILE - read from file, scale in runtime
96-
- drop to db, scale from function in runtime
97-
- CODE - run, read from file
98-
- run, store in db, read from db
99-
100-
TEST:
101-
- use forecast from runtime
102-
- read forecast from file (TD)
103-
(does not make sense for TI (too much FS space) unless is already
104-
dropped to DB)
105-
"""
106-
10791
def __init__(
10892
self,
10993
name: str = None,
@@ -155,7 +139,7 @@ def __init__(
155139
log.info(f"Logging at {self.registry.logger}")
156140
add_fhandler(self.registry.logger)
157141

158-
log.debug(f"-------- BEGIN OF RUN --------")
142+
log.debug("-------- BEGIN OF RUN --------")
159143
log.info(f"Setting up experiment {self.name}:")
160144
log.info(f"\tStart: {self.start_date}")
161145
log.info(f"\tEnd: {self.end_date}")
@@ -554,7 +538,7 @@ def run(self) -> None:
554538
numpy.random.seed(self.seed)
555539

556540
self.task_graph.run()
557-
log.info(f"Calculation completed")
541+
log.info("Calculation completed")
558542
log.debug("Post-run forecast registry")
559543
self.registry.log_forecast_trees(self.timewindows)
560544
log.debug("Post-run result summary")
@@ -687,8 +671,6 @@ def from_yml(cls, config_yml: str, repr_dir=None, **kwargs):
687671
# experiment configuration file
688672
_dict = yaml.load(yml, NoAliasLoader)
689673
_dir_yml = dirname(config_yml)
690-
# uses yml path and append if a rel/abs path is given in config.
691-
_path = _dict.get("path", "")
692674

693675
# Only ABSOLUTE PATH
694676
_dict["path"] = abspath(join(_dir_yml, _dict.get("path", "")))
@@ -750,13 +732,10 @@ def test_stat(test_orig, test_repr):
750732
def get_results(self):
751733

752734
win_orig = timewindow2str(self.original.timewindows)
753-
win_repr = timewindow2str(self.reproduced.timewindows)
754735

755736
tests_orig = self.original.tests
756-
tests_repr = self.reproduced.tests
757737

758738
models_orig = [i.name for i in self.original.models]
759-
models_repr = [i.name for i in self.reproduced.models]
760739

761740
results = dict.fromkeys([i.name for i in tests_orig])
762741

@@ -809,13 +788,10 @@ def get_hash(filename):
809788
def get_filecomp(self):
810789

811790
win_orig = timewindow2str(self.original.timewindows)
812-
win_repr = timewindow2str(self.reproduced.timewindows)
813791

814792
tests_orig = self.original.tests
815-
tests_repr = self.reproduced.tests
816793

817794
models_orig = [i.name for i in self.original.models]
818-
models_repr = [i.name for i in self.reproduced.models]
819795

820796
results = dict.fromkeys([i.name for i in tests_orig])
821797

floatcsep/postprocess/plot_handler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import importlib.util
22
import logging
33
import os
4-
from datetime import datetime
54
from typing import TYPE_CHECKING, Union
65

76
from cartopy import crs as ccrs

floatcsep/postprocess/reporting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def generate_report(experiment, timewindow=-1):
5757
# Generate catalog plot
5858
if experiment.catalog_repo.catalog is not None:
5959
report.add_figure(
60-
f"Input catalog",
60+
"Input catalog",
6161
[
6262
experiment.registry.get_figure("main_catalog_map"),
6363
experiment.registry.get_figure("main_catalog_time"),
@@ -434,7 +434,7 @@ def add_table(self, data, use_header=True):
434434
table (str): this can be added to subheading or other cell if
435435
desired.
436436
"""
437-
table = ['<div class="table table-striped">', f"<table>"]
437+
table = ['<div class="table table-striped">', "<table>"]
438438

439439
def make_header(row_):
440440
header = ["<tr>"]

floatcsep/utils/accessors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def download_file(url: str, filename: str) -> None:
104104
if total_size:
105105
print(f"Downloading file with size of {total_size / block_size:.3f} kB")
106106
else:
107-
print(f"Downloading file with unknown size")
107+
print("Downloading file with unknown size")
108108
with open(filename, "wb") as f:
109109
for data in r.iter_content(chunk_size=block_size):
110110
download_size += len(data)

floatcsep/utils/helpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from csep.core.regions import CartesianGrid2D
3131
from csep.models import EvaluationResult
3232
from csep.utils.calc import cleaner_range
33-
from csep.utils.plots import plot_spatial_dataset
3433

3534
# floatCSEP libraries
3635
import floatcsep.utils.accessors

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ testpaths = [
1313
line-length = 96
1414
skip-string-normalization = false
1515
target-version = ["py39", "py310", "py311"]
16+
17+
[tool.flake8]
18+
ignore = ["E203", "W503", "F401"]
19+
max-line-length = 96

0 commit comments

Comments
 (0)