Skip to content

Commit a257ff5

Browse files
Bradley AugsteinBradley Augstein
authored andcommitted
fix pre-commit errors
1 parent 45d912b commit a257ff5

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

heracles/catalog/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def where(self, selection, visibility=None):
440440

441441
@property
442442
def page_size(self):
443-
"""number of rows per page (default: 100_000)"""
443+
"""number of rows per page (default: 1_000_000)"""
444444
return self._page_size
445445

446446
@page_size.setter

heracles/fields.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ class Field(metaclass=ABCMeta):
6969
super().__init_subclass__()
7070
cls.__spin = spin'''
7171

72-
7372
def __init__(
7473
self,
7574
mapper: Mapper | None,
76-
*columns: str,
75+
*columns: str,
7776
weight: str | None = None,
7877
mask: str | None = None,
7978
) -> None:
@@ -83,13 +82,13 @@ def __init__(
8382
self.__columns = columns if columns else None
8483
self.__weight = weight if weight else None
8584
self.__mask = mask
86-
self.__spin = 0
85+
self.__spin = 0
8786

8887
@property
8988
def mapper(self) -> Mapper | None:
9089
"""Return the mapper used by this field."""
9190
return self.__mapper
92-
91+
9392
@property
9493
def weight(self) -> str | None:
9594
"""Return the mapper used by this field."""
@@ -118,15 +117,18 @@ async def __call__(
118117
) -> ArrayLike:
119118
"""Implementation for mapping a catalogue."""
120119
...
121-
120+
122121
def CheckColumns(self, *expected):
123-
if(self.columns==None):
124-
raise ValueError("No columns defined!")
125-
if(len(expected)!=len(self.columns)):
122+
if self.columns is None:
123+
msg = "No columns defined!"
124+
raise ValueError(msg)
125+
if len(expected) != len(self.columns):
126126
error = "Column error. Expected " + str(len(expected)) + " columns"
127-
error += " with a format " + str(expected) + ". Received " + str(self.columns)
127+
error += (
128+
" with a format " + str(expected) + ". Received " + str(self.columns)
129+
)
128130
raise ValueError(error)
129-
131+
130132

131133
async def _pages(
132134
catalog: Catalog,
@@ -166,7 +168,7 @@ def __init__(
166168
mask: str | None = None,
167169
) -> None:
168170
"""Create a position field."""
169-
super().__init__(mapper, *columns,weight=weight, mask=mask)
171+
super().__init__(mapper, *columns, weight=weight, mask=mask)
170172
self.__overdensity = overdensity
171173
self.__nbar = nbar
172174

@@ -198,15 +200,14 @@ async def __call__(
198200
msg = "cannot compute density contrast: no visibility in catalog"
199201
raise ValueError(msg)
200202

201-
#get mapper
203+
# get mapper
202204
mapper = self.mapper
203205

204206
# get catalogue column definition
205207
col = self.columns
206208
self.CheckColumns("longitude", "latitude")
207209

208-
#if(len(col)!=2):
209-
# raise ValueError("Expect 2 colummns, longitude and latitude")
210+
# if(len(col)!=2):
210211

211212
# position map
212213
pos = mapper.create(spin=self.spin)
@@ -285,7 +286,7 @@ async def __call__(
285286
# get the column definition of the catalogue
286287
col = self.columns
287288
self.CheckColumns("longitude", "latitude", "value")
288-
289+
289290
wcol = self.weight
290291
# scalar field map
291292
val = mapper.create(spin=self.spin)
@@ -355,9 +356,9 @@ async def __call__(
355356

356357
# get the column definition of the catalogue
357358
col = self.columns
358-
359+
359360
self.CheckColumns("longitude", "latitude", "real", "imag")
360-
361+
361362
wcol = self.weight
362363

363364
# complex map with real and imaginary part
@@ -508,16 +509,17 @@ async def __call__(
508509

509510
class Spin2Field(ComplexField):
510511
"""Spin-2 complex field."""
512+
511513
def __init__(
512514
self,
513515
mapper: Mapper | None,
514-
*columns: str,
516+
*columns: str,
515517
weight: str | None,
516518
mask: str | None = None,
517519
) -> None:
518520
"""Initialise the field."""
519-
super().__init__(mapper, *columns,weight=weight, mask=mask)
520-
self.__spin=2
521+
super().__init__(mapper, *columns, weight=weight, mask=mask)
522+
self.__spin = 2
521523

522524

523525
Shears = Spin2Field

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dependencies = [
2525
"coroutines",
2626
"fitsio",
2727
"healpy",
28+
"matplotlib",
2829
"numba",
2930
"numpy",
3031
]

tests/test_fields.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,29 @@ def catalog(page):
7878

7979

8080
def test_field_abc():
81-
from unittest.mock import Mock
82-
83-
from heracles.fields import Columns, Field
81+
from heracles.fields import Field
8482

8583
with pytest.raises(TypeError):
8684
Field()
8785

8886
class SpinLessField(Field):
89-
async def __call__(self):
90-
pass
87+
async def __call__(self):
88+
pass
89+
9190
f = SpinLessField(None, weight=None)
9291
assert f.spin == 0
9392

9493
class TestField(Field):
9594
async def __call__(self):
9695
pass
9796

98-
f = TestField(None, weight = None)
97+
f = TestField(None, weight=None)
9998

10099
assert f.mapper is None
101100
assert f.columns is None
102101
assert f.spin == 0
103102

104-
with pytest.raises(ValueError,match="No columns defined"):
103+
with pytest.raises(ValueError, match="No columns defined"):
105104
f.CheckColumns(None)
106105

107106
with pytest.raises(ValueError):
@@ -326,7 +325,7 @@ def test_complex_field(mapper, catalog):
326325
}
327326
print(testdata)
328327
print(m.dtype.metadata)
329-
'''assert m.dtype.metadata == {
328+
"""assert m.dtype.metadata == {
330329
"catalog": catalog.label,
331330
"spin": 2,
332331
"wbar": pytest.approx(wbar),
@@ -336,7 +335,7 @@ def test_complex_field(mapper, catalog):
336335
"lmax": mapper.lmax,
337336
"deconv": mapper.deconvolve,
338337
"bias": pytest.approx(bias / wbar**2, abs=1e-6),
339-
}'''
338+
}"""
340339
np.testing.assert_array_almost_equal(m, 0)
341340

342341

@@ -345,7 +344,7 @@ def test_weights(mapper, catalog):
345344

346345
npix = 12 * mapper.nside**2
347346

348-
f = Weights(mapper, "ra", "dec", weight = "w")
347+
f = Weights(mapper, "ra", "dec", weight="w")
349348
m = coroutines.run(f(catalog))
350349

351350
w = next(iter(catalog))["w"]

0 commit comments

Comments
 (0)