Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v0.4.1 #134

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xobjects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@

from .general import _print

from .test_helpers import assert_allclose
from .general import assert_allclose

from ._version import __version__
2 changes: 1 addition & 1 deletion xobjects/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.0"
__version__ = "0.4.1"
15 changes: 15 additions & 0 deletions xobjects/general.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# copyright ################################# #
# This file is part of the Xobjects Package. #
# Copyright (c) CERN, 2024. #
# ########################################### #
from numpy.testing import assert_allclose as np_assert_allclose


class Print:
suppress = False

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


_print = Print()


def assert_allclose(a, b, rtol=1e-7, atol=1e-7):
if hasattr(a, "get"):
a = a.get()
if hasattr(b, "get"):
b = b.get()
np_assert_allclose(a, b, rtol=rtol, atol=atol)
10 changes: 7 additions & 3 deletions xobjects/hybrid_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ def __set__(self, container, value):
# in the latter case reference mechanism is used)
if not (
container._xobject._buffer is value._xobject._buffer
and (getattr(container._xobject, self.name) is not None and
getattr(container._xobject, self.name)._offset == value._xobject._offset)
and (
getattr(container._xobject, self.name) is not None
and getattr(container._xobject, self.name)._offset
== value._xobject._offset
)
):
setattr(container._xobject, self.name, value._xobject)

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

@classmethod
def from_dict(cls, dct, _context=None, _buffer=None, _offset=None):
return HybridClass._static_from_dict(cls,
return HybridClass._static_from_dict(
cls,
dct,
_context=_context,
_buffer=_buffer,
Expand Down
8 changes: 0 additions & 8 deletions xobjects/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from functools import wraps
from typing import Callable, Iterable, Union
from numpy.testing import assert_allclose as np_assert_allclose

import pytest

Expand Down Expand Up @@ -84,10 +83,3 @@ def requires_context(context_name: str):
return lambda test_function: test_function

return pytest.mark.skip(f"{context_name} is unavailable on this platform.")

def assert_allclose(a, b, rtol=1e-7, atol=1e-7):
if hasattr(a, 'get'):
a = a.get()
if hasattr(b, 'get'):
b = b.get()
np_assert_allclose(a, b, rtol=rtol, atol=atol)
Loading