-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from perturbo-code/ivan-spectroscopy
Ultrafast spectroscopy: pump pulse generation
- Loading branch information
Showing
20 changed files
with
770 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,3 +133,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# vscode | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.f90 | ||
*.html | ||
*.png | ||
*.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[flake8] | ||
max-line-length = 160 | ||
ignore = E114, E127, E124, E221, W293, E721, W503, F841, F401 | ||
ignore = E114, E127, E124, E221, W293, E721, W503, F841, F401, E202 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
Memory management utilities | ||
""" | ||
|
||
import sys | ||
import numpy as np | ||
|
||
|
||
def get_size(array, name='array', dump=True): | ||
""" | ||
Get size of an array in MB | ||
Parameters | ||
---------- | ||
array : numpy array | ||
Array. | ||
name : | ||
Name of array, optional. | ||
dump : | ||
Specifies whether to print out or not the size | ||
Returns | ||
------- | ||
size : float | ||
Size in MB. | ||
""" | ||
|
||
# Check if the array is a numpy array and calculate size accordingly | ||
if isinstance(array, np.ndarray): | ||
# Calculate size in bytes for numpy array | ||
size_bytes = array.size * array.itemsize | ||
else: | ||
# Use sys.getsizeof() for other types of arrays | ||
size_bytes = sys.getsizeof(array) | ||
|
||
size_kb = size_bytes / 1024.0 | ||
|
||
if size_kb < 1024.0: | ||
|
||
size = size_kb | ||
unit = 'KB' | ||
|
||
elif size_kb / 1024.0 < 1024.0: | ||
|
||
size_mb = size_kb / 1024.0 | ||
size = size_mb | ||
unit = 'MB' | ||
|
||
else: | ||
|
||
size_gb = size_kb / 1024.0**2 | ||
size = size_gb | ||
unit = 'GB' | ||
|
||
if dump: | ||
print(f'===Size of {name:<10} {str(array.shape):<12} {str(array.dtype):<8}: {size:6.3f} {unit}') | ||
|
||
return size, unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.