sacc 0.16__tar.gz → 1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sacc-0.16 → sacc-1.0}/.github/workflows/desc-ci.yml +10 -3
- {sacc-0.16 → sacc-1.0}/.github/workflows/publish.yml +2 -1
- {sacc-0.16/sacc.egg-info → sacc-1.0}/PKG-INFO +16 -10
- sacc-1.0/pyproject.toml +52 -0
- {sacc-0.16 → sacc-1.0}/sacc/__init__.py +1 -1
- {sacc-0.16 → sacc-1.0}/sacc/data_types.py +0 -8
- {sacc-0.16 → sacc-1.0}/sacc/sacc.py +58 -14
- {sacc-0.16 → sacc-1.0}/sacc/tracers.py +0 -5
- {sacc-0.16 → sacc-1.0/sacc.egg-info}/PKG-INFO +16 -10
- {sacc-0.16 → sacc-1.0}/sacc.egg-info/SOURCES.txt +3 -2
- sacc-1.0/test/__init__.py +0 -0
- sacc-0.16/test/test_sacc2.py → sacc-1.0/test/test_sacc.py +99 -14
- sacc-0.16/setup.py +0 -31
- {sacc-0.16 → sacc-1.0}/.git_archival.txt +0 -0
- {sacc-0.16 → sacc-1.0}/.gitattributes +0 -0
- {sacc-0.16 → sacc-1.0}/.gitignore +0 -0
- {sacc-0.16 → sacc-1.0}/.readthedocs.yml +0 -0
- {sacc-0.16 → sacc-1.0}/LICENSE +0 -0
- {sacc-0.16 → sacc-1.0}/MANIFEST.in +0 -0
- {sacc-0.16 → sacc-1.0}/README.md +0 -0
- {sacc-0.16 → sacc-1.0}/doc/Makefile +0 -0
- {sacc-0.16 → sacc-1.0}/doc/format.md +0 -0
- {sacc-0.16 → sacc-1.0}/doc/requirements.txt +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/Makefile +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/api.rst +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/conf.py +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/covariance.rst +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/data_types.rst +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/index.rst +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/intro.rst +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/sacc.rst +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/tracers.rst +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/utils.rst +0 -0
- {sacc-0.16 → sacc-1.0}/doc/source/windows.rst +0 -0
- {sacc-0.16 → sacc-1.0}/examples/.gitignore +0 -0
- {sacc-0.16 → sacc-1.0}/examples/CMB_LSS_read.ipynb +0 -0
- {sacc-0.16 → sacc-1.0}/examples/CMB_LSS_write.ipynb +0 -0
- {sacc-0.16 → sacc-1.0}/examples/Convert_DES_Sacc.ipynb +0 -0
- {sacc-0.16 → sacc-1.0}/examples/Convert_KIDS_Sacc.ipynb +0 -0
- {sacc-0.16 → sacc-1.0}/examples/Create_Sacc.ipynb +0 -0
- {sacc-0.16 → sacc-1.0}/examples/README.md +0 -0
- {sacc-0.16 → sacc-1.0}/examples/SACC_for_clusters.ipynb +0 -0
- {sacc-0.16 → sacc-1.0}/examples/SACC_read.ipynb +0 -0
- {sacc-0.16 → sacc-1.0}/examples/SACC_write.ipynb +0 -0
- {sacc-0.16 → sacc-1.0}/examples/demo_sacc_for_clusters_N+M.ipynb +0 -0
- {sacc-0.16 → sacc-1.0}/examples/example-txpipe-sacc1.sacc +0 -0
- {sacc-0.16 → sacc-1.0}/requirements.txt +0 -0
- {sacc-0.16 → sacc-1.0}/sacc/covariance.py +0 -0
- {sacc-0.16 → sacc-1.0}/sacc/utils.py +0 -0
- {sacc-0.16 → sacc-1.0}/sacc/windows.py +0 -0
- {sacc-0.16 → sacc-1.0}/sacc.egg-info/dependency_links.txt +0 -0
- {sacc-0.16 → sacc-1.0}/sacc.egg-info/requires.txt +3 -3
- {sacc-0.16 → sacc-1.0}/sacc.egg-info/top_level.txt +0 -0
- {sacc-0.16 → sacc-1.0}/setup.cfg +0 -0
- {sacc-0.16 → sacc-1.0}/test/data/.gitignore +0 -0
- {sacc-0.16 → sacc-1.0}/test/make_test_data.py +0 -0
- {sacc-0.16 → sacc-1.0}/test/test_cluster_data_tracers.py +0 -0
@@ -25,9 +25,16 @@ jobs:
|
|
25
25
|
|
26
26
|
- name: Dependencies
|
27
27
|
run: |
|
28
|
-
python -m pip install --upgrade numpy pytest
|
28
|
+
python -m pip install --upgrade numpy pytest pytest-cov coverage pip
|
29
29
|
python -m pip install '.[all]'
|
30
30
|
|
31
|
-
- name: Run tests
|
31
|
+
- name: Run tests and measure coverage
|
32
32
|
run: |
|
33
|
-
pytest -
|
33
|
+
pytest --cov sacc --cov-report xml:coverage.xml ./test
|
34
|
+
|
35
|
+
- name: Report coverage
|
36
|
+
uses: orgoro/coverage@v3.2
|
37
|
+
if: matrix.python-version == '3.11'
|
38
|
+
with:
|
39
|
+
coverageFile: ./coverage.xml
|
40
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
@@ -1,17 +1,25 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: sacc
|
3
|
-
Version: 0
|
3
|
+
Version: 1.0
|
4
4
|
Summary: SACC - the LSST/DESC summary statistic data format library
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
Author-email: LSST DESC <joezuntz@googlemail.com>
|
6
|
+
License: BSD-3-Clause
|
7
|
+
Project-URL: Homepage, https://github.com/LSSTDESC/sacc
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
10
|
Description-Content-Type: text/markdown
|
11
|
+
License-File: LICENSE
|
12
|
+
Requires-Dist: scipy
|
13
|
+
Requires-Dist: numpy>=1.20
|
14
|
+
Requires-Dist: astropy
|
11
15
|
Provides-Extra: all
|
16
|
+
Requires-Dist: qp-prob[all]; extra == "all"
|
17
|
+
Requires-Dist: numpydoc; extra == "all"
|
12
18
|
Provides-Extra: doc
|
19
|
+
Requires-Dist: numpydoc; extra == "doc"
|
13
20
|
Provides-Extra: qp
|
14
|
-
|
21
|
+
Requires-Dist: qp-prob[all]; extra == "qp"
|
22
|
+
Dynamic: license-file
|
15
23
|
|
16
24
|
Sacc
|
17
25
|
====
|
@@ -58,5 +66,3 @@ Citation
|
|
58
66
|
Sacc has been submitted to the [Astrophysics Source Code Library](https://ascl.net/code/v/2277); follow the link that will appear there to NASA ADS to export a bibtex citation.
|
59
67
|
|
60
68
|
The core developers of Sacc are Joe Zuntz (maintainer), David Alonso, and Matt Becker.
|
61
|
-
|
62
|
-
|
sacc-1.0/pyproject.toml
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
[project]
|
2
|
+
name = "sacc"
|
3
|
+
description = "SACC - the LSST/DESC summary statistic data format library"
|
4
|
+
readme = "README.md"
|
5
|
+
license = { text = "BSD-3-Clause" }
|
6
|
+
authors = [
|
7
|
+
{ name = "LSST DESC", email = "joezuntz@googlemail.com" }
|
8
|
+
]
|
9
|
+
dynamic = ["version"]
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
classifiers = [
|
14
|
+
"Programming Language :: Python :: 3",
|
15
|
+
"Operating System :: OS Independent"
|
16
|
+
]
|
17
|
+
|
18
|
+
dependencies = [
|
19
|
+
"scipy",
|
20
|
+
"numpy>=1.20",
|
21
|
+
"astropy"
|
22
|
+
]
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
[build-system]
|
27
|
+
requires = [
|
28
|
+
"setuptools>=42",
|
29
|
+
"setuptools_scm<7.0",
|
30
|
+
"setuptools_scm_git_archive",
|
31
|
+
"wheel"
|
32
|
+
]
|
33
|
+
build-backend = "setuptools.build_meta"
|
34
|
+
|
35
|
+
[project.urls]
|
36
|
+
Homepage = "https://github.com/LSSTDESC/sacc"
|
37
|
+
|
38
|
+
|
39
|
+
[project.optional-dependencies]
|
40
|
+
all = ["qp-prob[all]", "numpydoc"]
|
41
|
+
doc = ["numpydoc"]
|
42
|
+
qp = ["qp-prob[all]"]
|
43
|
+
|
44
|
+
[tool.setuptools.packages.find]
|
45
|
+
where = ["."]
|
46
|
+
include = ["sacc"]
|
47
|
+
|
48
|
+
[tool.setuptools.dynamic]
|
49
|
+
version = {attr = "sacc.__version__"}
|
50
|
+
|
51
|
+
[tool.coverage.run]
|
52
|
+
relative_paths = true
|
@@ -3,4 +3,4 @@ from .windows import Window, BandpowerWindow, TopHatWindow, LogTopHatWindow # n
|
|
3
3
|
from .data_types import standard_types, parse_data_type_name, build_data_type_name # noqa
|
4
4
|
from .tracers import BaseTracer # noqa
|
5
5
|
from .covariance import BaseCovariance # noqa
|
6
|
-
__version__ = '0
|
6
|
+
__version__ = '1.0' #noqa
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import warnings
|
2
1
|
from collections import namedtuple
|
3
2
|
from astropy.table import Table
|
4
3
|
|
@@ -298,13 +297,6 @@ class DataPoint:
|
|
298
297
|
f"{data_type} "
|
299
298
|
"(ignore_missing_tags=False)")
|
300
299
|
|
301
|
-
# We encourage people to use existing type names, and issue a
|
302
|
-
# warning if they do not to prod them in the right direction.
|
303
|
-
if data_type not in standard_types:
|
304
|
-
warnings.warn(f"Unknown data_type value {data_type}. "
|
305
|
-
"If possible use a pre-defined type, or "
|
306
|
-
"add to the list.")
|
307
|
-
|
308
300
|
def __repr__(self):
|
309
301
|
t = ", ".join(f'{k}={v}' for (k, v) in self.tags.items())
|
310
302
|
st = f"DataPoint(data_type='{self.data_type}', "
|
@@ -371,12 +371,14 @@ class Sacc:
|
|
371
371
|
# Record this index
|
372
372
|
if ok:
|
373
373
|
indices.append(i)
|
374
|
+
|
374
375
|
if len(indices) == 0 and warn_empty:
|
375
376
|
if tracers is None:
|
376
377
|
warnings.warn("Empty index selected")
|
377
378
|
else:
|
378
379
|
warnings.warn("Empty index selected - maybe you "
|
379
380
|
"should check the tracer order?")
|
381
|
+
|
380
382
|
return np.array(indices, dtype=int)
|
381
383
|
|
382
384
|
def remove_selection(self, data_type=None, tracers=None,
|
@@ -603,6 +605,40 @@ class Sacc:
|
|
603
605
|
indices = self.indices(data_type=data_type, tracers=tracers, **select)
|
604
606
|
return self.mean[indices]
|
605
607
|
|
608
|
+
def get_standard_deviation(self, data_type=None, tracers=None, **select):
|
609
|
+
"""
|
610
|
+
Get standard deviation values for each data point matching the criteria.
|
611
|
+
|
612
|
+
This requires the covariance matrix to be set.
|
613
|
+
|
614
|
+
Parameters
|
615
|
+
----------
|
616
|
+
|
617
|
+
data_type: str
|
618
|
+
Select only data points which are of this data type.
|
619
|
+
If None (the default) then match any data types
|
620
|
+
|
621
|
+
tracers: tuple
|
622
|
+
Select only data points which match this tracer combination.
|
623
|
+
If None (the default) then match any tracer combinations.
|
624
|
+
|
625
|
+
**select:
|
626
|
+
Select only data points with tag names and values matching
|
627
|
+
all values provided in this kwargs option.
|
628
|
+
You can also use the syntax name__lt=value or
|
629
|
+
name__gt=value in the selection to select points
|
630
|
+
less or greater than a threshold
|
631
|
+
|
632
|
+
Returns
|
633
|
+
-------
|
634
|
+
values: array
|
635
|
+
The standard deviation values for each matching data point,
|
636
|
+
in the order they were added.
|
637
|
+
|
638
|
+
"""
|
639
|
+
indices = self.indices(data_type=data_type, tracers=tracers, **select)
|
640
|
+
return np.sqrt(self.covariance.get_block(indices).diagonal())
|
641
|
+
|
606
642
|
def get_data_types(self, tracers=None):
|
607
643
|
"""
|
608
644
|
Get a list of the different data types stored in the Sacc
|
@@ -796,20 +832,19 @@ class Sacc:
|
|
796
832
|
|
797
833
|
# Since we don't want to re-order the file as a side effect
|
798
834
|
# we first make a copy of ourself and re-order that.
|
799
|
-
S = self.copy()
|
800
|
-
S.to_canonical_order()
|
801
|
-
|
802
835
|
# Tables for the windows
|
803
|
-
tables, window_ids =
|
836
|
+
tables, window_ids = self._make_window_tables()
|
804
837
|
lookup = {'window': window_ids}
|
805
838
|
|
806
839
|
# Tables for the tracers
|
807
|
-
tables += BaseTracer.to_tables(
|
840
|
+
tables += BaseTracer.to_tables(self.tracers.values())
|
808
841
|
|
809
842
|
# Tables for the data sets
|
810
|
-
for dt in
|
811
|
-
|
843
|
+
for dt in self.get_data_types():
|
844
|
+
indices = self.indices(dt)
|
845
|
+
data = [self.data[i] for i in indices]
|
812
846
|
table = DataPoint.to_table(data, lookup)
|
847
|
+
table.add_column(indices, name='sacc_ordering')
|
813
848
|
# Could move this inside to_table?
|
814
849
|
table.meta['SACCTYPE'] = 'data'
|
815
850
|
table.meta['SACCNAME'] = dt
|
@@ -822,8 +857,8 @@ class Sacc:
|
|
822
857
|
# save any global metadata in the header.
|
823
858
|
# We save the keys and values as separate header cards,
|
824
859
|
# because otherwise the keys are all forced to upper case
|
825
|
-
hdr['NMETA'] = len(
|
826
|
-
for i, (k, v) in enumerate(
|
860
|
+
hdr['NMETA'] = len(self.metadata)
|
861
|
+
for i, (k, v) in enumerate(self.metadata.items()):
|
827
862
|
hdr[f'KEY{i}'] = k
|
828
863
|
hdr[f'VAL{i}'] = v
|
829
864
|
hdus = [fits.PrimaryHDU(header=hdr)] + \
|
@@ -833,8 +868,8 @@ class Sacc:
|
|
833
868
|
# All the other data elements become astropy tables first,
|
834
869
|
# But covariances are a bit more complicated and dense, so we
|
835
870
|
# allow them to convert straight to
|
836
|
-
if
|
837
|
-
hdus.append(
|
871
|
+
if self.covariance is not None:
|
872
|
+
hdus.append(self.covariance.to_hdu())
|
838
873
|
|
839
874
|
# Make and save the final FITS data
|
840
875
|
hdu_list = fits.HDUList(hdus)
|
@@ -896,9 +931,18 @@ class Sacc:
|
|
896
931
|
lookup = {'window': windows}
|
897
932
|
|
898
933
|
# Collect together all the data points from the different sections
|
899
|
-
|
934
|
+
data_unordered = []
|
935
|
+
index = []
|
900
936
|
for table in data_tables:
|
901
|
-
|
937
|
+
index += table["sacc_ordering"].tolist()
|
938
|
+
table.remove_column('sacc_ordering')
|
939
|
+
data_unordered += DataPoint.from_table(table, lookup)
|
940
|
+
|
941
|
+
# Put the data back in its original order, matching the
|
942
|
+
# covariance.
|
943
|
+
data = [None for i in range(len(data_unordered))]
|
944
|
+
for i, d in zip(index, data_unordered):
|
945
|
+
data[i] = d
|
902
946
|
|
903
947
|
# Finally, take all the pieces that we have collected
|
904
948
|
# and add them all into this data set.
|
@@ -986,7 +1030,7 @@ class Sacc:
|
|
986
1030
|
"later.")
|
987
1031
|
ws = ws[0]
|
988
1032
|
if not isinstance(ws, BandpowerWindow):
|
989
|
-
warnings.warn("No bandpower windows associated
|
1033
|
+
warnings.warn("No bandpower windows associated with these data")
|
990
1034
|
return None
|
991
1035
|
else:
|
992
1036
|
w_inds = np.array(self._get_tags_by_index(['window_ind'],
|
@@ -2,7 +2,6 @@ import numpy as np
|
|
2
2
|
from astropy.table import Table
|
3
3
|
from .utils import (Namespace, hide_null_values,
|
4
4
|
remove_dict_null_values, unique_list)
|
5
|
-
import warnings
|
6
5
|
|
7
6
|
standard_quantities = Namespace('galaxy_shear',
|
8
7
|
'galaxy_density',
|
@@ -40,10 +39,6 @@ class BaseTracer:
|
|
40
39
|
# We encourage people to use existing quantity names, and issue a
|
41
40
|
# warning if they do not to prod them in the right direction.
|
42
41
|
quantity = kwargs.pop('quantity', 'generic')
|
43
|
-
if quantity not in standard_quantities:
|
44
|
-
warnings.warn(f"Unknown quantity {quantity}. "
|
45
|
-
"If possible use a pre-defined quantity, or "
|
46
|
-
"add to the list.")
|
47
42
|
self.name = name
|
48
43
|
self.quantity = quantity
|
49
44
|
self.metadata = kwargs.pop('metadata', {})
|
@@ -1,17 +1,25 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: sacc
|
3
|
-
Version: 0
|
3
|
+
Version: 1.0
|
4
4
|
Summary: SACC - the LSST/DESC summary statistic data format library
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
Author-email: LSST DESC <joezuntz@googlemail.com>
|
6
|
+
License: BSD-3-Clause
|
7
|
+
Project-URL: Homepage, https://github.com/LSSTDESC/sacc
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
10
|
Description-Content-Type: text/markdown
|
11
|
+
License-File: LICENSE
|
12
|
+
Requires-Dist: scipy
|
13
|
+
Requires-Dist: numpy>=1.20
|
14
|
+
Requires-Dist: astropy
|
11
15
|
Provides-Extra: all
|
16
|
+
Requires-Dist: qp-prob[all]; extra == "all"
|
17
|
+
Requires-Dist: numpydoc; extra == "all"
|
12
18
|
Provides-Extra: doc
|
19
|
+
Requires-Dist: numpydoc; extra == "doc"
|
13
20
|
Provides-Extra: qp
|
14
|
-
|
21
|
+
Requires-Dist: qp-prob[all]; extra == "qp"
|
22
|
+
Dynamic: license-file
|
15
23
|
|
16
24
|
Sacc
|
17
25
|
====
|
@@ -58,5 +66,3 @@ Citation
|
|
58
66
|
Sacc has been submitted to the [Astrophysics Source Code Library](https://ascl.net/code/v/2277); follow the link that will appear there to NASA ADS to export a bibtex citation.
|
59
67
|
|
60
68
|
The core developers of Sacc are Joe Zuntz (maintainer), David Alonso, and Matt Becker.
|
61
|
-
|
62
|
-
|
@@ -5,8 +5,8 @@
|
|
5
5
|
LICENSE
|
6
6
|
MANIFEST.in
|
7
7
|
README.md
|
8
|
+
pyproject.toml
|
8
9
|
requirements.txt
|
9
|
-
setup.py
|
10
10
|
.github/workflows/desc-ci.yml
|
11
11
|
.github/workflows/publish.yml
|
12
12
|
doc/Makefile
|
@@ -47,7 +47,8 @@ sacc.egg-info/SOURCES.txt
|
|
47
47
|
sacc.egg-info/dependency_links.txt
|
48
48
|
sacc.egg-info/requires.txt
|
49
49
|
sacc.egg-info/top_level.txt
|
50
|
+
test/__init__.py
|
50
51
|
test/make_test_data.py
|
51
52
|
test/test_cluster_data_tracers.py
|
52
|
-
test/
|
53
|
+
test/test_sacc.py
|
53
54
|
test/data/.gitignore
|
File without changes
|
@@ -8,7 +8,11 @@ import os
|
|
8
8
|
import pathlib
|
9
9
|
import urllib
|
10
10
|
import time
|
11
|
-
import
|
11
|
+
import warnings
|
12
|
+
try:
|
13
|
+
import qp
|
14
|
+
except:
|
15
|
+
pass
|
12
16
|
|
13
17
|
test_dir = pathlib.Path(__file__).resolve().parent
|
14
18
|
test_data_dir = test_dir / 'data'
|
@@ -79,20 +83,58 @@ def test_add_covariance():
|
|
79
83
|
s.add_covariance(0 * cov, overwrite=True)
|
80
84
|
assert np.all(s.covariance.covmat == 0 * cov)
|
81
85
|
|
86
|
+
def test_get_sigma():
|
87
|
+
s_base = get_filled_sacc()
|
88
|
+
n = len(s_base)
|
89
|
+
|
90
|
+
# first check it works with a diagonal cov
|
91
|
+
# for the full matrix
|
92
|
+
s = s_base.copy()
|
93
|
+
variance = np.random.uniform(size=n)
|
94
|
+
s.add_covariance(variance)
|
95
|
+
assert isinstance(s.covariance, sacc.covariance.DiagonalCovariance)
|
96
|
+
sigma = s.get_standard_deviation()
|
97
|
+
assert np.allclose(sigma, variance ** 0.5)
|
98
|
+
|
99
|
+
# Now check the last 20 data points work
|
100
|
+
tracers = ('source_2', 'source_2')
|
101
|
+
dt = sacc.standard_types.galaxy_shear_cl_bb
|
102
|
+
sigma = s.get_standard_deviation(tracers=tracers, data_type=dt)
|
103
|
+
assert len(sigma) == 20
|
104
|
+
assert np.allclose(sigma, variance[-20:] ** 0.5)
|
105
|
+
|
106
|
+
# Now check with a dense covariance
|
107
|
+
s = s_base.copy()
|
108
|
+
cov = np.random.uniform(size=(n, n))
|
109
|
+
# make symmetric out of habit
|
110
|
+
cov = (cov + cov.T) / 2
|
111
|
+
s.add_covariance(cov)
|
112
|
+
assert isinstance(s.covariance, sacc.covariance.FullCovariance)
|
113
|
+
|
114
|
+
sigma = s.get_standard_deviation()
|
115
|
+
assert np.allclose(sigma, np.sqrt(np.diagonal(cov)))
|
116
|
+
|
117
|
+
tracers = ('source_2', 'source_2')
|
118
|
+
dt = sacc.standard_types.galaxy_shear_cl_bb
|
119
|
+
sigma = s.get_standard_deviation(tracers=tracers, data_type=dt)
|
120
|
+
assert len(sigma) == 20
|
121
|
+
assert np.allclose(sigma, np.sqrt(np.diagonal(cov))[-20:])
|
122
|
+
|
123
|
+
# now block-diagonal
|
124
|
+
s = s_base.copy()
|
125
|
+
cov = [
|
126
|
+
np.random.uniform(size=(n//4, n//4))
|
127
|
+
for i in range(4)
|
128
|
+
]
|
129
|
+
s.add_covariance(cov)
|
130
|
+
assert isinstance(s.covariance, sacc.covariance.BlockDiagonalCovariance)
|
131
|
+
sigma = s.get_standard_deviation()
|
132
|
+
expected = np.concatenate([
|
133
|
+
np.sqrt(np.diagonal(c))
|
134
|
+
for c in cov
|
135
|
+
])
|
136
|
+
assert np.allclose(sigma, expected)
|
82
137
|
|
83
|
-
def test_quantity_warning():
|
84
|
-
s = sacc.Sacc()
|
85
|
-
with pytest.warns(UserWarning):
|
86
|
-
s.add_tracer('Misc', 'source_0',
|
87
|
-
quantity='dummy')
|
88
|
-
|
89
|
-
|
90
|
-
def test_data_type_warning():
|
91
|
-
s = sacc.Sacc()
|
92
|
-
s.add_tracer('Misc', 'source_0')
|
93
|
-
with pytest.warns(UserWarning):
|
94
|
-
s.add_data_point('cl_wrong', ('source_0', 'source_0'),
|
95
|
-
0.1, ell=10.)
|
96
138
|
|
97
139
|
|
98
140
|
def test_get_data_types():
|
@@ -891,3 +933,46 @@ def test_sacc_has_tracer():
|
|
891
933
|
assert not s.has_tracer("this_is_not_a_tracer")
|
892
934
|
for tracer_name in ['source_0', 'source_1', 'source_2']:
|
893
935
|
assert s.has_tracer(tracer_name)
|
936
|
+
|
937
|
+
def test_save_order_maintained():
|
938
|
+
s = sacc.Sacc()
|
939
|
+
|
940
|
+
# Tracer
|
941
|
+
s.add_tracer('misc', 'source_0')
|
942
|
+
|
943
|
+
# add a series of data points with alternating
|
944
|
+
# types so they will be saved in separate table
|
945
|
+
s.add_data_point("dt1", ('source_0',), 0.1, a=1)
|
946
|
+
s.add_data_point("dt2", ('source_0',), 0.1, b=2)
|
947
|
+
s.add_data_point("dt1", ('source_0',), 0.1, a=-1)
|
948
|
+
s.add_data_point("dt2", ('source_0',), 0.1, b=-2)
|
949
|
+
|
950
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
951
|
+
filename = os.path.join(tmpdir, 'test.sacc')
|
952
|
+
s.save_fits(filename)
|
953
|
+
s2 = sacc.Sacc.load_fits(filename)
|
954
|
+
|
955
|
+
# check that the order of the data points is maintained
|
956
|
+
assert len(s2) == 4
|
957
|
+
assert s2.data[0].data_type == "dt1"
|
958
|
+
assert s2.data[1].data_type == "dt2"
|
959
|
+
assert s2.data[2].data_type == "dt1"
|
960
|
+
assert s2.data[3].data_type == "dt2"
|
961
|
+
# and that the tags are all okay
|
962
|
+
assert s2.data[0].get_tag('a') == 1
|
963
|
+
assert s2.data[1].get_tag('b') == 2
|
964
|
+
assert s2.data[2].get_tag('a') == -1
|
965
|
+
assert s2.data[3].get_tag('b') == -2
|
966
|
+
|
967
|
+
def test_warn_empty():
|
968
|
+
s = sacc.Sacc()
|
969
|
+
|
970
|
+
# First check that no warning is raised if warn_empty is False
|
971
|
+
# which is the default
|
972
|
+
with warnings.catch_warnings():
|
973
|
+
warnings.simplefilter("error")
|
974
|
+
s.indices(data_type='non_existent_data_type', warn_empty=False)
|
975
|
+
|
976
|
+
# Now check that a warning is raised if warn_empty is True
|
977
|
+
with pytest.warns(UserWarning, match="Empty index selected"):
|
978
|
+
s.indices(data_type='non_existent_data_type', warn_empty=True)
|
sacc-0.16/setup.py
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python
|
2
|
-
from setuptools import setup
|
3
|
-
|
4
|
-
description = "SACC - the LSST/DESC summary statistic data format library"
|
5
|
-
|
6
|
-
with open('requirements.txt') as f:
|
7
|
-
requirements = f.read().splitlines()
|
8
|
-
|
9
|
-
requirements.remove("qp-prob")
|
10
|
-
requirements.remove("numpydoc")
|
11
|
-
|
12
|
-
with open('README.md') as f:
|
13
|
-
long_description = f.read()
|
14
|
-
|
15
|
-
setup(name="sacc",
|
16
|
-
description=description,
|
17
|
-
long_description=long_description,
|
18
|
-
long_description_content_type='text/markdown',
|
19
|
-
url="https://github.com/LSSTDESC/sacc",
|
20
|
-
author="LSST DESC",
|
21
|
-
author_email="joezuntz@googlemail.com",
|
22
|
-
use_scm_version=True,
|
23
|
-
setup_requires=["setuptools_scm<7.0", "setuptools_scm_git_archive"],
|
24
|
-
install_requires=requirements,
|
25
|
-
extras_require = {
|
26
|
-
'all': ["qp-prob[all]", "numpydoc"],
|
27
|
-
'doc': ["numpydoc"],
|
28
|
-
'qp': ["qp-prob[all]"],
|
29
|
-
},
|
30
|
-
packages=['sacc'],
|
31
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sacc-0.16 → sacc-1.0}/LICENSE
RENAMED
File without changes
|
File without changes
|
{sacc-0.16 → sacc-1.0}/README.md
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sacc-0.16 → sacc-1.0}/setup.cfg
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|