Skip to content

Commit e45ca3d

Browse files
authored
Merge branch 'master' into logical_and_or
2 parents 653093e + a91bed6 commit e45ca3d

File tree

7 files changed

+30
-25
lines changed

7 files changed

+30
-25
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ after_success:
5858
- pylint mini_lambda # note that at the moment the report is simply lost, we dont transform the result into anything
5959
# ***documentation***
6060
- mkdocs build -f docs/mkdocs.yml
61+
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then exit 0; fi;
6162
- mv reports/junit site/
6263
# mkdocs gh-deploy requires special care :
6364
# ---grant the possibility to push on the repo---
@@ -71,7 +72,7 @@ after_success:
7172
- git fetch gh-remote && git fetch gh-remote gh-pages:gh-pages;
7273
# push but only if this is not a build triggered by a pull request
7374
# note: here we use the --dirty flag so that mkdocs does not clean the additional reports that we copied in the site
74-
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_PYTHON_VERSION}" = "3.5" ]; then echo "Pushing to github"; PYTHONPATH=mini_lambda/ mkdocs gh-deploy -v --dirty -f docs/mkdocs.yml --remote-name gh-remote; git push gh-remote gh-pages; fi;
75+
- if [ "${TRAVIS_PYTHON_VERSION}" = "3.5" ]; then echo "Pushing to github"; PYTHONPATH=mini_lambda/ mkdocs gh-deploy -v --dirty -f docs/mkdocs.yml --remote-name gh-remote; git push gh-remote gh-pages; fi;
7576
# - if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_PYTHON_VERSION}" = "3.5" ]; then echo "Pushing to github"; git push gh-remote gh-pages; fi;
7677

7778
deploy:

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
@@ -345,7 +345,8 @@ Note: although the above is valid, it is much more recommended to convert the wh
345345
Classes can be entirely made lambda-friendly at once. This will convert the constructor, as well as any other method that would be available.
346346

347347
```python
348-
from mini_lambda import X, _, make_lambda_friendly_class
348+
from mini_lambda import _, make_lambda_friendly_class
349+
from mini_lambda.numpy import X
349350
import numpy as np
350351
import pandas as pd
351352

@@ -361,7 +362,8 @@ str(expr) # 'DataFrame(X).max().values[0]'
361362
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.
362363

363364
```python
364-
from mini_lambda import _, C, X
365+
from mini_lambda import _, C
366+
from mini_lambda.numpy import X
365367
import numpy as np
366368
import pandas as pd
367369

mini_lambda/goodies.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,3 @@
2020

2121
# callables
2222
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

mini_lambda/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def And(a, b):
439439
440440
:param a: left operand
441441
:param b: right operand
442-
:return: expression evaluation 'and'
442+
:return: expression evaluating the and combination
443443
"""
444444
return _LambdaExpression._get_expression_for_method_with_args(_and, a, b)
445445

@@ -454,7 +454,7 @@ def Or(a, b):
454454
455455
:param a: left operand
456456
:param b: right operand
457-
:return: expression evaluation 'or'
457+
:return: expression evaluating the or combination
458458
"""
459459
return _LambdaExpression._get_expression_for_method_with_args(_or, a, b)
460460

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)