pint icon indicating copy to clipboard operation
pint copied to clipboard

Implement broadcast arrays

Open djpugh opened this issue 3 years ago • 7 comments

  • [x] Improves #981
  • [x] Executed pre-commit run --all-files with no errors
  • [x] The change is fully covered by automated unit tests
  • [x] Documented in docs/ as appropriate
  • [x] Added an entry to the CHANGES file

djpugh avatar Nov 06 '21 18:11 djpugh

I think I need this. I want to be able to broadcast a quantity to a dataframe thusly:

x['foo'] = Q_(1.0, ureg('m'))

Presently I get this error message:

TypeError: object of type 'int' has no len()

If I manually create a PintArray based on the length of X and do some extra work I can cause my scalar quantity to become part of the X dataframe. But a broadcast feature would be wonderful.

MichaelTiemannOSC avatar Dec 28 '21 13:12 MichaelTiemannOSC

@hgrecco - the previous tests failed on install of uncertainties==3.0.1

djpugh avatar Feb 18 '22 14:02 djpugh

TypeError: object of type 'int' has no len()

Note that you can work around this by setting ureg.force_ndarray_like = True or ureg.force_ndarray = True

keewis avatar Mar 15 '22 13:03 keewis

@hgrecco this seems to be passing and ready to merge - any other comments?

djpugh avatar Feb 25 '24 18:02 djpugh