Skip to content

Commit 1edc1b4

Browse files
Merge pull request #134 from xsuite/release/v0.4.1
Release/v0.4.1
2 parents 0af4bf1 + 48aacf9 commit 1edc1b4

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

xobjects/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636

3737
from .general import _print
3838

39-
from .test_helpers import assert_allclose
39+
from .general import assert_allclose
4040

4141
from ._version import __version__

xobjects/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.4.0"
1+
__version__ = "0.4.1"

xobjects/general.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# copyright ################################# #
2+
# This file is part of the Xobjects Package. #
3+
# Copyright (c) CERN, 2024. #
4+
# ########################################### #
5+
from numpy.testing import assert_allclose as np_assert_allclose
6+
7+
18
class Print:
29
suppress = False
310

@@ -7,3 +14,11 @@ def __call__(self, *args, **kwargs):
714

815

916
_print = Print()
17+
18+
19+
def assert_allclose(a, b, rtol=1e-7, atol=1e-7):
20+
if hasattr(a, "get"):
21+
a = a.get()
22+
if hasattr(b, "get"):
23+
b = b.get()
24+
np_assert_allclose(a, b, rtol=rtol, atol=atol)

xobjects/hybrid_class.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ def __set__(self, container, value):
4646
# in the latter case reference mechanism is used)
4747
if not (
4848
container._xobject._buffer is value._xobject._buffer
49-
and (getattr(container._xobject, self.name) is not None and
50-
getattr(container._xobject, self.name)._offset == value._xobject._offset)
49+
and (
50+
getattr(container._xobject, self.name) is not None
51+
and getattr(container._xobject, self.name)._offset
52+
== value._xobject._offset
53+
)
5154
):
5255
setattr(container._xobject, self.name, value._xobject)
5356

@@ -324,7 +327,8 @@ def _static_from_dict(cls, dct, _context=None, _buffer=None, _offset=None):
324327

325328
@classmethod
326329
def from_dict(cls, dct, _context=None, _buffer=None, _offset=None):
327-
return HybridClass._static_from_dict(cls,
330+
return HybridClass._static_from_dict(
331+
cls,
328332
dct,
329333
_context=_context,
330334
_buffer=_buffer,

xobjects/test_helpers.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from functools import wraps
77
from typing import Callable, Iterable, Union
8-
from numpy.testing import assert_allclose as np_assert_allclose
98

109
import pytest
1110

@@ -84,10 +83,3 @@ def requires_context(context_name: str):
8483
return lambda test_function: test_function
8584

8685
return pytest.mark.skip(f"{context_name} is unavailable on this platform.")
87-
88-
def assert_allclose(a, b, rtol=1e-7, atol=1e-7):
89-
if hasattr(a, 'get'):
90-
a = a.get()
91-
if hasattr(b, 'get'):
92-
b = b.get()
93-
np_assert_allclose(a, b, rtol=rtol, atol=atol)

0 commit comments

Comments
 (0)