Skip to content

Commit

Permalink
Closes #3376 more numpy imports (#3381)
Browse files Browse the repository at this point in the history
Co-authored-by: Amanda Potts <ajpotts@users.noreply.github.com>
  • Loading branch information
ajpotts and ajpotts authored Jul 9, 2024
1 parent 2cf454c commit 343cb5c
Show file tree
Hide file tree
Showing 17 changed files with 193 additions and 12 deletions.
120 changes: 108 additions & 12 deletions arkouda/numpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,61 @@
# flake8: noqa
from numpy import ( # noqa
NAN,
NINF,
NZERO,
PINF,
PZERO,
DataSource,
False_,
Inf,
Infinity,
NaN,
bool_,
ScalarType,
True_,
base_repr,
binary_repr,
byte,
cdouble,
cfloat,
clongdouble,
clongfloat,
compat,
csingle,
double,
e,
euler_gamma,
finfo,
flexible,
float32,
float64,
float_,
floating,
format_float_positional,
format_float_scientific,
half,
iinfo,
inexact,
inf,
infty,
int8,
int16,
int32,
int64,
int_,
intc,
integer,
intp,
isscalar,
issctype,
issubdtype,
longdouble,
longfloat,
longlong,
maximum_sctype,
nan,
newaxis,
number,
pi,
promote_types,
sctypeDict,
sctypes,
short,
signedinteger,
single,
Expand All @@ -49,65 +66,144 @@
uint32,
uint64,
uintc,
uintp,
ulonglong,
unsignedinteger,
ushort,
)

from arkouda.numpy import (
_builtins,
_mat,
_typing,
char,
ctypeslib,
dtypes,
exceptions,
fft,
lib,
linalg,
ma,
rec,
)
from arkouda.numpy._builtins import *
from arkouda.numpy._mat import *
from arkouda.numpy._typing import *
from arkouda.numpy.char import *
from arkouda.numpy.ctypeslib import *
from arkouda.numpy.dtypes import *
from arkouda.numpy.exceptions import *
from arkouda.numpy.fft import *
from arkouda.numpy.lib import *
from arkouda.numpy.lib.emath import *
from arkouda.numpy.linalg import *
from arkouda.numpy.ma import *
from arkouda.numpy.polynomial import *
from arkouda.numpy.rec import *

from ._numeric import floor

__all__ = [
"DataSource",
"False_",
"Inf",
"Infinity",
"NAN",
"NINF",
"NZERO",
"NaN",
"PINF",
"PZERO",
"Inf",
"Infinity",
"NaN",
"RankWarning",
"ScalarType",
"TooHardError",
"True_",
"_builtins",
"_mat",
"_numeric",
"_typing",
"add_docstring",
"add_newdoc",
"base_repr",
"binary_repr",
"bool_",
"number",
"byte",
"cdouble",
"cfloat",
"char",
"character",
"clongdouble",
"clongfloat",
"compat",
"csingle",
"ctypeslib",
"deprecate",
"deprecate_with_doc",
"disp",
"double",
"dtypes",
"e",
"emath",
"euler_gamma",
"exceptions",
"fft",
"finfo",
"flexible",
"float32",
"float64",
"float_",
"floating",
"floor",
"format_float_positional",
"format_float_scientific",
"format_parser",
"half",
"iinfo",
"inexact",
"inf",
"infty",
"int8",
"int16",
"int32",
"int64",
"int8",
"int_",
"intc",
"integer",
"intp",
"isscalar",
"issctype",
"issubclass_",
"issubdtype",
"integer",
"lib",
"linalg",
"longdouble",
"longfloat",
"longlong",
"ma",
"maximum_sctype",
"nan",
"newaxis",
"number",
"object_",
"pi",
"polynomial",
"promote_types",
"rec",
"sctypeDict",
"sctypes",
"short",
"signedinteger",
"single",
"str_",
"typename",
"ubyte",
"uint",
"uint8",
"uint16",
"uint32",
"uint64",
"uint8",
"uintc",
"uintp",
"ulonglong",
"unsignedinteger",
"ushort",
]
Empty file.
Empty file added arkouda/numpy/_mat/__init__.py
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions arkouda/numpy/char/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from numpy import bool_, character, int_, integer, object_, str_

__all__ = ["bool_", "character", "int_", "integer", "object_", "str_"]
3 changes: 3 additions & 0 deletions arkouda/numpy/ctypeslib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from numpy import integer

__all__ = ["integer"]
Empty file.
3 changes: 3 additions & 0 deletions arkouda/numpy/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from numpy import RankWarning, TooHardError

__all__ = ["RankWarning", "TooHardError"]
Empty file added arkouda/numpy/fft/__init__.py
Empty file.
30 changes: 30 additions & 0 deletions arkouda/numpy/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# flake8: noqa
from numpy import (
RankWarning,
add_docstring,
add_newdoc,
deprecate,
deprecate_with_doc,
disp,
issubclass_,
issubdtype,
polynomial,
typename,
)

from arkouda.numpy.lib import emath
from arkouda.numpy.lib.emath import *

__all__ = [
"RankWarning",
"add_docstring",
"add_newdoc",
"deprecate",
"deprecate_with_doc",
"disp",
"emath",
"issubclass_",
"issubdtype",
"polynomial",
"typename",
]
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions arkouda/numpy/ma/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from numpy import bool_

__all__ = ["bool_"]
3 changes: 3 additions & 0 deletions arkouda/numpy/polynomial/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from numpy import polynomial

__all__ = ["polynomial"]
Empty file.
3 changes: 3 additions & 0 deletions arkouda/numpy/rec/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from numpy import format_parser

__all__ = ["format_parser"]
37 changes: 37 additions & 0 deletions scripts/exclude_np.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This script finds all the classes and functions who's doc string contains "array". These functions are most likely not natively compatible with arkouda and should probalby be excluded from any automatic imports.

import inspect

def exclude(name, obj)->bool:
if hasattr(obj, "__doc__") and not name.startswith("__") and obj.__doc__ is not None:
if "array" in obj.__doc__:
return True
return False


def main():

import numpy as np

exclude_set = set()
for name, obj in inspect.getmembers(np):
if exclude(name, obj):
exclude_set.add(name)
if inspect.isclass(obj):
for func_name, func in inspect.getmembers(obj):
if exclude(name, obj):
exclude_set.add(name)

exclude_list = list(exclude_set)
keep_list = list(set(dir(np)).difference(exclude_list))
keep_list = [item for item in keep_list if not item.startswith("_")]
keep_list = sorted(keep_list)

print("EXCLUDE:")
print(exclude_list)
print("KEEP:")
print(keep_list)


if __name__ == "__main__":
main()

0 comments on commit 343cb5c

Please sign in to comment.