Skip to content

Commit

Permalink
Fix some C compiler errors. PEP8. imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed Oct 23, 2024
1 parent c45849a commit f78639f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 25 deletions.
2 changes: 2 additions & 0 deletions drizzle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""
from importlib.metadata import PackageNotFoundError, version

from drizzle import cdrizzle, resample, utils # noqa: F401

try:
__version__ = version(__name__)
except PackageNotFoundError:
Expand Down
4 changes: 3 additions & 1 deletion drizzle/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"""
import numpy as np

from . import cdrizzle
from drizzle import cdrizzle

__all__ = ["blot_image", "Drizzle"]

SUPPORTED_DRIZZLE_KERNELS = [
"square",
Expand Down
1 change: 0 additions & 1 deletion drizzle/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import warnings

Check warning on line 4 in drizzle/util.py

View check run for this annotation

Codecov / codecov/patch

drizzle/util.py#L4

Added line #L4 was not covered by tests


warnings.warn(

Check warning on line 6 in drizzle/util.py

View check run for this annotation

Codecov / codecov/patch

drizzle/util.py#L6

Added line #L6 was not covered by tests
"Module 'drizzle.util' has been deprecated since version 2.0.0 "
"and it will be removed in a future release. "
Expand Down
17 changes: 9 additions & 8 deletions src/cdrizzleapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ invert_pixmap_wrap(PyObject *self, PyObject *args)
struct driz_param_t par;
double *xy, *xyin;
npy_intp *ndim, xyin_dim = 2;
const double half = 0.5 - DBL_EPSILON;

xyin = (double *) malloc(2 * sizeof(double));

Expand All @@ -502,19 +503,19 @@ invert_pixmap_wrap(PyObject *self, PyObject *args)
ndim = PyArray_DIMS(pixmap_arr);

if (bbox == Py_None) {
par.xmin = -0.5;
par.xmax = ndim[1] - 0.5;
par.ymin = -0.5;
par.ymax = ndim[0] - 0.5;
par.xmin = 0;
par.xmax = ndim[1] - 1;
par.ymin = 0;
par.ymax = ndim[0] - 1;
} else {
bbox_arr = (PyArrayObject *)PyArray_ContiguousFromAny(bbox, NPY_DOUBLE, 2, 2);
if (!bbox_arr) {
return PyErr_Format(gl_Error, "Invalid input bounding box.");
}
par.xmin = *(double*) PyArray_GETPTR2(bbox_arr, 0, 0);
par.xmax = *(double*) PyArray_GETPTR2(bbox_arr, 0, 1);
par.ymin = *(double*) PyArray_GETPTR2(bbox_arr, 1, 0);
par.ymax = *(double*) PyArray_GETPTR2(bbox_arr, 1, 1);
par.xmin = (integer_t)(*(double*) PyArray_GETPTR2(bbox_arr, 0, 0) - half);
par.xmax = (integer_t)(*(double*) PyArray_GETPTR2(bbox_arr, 0, 1) + half);
par.ymin = (integer_t)(*(double*) PyArray_GETPTR2(bbox_arr, 1, 0) - half);
par.ymax = (integer_t)(*(double*) PyArray_GETPTR2(bbox_arr, 1, 1) + half);
}

xy = (double *)PyArray_DATA(xyout_arr);
Expand Down
9 changes: 3 additions & 6 deletions src/cdrizzlebox.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
#include <stdlib.h>


static char buf[1024];


/** --------------------------------------------------------------------------------------------------
* Update the flux and counts in the output image using a weighted average
*
Expand Down Expand Up @@ -251,7 +248,7 @@ static int
do_kernel_point(struct driz_param_t* p) {
struct scanner s;
integer_t i, j, ii, jj;
integer_t ybounds[2], osize[2];
integer_t osize[2];
float scale2, vc, d, dow;
integer_t bv;
int xmin, xmax, ymin, ymax, n;
Expand Down Expand Up @@ -341,7 +338,7 @@ static int
do_kernel_gaussian(struct driz_param_t* p) {
struct scanner s;
integer_t bv, i, j, ii, jj, nxi, nxa, nyi, nya, nhit;
integer_t ybounds[2], osize[2];
integer_t osize[2];
float vc, d, dow;
double gaussian_efac, gaussian_es;
double pfo, ac, scale2, xxi, xxa, yyi, yya, w, ddx, ddy, r2, dover;
Expand Down Expand Up @@ -469,7 +466,7 @@ static int
do_kernel_lanczos(struct driz_param_t* p) {
struct scanner s;
integer_t bv, i, j, ii, jj, nxi, nxa, nyi, nya, nhit, ix, iy;
integer_t ybounds[2], osize[2];
integer_t osize[2];
float scale2, vc, d, dow;
double pfo, xx, yy, xxi, xxa, yyi, yya, w, dx, dy, dover;
int kernel_order;
Expand Down
11 changes: 4 additions & 7 deletions src/cdrizzlemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ shrink_image_section(PyArrayObject *pixmap, int *xmin, int *xmax, int *ymin,
int
interpolate_point(struct driz_param_t *par, double xin, double yin,
double *xout, double *yout) {
int ipix, jpix, npix, idim;
int i0, j0, nx2, ny2;
npy_intp *ndim;
double x, y, x1, y1, f00, f01, f10, f11, g00, g01, g10, g11;
Expand Down Expand Up @@ -207,6 +206,7 @@ map_point(struct driz_param_t *par, double xin, double yin, double *xout,
if (i >= par->xmin && i <= par->xmax && j >= par->ymin &&
j <= par->ymax) {
status = map_pixel(par->pixmap, i, j, xout, yout);
return status;
} else {
return 1;
}
Expand Down Expand Up @@ -492,14 +492,14 @@ clip_polygon_to_window(const struct polygon *p, const struct polygon *wnd,
int v1_inside, v2_inside;
struct polygon p1, p2, *ppin, *ppout, *tpp;
struct vertex *pv, *pv_, *wv, *wv_, dp, dw, vi;
double t, u, d, signed_area, app_, aww_;
double d, app_, aww_;

if ((p->npv < 3) || (wnd->npv < 3)) {
return 1;
}

orient_ccw(p);
orient_ccw(wnd);
orient_ccw((struct polygon *)p);
orient_ccw((struct polygon *)wnd);

p1 = *p;

Expand Down Expand Up @@ -906,9 +906,6 @@ int
init_image_scanner(struct driz_param_t *par, struct scanner *s, int *ymin,
int *ymax) {
struct polygon p, q, pq, inpq;
double xyin[2], xyout[2];
integer_t isize[2], osize[2];
int ipoint;
int k, n;
npy_intp *ndim;

Expand Down
2 changes: 0 additions & 2 deletions src/tests/utest_cdrizzle.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ FCT_BGN_FN(utest_cdrizzle)

/* Test for half overlap */

integer_t ybounds[2]; /* start of in-bounds */
struct driz_param_t *p; /* parameter structure */

p = setup_parameters();
Expand All @@ -639,7 +638,6 @@ FCT_BGN_FN(utest_cdrizzle)

/* Test for negative half overlap */

integer_t ybounds[2]; /* start of in-bounds */
struct driz_param_t *p; /* parameter structure */

p = setup_parameters();
Expand Down

0 comments on commit f78639f

Please sign in to comment.