Skip to content

Commit a93fa77

Browse files
committed
fix: uncap numpy (#502)
* fix: uncap numpy * fix pre-commit
1 parent 0401fcc commit a93fa77

File tree

5 files changed

+69
-61
lines changed

5 files changed

+69
-61
lines changed

docs/changelog.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22

33
## Version 1.4
44

5+
### Version 1.4.3
6+
7+
#### Fixes
8+
9+
- fix: uncap numpy [#502][]
10+
11+
[#502]: https://github.com/scikit-hep/vector/pull/502
12+
513
### Version 1.4.2
614

715
#### Fixes
816

9-
- fix: depend on numpy<2.1 to support numba
10-
- fix: fix ci for awkward v1.x (numpy v2 is out)
11-
- fix: sympy tests (sympy v1.13)
17+
- fix: depend on numpy<2.1 to support numba [#476][]
18+
- fix: fix ci for awkward v1.x (numpy v2 is out) [#479][]
19+
- fix: sympy tests (sympy v1.13) [#485][]
1220

1321
#### Documentation
1422

15-
- docs: update intro notebook + readme
23+
- docs: update intro notebook + readme [#489][]
1624

1725
[#476]: https://github.com/scikit-hep/vector/pull/476
1826
[#479]: https://github.com/scikit-hep/vector/pull/479

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dynamic = [
4242
"version",
4343
]
4444
dependencies = [
45-
"numpy>=1.13.3,<2.1",
45+
"numpy>=1.13.3",
4646
"packaging>=19",
4747
]
4848
optional-dependencies.awkward = [

src/vector/backends/numpy.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -215,38 +215,38 @@ def _getitem(
215215
)
216216
if hasattr(array, "_longitudinal_type"):
217217
longitudinal = array._longitudinal_type.ObjectClass(
218-
*(out[x] for x in _coordinate_class_to_names[_ltype(array)]) # type: ignore[arg-type]
218+
*(out[x] for x in _coordinate_class_to_names[_ltype(array)])
219219
)
220220
if hasattr(array, "_temporal_type"):
221221
temporal = array._temporal_type.ObjectClass(
222-
*(out[x] for x in _coordinate_class_to_names[_ttype(array)]) # type: ignore[arg-type]
222+
*(out[x] for x in _coordinate_class_to_names[_ttype(array)])
223223
)
224224
if temporal is not None:
225225
return array.ObjectClass(
226226
azimuthal=azimuthal,
227-
longitudinal=longitudinal, # type: ignore[arg-type, return-value]
227+
longitudinal=longitudinal, # type: ignore[arg-type]
228228
temporal=temporal, # type: ignore[arg-type]
229229
)
230230
elif longitudinal is not None:
231-
return array.ObjectClass(azimuthal=azimuthal, longitudinal=longitudinal) # type: ignore[arg-type, return-value]
231+
return array.ObjectClass(azimuthal=azimuthal, longitudinal=longitudinal) # type: ignore[arg-type]
232232
elif azimuthal is not None:
233-
return array.ObjectClass(azimuthal=azimuthal) # type: ignore[return-value]
233+
return array.ObjectClass(azimuthal=azimuthal)
234234
elif issubclass(array.ObjectClass, vector.backends.object.AzimuthalObject):
235-
return array.ObjectClass(*tuple(out)[:2]) # type: ignore[arg-type, return-value]
235+
return array.ObjectClass(*tuple(out)[:2]) # type: ignore[arg-type]
236236
elif issubclass(array.ObjectClass, vector.backends.object.LongitudinalObject):
237237
coords = (
238238
out.view(numpy.ndarray)[0]
239239
if len(out) == 1 # type: ignore[arg-type]
240240
else out.view(numpy.ndarray)[2]
241241
)
242-
return array.ObjectClass(coords) # type: ignore[return-value]
242+
return array.ObjectClass(coords)
243243
else:
244244
coords = (
245245
out.view(numpy.ndarray)[0]
246246
if len(out) == 1 # type: ignore[arg-type]
247247
else out.view(numpy.ndarray)[3]
248248
)
249-
return array.ObjectClass(coords) # type: ignore[return-value]
249+
return array.ObjectClass(coords)
250250

251251

252252
def _array_repr(
@@ -879,14 +879,14 @@ def sum(
879879
keepdims=keepdims,
880880
initial=initial,
881881
where=where,
882-
), # type: ignore[call-overload]
882+
),
883883
)
884884

885885
def __eq__(self, other: typing.Any) -> typing.Any:
886-
return numpy.equal(self, other) # type: ignore[call-overload]
886+
return numpy.equal(self, other)
887887

888888
def __ne__(self, other: typing.Any) -> typing.Any:
889-
return numpy.not_equal(self, other) # type: ignore[call-overload]
889+
return numpy.not_equal(self, other)
890890

891891
def __reduce__(self) -> str | tuple[typing.Any, ...]:
892892
pickled_state = super().__reduce__()
@@ -1197,7 +1197,7 @@ def azimuthal(self) -> AzimuthalNumpy:
11971197
AzimuthalNumpyXY([(1.1, 2.1), (1.2, 2.2), (1.3, 2.3), (1.4, 2.4),
11981198
(1.5, 2.5)], dtype=[('x', '<f8'), ('y', '<f8')])
11991199
"""
1200-
return self.view(self._azimuthal_type) # type: ignore[return-value]
1200+
return self.view(self._azimuthal_type)
12011201

12021202
def _wrap_result(
12031203
self,
@@ -1305,7 +1305,7 @@ def __setitem__(self, where: typing.Any, what: typing.Any) -> None:
13051305
return _setitem(self, where, what, False)
13061306

13071307

1308-
class MomentumNumpy2D(PlanarMomentum, VectorNumpy2D): # type: ignore[misc]
1308+
class MomentumNumpy2D(PlanarMomentum, VectorNumpy2D):
13091309
"""
13101310
Two dimensional momentum vector class for the NumPy backend. This class can be directly
13111311
used to construct two dimensional NumPy momentum vectors. For two dimensional
@@ -1427,13 +1427,13 @@ def __repr__(self) -> str:
14271427
def azimuthal(self) -> AzimuthalNumpy:
14281428
"""Returns the azimuthal type class for the given ``VectorNumpy3D`` object."""
14291429
# TODO: Add an example here - see https://github.com/scikit-hep/vector/issues/194
1430-
return self.view(self._azimuthal_type) # type: ignore[return-value]
1430+
return self.view(self._azimuthal_type)
14311431

14321432
@property
14331433
def longitudinal(self) -> LongitudinalNumpy:
14341434
"""Returns the longitudinal type class for the given ``VectorNumpy3D`` object."""
14351435
# TODO: Add an example here - see https://github.com/scikit-hep/vector/issues/194
1436-
return self.view(self._longitudinal_type) # type: ignore[return-value]
1436+
return self.view(self._longitudinal_type)
14371437

14381438
def _wrap_result(
14391439
self,
@@ -1562,7 +1562,7 @@ def __setitem__(self, where: typing.Any, what: typing.Any) -> None:
15621562
return _setitem(self, where, what, False)
15631563

15641564

1565-
class MomentumNumpy3D(SpatialMomentum, VectorNumpy3D): # type: ignore[misc]
1565+
class MomentumNumpy3D(SpatialMomentum, VectorNumpy3D):
15661566
"""
15671567
Three dimensional momentum vector class for the NumPy backend. This class can be directly
15681568
used to construct three dimensional NumPy momentum vectors. For three dimensional
@@ -1707,19 +1707,19 @@ def __repr__(self) -> str:
17071707
def azimuthal(self) -> AzimuthalNumpy:
17081708
"""Returns the azimuthal type class for the given ``VectorNumpy4D`` object."""
17091709
# TODO: Add an example here - see https://github.com/scikit-hep/vector/issues/194
1710-
return self.view(self._azimuthal_type) # type: ignore[return-value]
1710+
return self.view(self._azimuthal_type)
17111711

17121712
@property
17131713
def longitudinal(self) -> LongitudinalNumpy:
17141714
"""Returns the longitudinal type class for the given ``Vectornumpy4D`` object."""
17151715
# TODO: Add an example here - see https://github.com/scikit-hep/vector/issues/194
1716-
return self.view(self._longitudinal_type) # type: ignore[return-value]
1716+
return self.view(self._longitudinal_type)
17171717

17181718
@property
17191719
def temporal(self) -> TemporalNumpy:
17201720
"""Returns the azimuthal type class for the given ``VectorNumpy4D`` object."""
17211721
# TODO: Add an example here - see https://github.com/scikit-hep/vector/issues/194
1722-
return self.view(self._temporal_type) # type: ignore[return-value]
1722+
return self.view(self._temporal_type)
17231723

17241724
def _wrap_result(
17251725
self,
@@ -1882,7 +1882,7 @@ def __setitem__(self, where: typing.Any, what: typing.Any) -> None:
18821882
return _setitem(self, where, what, False)
18831883

18841884

1885-
class MomentumNumpy4D(LorentzMomentum, VectorNumpy4D): # type: ignore[misc]
1885+
class MomentumNumpy4D(LorentzMomentum, VectorNumpy4D):
18861886
"""
18871887
Four dimensional momentum vector class for the NumPy backend. This class can be directly
18881888
used to construct four dimensional NumPy momentum vectors. For three dimensional

src/vector/backends/object.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -332,61 +332,61 @@ class VectorObject(Vector):
332332
lib = numpy
333333

334334
def __eq__(self, other: typing.Any) -> typing.Any:
335-
return numpy.equal(self, other) # type: ignore[call-overload]
335+
return numpy.equal(self, other)
336336

337337
def __ne__(self, other: typing.Any) -> typing.Any:
338-
return numpy.not_equal(self, other) # type: ignore[call-overload]
338+
return numpy.not_equal(self, other)
339339

340340
def __abs__(self) -> float:
341341
return numpy.absolute(self)
342342

343343
def __add__(self, other: VectorProtocol) -> VectorProtocol:
344-
return numpy.add(self, other) # type: ignore[call-overload]
344+
return numpy.add(self, other)
345345

346346
def __radd__(self, other: VectorProtocol) -> VectorProtocol:
347-
return numpy.add(other, self) # type: ignore[call-overload]
347+
return numpy.add(other, self)
348348

349349
def __iadd__(self: SameVectorType, other: VectorProtocol) -> SameVectorType:
350-
return _replace_data(self, numpy.add(self, other)) # type: ignore[call-overload]
350+
return _replace_data(self, numpy.add(self, other))
351351

352352
def __sub__(self, other: VectorProtocol) -> VectorProtocol:
353-
return numpy.subtract(self, other) # type: ignore[call-overload]
353+
return numpy.subtract(self, other)
354354

355355
def __rsub__(self, other: VectorProtocol) -> VectorProtocol:
356-
return numpy.subtract(other, self) # type: ignore[call-overload]
356+
return numpy.subtract(other, self)
357357

358358
def __isub__(self: SameVectorType, other: VectorProtocol) -> SameVectorType:
359-
return _replace_data(self, numpy.subtract(self, other)) # type: ignore[call-overload]
359+
return _replace_data(self, numpy.subtract(self, other))
360360

361361
def __mul__(self, other: float) -> VectorProtocol:
362-
return numpy.multiply(self, other) # type: ignore[call-overload]
362+
return numpy.multiply(self, other)
363363

364364
def __rmul__(self, other: float) -> VectorProtocol:
365-
return numpy.multiply(other, self) # type: ignore[call-overload]
365+
return numpy.multiply(other, self)
366366

367367
def __imul__(self: SameVectorType, other: float) -> SameVectorType:
368-
return _replace_data(self, numpy.multiply(self, other)) # type: ignore[call-overload]
368+
return _replace_data(self, numpy.multiply(self, other))
369369

370370
def __neg__(self: SameVectorType) -> SameVectorType:
371-
return numpy.negative(self) # type: ignore[call-overload]
371+
return numpy.negative(self)
372372

373373
def __pos__(self: SameVectorType) -> SameVectorType:
374-
return numpy.positive(self) # type: ignore[call-overload]
374+
return numpy.positive(self)
375375

376376
def __truediv__(self, other: float) -> VectorProtocol:
377-
return numpy.true_divide(self, other) # type: ignore[call-overload]
377+
return numpy.true_divide(self, other)
378378

379379
def __rtruediv__(self, other: float) -> VectorProtocol:
380-
return numpy.true_divide(other, self) # type: ignore[call-overload]
380+
return numpy.true_divide(other, self)
381381

382382
def __itruediv__(self: SameVectorType, other: float) -> VectorProtocol:
383-
return _replace_data(self, numpy.true_divide(self, other)) # type: ignore[call-overload]
383+
return _replace_data(self, numpy.true_divide(self, other))
384384

385385
def __pow__(self, other: float) -> float:
386-
return numpy.square(self) if other == 2 else numpy.power(self, other) # type: ignore[call-overload]
386+
return numpy.square(self) if other == 2 else numpy.power(self, other)
387387

388388
def __matmul__(self, other: VectorProtocol) -> float:
389-
return numpy.matmul(self, other) # type: ignore[call-overload]
389+
return numpy.matmul(self, other)
390390

391391
def __array_ufunc__(
392392
self,

src/vector/backends/sympy.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -345,61 +345,61 @@ class VectorSympy(Vector):
345345
lib = SympyLib()
346346

347347
def __eq__(self, other: typing.Any) -> typing.Any:
348-
return numpy.equal(self, other) # type: ignore[call-overload]
348+
return numpy.equal(self, other)
349349

350350
def __ne__(self, other: typing.Any) -> typing.Any:
351-
return numpy.not_equal(self, other) # type: ignore[call-overload]
351+
return numpy.not_equal(self, other)
352352

353353
def __abs__(self) -> float:
354354
return numpy.absolute(self)
355355

356356
def __add__(self, other: VectorProtocol) -> VectorProtocol:
357-
return numpy.add(self, other) # type: ignore[call-overload]
357+
return numpy.add(self, other)
358358

359359
def __radd__(self, other: VectorProtocol) -> VectorProtocol:
360-
return numpy.add(other, self) # type: ignore[call-overload]
360+
return numpy.add(other, self)
361361

362362
def __iadd__(self: SameVectorType, other: VectorProtocol) -> SameVectorType:
363-
return _replace_data(self, numpy.add(self, other)) # type: ignore[call-overload]
363+
return _replace_data(self, numpy.add(self, other))
364364

365365
def __sub__(self, other: VectorProtocol) -> VectorProtocol:
366-
return numpy.subtract(self, other) # type: ignore[call-overload]
366+
return numpy.subtract(self, other)
367367

368368
def __rsub__(self, other: VectorProtocol) -> VectorProtocol:
369-
return numpy.subtract(other, self) # type: ignore[call-overload]
369+
return numpy.subtract(other, self)
370370

371371
def __isub__(self: SameVectorType, other: VectorProtocol) -> SameVectorType:
372-
return _replace_data(self, numpy.subtract(self, other)) # type: ignore[call-overload]
372+
return _replace_data(self, numpy.subtract(self, other))
373373

374374
def __mul__(self, other: float) -> VectorProtocol:
375-
return numpy.multiply(self, other) # type: ignore[call-overload]
375+
return numpy.multiply(self, other)
376376

377377
def __rmul__(self, other: float) -> VectorProtocol:
378-
return numpy.multiply(other, self) # type: ignore[call-overload]
378+
return numpy.multiply(other, self)
379379

380380
def __imul__(self: SameVectorType, other: float) -> SameVectorType:
381-
return _replace_data(self, numpy.multiply(self, other)) # type: ignore[call-overload]
381+
return _replace_data(self, numpy.multiply(self, other))
382382

383383
def __neg__(self: SameVectorType) -> SameVectorType:
384-
return numpy.negative(self) # type: ignore[call-overload]
384+
return numpy.negative(self)
385385

386386
def __pos__(self: SameVectorType) -> SameVectorType:
387-
return numpy.positive(self) # type: ignore[call-overload]
387+
return numpy.positive(self)
388388

389389
def __truediv__(self, other: float) -> VectorProtocol:
390-
return numpy.true_divide(self, other) # type: ignore[call-overload]
390+
return numpy.true_divide(self, other)
391391

392392
def __rtruediv__(self, other: float) -> VectorProtocol:
393-
return numpy.true_divide(other, self) # type: ignore[call-overload]
393+
return numpy.true_divide(other, self)
394394

395395
def __itruediv__(self: SameVectorType, other: float) -> VectorProtocol:
396-
return _replace_data(self, numpy.true_divide(self, other)) # type: ignore[call-overload]
396+
return _replace_data(self, numpy.true_divide(self, other))
397397

398398
def __pow__(self, other: float) -> float:
399-
return numpy.power(self, other) # type: ignore[call-overload]
399+
return numpy.power(self, other)
400400

401401
def __matmul__(self, other: VectorProtocol) -> float:
402-
return numpy.matmul(self, other) # type: ignore[call-overload]
402+
return numpy.matmul(self, other)
403403

404404
def __array_ufunc__(
405405
self,

0 commit comments

Comments
 (0)