Skip to content

Commit

Permalink
PICMI (Bucket): NumPy 2.0 Compatibility (#5075)
Browse files Browse the repository at this point in the history
* PICMI (Bucket): NumPy 2.0 Compatibility

`repr` returns `'np.float64(value)'` instead of `'value'` in
NumPy 2.0

* Use fstrings
* Remove outdated comment
* `requirements.txt`: Relax `numpy` version

Version 1 and 2 support.

* Remove outdated comment

---------

Co-authored-by: David Grote <dpgrote@lbl.gov>
  • Loading branch information
ax3l and dpgrote authored Jul 25, 2024
1 parent eda6af5 commit 675369d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions Python/pywarpx/Bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ def attrlist(self):
for attr, value in self.argvattrs.items():
if value is None:
continue
# --- repr is applied to value so that for floats, all of the digits are included.
# --- The strip of "'" is then needed when value is a string.
if isinstance(value, str):
if value.find('=') > -1:
# --- Expressions with temporary variables need to be inside quotes
Expand All @@ -73,11 +71,11 @@ def attrlist(self):
continue
# --- For lists, tuples, and arrays make a space delimited string of the values.
# --- The lambda is needed in case this is a list of strings.
rhs = ' '.join(map(lambda s : repr(s).strip("'"), value))
rhs = ' '.join(map(lambda s : f'{s}', value))
elif isinstance(value, bool):
rhs = 1 if value else 0
else:
rhs = value
attrstring = '{0}.{1} = {2}'.format(self.instancename, attr, repr(rhs).strip("'"))
attrstring = f'{self.instancename}.{attr} = {rhs}'
result += [attrstring]
return result
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# basic dependencies
numpy~=1.15
numpy>=1.15
periodictable~=1.5

# PICMI
Expand Down

0 comments on commit 675369d

Please sign in to comment.