Skip to content

Commit

Permalink
vaex-core: remove need for legacy printoptions
Browse files Browse the repository at this point in the history
  • Loading branch information
2maz committed Jan 19, 2025
1 parent da02384 commit da5fe8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 1 addition & 5 deletions packages/vaex-core/vaex/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@
PRINT_MAX_COUNT = 10

expression_namespace = {}
expression_namespace['np'] = np
expression_namespace['nan'] = np.nan


expression_namespace = {}
expression_namespace['nan'] = np.nan


_binary_ops = [
dict(code="+", name='add', op=operator.add),
dict(code="in", name='contains', op=operator.contains),
Expand Down
19 changes: 13 additions & 6 deletions packages/vaex-core/vaex/expresso.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ def validate_expression(expr, variable_set, function_set=[], names=None):
elif isinstance(expr, ast_Str):
pass # as well as strings
elif isinstance(expr, _ast.Call):
validate_func(expr.func, function_set)
last_func = expr
for arg in expr.args:
validate_expression(arg, variable_set, function_set, names)
for arg in expr.keywords:
validate_expression(arg, variable_set, function_set, names)
if isinstance(expr.func, _ast.Attribute):
pass
else:
validate_func(expr.func, function_set)
last_func = expr
for arg in expr.args:
validate_expression(arg, variable_set, function_set, names)
for arg in expr.keywords:
validate_expression(arg, variable_set, function_set, names)
elif isinstance(expr, _ast.Compare):
validate_expression(expr.left, variable_set, function_set, names)
for op in expr.ops:
Expand Down Expand Up @@ -370,6 +373,10 @@ def visit_Dict(self, node):
return '{' + ', '.join(parts) + '}'

def visit_Call(self, node):
if isinstance(node.func, _ast.Attribute):
# assuming np.float64(0.0) for instance
return str(node.args[0].value)

args = [self.visit(k) for k in node.args]
keywords = []
if hasattr(node, 'keywords'):
Expand Down
3 changes: 0 additions & 3 deletions tests/geo_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from common import *

if np.lib.NumpyVersion(np.__version__) >= "2.0.0":
np.set_printoptions(legacy="1.25")

def test_virtual_columns_spherical():
df = vaex.from_scalars(alpha=0, delta=0, distance=1)
df.add_virtual_columns_spherical_to_cartesian("alpha", "delta", "distance", "x", "y", "z", radians=False)
Expand Down

0 comments on commit da5fe8a

Please sign in to comment.