Skip to content

Commit

Permalink
use boolean vector to see what types an xform supports - #511
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Dec 26, 2024
1 parent d712a4d commit 996baab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions lib/PDL/Core/pdlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,6 @@ static inline pdl_error pdl__transtype_select(
) {
pdl_error PDL_err = {0, NULL, 0};
*retval = PDL_INVALID;
pdl_datatypes last_dtype = PDL_INVALID;
PDL_Indx i;
pdl_transvtable *vtable = trans->vtable;
for (i=0; i<vtable->npdls; i++) {
Expand All @@ -1104,8 +1103,11 @@ static inline pdl_error pdl__transtype_select(
"%s: ndarray %s must be real, but is type %s",
vtable->name, vtable->par_names[i], PDL_TYPENAME(dtype));
}
if (vtable->gentypes[0] != PDL_INVALID &&
vtable->gentypes[1] == PDL_INVALID) {
char type_avail[PDL.ntypes]; for (i=0; i<PDL.ntypes; i++) type_avail[i] = 0;
pdl_datatypes last_dtype = PDL_INVALID;
for (i=0; vtable->gentypes[i]!=-1; i++)
type_avail[last_dtype = vtable->gentypes[i]] = 1;
if (vtable->gentypes[0] == last_dtype) {
*retval = vtable->gentypes[0]; /* only one allowed type, use that */
return PDL_err;
}
Expand All @@ -1130,12 +1132,7 @@ static inline pdl_error pdl__transtype_select(
))
*retval = new_transtype;
}
for (i=0; vtable->gentypes[i]!=-1; i++) {
last_dtype = vtable->gentypes[i];
if (*retval != last_dtype) continue;
return PDL_err;
}
*retval = last_dtype;
if (*retval == PDL_INVALID || !type_avail[*retval]) *retval = last_dtype;
return PDL_err;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/PDL/IO/Misc.pd
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ sub PDL::swcols{
The default value is to assign C<$PDL::undefval> to undefined values,
but if C<UNDEFINED> is set this is used instead. This would normally
be set to a number, but if it is set to C<Bad> and PDL is compiled
with Badvalue support (see L<PDL::Bad/>) then undefined values are set to
with Badvalue support (see L<PDL::Bad>) then undefined values are set to
the appropriate badvalue and the column is marked as bad.
DEFTYPE: Sets the default type of the columns - see the documentation for
Expand Down

0 comments on commit 996baab

Please sign in to comment.