Skip to content

Commit 922e79d

Browse files
committed
More pylint fixes to sample code and scripts
1 parent da29997 commit 922e79d

25 files changed

Lines changed: 109 additions & 132 deletions

Stoner/core/Typing.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

Stoner/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"Typing",
2222
]
2323

24-
from . import Typing, array, base, exceptions, utils
24+
from . import array, base, exceptions, utils
2525
from .array import DataArray
2626
from .base import RegexpDict, TypeHintedDict, metadataObject, string_to_type
2727
from .setas import Setas as _setas

Stoner/core/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from ..compat import _pattern_type, int_types, string_types
2323
from ..tools import iscomparable, isiterable
2424
from .exceptions import StonerAssertionError
25-
from .Typing import Filename, RegExp, String_Types
25+
from ..tools.typing import Filename, RegExp
2626

2727
try:
2828
from blist import sorteddict as SortedDict
@@ -65,7 +65,7 @@ def literal_eval(string: str) -> Any:
6565
raise ValueError(f"Cannot interpret {string} as valid Python") from err
6666

6767

68-
def string_to_type(value: String_Types) -> Any:
68+
def string_to_type(value: str) -> Any:
6969
"""Given a string value try to work out if there is a better python type dor the value.
7070
7171
First of all the first character is checked to see if it is a [ or { which would

Stoner/plot/formats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,8 @@ def new_figure(self, figure=False, projection="rectilinear", figsize=None, no_ax
510510
if no_axes:
511511
fig = plt.figure(figsize=figsize, **kargs)
512512
# Remove any auto-created axes if present (defensive)
513-
for ax in list(fig.axes):
514-
ax.remove()
513+
for axis in list(fig.axes):
514+
axis.remove()
515515
return fig, None
516516

517517
# Standard 2D case: prefer subplots for users expecting a (fig, ax) pair

Stoner/tools/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from ..compat import bytes2str, path_types, str2bytes, string_types
1717
from ..core.base import SortedMultivalueDict, metadataObject
1818
from ..core.exceptions import StonerLoadError, StonerUnrecognisedFormat
19-
from ..core.Typing import Filename
19+
from ..tools.typing import Filename
2020
from .decorators import make_Data, make_Image
2121
from .widgets import fileDialog
2222

Stoner/tools/typing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@
1111
from ..core.setas import setas
1212
from ..image.core import ImageArray, ImageFile
1313
else:
14-
setas = type("setas", (), {})
14+
Setas = type("Setas", (), {})
1515
Data = type("Data", (), {})
1616
ImageArray = type("ImageArray", (), {})
1717
ImageFile = type("ImageFile", (), {})
1818

1919
Args = Tuple[Any]
2020
Kwargs = Mapping[str, Any]
21-
Single_Index = Union[str, int, Pattern]
22-
Index = Union[Single_Index, Sequence[Union[int, str, Pattern]]]
21+
SingleIndex = Union[str, int, Pattern]
22+
Index = Union[SingleIndex, Sequence[Union[int, str, Pattern]]]
2323
Filename = Union[str, Path, bool]
2424

2525
RegExp = Pattern
26-
Path_Types = Filename
26+
PathTypes = Filename
2727

2828

2929
# Setas
3030
Setas_Base = Sequence[str]
3131
Setas_Dict = Mapping[str, Index]
32-
Setas = Union[Setas_Base, Setas_Dict, str, setas]
32+
Setas = Union[Setas_Base, Setas_Dict, str, Setas]
3333

3434
# Other useful types
3535
Numeric = Union[float, int, complex]

doc/samples/3D_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""3D surface plot example."""
22

3-
# pylint: disable=invalid-name
3+
# pylint: disable=invalid-name, no-name-in-module
44
import matplotlib.cm
55
import numpy as np
66

doc/samples/curve_fit_plane.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Use curve_fit to fit a plane to some data."""
22

3-
# pylint: disable=invalid-name
3+
# pylint: disable=invalid-name, no-name-in-module, no-member
44
import matplotlib.cm as cmap
55
from numpy import array, column_stack, linspace, meshgrid
66
from numpy.random import normal, seed
@@ -43,9 +43,7 @@ def plane(coord, a, b, c):
4343
e.plot_xyz(linewidth=0, cmap=cmap.jet, alpha=0.5, figure=d.fig)
4444

4545
txt = "$z=c-ax+by$\n"
46-
txt += "\n".join(
47-
[d.format("plane:{}".format(k), latex=True) for k in ["a", "b", "c"]]
48-
)
46+
txt += "\n".join([d.format(f"plane:{k}", latex=True) for k in ["a", "b", "c"]])
4947

5048
ax = d.axes[0]
5149
ax.text(-30, -10, 10, txt)

doc/samples/decompose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
d.text(
1919
-6,
2020
-800,
21-
"Coefficients\n{}".format(str_coeffs),
21+
f"Coefficients\n{str_coeffs}",
2222
fontdict={"size": "x-small"},
2323
)
2424
d.ylabel = "Data"

doc/samples/differential_evolution_simple.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313
d = Data(x, y, column_headers=["Time", "Signal"], setas="xy")
1414

15-
func = lambda x, A, B, C: A + B * exp(-x / C)
15+
16+
def func(x, A, B, C):
17+
"""Quick fitting function."""
18+
return A + B * exp(-x / C)
1619

1720

1821
# Do the fitting and plot the result

0 commit comments

Comments
 (0)