You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Barril version: 1.10.0 (build py_0 from conda-forge)
Python version: Python 3.6.7 (build he025d50_1008_cpython from conda-forge)
Operating System: Microsoft Windows 10 Pro (10.0.19041 N/A Build 19041)
Description
Operating with empty Arrays (values are an empty list or tuple) barril will raise an UnboundLocalError.
When using an empty numpy.ndarray as values there is no error and an empty Array is returned (this is the workaround we are using, force the relevant Arrays to hold numpy.ndarrays).
What I Did
>>> from barril.units import Array
>>> Array([1, 2], 's') / 2
Array(time, [0.5, 1.0], s)
>>> 2 / Array([1, 2], 's')
Array(1 / time, [2.0, 1.0], 1/s)
>>> Array([1], 's') / 2
Array(time, [0.5], s)
>>> Array([], 's') / 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "W:\alfasim\envs\_alfasim_gui-win64-py36\lib\site-packages\barril\units\_array.py", line 286, in __truediv__
return self._DoOperation(self, other, "Divide")
File "W:\alfasim\envs\_alfasim_gui-win64-py36\lib\site-packages\barril\units\_array.py", line 360, in _DoOperation
return self.__class__.CreateWithQuantity(q, result)
UnboundLocalError: local variable 'q' referenced before assignment
>>> 2 / Array([], 's')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "W:\alfasim\envs\_alfasim_gui-win64-py36\lib\site-packages\barril\units\_array.py", line 302, in __rtruediv__
return self._DoOperation(other, self, "Divide")
File "W:\alfasim\envs\_alfasim_gui-win64-py36\lib\site-packages\barril\units\_array.py", line 360, in _DoOperation
return self.__class__.CreateWithQuantity(q, result)
UnboundLocalError: local variable 'q' referenced before assignment
>>>
The text was updated successfully, but these errors were encountered:
Description
Operating with empty
Array
s (values are an empty list or tuple) barril will raise anUnboundLocalError
.When using an empty
numpy.ndarray
as values there is no error and an emptyArray
is returned (this is the workaround we are using, force the relevantArray
s to holdnumpy.ndarray
s).What I Did
The text was updated successfully, but these errors were encountered: