Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/ci_run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: test

on:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
# name: test (Python ${{ matrix.python-version }}, ${{ matrix.os }})
name: test (env file ${{ matrix.environment-files }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ "ubuntu-latest"]
# python-version: [ "3.10" , "3.11" ]
environment-files: ["environment-3.9.yml", "environment-3.9-pinned.yml", "environment-3.10.yml", "environment-3.11.yml", "environment-3.10-pinned.yml", "environment-3.10-astropy.yml"]
fail-fast: false
env:
PYTHONUNBUFFERED: 1
defaults:
run:
shell: micromamba-shell {0}
steps:
- uses: actions/checkout@v4

- uses: mamba-org/setup-micromamba@v1
with:
# environment-name: pystrometry-${{ runner.os }}-py${{ matrix.python-version }}
environment-name: pystrometry-${{ runner.os }}-${{ matrix.environment-files }}
environment-file: ${{ matrix.environment-files }}
# create-args: >-
# python=${{ matrix.python-version }}
init-shell: none
generate-run-shell: true

# - run: pip install -e .[test] pytest-xdist

- run: pip list
- run: pip install pytest

- run: micromamba env export

# - run: python -c "import pystrometry; print('Version ' + pystrometry.__version__); print('Path ' + pystrometry.__path__[0])"

- run: pytest --durations=0 -vs -o log_cli=true --log-level=INFO pystrometry/tests
- run: pytest --durations=0 -vs -o log_cli=true --log-level=INFO pystrometry/utils/tests
94 changes: 0 additions & 94 deletions .github/workflows/python-package-conda.yml

This file was deleted.

18 changes: 18 additions & 0 deletions environment-3.10-astropy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: pystrometry-environment-3p10-astropy
channels:
- conda-forge
dependencies:
- python == 3.10
- numpy
- pip
- kepmodel
- pandas
- pyarrow
- matplotlib
- astroquery
- astropy == 6.0
- sympy
- scipy
- uncertainties
- pip:
- linearfit
5 changes: 5 additions & 0 deletions pystrometry/pystrometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4857,6 +4857,11 @@ def get_ephemeris(center='g@399', target='0', start_time=None, stop_time=None, s
with open(out_file, 'wb') as ephemeris:
ephemeris.write(content)

logging.info(f"Reading {horizons_file_seed} from {ephemeris_dir}")
files = os.listdir(ephemeris_dir)
for file in files:
logging.info(f"File in ephemeris_dir: {file}")

xyzdata = read_ephemeris(horizons_file_seed, overwrite=overwrite, ephemeris_path=ephemeris_dir)
return xyzdata

Expand Down
33 changes: 33 additions & 0 deletions pystrometry/tests/test_get_ephemeris.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import logging
import os

from astropy.table import Table
from astropy.time import Time

from ..pystrometry import get_ephemeris
from ..pystrometry import ephemeris_dir

logging.basicConfig(level=logging.INFO)

def test_get_ephemeris_valid_input():
# Define valid test inputs
center = 'g@399'
target = '0'
start_time = Time('2023-01-01T00:00:00')
stop_time = Time('2024-01-10T00:00:00')
step_size = '1d'

logging.info(f"\nephemeris_dir={ephemeris_dir}\n")
horizons_file_seed = '{}_{}_{}_{}_{}'.format(center, target, start_time, stop_time, step_size)
out_file = os.path.join(ephemeris_dir, horizons_file_seed + '.txt')

# Call the function
result = get_ephemeris(center=center, target=target, start_time=start_time, stop_time=stop_time, step_size=step_size)
assert os.path.isfile(out_file), f"Expected output file {out_file} does not exist."

# Validate the result
assert isinstance(result, Table), "Result should be an Astropy Table"
assert len(result) > 0, "Result table should not be empty"
assert 'X' in result.colnames, "Result table should contain 'X' column"
assert 'Y' in result.colnames, "Result table should contain 'Y' column"
assert 'Z' in result.colnames, "Result table should contain 'Z' column"