Skip to content

Commit 9025dd4

Browse files
committed
remove numpy and pandas to be imported by default
1 parent 61c10ba commit 9025dd4

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

docs/usage.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ For convenience, `mini_lambda` comes bundled with the following predefined input
2525
* boolean/int/float numbers: `b` / `i`, `j`, `n` / `x`, `y`
2626
* lists/mappings: `l` / `d`
2727
* callables: `f`
28-
* numpy arrays (if numpy is present): `X`, `Y`, `M`
29-
* pandas dataframes (if pandas is present): `df`
28+
* numpy arrays (if numpy is present): `X`, `Y`, `M` (from `mini_lambda.numpy`)
29+
* pandas dataframes (if pandas is present): `df` (from `mini_lambda.pandas`)
3030

3131

3232
## Lambda Expressions vs Lambda Functions
@@ -344,7 +344,8 @@ Note: although the above is valid, it is much more recommended to convert the wh
344344
Classes can be entirely made lambda-friendly at once. This will convert the constructor, as well as any other method that would be available.
345345

346346
```python
347-
from mini_lambda import X, _, make_lambda_friendly_class
347+
from mini_lambda import _, make_lambda_friendly_class
348+
from mini_lambda.numpy import X
348349
import numpy as np
349350
import pandas as pd
350351

@@ -360,7 +361,8 @@ str(expr) # 'DataFrame(X).max().values[0]'
360361
Actually the `Constant()` (alias `C()` or `make_lambda_friendly()`) function that we saw above to convert constants, is also able to convert methods ans classes. So if there is only a single conversion operator to remember, remember this one.
361362

362363
```python
363-
from mini_lambda import _, C, X
364+
from mini_lambda import _, C
365+
from mini_lambda.numpy import X
364366
import numpy as np
365367
import pandas as pd
366368

mini_lambda/goodies.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,4 @@
1919
d = InputVar('d', dict)
2020

2121
# callables
22-
f = InputVar('f', Callable)
23-
24-
try:
25-
import numpy as np
26-
# matrices/arrays
27-
X = InputVar('X', np.ndarray)
28-
Y = InputVar('Y', np.ndarray)
29-
M = InputVar('M', np.ndarray)
30-
except:
31-
pass
32-
33-
try:
34-
# data frames
35-
import pandas as pd
36-
df = InputVar('df', pd.DataFrame)
37-
except:
38-
pass
22+
f = InputVar('f', Callable)

mini_lambda/numpy.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import numpy as np
2+
3+
from mini_lambda.main import InputVar
4+
5+
6+
# matrices/arrays
7+
X = InputVar('X', np.ndarray)
8+
Y = InputVar('Y', np.ndarray)
9+
M = InputVar('M', np.ndarray)

mini_lambda/pandas.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import pandas as pd
2+
3+
from mini_lambda.main import InputVar
4+
5+
6+
# data frames
7+
df = InputVar('df', pd.DataFrame)

mini_lambda/tests/test_readme.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ def bar2(cls, times, num, den):
303303

304304
def test_doc_usage_other_classes():
305305
""" Tests that the example in doc/usage in the others/classes section works """
306-
from mini_lambda import X, _, make_lambda_friendly_class
306+
from mini_lambda import _, make_lambda_friendly_class
307+
from mini_lambda.numpy import X
307308
import numpy as np
308309
import pandas as pd
309310

@@ -316,7 +317,8 @@ def test_doc_usage_other_classes():
316317

317318
def test_doc_usage_all_at_once():
318319
""" Tests that the example in doc/usage in the others/anything section works """
319-
from mini_lambda import _, C, X
320+
from mini_lambda import _, C
321+
from mini_lambda.numpy import X
320322
import numpy as np
321323
import pandas as pd
322324

0 commit comments

Comments
 (0)