@@ -99,7 +99,7 @@ def test_no_scipy(scm_run):
9999 with pytest .raises (
100100 ImportError , match = "scipy is not installed. Run 'pip install scipy'"
101101 ):
102- scm_run .cumtrapz ()
102+ scm_run .cumulative_trapezoid ()
103103
104104
105105@OPS_MARK
@@ -113,10 +113,10 @@ def test_single_timeseries(op, base_single_scmrun, other_single_scmrun):
113113 exp_ts ["variable" ] = "Emissions|CO2|AFOLU"
114114
115115 if op in ["add" , "subtract" ]:
116- exp_ts ["unit" ] = "gigatC / a "
116+ exp_ts ["unit" ] = "gigatC / yr "
117117
118118 elif op == "multiply" :
119- exp_ts ["unit" ] = "gigatC ** 2 / a ** 2"
119+ exp_ts ["unit" ] = "gigatC ** 2 / yr ** 2"
120120
121121 elif op == "divide" :
122122 exp_ts ["unit" ] = "dimensionless"
@@ -170,7 +170,7 @@ def test_different_unit_error():
170170
171171 error_msg = re .escape (
172172 "Cannot convert from 'kelvin' ([temperature]) to "
173- "'gigatC' ([carbon ] * [mass ])"
173+ "'gigatC' ([mass ] * [carbon ])"
174174 )
175175 with pytest .raises (DimensionalityError , match = error_msg ):
176176 base .add (other , op_cols = {"variable" : "Warming plus Cumulative emissions CO2" })
@@ -262,10 +262,10 @@ def test_scalar_ops_pint(op):
262262 exp = ScmRun (exp_ts )
263263
264264 if op in ["add" , "subtract" ]:
265- exp ["unit" ] = "gigatC / a "
265+ exp ["unit" ] = "gigatC / yr "
266266
267267 elif op == "multiply" :
268- exp ["unit" ] = "gigatC * megatC / a ** 2"
268+ exp ["unit" ] = "gigatC * megatC / yr ** 2"
269269
270270 elif op == "divide" :
271271 exp ["unit" ] = "gigatC / megatC"
@@ -315,7 +315,7 @@ def test_scalar_multiply_pint_by_run():
315315 exp_ts = perform_pint_op (start , scalar , "multiply_inverse" )
316316 exp = ScmRun (exp_ts )
317317
318- exp ["unit" ] = "megatC * gigatC / a **2"
318+ exp ["unit" ] = "megatC * gigatC / yr **2"
319319
320320 res = scalar * start
321321
@@ -330,8 +330,8 @@ def test_scalar_ops_pint_wrong_unit(op):
330330 )
331331
332332 error_msg = re .escape (
333- "Cannot convert from 'gigatC / a ' ([carbon ] * [mass ] / [time]) "
334- "to 'CH4 * megametric_ton / a ' ([mass] * [methane] / [time])"
333+ "Cannot convert from 'gigatC / yr ' ([mass ] * [carbon ] / [time]) "
334+ "to 'megametric_ton * CH4 / yr ' ([mass] * [methane] / [time])"
335335 )
336336 with pytest .raises (DimensionalityError , match = error_msg ):
337337 if op == "add" :
@@ -356,10 +356,10 @@ def test_vector_ops_pint(op):
356356 exp = ScmRun (exp_ts )
357357
358358 if op in ["add" , "subtract" ]:
359- exp ["unit" ] = "gigatC / a "
359+ exp ["unit" ] = "gigatC / yr "
360360
361361 elif op == "multiply" :
362- exp ["unit" ] = "gigatC * megatC / a ** 2"
362+ exp ["unit" ] = "gigatC * megatC / yr ** 2"
363363
364364 elif op == "divide" :
365365 exp ["unit" ] = "gigatC / megatC"
@@ -391,8 +391,8 @@ def test_vector_ops_pint_wrong_unit(op, start_unit):
391391 )
392392
393393 error_msg = re .escape (
394- "Cannot convert from 'gigatC / a ' ([carbon ] * [mass ] / [time]) "
395- "to 'CH4 * megametric_ton / a ' ([mass] * [methane] / [time])"
394+ "Cannot convert from 'gigatC / yr ' ([mass ] * [carbon ] / [time]) "
395+ "to 'megametric_ton * CH4 / yr ' ([mass] * [methane] / [time])"
396396 )
397397 with pytest .raises (DimensionalityError , match = error_msg ):
398398 if op == "add" :
@@ -549,11 +549,11 @@ def test_wrong_length_ops(op):
549549# We can add initial back if use case arises. At the moment I can't see an easy
550550# way to make the units behave.
551551# @pytest.mark.parametrize("initial", (None, 0, 1, -1.345))
552- def test_cumtrapz (out_var ):
552+ def test_cumulative_trapezoid (out_var ):
553553 dat = [1 , 2 , 3 ]
554554 start = get_single_ts (data = dat , index = [1 , 2 , 3 ], unit = "GtC / yr" )
555555
556- res = start .cumtrapz (out_var = out_var )
556+ res = start .cumulative_trapezoid (out_var = out_var )
557557
558558 if out_var is None :
559559 exp_var = ("Cumulative " + start ["variable" ]).values
@@ -570,10 +570,10 @@ def test_cumtrapz(out_var):
570570 )
571571
572572
573- def test_cumtrapz_time_handling_big_jumps ():
573+ def test_cumulative_trapezoid_time_handling_big_jumps ():
574574 start = get_single_ts (data = [1 , 2 , 3 ], index = [10 , 20 , 50 ], unit = "GtC / yr" )
575575
576- res = start .cumtrapz ()
576+ res = start .cumulative_trapezoid ()
577577
578578 npt .assert_allclose (
579579 res .values .squeeze (),
@@ -582,12 +582,12 @@ def test_cumtrapz_time_handling_big_jumps():
582582 )
583583
584584
585- def test_cumtrapz_time_handling_all_over_jumps ():
585+ def test_cumulative_trapezoid_time_handling_all_over_jumps ():
586586 start = get_single_ts (
587587 data = [1 , 2 , 3 , 3 , 1.8 ], index = [10 , 10.1 , 11 , 20 , 50 ], unit = "GtC / yr"
588588 )
589589
590- res = start .cumtrapz ()
590+ res = start .cumulative_trapezoid ()
591591
592592 first = 0
593593 second = first + 1.5 * 0.1
@@ -603,7 +603,7 @@ def test_cumtrapz_time_handling_all_over_jumps():
603603 "method,exp" ,
604604 [
605605 ("cumsum" , [1 , 3 , 6 , np .nan , np .nan , np .nan , np .nan , np .nan ]),
606- ("cumtrapz " , [0 , 1.5 , 4 , np .nan , np .nan , np .nan , np .nan , np .nan ]),
606+ ("cumulative_trapezoid " , [0 , 1.5 , 4 , np .nan , np .nan , np .nan , np .nan , np .nan ]),
607607 ],
608608)
609609def test_integration_nan_handling (method , exp ):
@@ -633,7 +633,7 @@ def test_integration_nan_handling(method, exp):
633633@pytest .mark .xfail (
634634 _check_pandas_less_110 (), reason = "pandas<=1.1.0 does not have rtol argument"
635635)
636- def test_cumtrapz_multiple_ts ():
636+ def test_cumulative_trapezoid_multiple_ts ():
637637 variables = ["Emissions|CO2" , "Heat Uptake" , "Temperature" ]
638638 start = get_multiple_ts (
639639 data = np .array ([[1 , 2 , 3 ], [- 1 , - 2 , - 3 ], [0 , 5 , 10 ]]).T ,
@@ -642,7 +642,7 @@ def test_cumtrapz_multiple_ts():
642642 unit = ["Mt CO2 / yr" , "W / m^2" , "K" ],
643643 )
644644
645- res = start .cumtrapz ()
645+ res = start .cumulative_trapezoid ()
646646
647647 exp = get_single_ts (
648648 data = np .array ([[0 , 7.5 , 45 ], [0 , - 7.5 , - 45 ], [0 , 12.5 , 125 ]]).T ,
@@ -730,7 +730,9 @@ def test_integrate_deprecated():
730730 dat = [1 , 2 , 3 ]
731731 start = get_single_ts (data = dat , index = [2020 , 2021 , 2024 ], unit = "GtC / yr" )
732732
733- match = "integrate has been deprecated in preference of cumsum and cumtrapz"
733+ match = (
734+ "integrate has been deprecated in preference of cumsum and cumulative_trapezoid"
735+ )
734736 with pytest .warns (DeprecationWarning , match = match ):
735737 start .integrate ()
736738
0 commit comments