We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1d3b019 + bc7cbb0 commit 9769691Copy full SHA for 9769691
.github/workflows/build-test.yaml
@@ -13,10 +13,16 @@ jobs:
13
fail-fast: false
14
matrix:
15
os: [ubuntu-latest]
16
- python-version: [3.8, 3.9, "3.10", "3.11"]
+ python-version: [3.9, "3.10", "3.11", "3.12"]
17
sqlalchemy-version: ["1.4", "2.0"]
18
- numpy-version: ["1.18", "1.22"]
+ numpy-version: ["1.22", "1.26"]
19
TANGOS_TESTING_DB_BACKEND: [sqlite, mysql+pymysql, postgresql+psycopg2]
20
+ exclude:
21
+ - python-version: "3.12"
22
+ sqlalchemy-version: "1.4"
23
24
+ numpy-version: "1.22"
25
+
26
runs-on: ${{ matrix.os }}
27
env:
28
C: gcc-10
@@ -55,10 +61,10 @@ jobs:
55
61
- name: Install python dependencies
56
62
run: |
57
63
python -m pip install --upgrade pip setuptools wheel
58
- python -m pip install numpy~=${{ matrix.numpy-version}} scipy "matplotlib<3.3.0" pytest h5py pip webtest pyquery sphinx pygments pandas sqlalchemy~=${{ matrix.sqlalchemy-version}} cython pyramid ipython pyramid_mako PyMySQL[rsa] psycopg2-binary
64
+ python -m pip install numpy~=${{ matrix.numpy-version}} sqlalchemy~=${{ matrix.sqlalchemy-version}}
59
65
- name: Build and install tangos
60
66
- python setup.py develop
67
+ pip install -e .[test,rmdbs]
68
- name: Check that tangos can import without pynbody
69
70
python -c "import tangos"
setup.py
@@ -72,6 +72,7 @@ def get_version(rel_path):
72
"Programming Language :: Python :: 3.9",
73
"Programming Language :: Python :: 3.10",
74
"Programming Language :: Python :: 3.11",
75
+ "Programming Language :: Python :: 3.12",
76
"License :: OSI Approved :: BSD License",
77
],
78
author="Andrew Pontzen",
@@ -100,5 +101,9 @@ def get_version(rel_path):
100
101
tests_require=tests_require,
102
test_suite="tests",
103
long_description=long_description,
- long_description_content_type='text/markdown'
104
+ long_description_content_type='text/markdown',
105
+ extras_require={'test': tests_require,
106
+ 'rmdbs': ['PyMySQL[rsa]',
107
+ 'psycopg2-binary']
108
+ }
109
)
tangos/core/halo_data/link.py
@@ -16,13 +16,13 @@ class HaloLink(Base):
halo_from = relationship(SimulationObjectBase, primaryjoin=halo_from_id == SimulationObjectBase.id,
backref=backref('links', cascade_backrefs=False,
- lazy='dynamic',
+ lazy='dynamic', viewonly=True,
primaryjoin=halo_from_id == SimulationObjectBase.id),
cascade='')
halo_to = relationship(SimulationObjectBase, primaryjoin=(halo_to_id == SimulationObjectBase.id),
backref=backref('reverse_links', cascade_backrefs=False,
primaryjoin=halo_to_id == SimulationObjectBase.id),
tangos/core/halo_data/property.py
@@ -15,7 +15,7 @@ class HaloProperty(Base):
# n.b. backref defined below
halo = relationship(SimulationObjectBase, cascade='',
backref=backref('all_properties',overlaps='properties,deprecated_properties',
- cascade_backrefs=False),
+ cascade_backrefs=False, viewonly=True),
overlaps='properties,deprecated_properties')
data_float = Column(DOUBLE_PRECISION)
@@ -27,8 +27,10 @@ class HaloProperty(Base):
deprecated = Column(Boolean, default=False, nullable=False)
29
30
- creator = relationship(creator.Creator, backref=backref(
31
- 'properties', cascade_backrefs=False, lazy='dynamic'), cascade='save-update')
+ creator = relationship(creator.Creator,
+ backref=backref('properties', cascade_backrefs=False,
32
+ lazy='dynamic', viewonly=True),
33
+ cascade='save-update')
34
creator_id = Column(Integer, ForeignKey('creators.id'))
35
36
def __init__(self, halo, name, data):
tangos/properties/__init__.py
@@ -1,15 +1,15 @@
1
import functools
2
import importlib
3
import os
4
+import sys
5
import warnings
6
+from importlib.metadata import entry_points
7
8
import numpy as np
-import pkg_resources
-
9
-from tangos.util import timing_monitor
10
11
from .. import input_handlers, parallel_tasks
12
from ..log import logger
+from ..util import timing_monitor
class PropertyCalculationMetaClass(type):
@@ -569,6 +569,12 @@ def instantiate_class(simulation, property_name, silent_fail=False):
569
else:
570
return instance[0]
571
572
+def _get_entry_points():
573
+ if sys.version_info >= (3, 10):
574
+ return entry_points(group='tangos.property_modules')
575
+ else:
576
+ return entry_points().get('tangos.property_modules', [])
577
578
def _import_configured_property_modules():
579
if "PYTEST_CURRENT_TEST" in os.environ:
580
warnings.warn("Not importing external property modules during testing", ImportWarning)
@@ -582,7 +588,7 @@ def _import_configured_property_modules():
582
588
except ImportError:
583
589
warnings.warn("Failed to import requested property module %r. Some properties may be unavailable."%pm,
584
590
ImportWarning)
585
- for module in pkg_resources.iter_entry_points('tangos.property_modules'):
591
+ for module in _get_entry_points():
586
592
module.load()
587
593
594
_import_configured_property_modules()
tangos/testing/db_diff.py
@@ -104,12 +104,14 @@ def compare_timestep(self, ts):
def _joined_links_load(self, parent):
- return object_session(parent).query(core.HaloLink).with_parent(parent, type(parent).all_links).\
- options(joinedload(core.HaloLink.halo_to))
+ return (object_session(parent).query(core.HaloLink).where(
+ core.HaloLink.halo_from_id == parent.id
+ ).options(joinedload(core.HaloLink.halo_to)))
110
111
def _joined_properties_load(self, parent):
- return object_session(parent).query(core.HaloProperty).with_parent(parent, type(parent).all_properties).\
112
- options(undefer("*")).options(joinedload(core.HaloProperty.name))
+ return object_session(parent).query(core.HaloProperty).where(
113
+ core.HaloProperty.halo_id == parent.id
114
+ ).options(undefer("*")).options(joinedload(core.HaloProperty.name))
115
116
def compare_object(self, obj):
117
obj1 = get_object(obj, self.session1)
tangos/tools/consistent_trees_importer.py
@@ -113,7 +113,7 @@ def store_ids(self, ts, id_to_tree_id):
props = []
for o in objs.values():
if isinstance(o, PhantomHalo):
- tree_id = id_to_tree_id.get(-o.finder_id, None)
+ tree_id = id_to_tree_id.get(-int(o.finder_id), None)
118
tree_id = id_to_tree_id.get(o.finder_id, None)
119
if tree_id is not None:
tests/test_consistent_trees.py
@@ -20,7 +20,7 @@ def _create_dummy_simsnap():
f['pos'].units="Mpc"
f['vel'] = np.zeros((2097152, 3)).view(pynbody.array.SimArray)
f['vel'].units = "km s^-1"
- f['mass'] = np.zeros(2097152).view(pynbody.array.SimArray)
+ f['mass'] = np.ones(2097152).view(pynbody.array.SimArray)
f['mass'].units="Msol"
f.properties['boxsize'] = pynbody.units.Unit("50 Mpc")
return f
tests/test_stat_files.py
@@ -140,7 +140,7 @@ def test_import_properties_is_only_numeric_or_array():
140
141
property = importer._create_property(db_name, halo, np.array([42.0, 42.0, 42.0]))
142
assert property.data_is_array() == True
143
- assert property.data.dtype == np.floating
+ assert np.issubdtype(property.data.dtype, np.floating)
144
npt.assert_allclose(property.data, np.array([42.0, 42.0, 42.0]))
145
146
# Importing a string should fail
0 commit comments