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

add a special case for array scalars in YTArray.__str__ #1661

merged 3 commits into from Jan 11, 2018


None yet
7 participants
Copy link

ngoldbaum commented Jan 10, 2018

This fixes the recursion errors that we are seeing on Travis with NumPy 1.14.

# error on NumPy 1.14 and newer
if self.shape != ():
return super(YTArray, self).__str__()+' '+self.units.__str__()
return str(np.asarray(self)) + ' ' + str(self.units)

This comment has been minimized.

Copy link

mhvk Jan 10, 2018

I'd think you don't need the if-statement at all; you could just execute the second one unconditionally - or, probably a bit faster, do str(self.view(np.ndarray)) + ' ' + str(self.units) -- the latter is closer to what we do in astropy:

Copy link

eric-wieser left a comment

Can't you use the second branch in both cases?

Copy link

zingale left a comment

looks good to me

@cmsquared cmsquared requested review from cmsquared and removed request for cmsquared Jan 11, 2018


cphyc approved these changes Jan 11, 2018

@ngoldbaum ngoldbaum merged commit 12be5d4 into yt-project:master Jan 11, 2018

4 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
py2 Build finished.
py3 Build finished.

This comment has been minimized.

Copy link

cphyc commented Jan 11, 2018

@ngoldbaum ngoldbaum deleted the ngoldbaum:array-print-fix branch Dec 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.