Skip to content

Commit 74c43ec

Browse files
committed
Fixed issue in numpy and pandas submodules by renaming them: they were unable to import the external module with the same name. Also added them in init.
1 parent 533f12d commit 74c43ec

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

mini_lambda/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# (1) allow users to do
88
# import <package> as p and then p.<symbol>
99
__all__ = __get_all_submodules_symbols(__PACKAGE_NAME, __SUBMODULES_TO_EXPORT)
10+
__all__ += ['numpy_', 'pandas_']
1011
# Note: this is one way to do it, but it would be simpler to check the names in globals() at the end of this file.
1112

1213
# (2) allow users to do

mini_lambda/tests/test_readme.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def bar2(cls, times, num, den):
304304
def test_doc_usage_other_classes():
305305
""" Tests that the example in doc/usage in the others/classes section works """
306306
from mini_lambda import _, make_lambda_friendly_class
307-
from mini_lambda.numpy import X
307+
from mini_lambda.numpy_ import X
308308
import numpy as np
309309
import pandas as pd
310310

@@ -318,7 +318,7 @@ def test_doc_usage_other_classes():
318318
def test_doc_usage_all_at_once():
319319
""" Tests that the example in doc/usage in the others/anything section works """
320320
from mini_lambda import _, C
321-
from mini_lambda.numpy import X
321+
from mini_lambda.numpy_ import X
322322
import numpy as np
323323
import pandas as pd
324324

@@ -334,3 +334,17 @@ def test_doc_usage_already_imported():
334334
from mini_lambda import DDecimal # Decimal class
335335
from mini_lambda import Print # print() function
336336
from mini_lambda import Pi # math.pi constant
337+
338+
339+
def test_doc_optional():
340+
""""""
341+
342+
with pytest.raises(ImportError):
343+
from mini_lambda import X
344+
345+
from mini_lambda.numpy_ import X
346+
347+
with pytest.raises(ImportError):
348+
from mini_lambda import df
349+
350+
from mini_lambda.pandas_ import df

0 commit comments

Comments
 (0)