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
merged 3 commits into from Jan 11, 2018

Conversation

Projects
None yet
7 participants
@ngoldbaum
Copy link
Member

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

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: https://github.com/astropy/astropy/blob/master/astropy/units/quantity.py#L1250

@eric-wieser
Copy link

eric-wieser left a comment

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

@zingale
Copy link
Member

zingale left a comment

looks good to me

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

@cphyc

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
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
py2 Build finished.
Details
py3 Build finished.
Details
@cphyc

This comment has been minimized.

Copy link
Contributor

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.