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

Pandas deprecated functionality #233

Closed
chanhosuh opened this issue Sep 6, 2023 · 1 comment · Fixed by #235
Closed

Pandas deprecated functionality #233

chanhosuh opened this issue Sep 6, 2023 · 1 comment · Fixed by #235
Labels
bug Something isn't working

Comments

@chanhosuh
Copy link
Member

chanhosuh commented Sep 6, 2023

Version Information

Affects multiple versions of Python on different OSes, as shown in the CI run

What's your issue about?

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/multiprocessing/pool.py", line 51, in starmapstar
    return list(itertools.starmap(args[0], args[1]))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/curvesim/pipelines/__init__.py", line 93, in wrapped_strategy
    return strategy(*args)
           ^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/curvesim/templates/strategy.py", line 78, in __call__
    return state_log.compute_metrics()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/curvesim/metrics/state_log/log.py", line 54, in compute_metrics
    metric_data = [metric.compute(state_logs) for metric in self.metrics]
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/curvesim/metrics/state_log/log.py", line 54, in <listcomp>
    metric_data = [metric.compute(state_logs) for metric in self.metrics]
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/curvesim/metrics/base.py", line 60, in compute
    return data, summarize_data(data, self.summary_functions)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/curvesim/metrics/base.py", line [20](https://github.com/curveresearch/curvesim/actions/runs/6102733922/job/16561892741#step:6:21)2, in summarize_data
    stat = compute_summary_stat(record_df[metric], fn)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/curvesim/metrics/base.py", line 232, in compute_summary_stat
    return fn(data)
           ^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/curvesim/metrics/metrics.py", line 513, in compute_annualized_returns
    year_multipliers = timedelta64(1, "Y") / data.index.to_series().diff()
                       ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/pandas/core/generic.py", line [21](https://github.com/curveresearch/curvesim/actions/runs/6102733922/job/16561892741#step:6:22)02, in __array_ufunc__
    return arraylike.array_ufunc(self, ufunc, method, *inputs, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/pandas/core/arraylike.py", line [27](https://github.com/curveresearch/curvesim/actions/runs/6102733922/job/16561892741#step:6:28)3, in array_ufunc
    result = maybe_dispatch_ufunc_to_dunder_op(self, ufunc, method, *inputs, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ops_dispatch.pyx", line 113, in pandas._libs.ops_dispatch.maybe_dispatch_ufunc_to_dunder_op
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/pandas/core/ops/common.py", line 76, in new_method
    return method(self, other)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/pandas/core/arraylike.py", line 214, in __rtruediv__
    return self._arith_method(other, roperator.rtruediv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/pandas/core/series.py", line 5820, in _arith_method
    return base.IndexOpsMixin._arith_method(self, other, op)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/pandas/core/base.py", line 1[37](https://github.com/curveresearch/curvesim/actions/runs/6102733922/job/16561892741#step:6:38)5, in _arith_method
    rvalues = ops.maybe_prepare_scalar_for_op(rvalues, lvalues.shape)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/pandas/core/ops/array_ops.py", line 575, in maybe_prepare_scalar_for_op
    return Timedelta(obj)
           ^^^^^^^^^^^^^^
  File "timedeltas.pyx", line 18[46](https://github.com/curveresearch/curvesim/actions/runs/6102733922/job/16561892741#step:6:47), in pandas._libs.tslibs.timedeltas.Timedelta.__new__
ValueError: Unit Y is not supported. Only unambiguous timedelta values durations are supported. Allowed units are 'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns'

This error came from the CI, where we build the package on different OS and Python versions.

How can it be fixed?

https://stackoverflow.com/questions/60122391/valueerror-units-m-and-y-are-no-longer-supported-as-they-do-not-represent

according to the above, this has been deprecated for a few years now, so we should update the code to not use the "Y" as a unit, i.e. in

year_multipliers = timedelta64(1, "Y") / data.index.to_series().diff()
@chanhosuh chanhosuh added the bug Something isn't working label Sep 6, 2023
@chanhosuh
Copy link
Member Author

Fixed by #235.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant