Skip to content

Conversation

@Riyazul555
Copy link

@Riyazul555 Riyazul555 commented Jun 29, 2024


return ret_value

# Test with the DataFrame and multiline expression
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the test to a proper test file? I think pandas/tests/test_expressions.py is probably the best place for it.

obj = ti.reindex(reindexer, axis=axis)
terms[i].update(obj)

terms[i].update(terms[i].value.values)
Copy link
Contributor

@chaoyihu chaoyihu Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this line does fix the bug, nice job! But I'm curious about potential side effects: this line of code converts terms[i].value from pd.Series to np.ndarray, and removing it might affect the behavior of terms in whatever context it is used. Are the test failures related?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @chaoyihu I have added the test in the respective file
But here what you want me to do further in this terms[i].value ??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should wait and see if it passes the checks after this revision.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick response! I viewed your changes and left new comments.

The check failures seem to have been caused by the import line you added to the beginning of align.py - from __future__ imports must occur at the beginning of the file.

You probably should also rebase your branch on main, since your branch is significantly behind.

For now, I do not think you need to do anything further with terms[i]. Can you revise the code, do a rebase, then push again and wait to see if it passes the checks?

If it does, someone with write access will likely come to inspect and merge your code.

@Riyazul555
Copy link
Author

I have moved the test in the respective file
Do check it out @chaoyihu and let me know about terms[i].value .....what you want me o do further?
Thanks

Core eval alignment algorithms.
"""

import pandas as pd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this import line.


return ret_value

# Test with the DataFrame and multiline expression
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't forget to remove this block of code from align.py, since you've added it to the test file.

import re

import numpy as np
import pandas as pd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this line.

# Define expected values manually or calculate based on expectation
expected_first_ret = df['first'] / df['pre'].fillna(df['first']) - 1.0
expected_last_ret = df['last'] / df['pre'].fillna(df['first']) - 1.0
expected = pd.DataFrame({"first_ret": expected_first_ret, "last_ret": expected_last_ret})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use DataFrame instead of pd.DataFrame.


# New test added here
def test_multiline_expression(self):
df = pd.DataFrame({"first": [9.76, 9.76, 9.76], "last": [9.76, 9.76, 9.76], "pre": [9.75, 9.76, 9.76]})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use DataFrame instead of pd.DataFrame.

@Riyazul555
Copy link
Author

I am closing this PR
Supersede by #59189

@Riyazul555 Riyazul555 closed this Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants