fullwave25 1.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fullwave25 might be problematic. Click here for more details.

Files changed (225) hide show
  1. fullwave/__init__.py +28 -0
  2. fullwave/constants/__init__.py +5 -0
  3. fullwave/constants/material_properties.py +112 -0
  4. fullwave/grid.py +222 -0
  5. fullwave/medium.py +1042 -0
  6. fullwave/medium_builder/__init__.py +12 -0
  7. fullwave/medium_builder/domain.py +151 -0
  8. fullwave/medium_builder/medium_builder.py +198 -0
  9. fullwave/medium_builder/presets/__init__.py +8 -0
  10. fullwave/medium_builder/presets/data/.keep +0 -0
  11. fullwave/medium_builder/presets/data/abdominal_wall/i2365f_etfw1.mat +0 -0
  12. fullwave/medium_builder/presets/domain_abdominal_wall.py +293 -0
  13. fullwave/medium_builder/presets/domain_background.py +140 -0
  14. fullwave/medium_builder/presets/domain_scatterer.py +179 -0
  15. fullwave/medium_builder/presets/domain_simple.py +92 -0
  16. fullwave/medium_builder/presets/domain_water_gel.py +1 -0
  17. fullwave/sensor.py +161 -0
  18. fullwave/solver/__init__.py +1 -0
  19. fullwave/solver/bins/database/relaxation_params_database_num_relax=2_20251027_1437.mat +0 -0
  20. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenu +0 -0
  21. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_100_cuda129 +0 -0
  22. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_101_cuda129 +0 -0
  23. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_120_cuda129 +0 -0
  24. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_61_cuda118 +0 -0
  25. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_61_cuda124 +0 -0
  26. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_61_cuda126 +0 -0
  27. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_61_cuda129 +0 -0
  28. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_70_cuda118 +0 -0
  29. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_70_cuda124 +0 -0
  30. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_70_cuda126 +0 -0
  31. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_70_cuda129 +0 -0
  32. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_75_cuda118 +0 -0
  33. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_75_cuda124 +0 -0
  34. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_75_cuda126 +0 -0
  35. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_75_cuda129 +0 -0
  36. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_80_cuda118 +0 -0
  37. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_80_cuda124 +0 -0
  38. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_80_cuda126 +0 -0
  39. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_80_cuda129 +0 -0
  40. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_86_cuda118 +0 -0
  41. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_86_cuda124 +0 -0
  42. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_86_cuda126 +0 -0
  43. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_86_cuda129 +0 -0
  44. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_89_cuda118 +0 -0
  45. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_89_cuda126 +0 -0
  46. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_89_cuda129 +0 -0
  47. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_90_cuda118 +0 -0
  48. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_90_cuda124 +0 -0
  49. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_90_cuda126 +0 -0
  50. fullwave/solver/bins/exponential_attenuation/gpu/2d/fullwave2_2d_exponential_attenuation_gpu_sm_90_cuda129 +0 -0
  51. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_100_cuda129 +0 -0
  52. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_101_cuda129 +0 -0
  53. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_120_cuda129 +0 -0
  54. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_61_cuda118 +0 -0
  55. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_61_cuda124 +0 -0
  56. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_61_cuda126 +0 -0
  57. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_61_cuda129 +0 -0
  58. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_70_cuda118 +0 -0
  59. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_70_cuda124 +0 -0
  60. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_70_cuda126 +0 -0
  61. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_70_cuda129 +0 -0
  62. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_75_cuda118 +0 -0
  63. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_75_cuda124 +0 -0
  64. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_75_cuda126 +0 -0
  65. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_75_cuda129 +0 -0
  66. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_80_cuda118 +0 -0
  67. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_80_cuda124 +0 -0
  68. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_80_cuda126 +0 -0
  69. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_80_cuda129 +0 -0
  70. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_86_cuda118 +0 -0
  71. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_86_cuda124 +0 -0
  72. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_86_cuda126 +0 -0
  73. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_86_cuda129 +0 -0
  74. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_89_cuda118 +0 -0
  75. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_89_cuda124 +0 -0
  76. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_89_cuda126 +0 -0
  77. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_89_cuda129 +0 -0
  78. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_90_cuda118 +0 -0
  79. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_90_cuda124 +0 -0
  80. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_90_cuda126 +0 -0
  81. fullwave/solver/bins/exponential_attenuation/gpu/3d/fullwave2_3d_exponential_attenuation_gpu_sm_90_cuda129 +0 -0
  82. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_100_cuda129 +0 -0
  83. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_101_cuda129 +0 -0
  84. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_120_cuda129 +0 -0
  85. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_61_cuda118 +0 -0
  86. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_61_cuda124 +0 -0
  87. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_61_cuda126 +0 -0
  88. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_61_cuda129 +0 -0
  89. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_70_cuda118 +0 -0
  90. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_70_cuda124 +0 -0
  91. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_70_cuda126 +0 -0
  92. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_70_cuda129 +0 -0
  93. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_75_cuda118 +0 -0
  94. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_75_cuda124 +0 -0
  95. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_75_cuda126 +0 -0
  96. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_75_cuda129 +0 -0
  97. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_80_cuda118 +0 -0
  98. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_80_cuda124 +0 -0
  99. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_80_cuda126 +0 -0
  100. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_80_cuda129 +0 -0
  101. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_86_cuda118 +0 -0
  102. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_86_cuda124 +0 -0
  103. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_86_cuda126 +0 -0
  104. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_86_cuda129 +0 -0
  105. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_89_cuda118 +0 -0
  106. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_89_cuda124 +0 -0
  107. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_89_cuda126 +0 -0
  108. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_89_cuda129 +0 -0
  109. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_90_cuda118 +0 -0
  110. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_90_cuda124 +0 -0
  111. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_90_cuda126 +0 -0
  112. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_isotropic_multi_gpu_sm_90_cuda129 +0 -0
  113. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_100_cuda129 +0 -0
  114. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_101_cuda129 +0 -0
  115. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_120_cuda129 +0 -0
  116. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_61_cuda118 +0 -0
  117. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_61_cuda124 +0 -0
  118. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_61_cuda126 +0 -0
  119. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_61_cuda129 +0 -0
  120. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_70_cuda118 +0 -0
  121. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_70_cuda124 +0 -0
  122. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_70_cuda126 +0 -0
  123. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_70_cuda129 +0 -0
  124. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_75_cuda118 +0 -0
  125. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_75_cuda124 +0 -0
  126. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_75_cuda126 +0 -0
  127. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_75_cuda129 +0 -0
  128. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_80_cuda118 +0 -0
  129. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_80_cuda124 +0 -0
  130. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_80_cuda126 +0 -0
  131. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_80_cuda129 +0 -0
  132. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_86_cuda118 +0 -0
  133. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_86_cuda124 +0 -0
  134. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_86_cuda126 +0 -0
  135. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_86_cuda129 +0 -0
  136. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_89_cuda118 +0 -0
  137. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_89_cuda124 +0 -0
  138. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_89_cuda126 +0 -0
  139. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_89_cuda129 +0 -0
  140. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_90_cuda118 +0 -0
  141. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_90_cuda124 +0 -0
  142. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_90_cuda126 +0 -0
  143. fullwave/solver/bins/gpu/2d/num_relax=2/fullwave2_2d_2_relax_multi_gpu_sm_90_cuda129 +0 -0
  144. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_100_cuda129 +0 -0
  145. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_101_cuda129 +0 -0
  146. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_120_cuda129 +0 -0
  147. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_61_cuda118 +0 -0
  148. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_61_cuda124 +0 -0
  149. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_61_cuda126 +0 -0
  150. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_61_cuda129 +0 -0
  151. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_70_cuda118 +0 -0
  152. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_70_cuda124 +0 -0
  153. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_70_cuda126 +0 -0
  154. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_70_cuda129 +0 -0
  155. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_75_cuda118 +0 -0
  156. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_75_cuda124 +0 -0
  157. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_75_cuda126 +0 -0
  158. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_75_cuda129 +0 -0
  159. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_80_cuda118 +0 -0
  160. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_80_cuda124 +0 -0
  161. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_80_cuda126 +0 -0
  162. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_80_cuda129 +0 -0
  163. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_86_cuda118 +0 -0
  164. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_86_cuda124 +0 -0
  165. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_86_cuda126 +0 -0
  166. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_86_cuda129 +0 -0
  167. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_89_cuda118 +0 -0
  168. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_89_cuda124 +0 -0
  169. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_89_cuda126 +0 -0
  170. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_89_cuda129 +0 -0
  171. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_90_cuda118 +0 -0
  172. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_90_cuda124 +0 -0
  173. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_90_cuda126 +0 -0
  174. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_isotropic_multi_gpu_sm_90_cuda129 +0 -0
  175. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_100_cuda129 +0 -0
  176. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_101_cuda129 +0 -0
  177. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_120_cuda129 +0 -0
  178. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_61_cuda118 +0 -0
  179. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_61_cuda124 +0 -0
  180. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_61_cuda126 +0 -0
  181. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_61_cuda129 +0 -0
  182. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_70_cuda118 +0 -0
  183. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_70_cuda124 +0 -0
  184. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_70_cuda126 +0 -0
  185. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_70_cuda129 +0 -0
  186. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_75_cuda118 +0 -0
  187. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_75_cuda124 +0 -0
  188. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_75_cuda126 +0 -0
  189. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_75_cuda129 +0 -0
  190. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_80_cuda118 +0 -0
  191. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_80_cuda124 +0 -0
  192. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_80_cuda126 +0 -0
  193. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_80_cuda129 +0 -0
  194. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_86_cuda118 +0 -0
  195. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_86_cuda124 +0 -0
  196. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_86_cuda126 +0 -0
  197. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_86_cuda129 +0 -0
  198. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_89_cuda118 +0 -0
  199. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_89_cuda124 +0 -0
  200. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_89_cuda126 +0 -0
  201. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_89_cuda129 +0 -0
  202. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_90_cuda118 +0 -0
  203. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_90_cuda124 +0 -0
  204. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_90_cuda126 +0 -0
  205. fullwave/solver/bins/gpu/3d/num_relax=2/fullwave2_3d_2_relax_multi_gpu_sm_90_cuda129 +0 -0
  206. fullwave/solver/cuda_utils.py +392 -0
  207. fullwave/solver/input_file_writer.py +853 -0
  208. fullwave/solver/launcher.py +134 -0
  209. fullwave/solver/pml_builder.py +1923 -0
  210. fullwave/solver/solver.py +750 -0
  211. fullwave/solver/utils.py +83 -0
  212. fullwave/source.py +173 -0
  213. fullwave/transducer.py +1003 -0
  214. fullwave/utils/__init__.py +12 -0
  215. fullwave/utils/check_functions.py +48 -0
  216. fullwave/utils/coordinates.py +155 -0
  217. fullwave/utils/memory_tempfile.py +439 -0
  218. fullwave/utils/numerical.py +111 -0
  219. fullwave/utils/plot_utils.py +1122 -0
  220. fullwave/utils/pulse.py +72 -0
  221. fullwave/utils/relaxation_parameters.py +212 -0
  222. fullwave/utils/signal_process.py +197 -0
  223. fullwave25-1.0.7.dist-info/METADATA +292 -0
  224. fullwave25-1.0.7.dist-info/RECORD +225 -0
  225. fullwave25-1.0.7.dist-info/WHEEL +4 -0
@@ -0,0 +1,12 @@
1
+ """misc utils for fullwave package."""
2
+
3
+ from . import pulse, relaxation_parameters, signal_process
4
+ from .memory_tempfile import MemoryTempfile
5
+
6
+ # "FullwaveSolver",
7
+ __all__ = [
8
+ "MemoryTempfile",
9
+ "pulse",
10
+ "relaxation_parameters",
11
+ "signal_process",
12
+ ]
@@ -0,0 +1,48 @@
1
+ """collections of functions to check the input values."""
2
+
3
+ from pathlib import Path
4
+ from typing import Any
5
+
6
+
7
+ def check_instance(target_var: Any, instance: Any) -> None: # noqa: ANN401
8
+ """Check whether target_var is an instance of the specified type.
9
+
10
+ Raises:
11
+ TypeError: If target_var is not an instance of instance.
12
+
13
+ """
14
+ if not isinstance(target_var, instance):
15
+ error_message = f"{target_var} is not a {instance} instance"
16
+ raise TypeError(error_message)
17
+
18
+
19
+ def check_path_exists(target_path: Path) -> None:
20
+ """Check whether the provided target_path exists.
21
+
22
+ Raises:
23
+ ValueError: If target_path does not exist.
24
+
25
+ """
26
+ if not target_path.exists():
27
+ error_message = f"{target_path} does not exist"
28
+ raise ValueError(error_message)
29
+
30
+
31
+ def check_compatible_value(
32
+ value: Any, # noqa: ANN401
33
+ compatible_values: list[Any],
34
+ error_message_template: str = "",
35
+ ) -> None:
36
+ """Check whether the provided value is in the list of compatible values.
37
+
38
+ Raises:
39
+ ValueError: If value is not in compatible_values.
40
+
41
+ """
42
+ if value not in compatible_values:
43
+ error_message = (
44
+ f"{value} is not compatible. "
45
+ f"Compatible values are: {compatible_values}. "
46
+ f"{error_message_template}"
47
+ )
48
+ raise ValueError(error_message)
@@ -0,0 +1,155 @@
1
+ """It manipulates the coordinates of the mask."""
2
+
3
+ import numpy as np
4
+ from numpy.typing import NDArray
5
+
6
+
7
+ def make_circle_idx(
8
+ dims: NDArray[np.float64],
9
+ cen: NDArray[np.float64],
10
+ rad: float,
11
+ ) -> NDArray[np.bool_]:
12
+ """Make a circle index mask.
13
+
14
+ Args:
15
+ dims: The dimensions of the mask.
16
+ cen: The center of the circle.
17
+ rad: The radius of the circle.
18
+
19
+ Returns:
20
+ mask: The mask of the circle.
21
+
22
+ """
23
+ x, y = np.meshgrid(np.arange(dims[0]), np.arange(dims[1]), indexing="ij")
24
+ dist = np.sqrt(np.round((x - cen[0]) + 1e-9) ** 2 + np.round((y - cen[1]) + 1e-9) ** 2)
25
+ return dist <= rad
26
+
27
+
28
+ def map_to_coords(
29
+ map_data: NDArray[np.float64 | np.int64 | np.bool],
30
+ *,
31
+ export_as_xyz: bool = False,
32
+ ) -> NDArray[np.int64]:
33
+ """Map the mask map to coordinates.
34
+
35
+ Returns:
36
+ NDArray[np.int64]: An array of coordinates corresponding to non-zero elements in the mask.
37
+
38
+ """
39
+ is_3d = map_data.ndim == 3
40
+ # indices = np.where(map_data.T != 0)
41
+ indices = np.where(map_data != 0)
42
+ if is_3d:
43
+ # out = np.array([indices[2], indices[1], indices[0]]).T
44
+ # out = np.array([indices[2], indices[1], indices[0]]).T
45
+ out = np.array([*indices]).T
46
+
47
+ if export_as_xyz:
48
+ out = np.stack([out[:, 2], out[:, 1], out[:, 0]], axis=1)
49
+ else:
50
+ out = np.array([*indices]).T
51
+ if export_as_xyz:
52
+ out = np.stack([out[:, 1], out[:, 0]], axis=1)
53
+ return out
54
+
55
+
56
+ def coords_to_map(
57
+ coords: NDArray[np.int64],
58
+ grid_shape: NDArray[np.int64] | tuple[int, ...],
59
+ *,
60
+ is_3d: bool = False,
61
+ ) -> NDArray[np.int64]:
62
+ """Map the coordinates to a mask map.
63
+
64
+ Parameters
65
+ ----------
66
+ coords: NDArray[np.int64]
67
+ The coordinates to map.
68
+ grid_shape: tuple[int, ...]
69
+ The shape of the grid.
70
+ is_3d: bool
71
+ Whether the grid is 3D or not.
72
+
73
+ Returns
74
+ -------
75
+ NDArray[np.int64]: The mask map.
76
+
77
+ """
78
+ mask = np.zeros(grid_shape, dtype=int)
79
+ if is_3d:
80
+ mask = np.zeros((grid_shape[0], grid_shape[1], grid_shape[2]), dtype=int)
81
+ mask[coords[:, 0].astype(int), coords[:, 1].astype(int), coords[:, 2].astype(int)] = 1
82
+ else:
83
+ mask = np.zeros((grid_shape[0], grid_shape[1]), dtype=int)
84
+ mask[coords[:, 0].astype(int), coords[:, 1].astype(int)] = 1
85
+ return mask
86
+
87
+
88
+ def coords_to_index_map(
89
+ coords: NDArray[np.int64],
90
+ grid_shape: NDArray[np.int64] | tuple[int, ...],
91
+ *,
92
+ is_3d: bool = False,
93
+ ) -> NDArray[np.int64]:
94
+ """Map the coordinates to an index map."""
95
+ mask = np.zeros(grid_shape, dtype=int)
96
+ if is_3d:
97
+ mask = np.zeros((grid_shape[0], grid_shape[1], grid_shape[2]), dtype=int)
98
+ mask[coords[:, 0].astype(int), coords[:, 1].astype(int), coords[:, 2].astype(int)] = (
99
+ np.arange(coords.shape[0]) + 1
100
+ )
101
+ else:
102
+ mask = np.zeros((grid_shape[0], grid_shape[1]), dtype=int)
103
+ mask[coords[:, 0].astype(int), coords[:, 1].astype(int)] = np.arange(coords.shape[0]) + 1
104
+ return mask
105
+
106
+
107
+ def map_to_coords_with_sort(map_data: NDArray[np.int64]) -> NDArray[np.int64]:
108
+ """Map the mask map to coordinates with sorting.
109
+
110
+ Args:
111
+ map_data: The mask map.
112
+
113
+ Returns:
114
+ NDArray[np.int64]: An array of coordinates corresponding to non-zero elements in the mask.
115
+
116
+ """
117
+ coords = map_to_coordinates(map_data)
118
+ return coords[:, np.argsort(coords[0], kind="mergesort")].T
119
+
120
+
121
+ def map_to_coordinates(
122
+ map_data: NDArray[np.int64],
123
+ *,
124
+ is_3d: bool = False,
125
+ sort: bool = False,
126
+ ) -> NDArray[np.int64]:
127
+ """Map the mask map to coordinates.
128
+
129
+ Args:
130
+ map_data: The mask map.
131
+ is_3d: Whether the grid is 3D or not.
132
+ sort: Whether to sort the coordinates by the first dimension.
133
+
134
+ Returns:
135
+ NDArray[np.int64]: An array of coordinates corresponding to non-zero elements in the mask.
136
+
137
+ """
138
+ if is_3d:
139
+ idx, idy, idz = np.where(map_data != 0)
140
+ if idx.shape[0] == 0 or idy.shape[0] == 0 or idz.shape[0] == 0:
141
+ return np.array([[], [], []]).T
142
+ coords = np.array([idx, idy, idz])
143
+ else:
144
+ idx, idy = np.where(map_data != 0)
145
+ if idx.shape[0] == 0 or idy.shape[0] == 0:
146
+ return np.array([[], []]).T
147
+ coords = np.array([idx, idy])
148
+
149
+ unique_num_list = np.unique(coords[1])
150
+ unique_num_list.sort()
151
+ out_list = [np.sort(coords[:, coords[1] == value]) for value in unique_num_list]
152
+ coords = np.concatenate(out_list, axis=1)
153
+ if sort:
154
+ return coords[:, np.argsort(coords[0], kind="mergesort")]
155
+ return coords
@@ -0,0 +1,439 @@
1
+ """memory-tempfile.
2
+
3
+ adapted from
4
+ https://github.com/mbello/memory-tempfile/commit/c06b5405672435d861ac1d47db77c8067a6de77a
5
+ """
6
+
7
+ import os
8
+ import platform
9
+ import sys
10
+ import tempfile
11
+ from collections import OrderedDict
12
+ from pathlib import Path
13
+
14
+ MEM_BASED_FS = ["tmpfs", "ramfs"]
15
+ SUITABLE_PATHS = ["/tmp", "/run/user/{uid}", "/run/shm", "/dev/shm"] # noqa: S108
16
+
17
+
18
+ class MemoryTempfile:
19
+ """MemoryTempfile class for creating temporary files in memory-based filesystems.
20
+
21
+ This class is a wrapper around the tempfile module to provide
22
+ functionality for creating temporary files in memory-based filesystems
23
+ (e.g., tmpfs, ramfs) on Linux systems.
24
+ It allows users to specify preferred paths, remove certain paths,
25
+ and add additional paths for temporary files.
26
+ The class also provides methods to check if a memory temporary directory
27
+ is found, get the usable memory temporary directory paths,
28
+ and create temporary files and directories.
29
+ """
30
+
31
+ def __init__( # noqa: C901, PLR0912
32
+ self,
33
+ *,
34
+ preferred_paths: list | None = None,
35
+ remove_paths: list | bool | None = None,
36
+ additional_paths: list | None = None,
37
+ filesystem_types: list | None = None,
38
+ fallback: str | bool | None = None,
39
+ ) -> None:
40
+ """Initialize MemoryTempfile instance.
41
+
42
+ Parameters
43
+ ----------
44
+ preferred_paths : list, optional
45
+ List of preferred paths for temporary files.
46
+ remove_paths : list | bool, optional
47
+ List of paths to remove from the suitable paths.
48
+ If True, all suitable paths are removed.
49
+ additional_paths : list, optional
50
+ List of additional paths to include in the suitable paths.
51
+ filesystem_types : list, optional
52
+ List of filesystem types to consider as memory-based.
53
+ fallback : str | bool, optional
54
+ Fallback path to use if no memory temporary directory is found.
55
+ If True, the fallback is set to the system's temporary directory.
56
+ If False, no fallback is used.
57
+
58
+ Raises
59
+ ------
60
+ RuntimeError
61
+ If no memory temporary directory is found and fallback is disabled.
62
+
63
+ """
64
+ self.os_tempdir = tempfile.gettempdir()
65
+ suitable_paths = [self.os_tempdir, *SUITABLE_PATHS]
66
+
67
+ if isinstance(fallback, bool):
68
+ self.fallback = self.os_tempdir if fallback else None
69
+ else:
70
+ self.fallback = fallback
71
+
72
+ if platform.system() == "Linux":
73
+ self.filesystem_types = (
74
+ list(filesystem_types) if filesystem_types is not None else MEM_BASED_FS
75
+ )
76
+
77
+ preferred_paths = [] if preferred_paths is None else preferred_paths
78
+
79
+ if isinstance(remove_paths, bool) and remove_paths:
80
+ suitable_paths = []
81
+ elif isinstance(remove_paths, list) and len(remove_paths) > 0:
82
+ suitable_paths = [i for i in suitable_paths if i not in remove_paths]
83
+
84
+ additional_paths = [] if additional_paths is None else additional_paths
85
+
86
+ self.suitable_paths = preferred_paths + suitable_paths + additional_paths
87
+
88
+ uid = os.geteuid()
89
+
90
+ with Path("/proc/self/mountinfo").open(encoding="utf-8") as file:
91
+ mnt_info = {i[2]: i for i in [line.split() for line in file]}
92
+
93
+ self.usable_paths: OrderedDict = OrderedDict()
94
+ for path in self.suitable_paths:
95
+ path_uid = path.replace("{uid}", str(uid))
96
+
97
+ # We may have repeated
98
+ if self.usable_paths.get(path_uid) is not None:
99
+ continue
100
+ self.usable_paths[path_uid] = False
101
+ try:
102
+ dev = Path(path_uid).stat().st_dev
103
+ major, minor = os.major(dev), os.minor(dev)
104
+ mp = mnt_info.get(f"{major}:{minor}")
105
+ if mp and mp[mp.index("-", 6) + 1] in self.filesystem_types:
106
+ self.usable_paths[path_uid] = mp
107
+ except FileNotFoundError:
108
+ pass
109
+
110
+ for key in [k for k, v in self.usable_paths.items() if not v]:
111
+ del self.usable_paths[key]
112
+
113
+ if len(self.usable_paths) > 0:
114
+ self.tempdir = Path(next(iter(self.usable_paths.keys())))
115
+ elif self.fallback is not None:
116
+ self.tempdir = Path(self.fallback)
117
+ else:
118
+ error_message = "No memory temporary dir found and fallback is disabled.\n"
119
+ raise RuntimeError(error_message)
120
+
121
+ def found_mem_tempdir(self) -> bool:
122
+ """Check if any memory temporary directory is found.
123
+
124
+ Returns
125
+ -------
126
+ bool
127
+ True if any memory temporary directory is found, False otherwise.
128
+
129
+ """
130
+ return len(self.usable_paths) > 0
131
+
132
+ def using_mem_tempdir(self) -> bool:
133
+ """Check if the current temporary directory is a memory temporary directory.
134
+
135
+ Returns
136
+ -------
137
+ bool
138
+ True if the current temporary directory is a memory temporary directory,
139
+ False otherwise.
140
+
141
+ """
142
+ return self.tempdir in self.usable_paths
143
+
144
+ def get_usable_mem_tempdir_paths(self) -> list:
145
+ """Get the list of usable memory temporary directory paths.
146
+
147
+ Returns
148
+ -------
149
+ list
150
+ List of usable memory temporary directory paths.
151
+
152
+ """
153
+ return list(self.usable_paths.keys())
154
+
155
+ def gettempdir(self) -> Path:
156
+ """Get the current temporary directory.
157
+
158
+ Returns
159
+ -------
160
+ Path
161
+ The current temporary directory.
162
+
163
+ """
164
+ return self.tempdir
165
+
166
+ def gettempdirb(self) -> bytes:
167
+ """Get the current temporary directory as bytes.
168
+
169
+ Returns
170
+ -------
171
+ bytes
172
+ The current temporary directory as bytes.
173
+
174
+ """
175
+ return str(self.tempdir).encode(sys.getfilesystemencoding(), "surrogateescape")
176
+
177
+ def mkdtemp(
178
+ self,
179
+ suffix: str | None = None,
180
+ prefix: str | None = None,
181
+ dir: str | None = None, # noqa: A002
182
+ ) -> str:
183
+ """Create a temporary directory.
184
+
185
+ Parameters
186
+ ----------
187
+ suffix : str, optional
188
+ Suffix for the temporary directory name.
189
+ prefix : str, optional
190
+ Prefix for the temporary directory name.
191
+ dir : str, optional
192
+ Directory where the temporary directory will be created.
193
+
194
+ Returns
195
+ -------
196
+ str
197
+ The name of the created temporary directory.
198
+
199
+ """
200
+ return tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=dir or self.tempdir)
201
+
202
+ def mkstemp(
203
+ self,
204
+ suffix: str | None = None,
205
+ prefix: str | None = None,
206
+ dir: str | None = None, # noqa: A002
207
+ *,
208
+ text: bool = False,
209
+ ) -> tuple[int, str]:
210
+ """Create a temporary file using mkstemp and return a tuple (file descriptor, file name).
211
+
212
+ Parameters
213
+ ----------
214
+ suffix : str, optional
215
+ Suffix for the temporary file name.
216
+ prefix : str, optional
217
+ Prefix for the temporary file name.
218
+ dir : str, optional
219
+ Directory where the temporary file will be created.
220
+ text : bool, optional
221
+ If True, the file will be opened in text mode (default is False).
222
+
223
+ Returns
224
+ -------
225
+ tuple[int, str]
226
+ A tuple containing the file descriptor and the name of the created temporary file.
227
+
228
+ """
229
+ return tempfile.mkstemp(
230
+ suffix=suffix,
231
+ prefix=prefix,
232
+ dir=dir or self.tempdir,
233
+ text=text,
234
+ )
235
+
236
+ def TemporaryDirectory( # noqa: N802
237
+ self,
238
+ suffix: str | None = None,
239
+ prefix: str | None = None,
240
+ dir: str | None = None, # noqa: A002
241
+ ) -> tempfile.TemporaryDirectory[str]:
242
+ """Create a temporary directory and return a TemporaryDirectory object.
243
+
244
+ Parameters
245
+ ----------
246
+ suffix : str, optional
247
+ Suffix for the temporary file name.
248
+ prefix : str, optional
249
+ Prefix for the temporary file name.
250
+ dir : str, optional
251
+ Directory where the temporary file will be created.
252
+
253
+ Returns
254
+ -------
255
+ tempfile.TemporaryDirectory[str]
256
+ A TemporaryDirectory object representing the created temporary directory.
257
+
258
+ """
259
+ return tempfile.TemporaryDirectory(
260
+ suffix=suffix,
261
+ prefix=prefix,
262
+ dir=dir or self.tempdir,
263
+ )
264
+
265
+ def SpooledTemporaryFile( # noqa: N802
266
+ self,
267
+ max_size: int = 0,
268
+ mode: str = "w+b",
269
+ buffering: int = -1,
270
+ encoding: str | None = None,
271
+ newline: str | None = None,
272
+ suffix: str | None = None,
273
+ prefix: str | None = None,
274
+ dir: str | None = None, # noqa: A002
275
+ ) -> tempfile.SpooledTemporaryFile:
276
+ """Create a spooled temporary file.
277
+
278
+ Parameters
279
+ ----------
280
+ max_size : int, optional
281
+ Maximum size of the file before it is moved to disk.
282
+ mode : str, optional
283
+ Mode in which the file is opened (default is 'w+b').
284
+ buffering : int, optional
285
+ Buffering policy (default is -1, which means the default buffering).
286
+ encoding : str, optional
287
+ Encoding of the file (default is None).
288
+ newline : str, optional
289
+ Newline handling (default is None).
290
+ suffix : str, optional
291
+ Suffix for the temporary file name (default is None).
292
+ prefix : str, optional
293
+ Prefix for the temporary file name (default is None).
294
+ dir : str, optional
295
+ Directory where the temporary file will be created (default is None).
296
+
297
+ Returns
298
+ -------
299
+ tempfile.SpooledTemporaryFile
300
+ A SpooledTemporaryFile object representing the created temporary file.
301
+
302
+ Notes
303
+ -----
304
+ Temporary file wrapper, specialized to switch from BytesIO
305
+ or StringIO to a real file when it exceeds a certain size or
306
+ when a fileno is needed.
307
+
308
+ """
309
+ return tempfile.SpooledTemporaryFile(
310
+ max_size=max_size,
311
+ mode=mode,
312
+ buffering=buffering,
313
+ encoding=encoding,
314
+ newline=newline,
315
+ suffix=suffix,
316
+ prefix=prefix,
317
+ dir=dir or self.tempdir,
318
+ )
319
+
320
+ def NamedTemporaryFile( # noqa: N802
321
+ self,
322
+ mode: str = "w+b",
323
+ buffering: int = -1,
324
+ encoding: str | None = None,
325
+ newline: str | None = None,
326
+ suffix: str | None = None,
327
+ prefix: str | None = None,
328
+ dir: str | None = None, # noqa: A002
329
+ *,
330
+ delete: bool = True,
331
+ ) -> tempfile.NamedTemporaryFile:
332
+ """Create and return a temporary file.
333
+
334
+ Parameters
335
+ ----------
336
+ mode : str, optional
337
+ Mode in which the file is opened (default is 'w+b').
338
+ buffering : int, optional
339
+ Buffering policy (default is -1, which means the default buffering).
340
+ encoding : str, optional
341
+ Encoding of the file (default is None).
342
+ newline : str, optional
343
+ Newline handling (default is None).
344
+ suffix : str, optional
345
+ Suffix for the temporary file name (default is None).
346
+ prefix : str, optional
347
+ Prefix for the temporary file name (default is None).
348
+ dir : str, optional
349
+ Directory where the temporary file will be created (default is None).
350
+ delete : bool, optional
351
+ If True, the file will be deleted when closed (default is True).
352
+
353
+ m Returns
354
+ -------
355
+ tempfile.NamedTemporaryFile
356
+ A NamedTemporaryFile object representing the created temporary file.
357
+
358
+ """
359
+ return tempfile.NamedTemporaryFile(
360
+ mode=mode,
361
+ buffering=buffering,
362
+ encoding=encoding,
363
+ newline=newline,
364
+ suffix=suffix,
365
+ prefix=prefix,
366
+ dir=dir or self.tempdir,
367
+ delete=delete,
368
+ )
369
+
370
+ def TemporaryFile( # noqa: N802
371
+ self,
372
+ mode: str = "w+b",
373
+ buffering: int = -1,
374
+ encoding: str | None = None,
375
+ newline: str | None = None,
376
+ suffix: str | None = None,
377
+ prefix: str | None = None,
378
+ dir: str | None = None, # noqa: A002
379
+ ) -> tempfile.TemporaryFile:
380
+ """Create and return a temporary file.
381
+
382
+ Parameters
383
+ ----------
384
+ mode : str, optional
385
+ Mode in which the file is opened (default is 'w+b').
386
+ buffering : int, optional
387
+ Buffering policy (default is -1, which means the default buffering).
388
+ encoding : str, optional
389
+ Encoding of the file (default is None).
390
+ newline : str, optional
391
+ Newline handling (default is None).
392
+ suffix : str, optional
393
+ Suffix for the temporary file name (default is None).
394
+ prefix : str, optional
395
+ Prefix for the temporary file name (default is None).
396
+ dir : str, optional
397
+ Directory where the temporary file will be created (default is None).
398
+
399
+ Returns
400
+ -------
401
+ tempfile.TemporaryFile
402
+ A TemporaryFile object representing the created temporary file.
403
+
404
+ -----
405
+
406
+ """
407
+ return tempfile.TemporaryFile(
408
+ mode=mode,
409
+ buffering=buffering,
410
+ encoding=encoding,
411
+ newline=newline,
412
+ suffix=suffix,
413
+ prefix=prefix,
414
+ dir=dir or self.tempdir,
415
+ )
416
+
417
+ @staticmethod
418
+ def gettempprefix() -> str:
419
+ """Return the default temporary directory.
420
+
421
+ Returns
422
+ -------
423
+ str
424
+ The default temporary directory.
425
+
426
+ """
427
+ return tempfile.gettempdir()
428
+
429
+ @staticmethod
430
+ def gettempprefixb() -> bytes:
431
+ """Return the default temporary directory as bytes.
432
+
433
+ Returns
434
+ -------
435
+ bytes
436
+ The default temporary directory as bytes.
437
+
438
+ """
439
+ return tempfile.gettempprefixb()