Skip to content

Commit

Permalink
Switch from class to package based installation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmert committed Mar 18, 2021
1 parent cad194a commit af7db38
Show file tree
Hide file tree
Showing 25 changed files with 27 additions and 84 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.9.0)
cmake_policy(SET CMP0017 NEW) # https://cmake.org/cmake/help/v3.11/policy/CMP0017.html

project(healmex CXX)
option(ASCLASS "install healmex as a Matlab class" ON)
option(ASPACKAGE "install healmex as a Matlab package" ON)
option(USE_SYSTEM_HEALPIX "use OS healpix library (if present)" ON)

# Include environment's paths library searches
Expand Down Expand Up @@ -114,28 +114,28 @@ if ((NOT LIBSHARP_FOUND) OR (NOT HEALPIX_CXX_FOUND))
add_dependencies(healmex libsharp healpix)
endif()

if (ASCLASS)
if (ASPACKAGE)
set(PKGBASE "")
set(CLASSPREFIX "healmex.")
set(PACKAGEPREFIX "healmex.")
else()
set(PKGBASE "@healmex/")
set(CLASSPREFIX "")
set(PKGBASE "+healmex/")
set(PACKAGEPREFIX "")
endif()

file(GLOB MFILES "${CMAKE_SOURCE_DIR}/matlab/@healmex/*.m")
file(GLOB INFILES "${CMAKE_SOURCE_DIR}/matlab/@healmex/*.m.in")
file(GLOB MFILES "${CMAKE_SOURCE_DIR}/matlab/+healmex/*.m")
file(GLOB INFILES "${CMAKE_SOURCE_DIR}/matlab/+healmex/*.m.in")

# Copy Matlab scripts into the build directory.
foreach(INFILE ${INFILES})
get_filename_component(FILENAME ${INFILE} NAME_WE)
set(FILENAME "${CMAKE_BINARY_DIR}/matlab/@healmex/${FILENAME}.m")
set(FILENAME "${CMAKE_BINARY_DIR}/matlab/+healmex/${FILENAME}.m")
message(STATUS "Configuring: ${FILENAME}")
configure_file(${INFILE} ${FILENAME} @ONLY)
endforeach()
if (NOT (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}))
foreach(MFILE ${MFILES})
get_filename_component(FILENAME ${MFILE} NAME)
set(FILENAME "${CMAKE_BINARY_DIR}/matlab/@healmex/${FILENAME}")
set(FILENAME "${CMAKE_BINARY_DIR}/matlab/+healmex/${FILENAME}")
message(STATUS "Staging: ${FILENAME}")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MFILE} ${FILENAME})
Expand All @@ -146,7 +146,7 @@ endif()
install(DIRECTORY ${CMAKE_BINARY_DIR}/matlab/
DESTINATION ${CMAKE_INSTALL_PREFIX}
FILES_MATCHING
PATTERN "@healmex" EXCLUDE
PATTERN "+healmex" EXCLUDE
PATTERN "*.mex*"
)
install(DIRECTORY ${CMAKE_BINARY_DIR}/matlab/${PKGBASE}
Expand Down
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,24 @@ The following are available options which can be set during configuration.
Each should be set in either the interact `ccmake` prompt or via a CMake
variable definition with `cmake -DVAR=VALUE`.

* **`ASCLASS`**: Defaults to `ON`. If `ON`, the package is installed as a
Matlab class. Otherwise if `OFF`, the package is installed as a classless
* **`ASPACKAGE`**: Defaults to `ON`. If `ON`, the package is installed as a
Matlab package. Otherwise if `OFF`, the package is installed as a flat
set of functions.

## Usage

If installed as a Matlab class, the bindings in Matlab are presented as static
methods of the `healmex` class. A list of all methods can be obtained with
`disp(healmex)`:
```matlab
>> disp(healmex)
healmex with methods:
...
```
If installed as a Matlab package, the bindings in Matlab are presented as
methods within the `healmex` package namespace.

Help is available for each binding
```matlab
>> help healmex.pix2ang
[theta,phi] = pix2ang(nside, ipix)
[theta, phi] = pix2ang(nside, ipix, varargin)
Calculates HEALPix pixel center locations for pixel indices ipix in an
Nside = nside map, returning the colatitude theta and azimuth phi spherical
locations.
INPUTS
nside The HEALPix Nside parameter.
ipix Pixel indices.
...
```
with descriptions of the calling convention for each binding. For example,
a call to `pix2ang` to convert pixel 72 in an Nside = 4 map to θ and φ
Expand All @@ -98,7 +94,7 @@ ph =
0.7854
```
If installed in the classless form, the `healmex.` prefix from calls should
If installed in the flat form, the `healmex.` prefix from calls should
be removed.

[healpix]: https://healpix.sourceforge.io/index.php
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function cl = alm2cl(alms1, alms2, varargin)
parse(p, varargin{:});
opt = p.Results;

[lmax, mmax] = @CLASSPREFIX@alm_getlmmax(alms, opt.lmax, opt.mmax);
[lmax, mmax] = @PACKAGEPREFIX@alm_getlmmax(alms, opt.lmax, opt.mmax);
if ~exist('alms2', 'var') || isempty(alms2)
alms2 = alms1;
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function maps = alm2map(alms, nside, varargin)
parse(p, varargin{:});
opt = p.Results;

[lmax, mmax] = @CLASSPREFIX@alm_getlmmax(alms, opt.lmax, opt.mmax);
[lmax, mmax] = @PACKAGEPREFIX@alm_getlmmax(alms, opt.lmax, opt.mmax);

if size(alms, 2) == 1
% T-only alms - pass through empty/dummy complex alms as almsG & almsC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function maps = alm2map_der1(alms, nside, varargin)
parse(p, varargin{:});
opt = p.Results;

[lmax, mmax] = @CLASSPREFIX@alm_getlmmax(alms, opt.lmax, opt.mmax);
[lmax, mmax] = @PACKAGEPREFIX@alm_getlmmax(alms, opt.lmax, opt.mmax);

if size(alms, 2) ~= 1
error('alm2map_der1: Expected alms to have size 1 in second dimension, got %d', ...
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function alms = almxfl(alms, fl, varargin)
parse(p, varargin{:});
opt = p.Results;

[lmax, mmax] = @CLASSPREFIX@alm_getlmmax(alms, opt.lmax, opt.mmax);
[lmax, mmax] = @PACKAGEPREFIX@alm_getlmmax(alms, opt.lmax, opt.mmax);

alms = complex(double(alms));
for ii = 1:size(alms,2)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function alms = map2alm(maps, varargin)
lmax = opt.lmax;
mmax = opt.mmax;
iter = opt.iter;
nside = @CLASSPREFIX@npix2nside(size(maps, 1));
nside = @PACKAGEPREFIX@npix2nside(size(maps, 1));

if isempty(lmax)
lmax = 3 * nside - 1;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function alms = rotate_alm(alms, rotate, varargin)
parse(p, varargin{:});
opt = p.Results;

[lmax, mmax] = @CLASSPREFIX@alm_getlmmax(alms, opt.lmax, opt.mmax);
[lmax, mmax] = @PACKAGEPREFIX@alm_getlmmax(alms, opt.lmax, opt.mmax);

if size(alms, 2) == 1
% T-only alms - pass through empty/dummy complex alms as almsG & almsC
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 0 additions & 53 deletions matlab/@healmex/healmex.m

This file was deleted.

0 comments on commit af7db38

Please sign in to comment.