Skip to content

Commit

Permalink
Update to Numpy >= 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
snakesonabrain committed Sep 14, 2024
1 parent 339f9b2 commit 46eadd1
Show file tree
Hide file tree
Showing 23 changed files with 93 additions and 91 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
v0.13.0, TBD
- Update of requirements to Numpy >= 2.1
- Ensured the cv arrays in consolidation calcs are treated as Numpy arrays
- Increased the timeout for interactive parameter selection to two minutes
- Added formula for calculation of void ratio from dry density
Expand Down
12 changes: 6 additions & 6 deletions groundhog/deepfoundations/axialcapacity/endbearing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
}

API_UNIT_END_BEARING_CLAY_ERRORRETURN = {
'q_b_coring [kPa]': np.NaN,
'q_b_plugged [kPa]': np.NaN,
'q_b_coring [kPa]': np.nan,
'q_b_plugged [kPa]': np.nan,
'plugged': None,
'internal_friction': False
}
Expand Down Expand Up @@ -63,12 +63,12 @@ def API_unit_end_bearing_clay(undrained_shear_strength,N_c=9.0,**kwargs):
}

API_UNIT_END_BEARING_SAND_RP2GEO_ERRORRETURN = {
'q_b_coring [kPa]': np.NaN,
'q_b_plugged [kPa]': np.NaN,
'q_b_coring [kPa]': np.nan,
'q_b_plugged [kPa]': np.nan,
'plugged': None,
'internal_friction': False,
'q_b_lim [kPa]': np.NaN,
'Nq [-]': np.NaN
'q_b_lim [kPa]': np.nan,
'Nq [-]': np.nan
}

@Validator(API_UNIT_END_BEARING_SAND_RP2GEO, API_UNIT_END_BEARING_SAND_RP2GEO_ERRORRETURN)
Expand Down
2 changes: 1 addition & 1 deletion groundhog/deepfoundations/axialcapacity/koppejan.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def calculate_base_resistance(self, alpha_p, base_coefficient=1, crosssection_co
self.qcavg = 0.5 * (0.5 * (self.qcI + self.qcII) + self.qcIII)
self.qbmax = min(15.0, alpha_p * base_coefficient * crosssection_coefficient * self.qcavg)

if coring and np.math.isnan(wall_thickness):
if coring and np.isnan(wall_thickness):
raise ValueError("For a coring pile, a wall thickness needs to be provided (in mm)")

if coring:
Expand Down
24 changes: 12 additions & 12 deletions groundhog/deepfoundations/axialcapacity/skinfriction.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
}

API_UNIT_SHAFT_FRICTION_SAND_RP2GEO_ERRORRETURN = {
'f_s_comp_out [kPa]': np.NaN,
'f_s_comp_in [kPa]': np.NaN,
'f_s_tens_out [kPa]': np.NaN,
'f_s_tens_in [kPa]': np.NaN,
'f_s_lim [kPa]': np.NaN,
'beta [-]': np.NaN,
'f_s_comp_out [kPa]': np.nan,
'f_s_comp_in [kPa]': np.nan,
'f_s_tens_out [kPa]': np.nan,
'f_s_tens_in [kPa]': np.nan,
'f_s_lim [kPa]': np.nan,
'beta [-]': np.nan,
}

@Validator(API_UNIT_SHAFT_FRICTION_SAND_RP2GEO, API_UNIT_SHAFT_FRICTION_SAND_RP2GEO_ERRORRETURN)
Expand Down Expand Up @@ -104,12 +104,12 @@ def API_unit_shaft_friction_sand_rp2geo(api_relativedensity, api_soildescription
}

API_UNIT_SHAFT_FRICTION_CLAY_ERRORRETURN = {
'f_s_comp_out [kPa]': np.NaN,
'f_s_comp_in [kPa]': np.NaN,
'f_s_tens_out [kPa]': np.NaN,
'f_s_tens_in [kPa]': np.NaN,
'psi [-]': np.NaN,
'alpha [-]': np.NaN,
'f_s_comp_out [kPa]': np.nan,
'f_s_comp_in [kPa]': np.nan,
'f_s_tens_out [kPa]': np.nan,
'f_s_tens_in [kPa]': np.nan,
'psi [-]': np.nan,
'alpha [-]': np.nan,
}

@Validator(API_UNIT_SHAFT_FRICTION_CLAY, API_UNIT_SHAFT_FRICTION_CLAY_ERRORRETURN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def stress_cylinder_elastic_isotropic(
borehole_radius / radius) ** 2)
_tangential_stress = farfield_pressure - (internal_pressure - farfield_pressure) * ((
borehole_radius / radius) ** 2)
if np.math.isnan(shear_modulus):
if np.isnan(shear_modulus):
try:
_radial_displacement = list(map(lambda _x: np.nan, _radial_stress))
except:
Expand Down
4 changes: 2 additions & 2 deletions groundhog/general/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ def validate_list(var_name,value,elementtype=None,order=None,unique=None,empty_a

if order=='ascending':
try:
if sorted(value)==value and (np.NaN not in value):
if sorted(value)==value and (np.nan not in value):
pass
else:
raise ValueError("List %s is not ascending" % str(value))
except Exception as err:
raise ValueError("%s" % str(err))
elif order=='descending':
try:
if sorted(value)==list(reversed(value)) and (np.NaN not in value):
if sorted(value)==list(reversed(value)) and (np.nan not in value):
pass
else:
raise ValueError("List %s is not descending" % str(value))
Expand Down
40 changes: 20 additions & 20 deletions groundhog/shallowfoundations/capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def verticalcapacity_undrained_api(effective_length, effective_width, su_base, s
else:
# Correction factors for linearly increasing su
dimensionless_increase = su_increase * effective_width / su_base
if not np.math.isnan(factor_f_override):
if not np.isnan(factor_f_override):
F_factor = factor_f_override
else:
if 0.0 <= dimensionless_increase <= 25.0:
Expand All @@ -190,7 +190,7 @@ def verticalcapacity_undrained_api(effective_length, effective_width, su_base, s
i_c = 0.5 - 0.5 * (1.0 - horizontal_load / (su_base * effective_length * effective_width)) ** 0.5
s_c = s_cv * (1.0 - 2.0 * i_c) * (effective_width / effective_length)
su2 = F_factor * (bearing_capacity_factor * su_base + 0.25 * su_increase * effective_width) / bearing_capacity_factor
if np.math.isnan(su_above_base):
if np.isnan(su_above_base):
raise ValueError("Undrained shear strength above base (su_above_base) must be specified for linearly increasing undrained shear strength cases")
d_c = 0.3 * (su_above_base / su2) * np.arctan(base_depth / effective_width)
b_c = 2.0 * np.radians(foundation_inclination) / (np.pi + 2.0)
Expand Down Expand Up @@ -484,7 +484,7 @@ def slidingcapacity_drained_api(vertical_load, effective_friction_angle, effecti
"""
base_capacity = vertical_load * np.tan(np.radians(effective_friction_angle))
K_p = (np.tan(np.radians(45.0 + 0.5 * effective_friction_angle))) ** 2.0
if np.math.isnan(reaction_factor_override):
if np.isnan(reaction_factor_override):
K_rd = K_p - (1.0 / K_p)
else:
K_rd = reaction_factor_override
Expand Down Expand Up @@ -559,14 +559,14 @@ def effectivearea_rectangle_api(length, width, vertical_load=np.nan, moment_leng
Reference - API RP 2GEO, 2011. API RP 2GEO Geotechnical and Foundation Design Considerations
"""
if (not np.math.isnan(vertical_load)) and (not np.math.isnan(moment_length)) and \
(not np.math.isnan(moment_width)) and np.math.isnan(eccentricity_length) and \
np.math.isnan(eccentricity_width):
if (not np.isnan(vertical_load)) and (not np.isnan(moment_length)) and \
(not np.isnan(moment_width)) and np.isnan(eccentricity_length) and \
np.isnan(eccentricity_width):
e1 = moment_length / vertical_load
e2 = moment_width / vertical_load
elif (not np.math.isnan(eccentricity_length)) and (not np.math.isnan(eccentricity_width)) and \
np.math.isnan(moment_length) and np.math.isnan(moment_width) and \
np.math.isnan(vertical_load):
elif (not np.isnan(eccentricity_length)) and (not np.isnan(eccentricity_width)) and \
np.isnan(moment_length) and np.isnan(moment_width) and \
np.isnan(vertical_load):
e1 = eccentricity_length
e2 = eccentricity_width
else:
Expand Down Expand Up @@ -634,11 +634,11 @@ def effectivearea_circle_api(foundation_radius, vertical_load=np.nan, overturnin
Reference - API RP 2GEO, 2011. API RP 2GEO Geotechnical and Foundation Design Considerations
"""
if not np.math.isnan(overturning_moment) and (not np.math.isnan(vertical_load)) and \
np.math.isnan(eccentricity):
if not np.isnan(overturning_moment) and (not np.isnan(vertical_load)) and \
np.isnan(eccentricity):
e2 = overturning_moment / vertical_load
elif np.math.isnan(overturning_moment) and np.math.isnan(vertical_load) and \
not np.math.isnan(eccentricity):
elif np.isnan(overturning_moment) and np.isnan(vertical_load) and \
not np.isnan(eccentricity):
e2 = eccentricity
else:
raise ValueError("Eccentricity needs to be specified either through moment or direct specification")
Expand Down Expand Up @@ -731,7 +731,7 @@ def envelope_drained_api(vertical_effective_stress,
"""

if np.math.isnan(effective_friction_angle_sliding):
if np.isnan(effective_friction_angle_sliding):
effective_friction_angle_sliding = effective_friction_angle - 5

_inclinations = np.linspace(0.0, 90.0, 100)
Expand Down Expand Up @@ -1223,14 +1223,14 @@ def set_geometry(self, option='rectangle', length=np.nan, width=np.nan, diameter
self.option = option

if option == 'rectangle':
if (np.math.isnan(length)) or (np.math.isnan(width)):
if (np.isnan(length)) or (np.isnan(width)):
raise ValueError("Length and width should be specified for a rectangular foundation")
self.length = length
self.width = width
self.diameter = np.nan
self.full_area = self.length * self.width
elif option == 'circle':
if np.math.isnan(diameter):
if np.isnan(diameter):
raise ValueError("Diameter should be specified for a circular foundation")
self.diameter = diameter
self.full_area = 0.25 * np.pi * (self.diameter ** 2)
Expand All @@ -1250,7 +1250,7 @@ def set_eccentricity(self, eccentricity_width, eccentricity_length=np.nan):
:return: Calculates the effective area of the foundation
"""
if self.option == 'rectangle':
if np.math.isnan(eccentricity_length):
if np.isnan(eccentricity_length):
raise ValueError("Eccentricity in the length direction needs to be specified")
eccentricity_result = effectivearea_rectangle_api(
length=self.length,
Expand Down Expand Up @@ -1352,7 +1352,7 @@ def set_soilparameters_undrained(self, unit_weight, su_base, su_increase=0.0, su
self.unit_weight = unit_weight
self.su_base = su_base
self.su_increase = su_increase
if np.math.isnan(su_above_base):
if np.isnan(su_above_base):
self.su_above_base = self.su_base
else:
self.su_above_base = su_above_base
Expand Down Expand Up @@ -1385,7 +1385,7 @@ def calculate_sliding_capacity(self, **kwargs):
:return: ``sliding`` attribute contains the results of the analysis, ``sliding_base_only`` gives the sliding capacity at the foundation base :math:`H_d` in kN, ``sliding_full`` gives the ultimate sliding resistance considering both base sliding and passive resistance :math:`H_d + \\Delta H` in kN
"""

if np.math.isnan(self.su_above_base):
if np.isnan(self.su_above_base):
self.su_above_base = 0

if self.option == 'circle':
Expand Down Expand Up @@ -1516,7 +1516,7 @@ def calculate_sliding_capacity(self, vertical_load, interface_frictionangle=np.n
else:
outofplane_dimension = self.length

if np.math.isnan(interface_frictionangle):
if np.isnan(interface_frictionangle):
interface_frictionangle = self.friction_angle - 5
else:
pass
Expand Down
2 changes: 1 addition & 1 deletion groundhog/shallowfoundations/settlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def set_foundation(self, width, shape="strip", length=np.nan, skirt_depth=0):
else:
raise ValueError("Foundation shape must be one of: 'strip', 'circular', 'rectangular'")
if shape == 'rectangular':
if np.math.isnan(length):
if np.isnan(length):
raise ValueError("Length needs to be defined for a rectangular foundation")
self.length = length
self.skirt_depth = skirt_depth
Expand Down
4 changes: 2 additions & 2 deletions groundhog/siteinvestigation/correlations/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ def shearwavevelocity_compressionindex_cha(
Reference - Cha et al (2014). Small-Strain Stiffness, Shear-Wave Velocity and Soil Compressibilitys. Journal of Geotechnical and Geoenvironmental Engineering.
"""
if np.math.isnan(alpha):
if np.isnan(alpha):
_alpha = calibration_factor_alpha_1 * (Cc ** calibration_factor_alpha_2)
else:
_alpha = alpha

if np.math.isnan(beta):
if np.isnan(beta):
_beta = calibration_factor_beta_1 * np.log10(Cc) + calibration_factor_beta_2
else:
_beta = beta
Expand Down
24 changes: 12 additions & 12 deletions groundhog/siteinvestigation/insitutests/pcpt_correlations.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
}

PCPT_NORMALISATIONS_ERRORRETURN = {
'qt [MPa]': np.NaN,
'qc [MPa]': np.NaN,
'u2 [MPa]': np.NaN,
'Delta u2 [MPa]': np.NaN,
'Rf [pct]': np.NaN,
'Bq [-]': np.NaN,
'Qt [-]': np.NaN,
'Fr [-]': np.NaN,
'qnet [MPa]': np.NaN,
'qt [MPa]': np.nan,
'qc [MPa]': np.nan,
'u2 [MPa]': np.nan,
'Delta u2 [MPa]': np.nan,
'Rf [pct]': np.nan,
'Bq [-]': np.nan,
'Qt [-]': np.nan,
'Fr [-]': np.nan,
'qnet [MPa]': np.nan,
}


Expand Down Expand Up @@ -778,8 +778,8 @@ def undrainedshearstrength_clay_radlunne(
}

FRICTIONANGLE_OVERBURDEN_KLEVEN_ERRORRETURN = {
'phi [deg]': np.NaN,
'sigma_m [kPa]': np.NaN
'phi [deg]': np.nan,
'sigma_m [kPa]': np.nan
}

@Validator(FRICTIONANGLE_OVERBURDEN_KLEVEN, FRICTIONANGLE_OVERBURDEN_KLEVEN_ERRORRETURN)
Expand Down Expand Up @@ -934,7 +934,7 @@ def ocr_cpt_lunne(Qt, Bq=np.nan, **kwargs):
0.671677717, 0.749877749, 0.810239222, 0.8645448, 0.942964248
]))

if np.math.isnan(Bq):
if np.isnan(Bq):
_OCR_Bq_LE = np.nan
_OCR_Bq_BE = np.nan
_OCR_Bq_HE = np.nan
Expand Down
4 changes: 2 additions & 2 deletions groundhog/siteinvestigation/insitutests/pcpt_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ def downhole_pcpt_corrections(self, area_ratio_override=np.nan):
push_data = self.data[self.data['Push'] == _push]
_push_z_min = push_data["z [m]"].min()
for i, row in push_data.iterrows():
if np.math.isnan(area_ratio_override):
if np.isnan(area_ratio_override):
area_ratio = row['area ratio [-]']
else:
area_ratio = area_ratio_override
Expand Down Expand Up @@ -1131,7 +1131,7 @@ def normalise_pcpt(self, qc_for_rf=False):
self.data.loc[i, "ft [MPa]"] = row['fs [MPa]'] - row['u2 [MPa]'] * (
(row['Sleeve cross-sectional area bottom [cm2]'] - row['Sleeve cross-sectional area top [cm2]']) / row['Cone sleeve_area [cm2]']
)
if np.math.isnan(self.data.loc[i, "ft [MPa]"]):
if np.isnan(self.data.loc[i, "ft [MPa]"]):
self.data.loc[i, "ft [MPa]"] = row['fs [MPa]']
except:
self.data.loc[i, "ft [MPa]"] = row['fs [MPa]']
Expand Down
16 changes: 8 additions & 8 deletions groundhog/siteinvestigation/insitutests/spt_correlations.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def spt_N60_correction(
"""

# Hammer efficiency correction
if np.math.isnan(eta_H):
if np.isnan(eta_H):
if country == 'Japan':
if hammertype == 'Donut':
if hammerrelease == 'Free fall':
Expand Down Expand Up @@ -225,7 +225,7 @@ def spt_N60_correction(
else:
raise ValueError("Hammer type not recognised for China.")
elif country == 'Other':
if np.math.isnan(eta_H):
if np.isnan(eta_H):
raise ValueError("For country='Other', an override for eta_H should be specified.")
else:
pass
Expand All @@ -235,7 +235,7 @@ def spt_N60_correction(
_eta_H = eta_H

# Borehole diameter correction
if np.math.isnan(eta_B):
if np.isnan(eta_B):
if 60 < borehole_diameter < 120:
_eta_B = 1
elif borehole_diameter == 150:
Expand All @@ -248,7 +248,7 @@ def spt_N60_correction(
_eta_B = eta_B

# Sample type correction
if np.math.isnan(eta_S):
if np.isnan(eta_S):
if samplertype == 'Standard sampler':
_eta_S = 1.0
elif samplertype == 'With liner for dense sand and clay':
Expand All @@ -261,7 +261,7 @@ def spt_N60_correction(
_eta_S = eta_S

# Rod length correction
if np.math.isnan(eta_R):
if np.isnan(eta_R):
if 0 <= rod_length < 4:
_eta_R = 0.75
elif 4 <= rod_length < 6:
Expand Down Expand Up @@ -350,14 +350,14 @@ def relativedensity_spt_kulhawymayne(
Reference - Kulhawy FH, Mayne PW (1990) Manual on estimating soil properties for foundation design. Electric Power Research Institute, Palo Alto
"""
if np.math.isnan(ca_override):
if np.isnan(ca_override):
if time_since_deposition == 1:
_C_A = 1
else:
_C_A = 1.2 + 0.05 * np.log10(time_since_deposition / 100)
else:
_C_A = ca_override
if np.math.isnan(cocr_override):
if np.isnan(cocr_override):
_C_OCR = ocr ** 0.18
else:
_C_OCR = cocr_override
Expand Down Expand Up @@ -427,7 +427,7 @@ def undrainedshearstrength_spt_salgado(
Reference - Salgado R (2008) The engineering of foundations. McGraw-Hill, New York
"""
if np.math.isnan(alpha_prime_override):
if np.isnan(alpha_prime_override):
_pi = [15, 20, 25, 30, 40, 60]
_alpha = [0.068, 0.055, 0.048, 0.045, 0.044, 0.043]
_alpha_prime = np.interp(pi, _pi, _alpha)
Expand Down
Loading

0 comments on commit 46eadd1

Please sign in to comment.