Skip to content

Commit 60a0c79

Browse files
authored
Merge pull request #773 from CyclingNinja/refresh_ruff
Applys explcit includes ruff file
2 parents eba37a7 + 2f0de2e commit 60a0c79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+419
-392
lines changed

.cruft.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/sunpy/package-template",
3-
"commit": "75f84c4adf1753af67967930c3335bc73bca9bf5",
3+
"commit": "51fb616094a4d7577c8898445aa50effb89afa31",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -16,7 +16,7 @@
1616
"enable_dynamic_dev_versions": "y",
1717
"include_example_code": "n",
1818
"include_cruft_update_github_workflow": "y",
19-
"use_extended_ruff_linting": "n",
19+
"use_extended_ruff_linting": "y",
2020
"_sphinx_theme": "sunpy",
2121
"_parent_project": "",
2222
"_install_requires": "",

.ruff.toml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,37 @@ select = [
1212
"E",
1313
"F",
1414
"W",
15-
#"UP",
16-
#"PT"
15+
"UP",
16+
"PT",
17+
"BLE",
18+
"A",
19+
"C4",
20+
"INP",
21+
"PIE",
22+
"T20",
23+
"RET",
24+
"TID",
25+
"PTH",
26+
"PD",
27+
"PLC",
28+
"PLE",
29+
"FLY",
30+
"NPY",
31+
"PERF",
32+
"RUF",
1733
]
1834
extend-ignore = [
19-
"E712",
20-
"E721",
2135
# pycodestyle (E, W)
2236
"E501", # ignore line length will use a formatter instead
2337
# pyupgrade (UP)
2438
"UP038", # Use | in isinstance - not compatible with models and is slower
39+
# numpy
40+
"NPY002", # TODO: migrate from np.random.rand to np.random.Generator
2541
# pytest (PT)
2642
"PT001", # Always use pytest.fixture()
2743
"PT004", # Fixtures which don't return anything should have leading _
44+
"PT011", # TODO: except(ValueRaises) is too broad
45+
"PT012", # TODO: except statement is too lengthy
2846
"PT023", # Always use () on pytest decorators
2947
# flake8-pie (PIE)
3048
"PIE808", # Disallow passing 0 as the first argument to range

docs/conf.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import warnings
55
import datetime
6+
from pathlib import Path
67

78
from astropy.utils.exceptions import AstropyDeprecationWarning
89
from matplotlib import MatplotlibDeprecationWarning
@@ -58,7 +59,7 @@
5859
]
5960

6061
# Add any paths that contain templates here, relative to this directory.
61-
# templates_path = ["_templates"] # NOQA: ERA001
62+
# templates_path = ["_templates"]
6263

6364
# List of patterns, relative to source directory, that match files and
6465
# directories to ignore when looking for source files.
@@ -116,7 +117,7 @@
116117
# Add any paths that contain custom static files (such as style sheets) here,
117118
# relative to this directory. They are copied after the builtin static files,
118119
# so a file named "default.css" will overwrite the builtin "default.css".
119-
# html_static_path = ["_static"] # NOQA: ERA001
120+
# html_static_path = ["_static"]
120121

121122
# By default, when rendering docstrings for classes, sphinx.ext.autodoc will
122123
# make docs with the class-level docstring and the class-method docstrings,
@@ -146,11 +147,11 @@
146147
# -- Sphinx Gallery ---------------------------------------------------------
147148

148149
sphinx_gallery_conf = {
149-
'backreferences_dir': os.path.join('generated', 'modules'),
150+
'backreferences_dir': Path('generated/modules'),
150151
'filename_pattern': '^((?!skip_).)*$',
151-
'examples_dirs': os.path.join('..', 'examples'),
152+
'examples_dirs': Path('../examples'),
152153
'within_subsection_order': "ExampleTitleSortKey",
153-
'gallery_dirs': os.path.join('generated', 'gallery'),
154+
'gallery_dirs': Path('generated/gallery'),
154155
'matplotlib_animations': True,
155156
"default_thumb_file": png_icon,
156157
'abort_on_example_error': False,

examples/creating_even_spaced_wavelength_visualisation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# `sequence=True` causes a sequence of maps to be returned, one for each image file.
3535
sequence_of_maps = sunpy.map.Map(aia_files, sequence=True)
3636
# Sort the maps in the sequence in order of wavelength.
37-
sequence_of_maps.maps = list(sorted(sequence_of_maps.maps, key=lambda m: m.wavelength))
37+
sequence_of_maps.maps = sorted(sequence_of_maps.maps, key=lambda m: m.wavelength)
3838

3939
#############################################################################
4040
# Using an `astropy.units.Quantity` of the wavelengths of the images, we can construct

ndcube/__init__.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""
2+
======
23
ndcube
34
======
45
5-
A base package for multi-dimensional contiguous and non-contiguous coordinate-aware arrays.
6+
A package for multi-dimensional contiguous and non-contiguous coordinate-aware arrays.
67
78
* Homepage: https://github.com/sunpy/ndcube
89
* Documentation: https://docs.sunpy.org/projects/ndcube/
@@ -14,4 +15,16 @@
1415
from .ndcube_sequence import NDCubeSequence, NDCubeSequenceBase
1516
from .version import version as __version__
1617

17-
__all__ = ['NDCube', 'NDCubeSequence', "NDCollection", "ExtraCoords", "GlobalCoords", "ExtraCoordsABC", "GlobalCoordsABC", "NDCubeBase", "NDCubeSequenceBase", "__version__"]
18+
19+
__all__ = [
20+
'NDCube',
21+
'NDCubeSequence',
22+
"NDCollection",
23+
"ExtraCoords",
24+
"GlobalCoords",
25+
"ExtraCoordsABC",
26+
"GlobalCoordsABC",
27+
"NDCubeBase",
28+
"NDCubeSequenceBase",
29+
"__version__",
30+
]

ndcube/conftest.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,7 @@ def ndcube_2d_ln_lt_uncert(wcs_2d_lt_ln):
479479
shape = (10, 12)
480480
data_cube = data_nd(shape)
481481
uncertainty = astropy.nddata.StdDevUncertainty(data_cube * 0.1)
482-
cube = NDCube(data_cube, wcs=wcs_2d_lt_ln, uncertainty=uncertainty)
483-
return cube
482+
return NDCube(data_cube, wcs=wcs_2d_lt_ln, uncertainty=uncertainty)
484483

485484

486485
@pytest.fixture
@@ -493,8 +492,7 @@ def ndcube_2d_ln_lt_mask_uncert(wcs_2d_lt_ln):
493492
mask[2, 0] = True
494493
mask[3, 3] = True
495494
mask[4:6, :4] = True
496-
cube = NDCube(data_cube, wcs=wcs_2d_lt_ln, uncertainty=uncertainty, mask=mask)
497-
return cube
495+
return NDCube(data_cube, wcs=wcs_2d_lt_ln, uncertainty=uncertainty, mask=mask)
498496

499497

500498
@pytest.fixture

ndcube/extra_coords/extra_coords.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ def __init__(self, ndcube=None):
149149

150150
# Lookup tables is a list of (pixel_dim, LookupTableCoord) to allow for
151151
# one pixel dimension having more than one lookup coord.
152-
self._lookup_tables = list()
153-
self._dropped_tables = list()
152+
self._lookup_tables = []
153+
self._dropped_tables = []
154154

155155
# We need a reference to the parent NDCube
156156
self._ndcube = ndcube
@@ -230,8 +230,8 @@ def add(self, name, array_dimension, lookup_table, physical_types=None, **kwargs
230230
self._lookup_tables.append((array_dimension, coord))
231231

232232
# Sort the LUTs so that the mapping and the wcs are ordered in pixel dim order
233-
self._lookup_tables = list(sorted(self._lookup_tables,
234-
key=lambda x: x[0] if isinstance(x[0], Integral) else x[0][0]))
233+
self._lookup_tables = sorted(self._lookup_tables,
234+
key=lambda x: x[0] if isinstance(x[0], Integral) else x[0][0])
235235

236236
@property
237237
def _name_lut_map(self):
@@ -243,7 +243,7 @@ def _name_lut_map(self):
243243
def keys(self):
244244
# docstring in ABC
245245
if not self.wcs:
246-
return tuple()
246+
return ()
247247

248248
return tuple(self.wcs.world_axis_names) if self.wcs.world_axis_names else None
249249

@@ -256,7 +256,7 @@ def mapping(self):
256256
# If mapping is not set but lookup_tables is empty then the extra
257257
# coords is empty, so there is no mapping.
258258
if not self._lookup_tables:
259-
return tuple()
259+
return ()
260260

261261
# The mapping is from the array index (position in the list) to the
262262
# pixel dimensions (numbers in the list)
@@ -292,7 +292,7 @@ def wcs(self):
292292
if not self._lookup_tables:
293293
return None
294294

295-
tcoords = set(lt[1] for lt in self._lookup_tables)
295+
tcoords = {lt[1] for lt in self._lookup_tables}
296296
# created a sorted list of unique items
297297
_tmp = set() # a temporary set
298298
tcoords = [x[1] for x in self._lookup_tables if x[1] not in _tmp and _tmp.add(x[1]) is None]
@@ -323,8 +323,7 @@ def is_empty(self):
323323
# docstring in ABC
324324
if not self._wcs and not self._lookup_tables:
325325
return True
326-
else:
327-
return False
326+
return False
328327

329328
def _getitem_string(self, item):
330329
"""
@@ -402,7 +401,7 @@ def __getitem__(self, item):
402401
if self._wcs:
403402
return self._getitem_wcs(item)
404403

405-
elif self._lookup_tables:
404+
if self._lookup_tables:
406405
return self._getitem_lookup_tables(item)
407406

408407
# If we get here this object is empty, so just return an empty extra coords
@@ -425,7 +424,7 @@ def dropped_world_dimensions(self):
425424

426425
return mtc.dropped_world_dimensions
427426

428-
return dict()
427+
return {}
429428

430429
def resample(self, factor, offset=0, ndcube=None, **kwargs):
431430
"""

0 commit comments

Comments
 (0)