Skip to content

Commit c8dc058

Browse files
committed
Merge branch 'master' into json_output
2 parents 4ef9e9d + ffdb4c3 commit c8dc058

33 files changed

+526
-163
lines changed

.github/workflows/cmake.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
runs-on: ${{matrix.os}}
2626

2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v5
2929

3030
- name: Install Linux Dependencies
3131
if: runner.environment == 'github-hosted' && runner.os == 'Linux'
@@ -36,19 +36,19 @@ jobs:
3636
sudo apt install gcc-14 g++-14 -y
3737
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 14 --slave /usr/bin/g++ g++ /usr/bin/g++-14
3838
sudo apt-get install libz-dev libbz2-dev liblzma-dev libflac-dev libnetcdf-dev libpython3-dev
39-
sudo pip install numpy scipy matplotlib astropy healpy sphinx sphinx-rtd-theme --break-system-packages
39+
sudo pip install numpy scipy matplotlib astropy healpy --break-system-packages
4040
4141
- name: Setup python on macOS
4242
if: runner.environment == 'github-hosted' && runner.os == 'macOS'
43-
uses: actions/setup-python@v5
43+
uses: actions/setup-python@v6
4444
with:
4545
python-version: '3.13'
4646

4747
- name: Install macOS Dependencies
4848
if: runner.environment == 'github-hosted' && runner.os == 'macOS'
4949
run: |
5050
brew install --overwrite bzip2 xz flac netcdf
51-
python3.13 -m pip install numpy scipy matplotlib astropy healpy sphinx sphinx-rtd-theme --break-system-packages
51+
python3.13 -m pip install numpy scipy matplotlib astropy healpy --break-system-packages
5252
5353
- name: Create Build Environment
5454
# Some projects don't allow in-source building, so create a separate build directory
@@ -85,19 +85,25 @@ jobs:
8585
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
8686
run: ctest -C $BUILD_TYPE --output-on-failure
8787

88+
- name: Docs Requirements
89+
if: runner.environment == 'github-hosted' && github.ref_name == 'master' && matrix.docs
90+
shell: bash
91+
run: |
92+
python3 -m pip install -r $GITHUB_WORKSPACE/doc/requirements.txt
93+
8894
- name: Docs
8995
if: github.ref_name == 'master' && matrix.docs
9096
working-directory: ${{runner.workspace}}/${{matrix.toolset}}
9197
shell: bash
9298
# Build docs
9399
run: |
94-
rm -f ${{runner.workspace}}/doc/moddoc_*.rst
100+
rm -f $GITHUB_WORKSPACE/doc/moddoc_*.rst
95101
rm -rf docs/
96102
cmake --build . --config $BUILD_TYPE --target docs
97103
98104
- name: Checkout gh_pages
99105
if: github.ref_name == 'master' && matrix.docs
100-
uses: actions/checkout@v4
106+
uses: actions/checkout@v5
101107
with:
102108
ref: gh-pages
103109
path: gh-pages

.github/workflows/wheels.yml

Lines changed: 16 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,60 +11,21 @@ concurrency:
1111

1212
jobs:
1313
build_wheels:
14-
name: Build wheels for ${{ matrix.build }}
14+
name: Build wheels for ${{ matrix.pyver }}-${{ matrix.build }}
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
fail-fast: false
1818
matrix:
19+
pyver: [cp39, cp310, cp311, cp312, cp313]
20+
os: [macos-14, ubuntu-24.04, ubuntu-24.04-arm]
1921
include:
20-
# macos-13 is an intel runner, macos-14 is apple silicon
21-
- os: macos-13
22-
build: cp38-macosx_x86_64
23-
target: 13.0
24-
- os: macos-13
25-
build: cp39-macosx_x86_64
26-
target: 13.0
27-
- os: macos-13
28-
build: cp310-macosx_x86_64
29-
target: 13.0
30-
- os: macos-13
31-
build: cp311-macosx_x86_64
32-
target: 13.0
33-
- os: macos-13
34-
build: cp312-macosx_x86_64
35-
target: 13.0
36-
- os: macos-13
37-
build: cp313-macosx_x86_64
38-
target: 13.0
39-
40-
- os: macos-14
41-
build: cp39-macosx_arm64
42-
target: 14.0
43-
- os: macos-14
44-
build: cp310-macosx_arm64
45-
target: 14.0
4622
- os: macos-14
47-
build: cp311-macosx_arm64
23+
build: macosx_arm64
4824
target: 14.0
49-
- os: macos-14
50-
build: cp312-macosx_arm64
51-
target: 14.0
52-
- os: macos-14
53-
build: cp313-macosx_arm64
54-
target: 14.0
55-
56-
- os: ubuntu-latest
57-
build: cp38-manylinux_x86_64
58-
- os: ubuntu-latest
59-
build: cp39-manylinux_x86_64
60-
- os: ubuntu-latest
61-
build: cp310-manylinux_x86_64
62-
- os: ubuntu-latest
63-
build: cp311-manylinux_x86_64
64-
- os: ubuntu-latest
65-
build: cp312-manylinux_x86_64
66-
- os: ubuntu-latest
67-
build: cp313-manylinux_x86_64
25+
- os: ubuntu-24.04
26+
build: manylinux_x86_64
27+
- os: ubuntu-24.04-arm
28+
build: manylinux_aarch64
6829

6930
steps:
7031
- name: Set macOS deployment target
@@ -77,17 +38,17 @@ jobs:
7738
run: brew install automake libtool
7839

7940
- name: Checkout
80-
uses: actions/checkout@v4
41+
uses: actions/checkout@v5
8142
with:
8243
fetch-depth: 0
8344
fetch-tags: true
8445

8546
- name: Build wheels
86-
uses: pypa/cibuildwheel@v2.23.3
47+
uses: pypa/cibuildwheel@v3.2.0
8748
env:
88-
CIBW_BUILD: ${{ matrix.build }}
89-
CIBW_BEFORE_ALL_LINUX: yum install -y zlib-devel bzip2-devel xz-devel netcdf-devel
90-
CIBW_BEFORE_ALL_MACOS: brew install netcdf
49+
CIBW_BUILD: ${{ matrix.pyver }}-${{ matrix.build }}
50+
CIBW_BEFORE_ALL_LINUX: yum install -y zlib-devel bzip2-devel xz-devel netcdf-devel cfitsio-devel
51+
CIBW_BEFORE_ALL_MACOS: brew install netcdf cfitsio
9152
CIBW_BEFORE_BUILD_MACOS: >
9253
ln -s $(dirname $(readlink -f $(which python3)))/python3-config $(dirname $(which python3))/python3-config &&
9354
pip install cmake && ./deps/install_flac.sh
@@ -115,14 +76,14 @@ jobs:
11576
- name: Upload artifacts
11677
uses: actions/upload-artifact@v4
11778
with:
118-
name: cibw-wheel-${{ matrix.build }}
79+
name: cibw-wheel-${{ matrix.pyver }}-${{ matrix.build }}
11980
path: ./wheelhouse/spt3g*.whl
12081

12182
build_sdist:
12283
name: Build source distribution
12384
runs-on: ubuntu-latest
12485
steps:
125-
- uses: actions/checkout@v4
86+
- uses: actions/checkout@v5
12687
with:
12788
fetch-depth: 0
12889
fetch-tags: true
@@ -144,7 +105,7 @@ jobs:
144105
if: github.event_name == 'release' && github.event.action == 'published'
145106
steps:
146107
- name: Download artifacts
147-
uses: actions/download-artifact@v4
108+
uses: actions/download-artifact@v5
148109
with:
149110
# unpacks all CIBW artifacts into dist/
150111
pattern: cibw-*

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
3232
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
3333

3434
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
35+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
3536

3637
# Find all the Python libraries
3738
set(THREADS_PREFER_PTHREAD_FLAG ON)
@@ -163,6 +164,7 @@ endif()
163164
add_custom_target(tarball
164165
COMMAND rm -rf ${CMAKE_BINARY_DIR}/tarball ${CMAKE_BINARY_DIR}/spt3g.tgz
165166
COMMAND mkdir ${CMAKE_BINARY_DIR}/tarball
167+
COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_BINARY_DIR}
166168
COMMAND ${CMAKE_SOURCE_DIR}/cmake/copy_build_dir.sh ${CMAKE_BINARY_DIR}
167169
COMMAND ${Python_EXECUTABLE} -m compileall -fq ${CMAKE_BINARY_DIR}/tarball
168170
COMMAND tar -C ${CMAKE_BINARY_DIR}/tarball/ -czf ${CMAKE_BINARY_DIR}/spt3g.tgz .

README.rst

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,16 @@ If your system defaults to Python 2, but you wish to use Python 3, please do the
5252

5353
On any system, this software requires numpy and scipy (hard requirements), plus astropy and healpy (optional).
5454

55-
Setup on RHEL6
56-
--------------
55+
Setup on RHEL Systems with OASIS
56+
--------------------------------
5757

58-
Note that on any RHEL6 system, you will need a newer compiler than ships with the OS. Please follow whatever directions apply at your site to achieve this. Alternately, if you have OASIS set up on your local system, run this before anything else (also works on several other operating systems, including RHEL7):
58+
If using RHEL8 or RHEL9 and you have OASIS set up on your local system, run this before anything else:
5959

6060
.. code-block:: shell
6161
62-
eval `/cvmfs/spt.opensciencegrid.org/py3-v4/setup.sh`
62+
eval `/cvmfs/spt.opensciencegrid.org/py3-v5/setup.sh`
63+
64+
This will add a relatively new compiler and all necessary development packages (FLAC, GSL, etc) for compiling this software.
6365

6466

6567
How to Build
@@ -91,6 +93,16 @@ Alternatively, for users that only use a single build environment, set the follo
9193
export LD_LIBRARY_PATH=$SPT3G_SOFTWARE_BUILD_PATH/lib:$LD_LIBRARY_PATH
9294
export PATH=$SPT3G_SOFTWARE_BUILD_PATH/bin:$PATH
9395
96+
Building the Documentation
97+
~~~~~~~~~~~~~~~~~~~~~~~~~~
98+
99+
You may find that you are missing some of the required packages for building the documentation. To fix this, run the following commands:
100+
101+
.. code-block:: shell
102+
103+
cd spt3g_software
104+
pip install -r doc/requirements.txt
105+
94106
To build the documentation in the build directory type:
95107

96108
.. code-block:: shell

calibration/python/bolopropertiesutils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def to_value(self, string):
9494
def extract_string(self, string, include_units=True):
9595
"""Return the band substring from the input string, or None if not
9696
found."""
97-
m = self._regex.match(string)
97+
m = self._regex.search(string)
9898
if not m:
9999
return None
100100
if not include_units:
@@ -104,10 +104,10 @@ def extract_string(self, string, include_units=True):
104104
def extract_value(self, value):
105105
"""Return the band in G3Units extracted from the input string, or None
106106
if not found."""
107-
s = extract_string(value, include_units=False)
107+
s = self.extract_string(value, include_units=False)
108108
if not s:
109109
return None
110-
return float(v) * self._uvalue
110+
return float(s) * self._uvalue
111111

112112

113113
# global instance used by functions below

core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ add_spt3g_test(pipeline_module)
116116
add_spt3g_test(multiproc)
117117
add_spt3g_test(frames)
118118
add_spt3g_test(frame_types)
119+
add_spt3g_test(frameobjects)
119120
add_spt3g_test(datatypes)
120121
if(FLAC_FOUND)
121122
add_spt3g_test(ts_nanencoding)
@@ -145,6 +146,7 @@ add_spt3g_test(timestrings)
145146
add_spt3g_test(testcomplexconv)
146147
add_spt3g_test(droporphanmetadata)
147148
add_spt3g_test(networktest SLOWTEST)
149+
add_spt3g_test(non_contiguous_vectors)
148150
add_spt3g_test(non_double_timestreams)
149151
add_spt3g_test(endprocessing)
150152
add_spt3g_test(lazyreader)

core/include/core/G3Map.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ G3MAP_OF(std::string, std::vector<bool>, G3MapVectorBool);
7373
G3MAP_OF(std::string, std::vector<std::string>, G3MapVectorString);
7474
G3MAP_OF(std::string, G3VectorVectorString, G3MapVectorVectorString);
7575
G3MAP_OF(std::string, std::vector<std::complex<double> >, G3MapVectorComplexDouble);
76+
G3MAP_OF(std::string, G3Time, G3MapTime);
7677
G3MAP_OF(std::string, G3VectorTime, G3MapVectorTime);
7778
G3MAP_OF(std::string, std::string, G3MapString);
7879

core/include/core/G3Timestream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ class G3TimestreamMap : public G3FrameObject,
271271
ts->start = start;
272272
ts->stop = stop;
273273
ts->units = units;
274-
ts->use_flac_ = compression_level;
275-
ts->flac_depth_ = bit_depth;
274+
ts->SetFLACCompression(compression_level);
275+
ts->SetFLACBitDepth(bit_depth);
276276
ts->root_data_ref_ = data;
277277
ts->data_ = data.get() + offset;
278278
ts->data_type_ = data_type;

core/include/core/container_pybindings.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ register_g3vector(py::module_ &scope, std::string name, Args &&...args)
163163

164164
cls.def(g3frameobject_picklesuite<V>());
165165

166+
cls.def("__str__", &V::Summary)
167+
.def("Summary", &V::Summary, "Short (one-line) description of the object")
168+
.def("Description", &V::Description,
169+
"Long-form human-readable description of the object");
170+
166171
return cls;
167172
}
168173

@@ -390,6 +395,11 @@ register_g3map(py::module_ &scope, std::string name, Args &&...args)
390395

391396
cls.def(g3frameobject_picklesuite<M>());
392397

398+
cls.def("__str__", &M::Summary)
399+
.def("Summary", &M::Summary, "Short (one-line) description of the object")
400+
.def("Description", &M::Description,
401+
"Long-form human-readable description of the object");
402+
393403
return cls;
394404
}
395405

core/include/core/serialization.h

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,21 @@ class G3Pickler
118118
{
119119
public:
120120
template <class T> static
121-
auto getstate(const py::object &self) {
121+
auto dumpstate(const T &obj) {
122122
std::vector<char> buffer;
123123
G3BufferOutputStream os(buffer);
124124
{
125125
cereal::PortableBinaryOutputArchive ar(os);
126-
ar << self.cast<const T &>();
126+
ar << obj;
127127
}
128128
os.flush();
129129

130-
py::bytes data(buffer.data(), buffer.size());
130+
return py::bytes(buffer.data(), buffer.size());
131+
}
132+
133+
template <class T> static
134+
auto getstate(const py::object &self) {
135+
py::bytes data = dumpstate<T>(self.cast<const T &>());
131136

132137
py::dict py_state;
133138
if (py::hasattr(self, "__dict__"))
@@ -136,27 +141,40 @@ class G3Pickler
136141
return py::make_tuple(py_state, data);
137142
}
138143

144+
template <class T> static
145+
auto loadstate(T &obj, const std::string_view &buffer) {
146+
G3BufferInputStream fis((char *)&buffer[0], buffer.size());
147+
cereal::PortableBinaryInputArchive ar(fis);
148+
149+
ar >> obj;
150+
}
151+
139152
template <class T> static
140153
auto setstate(const py::tuple &state) {
141154
auto py_state = state[0].cast<py::dict>();
142-
143155
auto buffer = state[1].cast<std::string_view>();
144-
G3BufferInputStream fis((char *)&buffer[0], buffer.size());
145-
cereal::PortableBinaryInputArchive ar(fis);
146156

147157
T obj;
148-
ar >> obj;
158+
loadstate<T>(obj, buffer);
149159

150160
return std::make_pair(std::move(obj), py_state);
151161
}
152162
};
153163

154164
// Call this function in a class .def method to enable pickling
155165
template <class T>
156-
auto
157-
g3frameobject_picklesuite()
166+
struct g3frameobject_picklesuite
158167
{
159-
return py::pickle(&G3Pickler::getstate<T>, &G3Pickler::setstate<T>);
168+
static constexpr bool op_enable_if_hook = true;
169+
170+
template <typename Class>
171+
void execute(Class &cl) const {
172+
cl.def(py::pickle(&G3Pickler::getstate<T>, &G3Pickler::setstate<T>));
173+
cl.def("_cereal_loads", &G3Pickler::loadstate<T>,
174+
"Populate this instance from a serialized data buffer");
175+
cl.def("_cereal_dumps", &G3Pickler::dumpstate<T>,
176+
"Save the state of this instance to a serialized data buffer");
177+
}
160178
};
161179

162180
// Register a G3FrameObject-derived class. Includes a copy constructor,

0 commit comments

Comments
 (0)