Skip to content

Unable to divide different units of time in numpy exp function #133

Open

Description

@lepmik
import quantities as pq
import numpy as np
a = 1 * pq.s
b = 1 * pq.ms
np.exp(a/b)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-9-8e7d5c758397> in <module>()
----> 1 np.exp(a/b)

/home/mikkel/apps/anaconda3/envs/expipe/lib/python3.6/site-packages/quantities/quantity.py in __array_prepare__(self, obj, context)
    229         #print self, obj, res, uf, objs
    230         try:
--> 231             res._dimensionality = p_dict[uf](*objs)
    232         except KeyError:
    233             raise ValueError(

/home/mikkel/apps/anaconda3/envs/expipe/lib/python3.6/site-packages/quantities/dimensionality.py in _d_dimensionless(q1, out)
    346 def _d_dimensionless(q1, out=None):
    347     if getattr(q1, 'dimensionality', None):
--> 348         raise ValueError("quantity must be dimensionless")
    349     return Dimensionality()
    350 p_dict[np.log] = _d_dimensionless

ValueError: quantity must be dimensionless

Activity

  1. added
    bug
    numpy-integration
    on Nov 17, 2026
  2. modified the milestones: 0.17.0, 0.18.0 on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnumpy-integration

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions