tests: add frame constraint generation test
All checks were successful
Tests / tests (pull_request) Successful in 6s
All checks were successful
Tests / tests (pull_request) Successful in 6s
This commit is contained in:
15
tests/cases/generator/04_frames.midas
Normal file
15
tests/cases/generator/04_frames.midas
Normal file
@@ -0,0 +1,15 @@
|
||||
predicate is_positive(v: float) = v >= 0
|
||||
type Positive = float where is_positive(_)
|
||||
|
||||
alias T1 = Frame[
|
||||
a: int
|
||||
]
|
||||
|
||||
alias T2 = Frame[
|
||||
a: int,
|
||||
b: str,
|
||||
c: Positive,
|
||||
d: float where is_positive(_)
|
||||
]
|
||||
|
||||
alias Positives = Column[Positive]
|
||||
13
tests/cases/generator/04_frames.py
Normal file
13
tests/cases/generator/04_frames.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from typing import Any
|
||||
|
||||
from midas import T1, T2, Column, Positive, Positives, cast
|
||||
|
||||
o: Any = object()
|
||||
|
||||
df1 = cast(T1, o)
|
||||
df2 = cast(T2, o)
|
||||
|
||||
df1 + df2
|
||||
|
||||
col1: Positives = df2["c"]
|
||||
col2 = cast(Column[Positive], col1)
|
||||
731
tests/cases/generator/04_frames.py.ref.txt
Normal file
731
tests/cases/generator/04_frames.py.ref.txt
Normal file
@@ -0,0 +1,731 @@
|
||||
Module(
|
||||
body=[
|
||||
FunctionDef(
|
||||
name='__midas_column_same_length__',
|
||||
args=arguments(
|
||||
posonlyargs=[],
|
||||
args=[
|
||||
arg(arg='column1'),
|
||||
arg(arg='column2')],
|
||||
kwonlyargs=[],
|
||||
kw_defaults=[],
|
||||
defaults=[]),
|
||||
body=[
|
||||
Return(
|
||||
value=Compare(
|
||||
left=Call(
|
||||
func=Name(id='len'),
|
||||
args=[
|
||||
Attribute(
|
||||
value=Name(id='column1'),
|
||||
attr='index')],
|
||||
keywords=[]),
|
||||
ops=[
|
||||
Eq()],
|
||||
comparators=[
|
||||
Call(
|
||||
func=Name(id='len'),
|
||||
args=[
|
||||
Attribute(
|
||||
value=Name(id='column2'),
|
||||
attr='index')],
|
||||
keywords=[])]))],
|
||||
decorator_list=[]),
|
||||
FunctionDef(
|
||||
name='__midas_frame_same_length__',
|
||||
args=arguments(
|
||||
posonlyargs=[],
|
||||
args=[
|
||||
arg(arg='frame1'),
|
||||
arg(arg='frame2')],
|
||||
kwonlyargs=[],
|
||||
kw_defaults=[],
|
||||
defaults=[]),
|
||||
body=[
|
||||
Return(
|
||||
value=Compare(
|
||||
left=Call(
|
||||
func=Name(id='len'),
|
||||
args=[
|
||||
Attribute(
|
||||
value=Name(id='frame1'),
|
||||
attr='index')],
|
||||
keywords=[]),
|
||||
ops=[
|
||||
Eq()],
|
||||
comparators=[
|
||||
Call(
|
||||
func=Name(id='len'),
|
||||
args=[
|
||||
Attribute(
|
||||
value=Name(id='frame2'),
|
||||
attr='index')],
|
||||
keywords=[])]))],
|
||||
decorator_list=[]),
|
||||
FunctionDef(
|
||||
name='__midas_is_column__',
|
||||
args=arguments(
|
||||
posonlyargs=[
|
||||
arg(arg='obj')],
|
||||
args=[],
|
||||
kwonlyargs=[],
|
||||
kw_defaults=[],
|
||||
defaults=[]),
|
||||
body=[
|
||||
Import(
|
||||
names=[
|
||||
alias(name='pandas', asname='pd')]),
|
||||
Return(
|
||||
value=Call(
|
||||
func=Name(id='isinstance'),
|
||||
args=[
|
||||
Name(id='obj'),
|
||||
Attribute(
|
||||
value=Name(id='pd'),
|
||||
attr='Series')],
|
||||
keywords=[]))],
|
||||
decorator_list=[],
|
||||
returns=Name(id='bool')),
|
||||
FunctionDef(
|
||||
name='__midas_is_dataframe__',
|
||||
args=arguments(
|
||||
posonlyargs=[
|
||||
arg(arg='obj')],
|
||||
args=[],
|
||||
kwonlyargs=[],
|
||||
kw_defaults=[],
|
||||
defaults=[]),
|
||||
body=[
|
||||
Import(
|
||||
names=[
|
||||
alias(name='pandas', asname='pd')]),
|
||||
Return(
|
||||
value=Call(
|
||||
func=Name(id='isinstance'),
|
||||
args=[
|
||||
Name(id='obj'),
|
||||
Attribute(
|
||||
value=Name(id='pd'),
|
||||
attr='DataFrame')],
|
||||
keywords=[]))],
|
||||
decorator_list=[],
|
||||
returns=Name(id='bool')),
|
||||
FunctionDef(
|
||||
name='__midas_is_positive__',
|
||||
args=arguments(
|
||||
posonlyargs=[],
|
||||
args=[
|
||||
arg(
|
||||
arg='v',
|
||||
annotation=Constant(value='float'))],
|
||||
kwonlyargs=[],
|
||||
kw_defaults=[],
|
||||
defaults=[]),
|
||||
body=[
|
||||
Return(
|
||||
value=Compare(
|
||||
left=Name(id='v'),
|
||||
ops=[
|
||||
GtE()],
|
||||
comparators=[
|
||||
Constant(value=0)]))],
|
||||
decorator_list=[],
|
||||
returns=Constant(value='bool')),
|
||||
FunctionDef(
|
||||
name='__midas_p0__',
|
||||
args=arguments(
|
||||
posonlyargs=[],
|
||||
args=[
|
||||
arg(
|
||||
arg='_',
|
||||
annotation=Constant(value='Any'))],
|
||||
kwonlyargs=[],
|
||||
kw_defaults=[],
|
||||
defaults=[]),
|
||||
body=[
|
||||
Return(
|
||||
value=Call(
|
||||
func=Name(id='__midas_is_positive__'),
|
||||
args=[
|
||||
Name(id='_')],
|
||||
keywords=[]))],
|
||||
decorator_list=[],
|
||||
returns=Constant(value='bool')),
|
||||
FunctionDef(
|
||||
name='__midas_p1__',
|
||||
args=arguments(
|
||||
posonlyargs=[],
|
||||
args=[
|
||||
arg(
|
||||
arg='_',
|
||||
annotation=Constant(value='Any'))],
|
||||
kwonlyargs=[],
|
||||
kw_defaults=[],
|
||||
defaults=[]),
|
||||
body=[
|
||||
Return(
|
||||
value=Call(
|
||||
func=Name(id='__midas_is_positive__'),
|
||||
args=[
|
||||
Name(id='_')],
|
||||
keywords=[]))],
|
||||
decorator_list=[],
|
||||
returns=Constant(value='bool')),
|
||||
ImportFrom(
|
||||
module='typing',
|
||||
names=[
|
||||
alias(name='Any')],
|
||||
level=0),
|
||||
ImportFrom(
|
||||
module='midas',
|
||||
names=[
|
||||
alias(name='T1'),
|
||||
alias(name='T2'),
|
||||
alias(name='Column'),
|
||||
alias(name='Positive'),
|
||||
alias(name='Positives'),
|
||||
alias(name='cast')],
|
||||
level=0),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='o')],
|
||||
value=Call(
|
||||
func=Name(id='object'),
|
||||
args=[],
|
||||
keywords=[])),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='__midas_a0__')],
|
||||
value=Name(id='o')),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_is_dataframe__'),
|
||||
args=[
|
||||
Name(id='__midas_a0__')],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L7:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='__midas_a0__')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=' to Frame[a: Column[int]]: Not a dataframe')])),
|
||||
Assert(
|
||||
test=Compare(
|
||||
left=Constant(value='a'),
|
||||
ops=[
|
||||
In()],
|
||||
comparators=[
|
||||
Name(id='__midas_a0__')]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L7:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='__midas_a0__')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to Frame[a: Column[int]]: Missing column 'a'")])),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_is_column__'),
|
||||
args=[
|
||||
Subscript(
|
||||
value=Name(id='__midas_a0__'),
|
||||
slice=Constant(value='a'))],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L7:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Subscript(
|
||||
value=Name(id='__midas_a0__'),
|
||||
slice=Constant(value='a'))],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to Column[int], in column 'a': Not a column")])),
|
||||
For(
|
||||
target=Name(id='value'),
|
||||
iter=Subscript(
|
||||
value=Name(id='__midas_a0__'),
|
||||
slice=Constant(value='a')),
|
||||
body=[
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='isinstance'),
|
||||
args=[
|
||||
Name(id='value'),
|
||||
Name(id='int')],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L7:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='value')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to int, in column 'a'")]))],
|
||||
orelse=[]),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='df1')],
|
||||
value=Name(id='__midas_a0__')),
|
||||
Delete(
|
||||
targets=[
|
||||
Name(id='__midas_a0__')]),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='__midas_a1__')],
|
||||
value=Name(id='o')),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_is_dataframe__'),
|
||||
args=[
|
||||
Name(id='__midas_a1__')],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='__midas_a1__')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=' to Frame[a: Column[int], b: Column[str], c: Column[Positive], d: Column[float where is_positive(_)]]: Not a dataframe')])),
|
||||
Assert(
|
||||
test=Compare(
|
||||
left=Constant(value='a'),
|
||||
ops=[
|
||||
In()],
|
||||
comparators=[
|
||||
Name(id='__midas_a1__')]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='__midas_a1__')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to Frame[a: Column[int], b: Column[str], c: Column[Positive], d: Column[float where is_positive(_)]]: Missing column 'a'")])),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_is_column__'),
|
||||
args=[
|
||||
Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='a'))],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='a'))],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to Column[int], in column 'a': Not a column")])),
|
||||
For(
|
||||
target=Name(id='value'),
|
||||
iter=Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='a')),
|
||||
body=[
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='isinstance'),
|
||||
args=[
|
||||
Name(id='value'),
|
||||
Name(id='int')],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='value')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to int, in column 'a'")]))],
|
||||
orelse=[]),
|
||||
Assert(
|
||||
test=Compare(
|
||||
left=Constant(value='b'),
|
||||
ops=[
|
||||
In()],
|
||||
comparators=[
|
||||
Name(id='__midas_a1__')]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='__midas_a1__')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to Frame[a: Column[int], b: Column[str], c: Column[Positive], d: Column[float where is_positive(_)]]: Missing column 'b'")])),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_is_column__'),
|
||||
args=[
|
||||
Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='b'))],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='b'))],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to Column[str], in column 'b': Not a column")])),
|
||||
For(
|
||||
target=Name(id='value'),
|
||||
iter=Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='b')),
|
||||
body=[
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='isinstance'),
|
||||
args=[
|
||||
Name(id='value'),
|
||||
Name(id='str')],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='value')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to str, in column 'b'")]))],
|
||||
orelse=[]),
|
||||
Assert(
|
||||
test=Compare(
|
||||
left=Constant(value='c'),
|
||||
ops=[
|
||||
In()],
|
||||
comparators=[
|
||||
Name(id='__midas_a1__')]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='__midas_a1__')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to Frame[a: Column[int], b: Column[str], c: Column[Positive], d: Column[float where is_positive(_)]]: Missing column 'c'")])),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_is_column__'),
|
||||
args=[
|
||||
Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='c'))],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='c'))],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to Column[Positive], in column 'c': Not a column")])),
|
||||
For(
|
||||
target=Name(id='value'),
|
||||
iter=Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='c')),
|
||||
body=[
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='isinstance'),
|
||||
args=[
|
||||
Name(id='value'),
|
||||
Name(id='float')],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='value')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to float, in column 'c'")])),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_p0__'),
|
||||
args=[
|
||||
Name(id='value')],
|
||||
keywords=[]),
|
||||
msg=Constant(value="04_frames.py:L8:7: ConstraintError: Value does not fit constraint 'is_positive(_)', in column 'c'"))],
|
||||
orelse=[]),
|
||||
Assert(
|
||||
test=Compare(
|
||||
left=Constant(value='d'),
|
||||
ops=[
|
||||
In()],
|
||||
comparators=[
|
||||
Name(id='__midas_a1__')]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='__midas_a1__')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to Frame[a: Column[int], b: Column[str], c: Column[Positive], d: Column[float where is_positive(_)]]: Missing column 'd'")])),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_is_column__'),
|
||||
args=[
|
||||
Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='d'))],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='d'))],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to Column[float where is_positive(_)], in column 'd': Not a column")])),
|
||||
For(
|
||||
target=Name(id='value'),
|
||||
iter=Subscript(
|
||||
value=Name(id='__midas_a1__'),
|
||||
slice=Constant(value='d')),
|
||||
body=[
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='isinstance'),
|
||||
args=[
|
||||
Name(id='value'),
|
||||
Name(id='float')],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L8:7: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='value')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=" to float, in column 'd'")])),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_p1__'),
|
||||
args=[
|
||||
Name(id='value')],
|
||||
keywords=[]),
|
||||
msg=Constant(value="04_frames.py:L8:7: ConstraintError: Value does not fit constraint 'is_positive(_)', in column 'd'"))],
|
||||
orelse=[]),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='df2')],
|
||||
value=Name(id='__midas_a1__')),
|
||||
Delete(
|
||||
targets=[
|
||||
Name(id='__midas_a1__')]),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='__midas_a2__')],
|
||||
value=Name(id='df1')),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='__midas_a3__')],
|
||||
value=Name(id='df2')),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_column_same_length__'),
|
||||
args=[
|
||||
Name(id='__midas_a2__'),
|
||||
Name(id='__midas_a3__')],
|
||||
keywords=[]),
|
||||
msg=Constant(value='04_frames.py:L10:1: AssertionError: Columns must have the same length')),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='__midas_a4__')],
|
||||
value=Name(id='__midas_a2__')),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='__midas_a5__')],
|
||||
value=Name(id='__midas_a3__')),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_frame_same_length__'),
|
||||
args=[
|
||||
Name(id='__midas_a4__'),
|
||||
Name(id='__midas_a5__')],
|
||||
keywords=[]),
|
||||
msg=Constant(value='04_frames.py:L10:1: AssertionError: DataFrames must have the same length')),
|
||||
Expr(
|
||||
value=BinOp(
|
||||
left=Name(id='__midas_a2__'),
|
||||
op=Add(),
|
||||
right=Name(id='__midas_a3__'))),
|
||||
Delete(
|
||||
targets=[
|
||||
Name(id='__midas_a2__'),
|
||||
Name(id='__midas_a3__'),
|
||||
Name(id='__midas_a4__'),
|
||||
Name(id='__midas_a5__')]),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='col1')],
|
||||
value=Subscript(
|
||||
value=Name(id='df2'),
|
||||
slice=Constant(value='c'))),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='__midas_a6__')],
|
||||
value=Name(id='col1')),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_is_column__'),
|
||||
args=[
|
||||
Name(id='__midas_a6__')],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L13:8: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='__midas_a6__')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=' to Column[Positive]: Not a column')])),
|
||||
For(
|
||||
target=Name(id='value'),
|
||||
iter=Name(id='__midas_a6__'),
|
||||
body=[
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='isinstance'),
|
||||
args=[
|
||||
Name(id='value'),
|
||||
Name(id='float')],
|
||||
keywords=[]),
|
||||
msg=JoinedStr(
|
||||
values=[
|
||||
Constant(value='04_frames.py:L13:8: CastError: Cannot cast '),
|
||||
FormattedValue(
|
||||
value=Attribute(
|
||||
value=Call(
|
||||
func=Name(id='type'),
|
||||
args=[
|
||||
Name(id='value')],
|
||||
keywords=[]),
|
||||
attr='__name__'),
|
||||
conversion=-1),
|
||||
Constant(value=' to float')])),
|
||||
Assert(
|
||||
test=Call(
|
||||
func=Name(id='__midas_p0__'),
|
||||
args=[
|
||||
Name(id='value')],
|
||||
keywords=[]),
|
||||
msg=Constant(value="04_frames.py:L13:8: ConstraintError: Value does not fit constraint 'is_positive(_)'"))],
|
||||
orelse=[]),
|
||||
Assign(
|
||||
targets=[
|
||||
Name(id='col2')],
|
||||
value=Name(id='__midas_a6__')),
|
||||
Delete(
|
||||
targets=[
|
||||
Name(id='__midas_a6__')])],
|
||||
type_ignores=[])
|
||||
Reference in New Issue
Block a user