Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Pandas deprecation warnings. #855

Merged
merged 33 commits into from
Nov 20, 2024
Merged

Fixing Pandas deprecation warnings. #855

merged 33 commits into from
Nov 20, 2024

Conversation

MahmoudAlamar03
Copy link
Contributor

@MahmoudAlamar03 MahmoudAlamar03 commented Nov 6, 2024

Checking for deprecation warnings. Unable to replicate the deprecation warnings mentioned by @andy-beer, currently working on resolving those sent directly:
warnings summary ====================================================================
tests/unit_tests/derived_model/test_derived_model.py::test_add_wells_from_ascii_file
tests/unit_tests/well/test_well_object_funcs.py::test_add_wells_from_ascii_file
tests/unit_tests/well/test_well_object_funcs.py::test_add_wells_from_ascii_file
/Users/andy/bifröst/resqpy_repo/resqpy/well/well_object_funcs.py:80: FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use sep='\s+' instead
df = pd.read_csv(trajectory_file,

tests/unit_tests/fault/test_fault.py::test_add_connection_set_and_tmults[inc_list0-tmult_dict0-expected_mult0]
tests/unit_tests/fault/test_fault.py::test_add_connection_set_and_tmults[inc_list1-tmult_dict1-expected_mult1]
tests/unit_tests/fault/test_fault.py::test_add_connection_set_and_tmults[inc_list2-tmult_dict2-expected_mult2]
tests/unit_tests/olio/test_read_nexus_fault.py::test_load_nexus_fault_mult_table[basic]
/Users/andy/bifröst/resqpy_repo/resqpy/olio/read_nexus_fault.py:117: FutureWarning: errors='ignore' is deprecated and will raise in a future version. Use to_numeric without passing errors and catch exceptions explicitly instead
df[column] = pd.to_numeric(df[column], errors = 'ignore')

tests/unit_tests/fault/test_fault.py::test_add_connection_set_and_tmults[inc_list2-tmult_dict2-expected_mult2]
tests/unit_tests/olio/test_read_nexus_fault.py::test_load_nexus_fault_mult_table[basic]
/Users/andy/bifröst/resqpy_repo/resqpy/olio/read_nexus_fault.py:67: FutureWarning: errors='ignore' is deprecated and will raise in a future version. Use to_numeric without passing errors and catch exceptions explicitly instead
df[column] = pd.to_numeric(df[column], errors = 'ignore')

tests/unit_tests/olio/test_relperm.py::test_col_headers
tests/unit_tests/olio/test_relperm.py::test_missing_vals
tests/unit_tests/olio/test_relperm.py::test_monotonicity
tests/unit_tests/olio/test_relperm.py::test_range
tests/unit_tests/olio/test_relperm.py::test_relperm
tests/unit_tests/olio/test_relperm.py::test_relperm_no_phase_combo[test_cols0-water-oil]
tests/unit_tests/olio/test_relperm.py::test_relperm_no_phase_combo[test_cols1-gas-oil]
tests/unit_tests/olio/test_relperm.py::test_relperm_no_phase_combo[test_cols2-gas-water]
/Users/andy/bifröst/resqpy_repo/resqpy/olio/relperm.py:94: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.

df['Pc'].replace('None', np.nan, inplace = True)

tests/unit_tests/well/test_blocked_well.py: 12 warnings
tests/unit_tests/well/test_well_object_funcs.py: 1 warning
tests/unit_tests/well/test_well_utils.py: 1 warning
/Users/andy/bifröst/resqpy_repo/resqpy/well/_blocked_well.py:880: FutureWarning: Series.getitem treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use ser.iloc[pos]
if pd.isna(row[0]) or pd.isna(row[1]) or pd.isna(row[2]):

tests/unit_tests/well/test_blocked_well.py: 12 warnings
tests/unit_tests/well/test_well_object_funcs.py: 1 warning
tests/unit_tests/well/test_well_utils.py: 1 warning
/Users/andy/bifröst/resqpy_repo/resqpy/well/_blocked_well.py:883: FutureWarning: Series.getitem treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use ser.iloc[pos]
cell_kji0[:] = row[2], row[1], row[0]

tests/unit_tests/well/test_deviation_survey.py::test_DeviationSurvey
/Users/andy/bifröst/resqpy_repo/resqpy/well/_deviation_survey.py:236: FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use sep='\s+' instead
df = pd.read_csv(deviation_survey_file,

tests/unit_tests/well/test_trajectory.py::test_load_from_ascii_file
tests/unit_tests/well/test_trajectory.py::test_load_from_ascii_file
tests/unit_tests/well/test_trajectory.py::test_arrays
/Users/andy/bifröst/resqpy_repo/resqpy/well/_trajectory.py:513: FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use sep='\s+' instead
df = pd.read_csv(trajectory_file,

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================ short test summary info ================================================================
SKIPPED [1] tests/unit_tests/test_resqpy.py:25: need --buildtest option to run
===================================================== 1189 passed, 1 skipped, 49 warnings in 23.72s

@MahmoudAlamar03 MahmoudAlamar03 self-assigned this Nov 6, 2024
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.

Project coverage is 83.66%. Comparing base (16efb3d) to head (48d3905).
Report is 47 commits behind head on master.

Files with missing lines Patch % Lines
resqpy/olio/read_nexus_fault.py 50.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #855   +/-   ##
=======================================
  Coverage   83.65%   83.66%           
=======================================
  Files         192      192           
  Lines       33601    33636   +35     
=======================================
+ Hits        28110    28142   +32     
- Misses       5491     5494    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@MahmoudAlamar03 MahmoudAlamar03 marked this pull request as ready for review November 20, 2024 00:12
@MahmoudAlamar03 MahmoudAlamar03 changed the title Running pipeline to check for deprecation warnings. Fixing Pandas deprecation warnings Nov 20, 2024
@MahmoudAlamar03 MahmoudAlamar03 changed the title Fixing Pandas deprecation warnings Fixing Pandas deprecation warnings. Nov 20, 2024
@@ -877,10 +877,10 @@ def derive_from_dataframe(self,
@staticmethod
def __cell_kji0_from_df(df, df_row):
row = df.iloc[df_row]
if pd.isna(row[0]) or pd.isna(row[1]) or pd.isna(row[2]):
if pd.isna(row.iloc[0]) or pd.isna(row.iloc[1]) or pd.isna(row.iloc[2]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's discuss these changes as I'm hazy about the use of iloc here.

@andy-beer andy-beer merged commit e17a635 into master Nov 20, 2024
9 of 10 checks passed
@andy-beer andy-beer deleted the deprecation_warnings branch November 20, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants