Skip to content

Commit

Permalink
Add get_include_path
Browse files Browse the repository at this point in the history
While we could make users use importlib.resources.files manually,
it is annoying, so provide a helper routine (this is based on
the logic we use in Sherpa).
  • Loading branch information
DougBurke committed Oct 8, 2024
1 parent d4fa0d2 commit 75f9185
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ from the refactoring done in 0.0.30, and move the include directory
into xspec_models_cxc/ so it is more-obvious why is is installed
(although it probably should be done more as some form of a data-file).

The module has gained the get_include_path() routine to provide access
to the include file, which will hopefully be needed to support access
to XSPEC user models (I have got this working for Sherpa so we should
be able to do something similar here).

## 0.0.30

Potential build improvements, including support for using the CXC
Expand Down
12 changes: 11 additions & 1 deletion template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
The XSPEC model library is automatically initialized when the first
call is made, and not when the module is loaded.
There are three types of symbols in this package:
There are four types of symbols in this package:
1. model functions, such as `apec` and `TBabs`, and `tableModel` for
table models.
2. routines that set or get values such as the abundance
table (`abundance`), cross-section table (`cross_sections`),
cosmology (`cosmology`), and the chatter level (`chatter`).
3. routines about the models: `info` and `list_models`.
4. routines about the API: `get_include_path`.
Examples
--------
Expand Down Expand Up @@ -131,7 +132,9 @@

from dataclasses import dataclass
from enum import Enum, auto
from importlib import resources
import logging
from pathlib import Path
from typing import List, Optional, Sequence

try:
Expand Down Expand Up @@ -324,3 +327,10 @@ def list_models(modeltype: Optional[ModelType] = None,
out.add(k)

return sorted(out)


def get_include_path() -> Path:
"""Return the location of the C++ include file."""

path = resources.files("xspec_models_cxc.include")
return path / "xspec_models_cxc.hh"

0 comments on commit 75f9185

Please sign in to comment.