Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
87 changes: 48 additions & 39 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
name: tests
name: pymangle CI

on:
push:
branches:
- master
pull_request: null
push:
branches:
- master
pull_request:
branches:
- master
- releases/*

jobs:
tests:
name: tests
strategy:
matrix:
pyver: [3.6, 3.7, 3.8]

runs-on: 'ubuntu-latest'

steps:
- uses: actions/checkout@v2

- uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.pyver }}
channels: conda-forge,defaults
channel-priority: strict
show-channel-urls: true

- name: configure conda and install code
shell: bash -l {0}
run: |
conda config --set always_yes yes
conda install --quiet setuptools flake8

python -m pip install -e .

- name: lint
shell: bash -l {0}
run: |
flake8 pymangle
- name: test
shell: bash -l {0}
run: |
python -c 'import pymangle; pymangle.test.test()'
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
py: [ "3.11" ]
CC: [ gcc ]
CXX: [ g++ ]

defaults:
run:
# cf. https://github.com/conda-incubator/setup-miniconda#important
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.pyver }}
channels: conda-forge,defaults
channel-priority: strict
show-channel-urls: true
miniforge-version: latest

- name: Install deps
run: |
conda config --set always_yes yes
conda install numpy pytest flake8

- name: Install pymangle
run:
pip install .

- name: lint
run: |
flake8 pymangle

- name: Run tests
run: |
pytest -vv tests/
1 change: 0 additions & 1 deletion pymangle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
from . import mangle
from .mangle import Mangle, genrand_cap
from .version import __version__
from . import test

__doc__ = mangle.__doc__
34 changes: 17 additions & 17 deletions pymangle/mangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from __future__ import print_function, absolute_import

from numpy import array
from numpy import array, longdouble
from . import _mangle


Expand Down Expand Up @@ -91,8 +91,8 @@ def polyid_and_weight(self, ra, dec):
------
polyd,weight tuple of arrays
"""
ra = array(ra, ndmin=1, dtype='f16', copy=False, order='C')
dec = array(dec, ndmin=1, dtype='f16', copy=False, order='C')
ra = array(ra, ndmin=1, dtype=longdouble, copy=False, order='C')
dec = array(dec, ndmin=1, dtype=longdouble, copy=False, order='C')
return super(Mangle, self).polyid_and_weight(ra, dec)

def polyid(self, ra, dec):
Expand All @@ -110,8 +110,8 @@ def polyid(self, ra, dec):
------
Array of poly ids
"""
ra = array(ra, ndmin=1, dtype='f16', copy=False, order='C')
dec = array(dec, ndmin=1, dtype='f16', copy=False, order='C')
ra = array(ra, ndmin=1, dtype=longdouble, copy=False, order='C')
dec = array(dec, ndmin=1, dtype=longdouble, copy=False, order='C')
return super(Mangle, self).polyid(ra, dec)

def weight(self, ra, dec):
Expand All @@ -129,8 +129,8 @@ def weight(self, ra, dec):
------
Array of weights
"""
ra = array(ra, ndmin=1, dtype='f16', copy=False, order='C')
dec = array(dec, ndmin=1, dtype='f16', copy=False, order='C')
ra = array(ra, ndmin=1, dtype=longdouble, copy=False, order='C')
dec = array(dec, ndmin=1, dtype=longdouble, copy=False, order='C')
return super(Mangle, self).weight(ra, dec)

def contains(self, ra, dec):
Expand All @@ -149,8 +149,8 @@ def contains(self, ra, dec):
Array of zeros or ones
"""
# we specify order to force contiguous
ra = array(ra, ndmin=1, dtype='f16', copy=False, order='C')
dec = array(dec, ndmin=1, dtype='f16', copy=False, order='C')
ra = array(ra, ndmin=1, dtype=longdouble, copy=False, order='C')
dec = array(dec, ndmin=1, dtype=longdouble, copy=False, order='C')
return super(Mangle, self).contains(ra, dec)

def check_quadrants(self,
Expand Down Expand Up @@ -194,10 +194,10 @@ def check_quadrants(self,
2**4 is set if fourth quadrant is OK
"""
# we specify order to force contiguous
ra = array(ra, ndmin=1, dtype='f16', copy=False, order='C')
dec = array(dec, ndmin=1, dtype='f16', copy=False, order='C')
ra = array(ra, ndmin=1, dtype=longdouble, copy=False, order='C')
dec = array(dec, ndmin=1, dtype=longdouble, copy=False, order='C')
angle_degrees = array(
angle_degrees, ndmin=1, dtype='f16', copy=False, order='C'
angle_degrees, ndmin=1, dtype=longdouble, copy=False, order='C'
)
return super(Mangle, self).check_quadrants(
ra, dec, angle_degrees,
Expand All @@ -219,8 +219,8 @@ def calc_simplepix(self, ra, dec):
------
Array of zeros or ones
"""
ra = array(ra, ndmin=1, dtype='f16', copy=False)
dec = array(dec, ndmin=1, dtype='f16', copy=False)
ra = array(ra, ndmin=1, dtype=longdouble, copy=False)
dec = array(dec, ndmin=1, dtype=longdouble, copy=False)
return super(Mangle, self).calc_simplepix(ra, dec)

def _set_weights(self, weights):
Expand All @@ -232,7 +232,7 @@ def _set_weights(self, weights):
)

# make long doubles
weights = array(weights, ndmin=1, dtype='f16', copy=False)
weights = array(weights, ndmin=1, dtype=longdouble, copy=False)

super(Mangle, self).set_weights(weights)

Expand Down Expand Up @@ -299,7 +299,7 @@ def set(self, data):
data: array or sequence
An length 4 array of 128 bit floats, or convertable to that.
"""
data = array(data, ndmin=1, dtype='f16', copy=False)
data = array(data, ndmin=1, dtype=longdouble, copy=False)
if data.size != 4:
raise ValueError(
"capdata must be an array of length 4, got %d" % data.size
Expand Down Expand Up @@ -414,7 +414,7 @@ def __init__(self, poly_id, pixel_id, weight, cap_vec):
raise ValueError("cap_vec must be of "
"type CapVec, got %s" % type(cap_vec))

wtarr = array(weight, ndmin=1, dtype='f16', copy=False)
wtarr = array(weight, ndmin=1, dtype=longdouble, copy=False)

super(Polygon, self).__init__(
poly_id,
Expand Down
2 changes: 1 addition & 1 deletion pymangle/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason
# 3) we can import it into the module
__version__ = '0.9.2'
__version__ = '0.9.3'
12 changes: 8 additions & 4 deletions register.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import os

rname='README.md'
rstname='README.rst'
rname = 'README.md'
rstname = 'README.rst'


def clear():
if os.path.exists(rstname):
os.remove(rstname)


def try_make_rst():
cmd="pandoc --from=markdown --to=rst {readme} -o {rst}"
cmd=cmd.format(readme=rname, rst=rstname)
cmd = "pandoc --from=markdown --to=rst {readme} -o {rst}"
cmd = cmd.format(readme=rname, rst=rstname)
os.system(cmd)


def register():
os.system("python setup.py register")


clear()

try_make_rst()
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def finalize_options(self):
self.include_dirs.extend(glob.glob("pymangle/*h"))


__version__ = None
exec(open('pymangle/version.py').read())

description = "A python code to read and work with Mangle masks."
Expand Down
9 changes: 0 additions & 9 deletions tests/test_import.py

This file was deleted.

Loading
Loading