Skip to content

Commit

Permalink
Fix merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vhaasteren committed Apr 21, 2024
2 parents 87813ee + daede07 commit 61ba269
Show file tree
Hide file tree
Showing 17 changed files with 563 additions and 128 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: enterprise CI targets

on:
push:
branches: [ master ]
branches: [ master, dev ]
pull_request:
branches: [ master ]
branches: [ master, dev ]
release:
types:
- published
Expand All @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- name: Checkout repository
Expand All @@ -38,6 +38,9 @@ jobs:
sudo apt-get install libsuitesparse-dev
curl -sSL https://raw.githubusercontent.com/vallis/libstempo/master/install_tempo2.sh | sh
- name: Install dependencies and package
env:
SUITESPARSE_INCLUDE_DIR: "/usr/local/opt/suite-sparse/include/suitesparse/"
SUITESPARSE_LIBRARY_DIR: "/usr/local/opt/suite-sparse/lib"
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements_dev.txt
Expand Down Expand Up @@ -69,7 +72,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
python-version: "3.8"
- name: Install non-python dependencies on linux
run: |
sudo apt-get install libsuitesparse-dev
Expand Down Expand Up @@ -115,7 +118,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -130,4 +133,4 @@ jobs:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
twine upload dist/*
55 changes: 44 additions & 11 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,38 @@ If you are proposing a feature:
Get Started!
------------

Ready to contribute? Here's how to set up `enterprise` for local development.
Ready to contribute? Here's how to set up ``enterprise`` for local development.

1. Fork the `enterprise` repo on GitHub.
Install the dependencies
~~~~~~~~~~~~~~~~~~~~~~~~

``enterprise`` relies on a lot of other software to function.
If you use the Anaconda distribution of Python, you can get all of this software using ``conda``.
First, you install the latest stable version of ``enterprise``, which will come with all of the dependencies.
Then you remove ``enterprise`` leaving everything else intact.
This way you can use your development version of ``enterprise`` instead of the stable version.
We will also need some additional software that is required to run the tests.

Start with a virtual environment with the extra dependencies required for running tests. In this case it is called ``ent_dev``::

$ conda create -n ent_dev -y -c conda-forge python=3.9 black=22.3.0 flake8 sphinx_rtd_theme pytest-cov
$ conda activate ent_dev

Now install everything else by running the commands::

$ conda install -c conda-forge enterprise-pulsar
$ conda remove enterprise-pulsar --force
$ pip install coverage-conditional-plugin


Get the enterprise source code and get to work!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1. Fork the ``enterprise`` repo on GitHub.
2. Clone your fork locally::

$ git clone git@github.com:your_name_here/enterprise.git
$ cd enterprise/
3. Set `enterprise/master` as upstream remote::
Expand All @@ -73,17 +99,25 @@ Ready to contribute? Here's how to set up `enterprise` for local development.
$ git pull upstream master

4. This is how you set up your fork for local development:

.. note::
You will need to have ``tempo`` and ``suitesparse`` installed before
running the commands below.
You will need to have ``tempo2`` and ``suitesparse`` installed before
running these commands.

::
If you installed the dependencies via conda, you are good to go!

$ cd enterprise/
If you set up a ``conda`` virtual environment with the dependencies already,
you can add your local fork of ``enterprise`` to it by running::

$ pip install -e .

If you manually installed the dependencies, this will make and activate a
Python3 virtual env with your local fork of ``enterprise``::
$ make init
$ source .enterprise/bin/activate


5. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature
Expand All @@ -93,7 +127,6 @@ Ready to contribute? Here's how to set up `enterprise` for local development.
6. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox (tox not implemented yet). Also check that any new docs are formatted correctly::

$ make test
$ make lint
$ make docs

To get flake8 and tox, just pip install them into your virtualenv.
Expand All @@ -114,9 +147,8 @@ Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring.
3. The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check
https://travis-ci.org/nanograv/enterprise/pull_requests
and make sure that the tests pass for all supported Python versions.
3. The pull request should work for all supported versions of Python: 3.8, 3.9, 3.10, and 3.11. You
can see the progress of the tests in the `Checks` tab of your GitHub pull request.

Tips
----
Expand All @@ -130,3 +162,4 @@ To track and checkout another user's branch::
$ git remote add other-user-username https://github.com/other-user-username/enterprise.git
$ git fetch other-user-username
$ git checkout --track -b branch-name other-user-username/branch-name

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Build Status](https://github.com/nanograv/enterprise/workflows/CI-Tests/badge.svg)](https://github.com/nanograv/enterprise/actions)
[![Documentation Status](https://readthedocs.org/projects/enterprise/badge/?version=latest)](https://enterprise.readthedocs.io/en/latest/?badge=latest)
[![Test Coverage](https://codecov.io/gh/nanograv/enterprise/branch/master/graph/badge.svg?token=YXSX3293VF)](https://codecov.io/gh/nanograv/enterprise)
![Python Versions](https://img.shields.io/badge/python-3.7%2C%203.8%2C%203.9%2C%203.10-blue.svg)
![Python Versions](https://img.shields.io/badge/python-3.8%2C%203.9%2C%203.10%2C%203.11-blue.svg)

[![Zenodo DOI 4059815](https://zenodo.org/badge/DOI/10.5281/zenodo.4059815.svg)](https://doi.org/10.5281/zenodo.4059815)

Expand All @@ -14,7 +14,7 @@ Inference SuitE) is a pulsar timing analysis code, aimed at noise
analysis, gravitational-wave searches, and timing model analysis.

- Note: `enterprise>=3.0` does not support Python2.7. You must use
Python \>= 3.7.
Python \>= 3.8.
- Free software: MIT license
- Documentation: <https://enterprise.readthedocs.io>.

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Welcome to enterprise's documentation!
.. image:: https://codecov.io/gh/nanograv/enterprise/branch/master/graph/badge.svg?token=YXSX3293VF
:target: https://codecov.io/gh/nanograv/enterprise
:alt: Test Coverage
.. image:: https://img.shields.io/badge/python-3.6%2C%203.7%2C%203.8-blue.svg
.. image:: https://img.shields.io/badge/python-3.8%2C%203.9%2C%203.10%2C%203.11-blue.svg
:alt: Python Versions

.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.4059815.svg
Expand Down
19 changes: 19 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ Installation
.. .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
Using conda
-----------

``enterprise`` is available via conda-forge as `enterprise-pulsar <https://anaconda.org/conda-forge/enterprise-pulsar>`_.
If you use the Anaconda distribution of Python, we strongly recommend installing via the ``conda`` command:

.. code-block:: console
$ conda install -c conda-forge enterprise-pulsar
From sources
------------

Expand Down Expand Up @@ -57,3 +68,11 @@ If you want to run tests or do any other development then also run:
.. _Github repo: https://github.com/nanograv/enterprise
.. _tarball: https://github.com/nanograv/enterprise/tarball/master


Tips
----

If you have a computer with an Apple Silicon chip, see `these instructions`_ on how to install Apple Intel packages using Rosetta.

.. _these instructions: https://conda-forge.org/docs/user/tipsandtricks.html#installing-apple-intel-packages-on-apple-silicon
22 changes: 18 additions & 4 deletions enterprise/pulsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
import pickle
from io import StringIO

import astropy.constants as const
import astropy.units as u
import numpy as np
from ephem import Ecliptic, Equatorial
from astropy.time import Time

import enterprise
from enterprise.signals import utils
Expand All @@ -36,6 +35,13 @@
logger.warning("PINT not installed. Will use libstempo instead.") # pragma: no cover
pint = None

try:
import astropy.constants as const
import astropy.units as u
except ImportError: # pragma: no cover
const = None
u = None

if pint is None and t2 is None:
err_msg = "Must have either PINT or libstempo timing package installed"
raise ImportError(err_msg)
Expand Down Expand Up @@ -110,7 +116,11 @@ def _get_radec_from_ecliptic(self, elong, elat):

def _get_pos(self):
return np.array(
[np.cos(self._raj) * np.cos(self._decj), np.sin(self._raj) * np.cos(self._decj), np.sin(self._decj)]
[
np.cos(self._raj) * np.cos(self._decj),
np.sin(self._raj) * np.cos(self._decj),
np.sin(self._decj),
]
)

def sort_data(self):
Expand Down Expand Up @@ -368,7 +378,11 @@ def __init__(self, toas, model, sort=True, drop_pintpsr=True, planets=True):
"AstrometryEquatorial" if "AstrometryEquatorial" in model.components else "AstrometryEcliptic"
)

self._pos_t = model.components[which_astrometry].ssb_to_psb_xyz_ICRS(model.get_barycentric_toas(toas)).value
self._pos_t = (
model.components[which_astrometry]
.ssb_to_psb_xyz_ICRS(Time(model.get_barycentric_toas(toas), format="mjd"))
.value
)

self.sort_data()

Expand Down
Loading

0 comments on commit 61ba269

Please sign in to comment.